<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11486">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><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, 34 insertions(+), 8 deletions(-)<br><br></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 e4f315a..7d9cb4e 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -2921,6 +2921,9 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* if we start gateway we don't need v21 detection sessions any more */</span><br><span style="color: hsl(120, 100%, 40%);">+ destroy_v21_sessions(gateway);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* create the FAX session */</span><br><span> if (!(s = fax_session_new(details, chan, gateway->s, gateway->token))) {</span><br><span> gateway->token = NULL;</span><br><span>@@ -2962,7 +2965,7 @@</span><br><span> }</span><br><span> </span><br><span> /*! \pre chan is locked on entry */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct ast_frame *fax_gateway_request_t38(struct fax_gateway *gateway, struct ast_channel *chan, struct ast_frame *f)</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_frame *fax_gateway_request_t38(struct fax_gateway *gateway, struct ast_channel *chan)</span><br><span> {</span><br><span> struct ast_frame *fp;</span><br><span> struct ast_control_t38_parameters t38_parameters = {</span><br><span>@@ -2981,7 +2984,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>@@ -2989,7 +2992,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>@@ -3018,17 +3021,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))) {</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>@@ -3190,7 +3216,7 @@</span><br><span> ast_channel_lock(chan);</span><br><span> if (state_other == T38_STATE_UNKNOWN) {</span><br><span> gateway->t38_state = T38_STATE_UNAVAILABLE;</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (state_other != T38_STATE_NEGOTIATING) {</span><br><span> ast_framehook_detach(chan, details->gateway_id);</span><br><span> details->gateway_id = -1;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11486">change 11486</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/+/11486"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I73bb24799bfe1a48adae9c034a2edbae54cc2a39 </div>
<div style="display:none"> Gerrit-Change-Number: 11486 </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-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>