<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11422">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_fax: gateway sends T.38 request to both endpoints if V.21 detected<br><br>According T.38 Gateway 'Use case 3'<br>https://wiki.asterisk.org/wiki/display/AST/T.38+Gateway<br>T.38 Gateway should send T.38 negotiation request to called endpoint<br>if FAX preamble (using V.21 detector) generated by called endpoint.<br>But it does not, because fax_gateway_detect_v21 constructs T.38<br>negotiation request, but forwards it only to other channel,<br>not to the channel on which FAX preamble is detected.<br><br>Some SIP endpoints could be improperly configured to rely on the other side<br>to initiate T.38 re-INVITEs.<br><br>With this patch the T.38 Gateway tries to negotiate with both sides<br>by sending T.38 negotiation request to both endpoints supported T.38.<br><br>Change-Id: I73bb24799bfe1a48adae9c034a2edbae54cc2a39<br>---<br>M res/res_fax.c<br>1 file changed, 29 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/22/11422/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_fax.c b/res/res_fax.c</span><br><span>index 7338507..42ad27d 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -2979,7 +2979,7 @@</span><br><span>     if (!details) {</span><br><span>              ast_log(LOG_ERROR, "no FAX session details found on chan %s for T.38 gateway session, odd\n", ast_channel_name(chan));</span><br><span>             ast_framehook_detach(chan, gateway->framehook);</span><br><span style="color: hsl(0, 100%, 40%);">-              return f;</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span>         }</span><br><span> </span><br><span>        t38_parameters_fax_to_ast(&t38_parameters, &details->our_t38_parameters);</span><br><span>@@ -2987,7 +2987,7 @@</span><br><span> </span><br><span>     if (!(fp = ast_frisolate(&control_frame))) {</span><br><span>             ast_log(LOG_ERROR, "error generating T.38 request control frame on chan %s for T.38 gateway session\n", ast_channel_name(chan));</span><br><span style="color: hsl(0, 100%, 40%);">-              return f;</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span>         }</span><br><span> </span><br><span>        gateway->t38_state = T38_STATE_NEGOTIATING;</span><br><span>@@ -3016,17 +3016,40 @@</span><br><span> </span><br><span>         if (gateway->detected_v21) {</span><br><span>              enum ast_t38_state state_other;</span><br><span style="color: hsl(120, 100%, 40%);">+               enum ast_t38_state state_active;</span><br><span style="color: hsl(120, 100%, 40%);">+              struct ast_frame *fp;</span><br><span> </span><br><span>            destroy_v21_sessions(gateway);</span><br><span> </span><br><span>           ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+             state_active = ast_channel_get_t38_state(active);</span><br><span>            state_other = ast_channel_get_t38_state(other);</span><br><span>              ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">-         if (state_other == T38_STATE_UNKNOWN) {</span><br><span style="color: hsl(0, 100%, 40%);">-                 ast_debug(1, "detected v21 preamble from %s\n", ast_channel_name(active));</span><br><span style="color: hsl(0, 100%, 40%);">-                    return fax_gateway_request_t38(gateway, chan, f);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           ast_debug(1, "detected v21 preamble from %s\n", ast_channel_name(active));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                if (state_active == T38_STATE_UNKNOWN || state_other == T38_STATE_UNKNOWN) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  if (!(fp = fax_gateway_request_t38(gateway, chan, f))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              return f;</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* May be called endpoint is improperly configured to rely on the calling endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+                     * to initiate T.38 re-INVITEs, send T.38 negotiation request to called endpoint */</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (state_active == T38_STATE_UNKNOWN) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              ast_debug(1, "sending T.38 negotiation request to %s\n", ast_channel_name(active));</span><br><span style="color: hsl(120, 100%, 40%);">+                         if (active == chan) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                 ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+                             }</span><br><span style="color: hsl(120, 100%, 40%);">+                             ast_write(active, fp);</span><br><span style="color: hsl(120, 100%, 40%);">+                                if (active == chan) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                 ast_channel_lock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+                               }</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (state_other == T38_STATE_UNKNOWN) {</span><br><span style="color: hsl(120, 100%, 40%);">+                               ast_debug(1, "sending T.38 negotiation request to %s\n", ast_channel_name(other));</span><br><span style="color: hsl(120, 100%, 40%);">+                          return fp;</span><br><span style="color: hsl(120, 100%, 40%);">+                    }</span><br><span>            } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                        ast_debug(1, "detected v21 preamble on %s, but %s does not support T.38 for T.38 gateway session\n", ast_channel_name(active), ast_channel_name(other));</span><br><span style="color: hsl(120, 100%, 40%);">+                    ast_debug(1, "neither %s nor %s support T.38 for T.38 gateway session\n", ast_channel_name(active), ast_channel_name(other));</span><br><span>              }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11422">change 11422</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11422"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I73bb24799bfe1a48adae9c034a2edbae54cc2a39 </div>
<div style="display:none"> Gerrit-Change-Number: 11422 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>