<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11297">View Change</a></p><div style="white-space:pre-wrap">Approvals:
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: Added a norefersub configuration setting<br><br>Added a new PJSIP global setting called norefersub.<br>Default is true to keep support working as before.<br><br>res_pjsip_refer: Configures PJSIP norefersub capability accordingly.<br><br>Checks the PJSIP global setting value.<br>If it is true (default) it adds the norefersub capability to PJSIP.<br>If it is false (disabled) it does not add the norefersub capability<br>to PJSIP.<br><br>This is useful for Cisco switches that do not follow RFC4488.<br><br>ASTERISK-28375 #close<br>Reported-by: Dan Cropp<br><br>Change-Id: I0b1c28ebc905d881f4a16e752715487a688b30e9<br>---<br>M configs/samples/pjsip.conf.sample<br>A contrib/ast-db-manage/config/versions/3a094a18e75b_pjsip_add_norefersub.py<br>A doc/CHANGES-staging/res_pjsip_add_norefersub_global_config.txt<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip.c<br>M res/res_pjsip/config_global.c<br>M res/res_pjsip_refer.c<br>7 files changed, 92 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 574efee..bbd0317 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -1132,6 +1132,11 @@</span><br><span> ; with extreme caution and only to mitigate specific issues.</span><br><span> ; Under certain conditions they could make things worse.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+;norefersub=yes ; Enable sending norefersub option tag in Supported header to advertise</span><br><span style="color: hsl(120, 100%, 40%);">+ ; that the User Agent is capable of accepting a REFER request with</span><br><span style="color: hsl(120, 100%, 40%);">+ ; creating an implicit subscription (see RFC 4488).</span><br><span style="color: hsl(120, 100%, 40%);">+ ; (default: "yes")</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl</span><br><span> ;==========================ACL SECTION OPTIONS=========================</span><br><span> ;[acl]</span><br><span>diff --git a/contrib/ast-db-manage/config/versions/3a094a18e75b_pjsip_add_norefersub.py b/contrib/ast-db-manage/config/versions/3a094a18e75b_pjsip_add_norefersub.py</span><br><span>new file mode 100644</span><br><span>index 0000000..1209ae2</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/ast-db-manage/config/versions/3a094a18e75b_pjsip_add_norefersub.py</span><br><span>@@ -0,0 +1,39 @@</span><br><span style="color: hsl(120, 100%, 40%);">+"""pjsip add norefersub</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Revision ID: 3a094a18e75b</span><br><span style="color: hsl(120, 100%, 40%);">+Revises: 80473bad3c16</span><br><span style="color: hsl(120, 100%, 40%);">+Create Date: 2019-04-17 09:25:42.040269</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 = '3a094a18e75b'</span><br><span style="color: hsl(120, 100%, 40%);">+down_revision = '80473bad3c16'</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=True)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ op.add_column('ps_globals', sa.Column('norefersub', 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_globals_norefersub_ast_bool_values', 'ps_globals')</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_column('ps_globals', 'norefersub')</span><br><span>diff --git a/doc/CHANGES-staging/res_pjsip_add_norefersub_global_config.txt b/doc/CHANGES-staging/res_pjsip_add_norefersub_global_config.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..4e07672</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_add_norefersub_global_config.txt</span><br><span>@@ -0,0 +1,13 @@</span><br><span style="color: hsl(120, 100%, 40%);">+res_pjsip: Added a norefersub configuration setting</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Added a new PJSIP global setting called norefersub.</span><br><span style="color: hsl(120, 100%, 40%);">+Default is true to keep support working as before.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+res_pjsip_refer: Configures PJSIP norefersub capability accordingly.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Checks the PJSIP global setting value.</span><br><span style="color: hsl(120, 100%, 40%);">+If it is true (default) it adds the norefersub capability to PJSIP.</span><br><span style="color: hsl(120, 100%, 40%);">+If it is false (disabled) it does not add the norefersub capability</span><br><span style="color: hsl(120, 100%, 40%);">+to PJSIP.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This is useful for Cisco switches that do not follow RFC4488.</span><br><span>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h</span><br><span>index 79c29cc..5e8dd3a 100644</span><br><span>--- a/include/asterisk/res_pjsip.h</span><br><span>+++ b/include/asterisk/res_pjsip.h</span><br><span>@@ -2788,6 +2788,13 @@</span><br><span> unsigned int ast_sip_get_use_callerid_contact(void);</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Retrieve the global setting 'norefersub'.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval non zero if norefersub is to be sent in "Supported" Headers</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+unsigned int ast_sip_get_norefersub(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span> * \brief Retrieve the global setting 'ignore_uri_user_options'.</span><br><span> * \since 13.12.0</span><br><span> *</span><br><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index 2d5f0da..7773549 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -1874,6 +1874,9 @@</span><br><span> </para></warning></span><br><span> </description></span><br><span> </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="norefersub" default="yes"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span> </configObject></span><br><span> </configFile></span><br><span> </configInfo></span><br><span>diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c</span><br><span>index 365d9aa..25a0b51 100644</span><br><span>--- a/res/res_pjsip/config_global.c</span><br><span>+++ b/res/res_pjsip/config_global.c</span><br><span>@@ -52,6 +52,7 @@</span><br><span> #define DEFAULT_USE_CALLERID_CONTACT 0</span><br><span> #define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION 1</span><br><span> #define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL</span><br><span style="color: hsl(120, 100%, 40%);">+#define DEFAULT_NOREFERSUB 1</span><br><span> </span><br><span> /*!</span><br><span> * \brief Cached global config object</span><br><span>@@ -113,6 +114,8 @@</span><br><span> unsigned int send_contact_status_on_update_registration;</span><br><span> /*! Trigger the distributor should use to pause accepting new dialogs */</span><br><span> enum ast_sip_taskprocessor_overload_trigger overload_trigger;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Nonzero if norefersub is to be sent in Supported header */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int norefersub;</span><br><span> };</span><br><span> </span><br><span> static void global_destructor(void *obj)</span><br><span>@@ -501,6 +504,21 @@</span><br><span> return trigger;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+unsigned int ast_sip_get_norefersub(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int norefersub;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct global_config *cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg = get_global_cfg();</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cfg) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return DEFAULT_NOREFERSUB;</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%);">+ norefersub = cfg->norefersub;</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return norefersub;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int overload_trigger_handler(const struct aco_option *opt,</span><br><span> struct ast_variable *var, void *obj)</span><br><span> {</span><br><span>@@ -704,6 +722,9 @@</span><br><span> ast_sorcery_object_field_register_custom(sorcery, "global", "taskprocessor_overload_trigger",</span><br><span> overload_trigger_map[DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER],</span><br><span> overload_trigger_handler, overload_trigger_to_str, NULL, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register(sorcery, "global", "norefersub",</span><br><span style="color: hsl(120, 100%, 40%);">+ DEFAULT_NOREFERSUB ? "yes" : "no",</span><br><span style="color: hsl(120, 100%, 40%);">+ OPT_YESNO_T, 1, FLDSET(struct global_config, norefersub));</span><br><span> </span><br><span> if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {</span><br><span> return -1;</span><br><span>diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c</span><br><span>index 9b35c6a..3c73801 100644</span><br><span>--- a/res/res_pjsip_refer.c</span><br><span>+++ b/res/res_pjsip_refer.c</span><br><span>@@ -1232,7 +1232,10 @@</span><br><span> </span><br><span> pjsip_replaces_init_module(ast_sip_get_pjsip_endpoint());</span><br><span> pjsip_xfer_init_module(ast_sip_get_pjsip_endpoint());</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_get_norefersub()) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> ast_sip_register_service(&refer_progress_module);</span><br><span> ast_sip_session_register_supplement(&refer_supplement);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11297">change 11297</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/+/11297"/><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: I0b1c28ebc905d881f4a16e752715487a688b30e9 </div>
<div style="display:none"> Gerrit-Change-Number: 11297 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Dan Cropp <dan@amtelco.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-MessageType: merged </div>