<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18449">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip: add allow_sending_180_after_183 option<br><br>added new global config option "allow_sending_180_after_183"<br>that if enabled will preserve 180 after a 183<br><br>ASTERISK-29842<br><br>Change-Id: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18<br>---<br>M channels/chan_pjsip.c<br>M configs/samples/pjsip.conf.sample<br>A contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py<br>A doc/CHANGES-staging/chan_pjsip_180_sdp.txt<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip/config_global.c<br>M res/res_pjsip/pjsip_config.xml<br>7 files changed, 94 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index 61c4cfb..d55bdf9 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -1630,8 +1630,12 @@</span><br><span> if (channel->session->endpoint->inband_progress ||</span><br><span> (channel->session->inv_session && channel->session->inv_session->neg &&</span><br><span> pjmedia_sdp_neg_get_state(channel->session->inv_session->neg) == PJMEDIA_SDP_NEG_STATE_DONE)) {</span><br><span style="color: hsl(0, 100%, 40%);">- response_code = 183;</span><br><span> res = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_get_allow_sending_180_after_183()) {</span><br><span style="color: hsl(120, 100%, 40%);">+ response_code = 180;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ response_code = 183;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> } else {</span><br><span> response_code = 180;</span><br><span> }</span><br><span>diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample</span><br><span>index 2d93bd1..0303050 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -1311,6 +1311,12 @@</span><br><span> ; creating an implicit subscription (see RFC 4488).</span><br><span> ; (default: "yes")</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+;allow_sending_180_after_183=yes ; Allow Asterisk to send 180 Ringing to an endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+ ; after 183 Session Progress has been send.</span><br><span style="color: hsl(120, 100%, 40%);">+ ; If disabled Asterisk will instead send only a</span><br><span style="color: hsl(120, 100%, 40%);">+ ; 183 Session Progress to the endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">+ ; (default: "no")</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/0bee61aa9425_allow_180_ringing_with_sdp.py b/contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py</span><br><span>new file mode 100644</span><br><span>index 0000000..a671140</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py</span><br><span>@@ -0,0 +1,36 @@</span><br><span style="color: hsl(120, 100%, 40%);">+"""allow_sending_180_after_183</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Revision ID: 0bee61aa9425</span><br><span style="color: hsl(120, 100%, 40%);">+Revises: 8f72185e437f</span><br><span style="color: hsl(120, 100%, 40%);">+Create Date: 2022-04-07 13:51:33.400664</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%);">+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%);">+# revision identifiers, used by Alembic.</span><br><span style="color: hsl(120, 100%, 40%);">+revision = '0bee61aa9425'</span><br><span style="color: hsl(120, 100%, 40%);">+down_revision = '8f72185e437f'</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%);">+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_globals', sa.Column('allow_sending_180_after_183', 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_allow_sending_180_after_183_ast_bool_values', 'ps_globals')</span><br><span style="color: hsl(120, 100%, 40%);">+ op.drop_column('ps_globals', 'allow_sending_180_after_183')</span><br><span>diff --git a/doc/CHANGES-staging/chan_pjsip_180_sdp.txt b/doc/CHANGES-staging/chan_pjsip_180_sdp.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..ffd14af</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/chan_pjsip_180_sdp.txt</span><br><span>@@ -0,0 +1,8 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: chan_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+added global config option "allow_sending_180_after_183"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Allow Asterisk to send 180 Ringing to an endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+after 183 Session Progress has been send.</span><br><span style="color: hsl(120, 100%, 40%);">+If disabled Asterisk will instead send only a</span><br><span style="color: hsl(120, 100%, 40%);">+183 Session Progress to the endpoint.</span><br><span>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h</span><br><span>index 209cdbf..ba95c27 100644</span><br><span>--- a/include/asterisk/res_pjsip.h</span><br><span>+++ b/include/asterisk/res_pjsip.h</span><br><span>@@ -3066,6 +3066,13 @@</span><br><span> unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void);</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Retrieve the global setting 'allow_sending_180_after_183'.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval non zero if disable.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+unsigned int ast_sip_get_allow_sending_180_after_183(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 'use_callerid_contact'.</span><br><span> * \since 13.24.0</span><br><span> *</span><br><span>diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c</span><br><span>index 5bc1cc6..4620c3f 100644</span><br><span>--- a/res/res_pjsip/config_global.c</span><br><span>+++ b/res/res_pjsip/config_global.c</span><br><span>@@ -48,6 +48,7 @@</span><br><span> #define DEFAULT_MWI_TPS_QUEUE_HIGH AST_TASKPROCESSOR_HIGH_WATER_LEVEL</span><br><span> #define DEFAULT_MWI_TPS_QUEUE_LOW -1</span><br><span> #define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED 0</span><br><span style="color: hsl(120, 100%, 40%);">+#define DEFAULT_ALLOW_SENDING_180_AFTER_183 0</span><br><span> #define DEFAULT_IGNORE_URI_USER_OPTIONS 0</span><br><span> #define DEFAULT_USE_CALLERID_CONTACT 0</span><br><span> #define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION 0</span><br><span>@@ -92,6 +93,8 @@</span><br><span> unsigned int contact_expiration_check_interval;</span><br><span> /*! Nonzero to disable multi domain support */</span><br><span> unsigned int disable_multi_domain;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Nonzero to disable changing 180/SDP to 183/SDP */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int allow_sending_180_after_183;</span><br><span> /*! The maximum number of unidentified requests per source IP address before a security event is logged */</span><br><span> unsigned int unidentified_request_count;</span><br><span> /*! The period during which unidentified requests are accumulated */</span><br><span>@@ -444,6 +447,21 @@</span><br><span> return disable_initial_unsolicited;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+unsigned int ast_sip_get_allow_sending_180_after_183(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int allow_sending_180_after_183;</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_ALLOW_SENDING_180_AFTER_183;</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%);">+ allow_sending_180_after_183 = cfg->allow_sending_180_after_183;</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return allow_sending_180_after_183;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> unsigned int ast_sip_get_ignore_uri_user_options(void)</span><br><span> {</span><br><span> unsigned int ignore_uri_user_options;</span><br><span>@@ -708,6 +726,9 @@</span><br><span> ast_sorcery_object_field_register(sorcery, "global", "mwi_disable_initial_unsolicited",</span><br><span> DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED ? "yes" : "no",</span><br><span> OPT_BOOL_T, 1, FLDSET(struct global_config, mwi.disable_initial_unsolicited));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register(sorcery, "global", "allow_sending_180_after_183",</span><br><span style="color: hsl(120, 100%, 40%);">+ DEFAULT_ALLOW_SENDING_180_AFTER_183 ? "yes" : "no",</span><br><span style="color: hsl(120, 100%, 40%);">+ OPT_BOOL_T, 1, FLDSET(struct global_config, allow_sending_180_after_183));</span><br><span> ast_sorcery_object_field_register(sorcery, "global", "ignore_uri_user_options",</span><br><span> DEFAULT_IGNORE_URI_USER_OPTIONS ? "yes" : "no",</span><br><span> OPT_BOOL_T, 1, FLDSET(struct global_config, ignore_uri_user_options));</span><br><span>diff --git a/res/res_pjsip/pjsip_config.xml b/res/res_pjsip/pjsip_config.xml</span><br><span>index 9a9ef48..84736d6 100644</span><br><span>--- a/res/res_pjsip/pjsip_config.xml</span><br><span>+++ b/res/res_pjsip/pjsip_config.xml</span><br><span>@@ -2348,6 +2348,17 @@</span><br><span> <configOption name="norefersub" default="yes"></span><br><span> <synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis></span><br><span> </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="allow_sending_180_after_183" default="no"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Allow 180 after 183</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <description><para></span><br><span style="color: hsl(120, 100%, 40%);">+ Allow Asterisk to send 180 Ringing to an endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+ after 183 Session Progress has been send.</span><br><span style="color: hsl(120, 100%, 40%);">+ If disabled Asterisk will instead send only a</span><br><span style="color: hsl(120, 100%, 40%);">+ 183 Session Progress to the endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">+ (default: "no")</span><br><span style="color: hsl(120, 100%, 40%);">+ </para></span><br><span style="color: hsl(120, 100%, 40%);">+ </description></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></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18449">change 18449</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/+/18449"/><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: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18 </div>
<div style="display:none"> Gerrit-Change-Number: 18449 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Mark Petersen <asterisk.org@zombie.dk> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Mark Petersen <bugs.digium.com@zombie.dk> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>