[Asterisk-code-review] res_pjsip.c: Added disable_rport option for pjsip.conf (asterisk[13])

Friendly Automation asteriskteam at digium.com
Tue Jul 7 09:01:44 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14647 )

Change subject: res_pjsip.c: Added disable_rport option for pjsip.conf
......................................................................

res_pjsip.c: Added disable_rport option for pjsip.conf

Currently when the pjsip making an outgoing request, it keep adding the
rport parameter in a request message as a default.

This causes unexpected rport handle at the other end.

Added option for disable this behaviour in the pjsip.conf.

This is a system option, but working as a gloabl option.

ASTERISK-28959

Change-Id: I9596675e52a742774738b5aad5d1fec32f477abc
---
M configs/samples/pjsip.conf.sample
A contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py
A doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt
M res/res_pjsip.c
M res/res_pjsip/config_system.c
5 files changed, 61 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index fd2d742..00da05d 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -1008,6 +1008,7 @@
                            ; This option must also be enabled on endpoints that
                            ; require this functionality.
                            ; (default: no)
+;disable_rport=no ; Disable the use of "rport" in outgoing requests.
 ;type=  ; Must be of type system (default: "")
 
 ;==========================GLOBAL SECTION OPTIONS=========================
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
new file mode 100644
index 0000000..c0e9df7
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/79290b511e4b_pjsip_add_disable_rport.py
@@ -0,0 +1,39 @@
+"""pjsip add disable_rport
+
+Revision ID: 79290b511e4b
+Revises: 339e1dfa644d
+Create Date: 2020-06-25 22:21:37.529880
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '79290b511e4b'
+down_revision = '339e1dfa644d'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+AST_BOOL_NAME = 'ast_bool_values'
+# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
+# those aliases.
+AST_BOOL_VALUES = [ '0', '1',
+                    'off', 'on',
+                    'false', 'true',
+                    'no', 'yes' ]
+
+
+def upgrade():
+    ############################# Enums ##############################
+
+    # ast_bool_values has already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
+
+    op.add_column('ps_systems', sa.Column('disable_rport', ast_bool_values))
+
+
+def downgrade():
+    if op.get_context().bind.dialect.name == 'mssql':
+        op.drop_constraint('ck_ps_systems_disable_rport_ast_bool_values','ps_systems')
+    op.drop_column('ps_systems', 'disable_rport')
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
new file mode 100644
index 0000000..a565e20
--- /dev/null
+++ b/doc/CHANGES-staging/res_pjsip_add_disable_rport_system_config.txt
@@ -0,0 +1,9 @@
+Subject: res_pjsip
+
+Added a new PJSIP system setting called disable_rport.
+Default is no to keep support working as before.
+
+If it is false (default) it adds the 'rport' parameter in the outgoing request message.
+If it is true it does not add the 'rport' parameter in the outgoing request message.
+
+This is a system option, but working as a global option.
\ No newline at end of file
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 0b7b634..10cb29c 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1699,6 +1699,12 @@
 						</para></note>
 					</description>
 				</configOption>
+				<configOption name="disable_rport" default="no">
+					<synopsis>Disable the use of rport in outgoing requests.</synopsis>
+					<description><para>
+						Remove "rport" parameter from the outgoing requests.
+					</para></description>
+				</configOption>
 				<configOption name="type">
 					<synopsis>Must be of type 'system' UNLESS the object name is 'system'.</synopsis>
 				</configOption>
diff --git a/res/res_pjsip/config_system.c b/res/res_pjsip/config_system.c
index 716a6da..e16738f 100644
--- a/res/res_pjsip/config_system.c
+++ b/res/res_pjsip/config_system.c
@@ -59,6 +59,8 @@
 	 */
 	unsigned int follow_early_media_fork;
 	unsigned int accept_multiple_sdp_answers;
+	/*! Disable the use of rport in outgoing requests */
+	unsigned int disable_rport;
 };
 
 static struct ast_threadpool_options sip_threadpool_options = {
@@ -131,6 +133,8 @@
 	pjsip_cfg()->endpt.disable_tcp_switch =
 		system->disable_tcp_switch ? PJ_TRUE : PJ_FALSE;
 
+	pjsip_cfg()->endpt.disable_rport = system->disable_rport ? PJ_TRUE : PJ_FALSE;
+
 	return 0;
 }
 
@@ -209,6 +213,8 @@
 			OPT_BOOL_T, 1, FLDSET(struct system_config, follow_early_media_fork));
 	ast_sorcery_object_field_register(system_sorcery, "system", "accept_multiple_sdp_answers", "no",
 			OPT_BOOL_T, 1, FLDSET(struct system_config, accept_multiple_sdp_answers));
+	ast_sorcery_object_field_register(system_sorcery, "system", "disable_rport", "no",
+			OPT_BOOL_T, 1, FLDSET(struct system_config, disable_rport));
 
 	ast_sorcery_load(system_sorcery);
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14647
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I9596675e52a742774738b5aad5d1fec32f477abc
Gerrit-Change-Number: 14647
Gerrit-PatchSet: 3
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200707/64ad6d84/attachment.html>


More information about the asterisk-code-review mailing list