<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14647">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
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip.c: Added disable_rport option for pjsip.conf<br><br>Currently when the pjsip making an outgoing request, it keep adding the<br>rport parameter in a request message as a default.<br><br>This causes unexpected rport handle at the other end.<br><br>Added option for disable this behaviour in the pjsip.conf.<br><br>This is a system option, but working as a gloabl option.<br><br>ASTERISK-28959<br><br>Change-Id: I9596675e52a742774738b5aad5d1fec32f477abc<br>---<br>M configs/samples/pjsip.conf.sample<br>A contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py<br>A doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt<br>M res/res_pjsip.c<br>M res/res_pjsip/config_system.c<br>5 files changed, 61 insertions(+), 0 deletions(-)<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 fd2d742..00da05d 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -1008,6 +1008,7 @@</span><br><span>                            ; This option must also be enabled on endpoints that</span><br><span>                            ; require this functionality.</span><br><span>                            ; (default: no)</span><br><span style="color: hsl(120, 100%, 40%);">+;disable_rport=no ; Disable the use of "rport" in outgoing requests.</span><br><span> ;type=  ; Must be of type system (default: "")</span><br><span> </span><br><span> ;==========================GLOBAL SECTION OPTIONS=========================</span><br><span>diff --git a/contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py b/contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py</span><br><span>new file mode 100644</span><br><span>index 0000000..c0e9df7</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py</span><br><span>@@ -0,0 +1,39 @@</span><br><span style="color: hsl(120, 100%, 40%);">+"""pjsip add disable_rport</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Revision ID: 79290b511e4b</span><br><span style="color: hsl(120, 100%, 40%);">+Revises: 339e1dfa644d</span><br><span style="color: hsl(120, 100%, 40%);">+Create Date: 2020-06-25 22:21:37.529880</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 = '79290b511e4b'</span><br><span style="color: hsl(120, 100%, 40%);">+down_revision = '339e1dfa644d'</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%);">+# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write</span><br><span style="color: hsl(120, 100%, 40%);">+# those aliases.</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def upgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+    ############################# Enums ##############################</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    # ast_bool_values has already been created, so use postgres enum object</span><br><span style="color: hsl(120, 100%, 40%);">+    # type to get around "already created" issue - works okay with mysql</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    op.add_column('ps_systems', sa.Column('disable_rport', 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%);">+    if op.get_context().bind.dialect.name == 'mssql':</span><br><span style="color: hsl(120, 100%, 40%);">+        op.drop_constraint('ck_ps_systems_disable_rport_ast_bool_values','ps_systems')</span><br><span style="color: hsl(120, 100%, 40%);">+    op.drop_column('ps_systems', 'disable_rport')</span><br><span>diff --git a/doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt b/doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..a565e20</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Added a new PJSIP system setting called disable_rport.</span><br><span style="color: hsl(120, 100%, 40%);">+Default is no to keep support working as before.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+If it is false (default) it adds the 'rport' parameter in the outgoing request message.</span><br><span style="color: hsl(120, 100%, 40%);">+If it is true it does not add the 'rport' parameter in the outgoing request message.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This is a system option, but working as a global option.</span><br><span>\ No newline at end of file</span><br><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index 0b7b634..10cb29c 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -1699,6 +1699,12 @@</span><br><span>                                           </para></note></span><br><span>                                   </description></span><br><span>                                 </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+                         <configOption name="disable_rport" default="no"></span><br><span style="color: hsl(120, 100%, 40%);">+                                    <synopsis>Disable the use of rport in outgoing requests.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+                                       <description><para></span><br><span style="color: hsl(120, 100%, 40%);">+                                               Remove "rport" parameter from the outgoing requests.</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="type"></span><br><span>                                   <synopsis>Must be of type 'system' UNLESS the object name is 'system'.</synopsis></span><br><span>                                </configOption></span><br><span>diff --git a/res/res_pjsip/config_system.c b/res/res_pjsip/config_system.c</span><br><span>index 716a6da..e16738f 100644</span><br><span>--- a/res/res_pjsip/config_system.c</span><br><span>+++ b/res/res_pjsip/config_system.c</span><br><span>@@ -59,6 +59,8 @@</span><br><span>    */</span><br><span>  unsigned int follow_early_media_fork;</span><br><span>        unsigned int accept_multiple_sdp_answers;</span><br><span style="color: hsl(120, 100%, 40%);">+     /*! Disable the use of rport in outgoing requests */</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int disable_rport;</span><br><span> };</span><br><span> </span><br><span> static struct ast_threadpool_options sip_threadpool_options = {</span><br><span>@@ -131,6 +133,8 @@</span><br><span>       pjsip_cfg()->endpt.disable_tcp_switch =</span><br><span>           system->disable_tcp_switch ? PJ_TRUE : PJ_FALSE;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+       pjsip_cfg()->endpt.disable_rport = system->disable_rport ? PJ_TRUE : PJ_FALSE;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       return 0;</span><br><span> }</span><br><span> </span><br><span>@@ -209,6 +213,8 @@</span><br><span>                     OPT_BOOL_T, 1, FLDSET(struct system_config, follow_early_media_fork));</span><br><span>       ast_sorcery_object_field_register(system_sorcery, "system", "accept_multiple_sdp_answers", "no",</span><br><span>                       OPT_BOOL_T, 1, FLDSET(struct system_config, accept_multiple_sdp_answers));</span><br><span style="color: hsl(120, 100%, 40%);">+    ast_sorcery_object_field_register(system_sorcery, "system", "disable_rport", "no",</span><br><span style="color: hsl(120, 100%, 40%);">+                      OPT_BOOL_T, 1, FLDSET(struct system_config, disable_rport));</span><br><span> </span><br><span>     ast_sorcery_load(system_sorcery);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14647">change 14647</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/+/14647"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I9596675e52a742774738b5aad5d1fec32f477abc </div>
<div style="display:none"> Gerrit-Change-Number: 14647 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@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@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>