<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16156">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: 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_pjsip_t38: bind UDPTL sessions like RTP<br><br>In res_pjsip_sdp_rtp, the bind_rtp_to_media_address option and the<br>fallback use of the transport's bind address solve problems sending<br>media on systems that cannot send ipv4 packets on ipv6 sockets, and<br>certain other situations. This change extends both of these behaviors<br>to UDPTL sessions as well in res_pjsip_t38, to fix fax-specific<br>problems on these systems, introducing a new option<br>endpoint/t38_bind_udptl_to_media_address.<br><br>ASTERISK-29402<br><br>Change-Id: I87220c0e9cdd2fe9d156846cb906debe08c63557<br>---<br>M configs/samples/pjsip.conf.sample<br>A contrib/ast-db-manage/config/versions/a06d8f8462d9_add_t38_bind_udptl_to_media_address.py<br>A doc/CHANGES-staging/res_pjsip_t38_bind_fixes.txt<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip.c<br>M res/res_pjsip/pjsip_configuration.c<br>M res/res_pjsip_t38.c<br>7 files changed, 96 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample</span><br><span>index 80888c3..2d57208 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -737,6 +737,9 @@</span><br><span> ; (default: "0")</span><br><span> ;t38_udptl_nat=no ; Whether NAT support is enabled on UDPTL sessions</span><br><span> ; (default: "no")</span><br><span style="color: hsl(120, 100%, 40%);">+;t38_bind_rtp_to_media_address= ; Bind the UDPTL session to the media_address.</span><br><span style="color: hsl(120, 100%, 40%);">+ ; This causes all UDPTL packets to be sent from</span><br><span style="color: hsl(120, 100%, 40%);">+ ; the specified address. (default: "no")</span><br><span> ;tone_zone= ; Set which country s indications to use for channels created</span><br><span> ; for this endpoint (default: "")</span><br><span> ;language= ; Set the default language to use for channels created for this</span><br><span>diff --git a/contrib/ast-db-manage/config/versions/a06d8f8462d9_add_t38_bind_udptl_to_media_address.py b/contrib/ast-db-manage/config/versions/a06d8f8462d9_add_t38_bind_udptl_to_media_address.py</span><br><span>new file mode 100644</span><br><span>index 0000000..2d9a58c</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/ast-db-manage/config/versions/a06d8f8462d9_add_t38_bind_udptl_to_media_address.py</span><br><span>@@ -0,0 +1,29 @@</span><br><span style="color: hsl(120, 100%, 40%);">+"""add t38_bind_udptl_to_media_address</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Revision ID: a06d8f8462d9</span><br><span style="color: hsl(120, 100%, 40%);">+Revises: f56d79a9f337</span><br><span style="color: hsl(120, 100%, 40%);">+Create Date: 2021-09-24 10:03:01.320480</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# revision identifiers, used by Alembic.</span><br><span style="color: hsl(120, 100%, 40%);">+revision = 'a06d8f8462d9'</span><br><span style="color: hsl(120, 100%, 40%);">+down_revision = 'f56d79a9f337'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+from alembic import op</span><br><span style="color: hsl(120, 100%, 40%);">+import sqlalchemy as sa</span><br><span style="color: hsl(120, 100%, 40%);">+from sqlalchemy.dialects.postgresql import ENUM</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AST_BOOL_NAME = 'ast_bool_values'</span><br><span style="color: hsl(120, 100%, 40%);">+AST_BOOL_VALUES = [ '0', '1',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'off', 'on',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'false', 'true',</span><br><span style="color: hsl(120, 100%, 40%);">+ 'no', 'yes' ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def upgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)</span><br><span style="color: hsl(120, 100%, 40%);">+ op.add_column('ps_endpoints', sa.Column('t38_bind_udptl_to_media_address', ast_bool_values))</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%);">+def downgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_column('ps_endpoints', 't38_bind_udptl_to_media_address')</span><br><span>diff --git a/doc/CHANGES-staging/res_pjsip_t38_bind_fixes.txt b/doc/CHANGES-staging/res_pjsip_t38_bind_fixes.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..d7bc8a1</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_t38_bind_fixes.txt</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_pjsip_t38</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In res_pjsip_sdp_rtp, the bind_rtp_to_media_address option and the</span><br><span style="color: hsl(120, 100%, 40%);">+fallback use of the transport's bind address solve problems sending</span><br><span style="color: hsl(120, 100%, 40%);">+media on systems that cannot send ipv4 packets on ipv6 sockets, and</span><br><span style="color: hsl(120, 100%, 40%);">+certain other situations. This change extends both of these behaviors</span><br><span style="color: hsl(120, 100%, 40%);">+to UDPTL sessions as well in res_pjsip_t38, to fix fax-specific</span><br><span style="color: hsl(120, 100%, 40%);">+problems on these systems, introducing a new option</span><br><span style="color: hsl(120, 100%, 40%);">+endpoint/t38_bind_udptl_to_media_address.</span><br><span>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h</span><br><span>index 8c5b775..7b9dcbd 100644</span><br><span>--- a/include/asterisk/res_pjsip.h</span><br><span>+++ b/include/asterisk/res_pjsip.h</span><br><span>@@ -760,6 +760,8 @@</span><br><span> unsigned int nat;</span><br><span> /*! Whether to use IPv6 for UDPTL or not */</span><br><span> unsigned int ipv6;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Bind the UDPTL instance to the media_address */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int bind_udptl_to_media_address;</span><br><span> };</span><br><span> </span><br><span> /*!</span><br><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index a375fe0..2b30317 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -940,6 +940,13 @@</span><br><span> When enabled the UDPTL stack will use IPv6.</span><br><span> </para></description></span><br><span> </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="t38_bind_udptl_to_media_address" default="no"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Bind the UDPTL instance to the media_adress</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <description><para></span><br><span style="color: hsl(120, 100%, 40%);">+ If media_address is specified, this option causes the UDPTL instance to be bound to</span><br><span style="color: hsl(120, 100%, 40%);">+ the specified ip address which causes the packets to be sent from that address.</span><br><span style="color: hsl(120, 100%, 40%);">+ </para></description></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span> <configOption name="tone_zone"></span><br><span> <synopsis>Set which country's indications to use for channels created for this endpoint.</synopsis></span><br><span> </configOption></span><br><span>@@ -2783,6 +2790,9 @@</span><br><span> <parameter name="T38UdptlIpv6"></span><br><span> <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl_ipv6']/synopsis/node())"/></para></span><br><span> </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="T38BindUdptlToMediaAddress"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_bind_udptl_to_media_address']/synopsis/node())"/></para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span> <parameter name="ToneZone"></span><br><span> <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tone_zone']/synopsis/node())"/></para></span><br><span> </parameter></span><br><span>diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c</span><br><span>index 6defa7c..c27b587 100644</span><br><span>--- a/res/res_pjsip/pjsip_configuration.c</span><br><span>+++ b/res/res_pjsip/pjsip_configuration.c</span><br><span>@@ -2077,6 +2077,7 @@</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, faxdetect_timeout));</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.nat));</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.ipv6));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_bind_udptl_to_media_address", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.bind_udptl_to_media_address));</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tone_zone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "language", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, language));</span><br><span> ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_on_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.onfeature));</span><br><span>diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c</span><br><span>index 5d7f68d..7df35d9 100644</span><br><span>--- a/res/res_pjsip_t38.c</span><br><span>+++ b/res/res_pjsip_t38.c</span><br><span>@@ -255,11 +255,52 @@</span><br><span> /*! \brief Initializes UDPTL support on a session, only done when actually needed */</span><br><span> static int t38_initialize_session(struct ast_sip_session *session, struct ast_sip_session_media *session_media)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sockaddr temp_media_address;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sockaddr *media_address = &address;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (session_media->udptl) {</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(session_media->udptl = ast_udptl_new_with_bindaddr(NULL, NULL, 0, &address))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (session->endpoint->media.t38.bind_udptl_to_media_address && !ast_strlen_zero(session->endpoint->media.address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sockaddr_parse(&temp_media_address, session->endpoint->media.address, 0)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(5, "Endpoint %s: Binding UDPTL media to %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_get_id(session->endpoint),</span><br><span style="color: hsl(120, 100%, 40%);">+ session->endpoint->media.address);</span><br><span style="color: hsl(120, 100%, 40%);">+ media_address = &temp_media_address;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(5, "Endpoint %s: UDPTL media address invalid: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_get_id(session->endpoint),</span><br><span style="color: hsl(120, 100%, 40%);">+ session->endpoint->media.address);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sip_transport *transport;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",</span><br><span style="color: hsl(120, 100%, 40%);">+ session->endpoint->transport);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (transport) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sip_transport_state *trans_state;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ trans_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (trans_state) {</span><br><span style="color: hsl(120, 100%, 40%);">+ char hoststr[PJ_INET6_ADDRSTRLEN];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_print(&trans_state->host, hoststr, sizeof(hoststr), 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sockaddr_parse(&temp_media_address, hoststr, 0)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(5, "Transport %s bound to %s: Using it for UDPTL media.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ session->endpoint->transport, hoststr);</span><br><span style="color: hsl(120, 100%, 40%);">+ media_address = &temp_media_address;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(5, "Transport %s bound to %s: Invalid for UDPTL media.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ session->endpoint->transport, hoststr);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(trans_state, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(transport, -1);</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(session_media->udptl = ast_udptl_new_with_bindaddr(NULL, NULL, 0, media_address))) {</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16156">change 16156</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/+/16156"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I87220c0e9cdd2fe9d156846cb906debe08c63557 </div>
<div style="display:none"> Gerrit-Change-Number: 16156 </div>
<div style="display:none"> Gerrit-PatchSet: 7 </div>
<div style="display:none"> Gerrit-Owner: Matthew Kern <mkern@alconconstruction.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@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Joe <ynadiv@corpit.xyz> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>