<p>Kevin Harwell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13443">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_fax: wrap v21 detected Asterisk initiated negotiation with config option<br><br>A previous patch:<br><br>Gerrit Change-Id: I73bb24799bfe1a48adae9c034a2edbae54cc2a39<br><br>made it so a T.38 Gateway tries to negotiate with both sides by sending T.38<br>negotiation request to both endpoints supported T.38 versus the previous<br>behavior of forwarding negotiation to the "other" channel once a preamble<br>was detected.<br><br>This had the unfortunate side effect of breaking some setups. Specifically<br>ones that set the max datagram option on an endpoint configuration (configured<br>max datagram was not propagated since Asterisk now initiates negotiations).<br><br>This patch adds a configuration option, "negotiate_both", that when enabled<br>makes it so Asterisk initiates the negotiation requests to both endpoints vs.<br>the previous behavior of waiting, and forwarding the request.<br><br>The default is disabled keeping with the old behavior.<br><br>ASTERISK-28660<br><br>Change-Id: I5deb875f3485e20bc75119ec743090655d864a1a<br>---<br>A doc/CHANGES-staging/res_fax_negotiate_both<br>M include/asterisk/res_fax.h<br>M res/res_fax.c<br>3 files changed, 35 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/43/13443/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_fax_negotiate_both b/doc/CHANGES-staging/res_fax_negotiate_both</span><br><span>new file mode 100644</span><br><span>index 0000000..73be756</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_fax_negotiate_both</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_fax</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Added configuration option "negotiate_both". This option is only used</span><br><span style="color: hsl(120, 100%, 40%);">+when a gateway is enabled, and a v21 preamble is detected. If this option</span><br><span style="color: hsl(120, 100%, 40%);">+is enabled, once a preamble is detected Asterisk will initiate negotiation</span><br><span style="color: hsl(120, 100%, 40%);">+requests to both T.38 enabled endpoint versus waiting, and forwarding a</span><br><span style="color: hsl(120, 100%, 40%);">+request from an initiating endpoint. Defaults to disabled.</span><br><span>diff --git a/include/asterisk/res_fax.h b/include/asterisk/res_fax.h</span><br><span>index c1dd378..dc455bb 100644</span><br><span>--- a/include/asterisk/res_fax.h</span><br><span>+++ b/include/asterisk/res_fax.h</span><br><span>@@ -189,6 +189,9 @@</span><br><span> int faxdetect_flags;</span><br><span> /*! Non-zero if T.38 is negotiated */</span><br><span> int is_t38_negotiated;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Upon v21 detection the gateway sends negotiation requests to both</span><br><span style="color: hsl(120, 100%, 40%);">+ T.38 endpoints, and do not wait on the "other" side to initiate */</span><br><span style="color: hsl(120, 100%, 40%);">+ int negotiate_both;</span><br><span> };</span><br><span> </span><br><span> struct ast_fax_tech;</span><br><span>diff --git a/res/res_fax.c b/res/res_fax.c</span><br><span>index 7d9cb4e..ebb2b46 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -226,6 +226,9 @@</span><br><span> <enum name="t38timeout"></span><br><span> <para>R/W The timeout used for T.38 negotiation.</para></span><br><span> </enum></span><br><span style="color: hsl(120, 100%, 40%);">+ <enum name="negotiate_both"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>R/W Upon v21 detection allow gateway to send negotiation requests to both T.38 endpoints, and do not wait on the "other" side to initiate (yes|no)</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </enum></span><br><span> </enumlist></span><br><span> </parameter></span><br><span> </syntax></span><br><span>@@ -722,6 +725,7 @@</span><br><span> d->gateway_id = -1;</span><br><span> d->faxdetect_id = -1;</span><br><span> d->gateway_timeout = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ d->negotiate_both = 0;</span><br><span> </span><br><span> return d;</span><br><span> }</span><br><span>@@ -3023,6 +3027,22 @@</span><br><span> enum ast_t38_state state_other;</span><br><span> enum ast_t38_state state_active;</span><br><span> struct ast_frame *fp;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_fax_session_details *details;</span><br><span style="color: hsl(120, 100%, 40%);">+ int negotiate_both = 0;</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%);">+ * The default behavior is to wait for the active endpoint to initiate negotiation.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Find out if this has been overridden. If so, instead of waiting have Asterisk</span><br><span style="color: hsl(120, 100%, 40%);">+ * initiate the negotiation requests out to both endpoints.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ details = find_or_create_details(active);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (details) {</span><br><span style="color: hsl(120, 100%, 40%);">+ negotiate_both = details->negotiate_both;</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(details, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Detect v21 - no session details for channel '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> destroy_v21_sessions(gateway);</span><br><span> </span><br><span>@@ -3039,7 +3059,7 @@</span><br><span> }</span><br><span> /* May be called endpoint is improperly configured to rely on the calling endpoint</span><br><span> * to initiate T.38 re-INVITEs, send T.38 negotiation request to called endpoint */</span><br><span style="color: hsl(0, 100%, 40%);">- if (state_active == T38_STATE_UNKNOWN) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (negotiate_both && state_active == T38_STATE_UNKNOWN) {</span><br><span> ast_debug(1, "sending T.38 negotiation request to %s\n", ast_channel_name(active));</span><br><span> if (active == chan) {</span><br><span> ast_channel_unlock(chan);</span><br><span>@@ -4557,6 +4577,8 @@</span><br><span> ast_fax_modem_to_str(details->modems, buf, len);</span><br><span> } else if (!strcasecmp(data, "t38timeout")) {</span><br><span> snprintf(buf, len, "%u", details->t38timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(data, "negotiate_both")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(buf, details->negotiate_both != -1 ? "yes" : "no", len);</span><br><span> } else {</span><br><span> ast_log(LOG_WARNING, "channel '%s' can't read FAXOPT(%s) because it is unhandled!\n", ast_channel_name(chan), data);</span><br><span> res = -1;</span><br><span>@@ -4695,6 +4717,8 @@</span><br><span> }</span><br><span> } else if ((!strcasecmp(data, "modem")) || (!strcasecmp(data, "modems"))) {</span><br><span> update_modem_bits(&details->modems, value);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(data, "negotiate_both")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ details->negotiate_both = ast_true(ast_skip_blanks(value));</span><br><span> } else {</span><br><span> ast_log(LOG_WARNING, "channel '%s' set FAXOPT(%s) to '%s' is unhandled!\n", ast_channel_name(chan), data, value);</span><br><span> res = -1;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13443">change 13443</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/+/13443"/><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: I5deb875f3485e20bc75119ec743090655d864a1a </div>
<div style="display:none"> Gerrit-Change-Number: 13443 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>