[Asterisk-code-review] chan_pjsip: add allow_sending_180_after_183 option (asterisk[master])
Mark Petersen
asteriskteam at digium.com
Tue Apr 26 13:39:19 CDT 2022
Mark Petersen has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18451 )
Change subject: chan_pjsip: add allow_sending_180_after_183 option
......................................................................
chan_pjsip: add allow_sending_180_after_183 option
added new global config option "allow_sending_180_after_183"
that if enabled will preserve 180 after a 183
ASTERISK-29842
Change-Id: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18
---
M channels/chan_pjsip.c
M configs/samples/pjsip.conf.sample
A contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py
A doc/CHANGES-staging/chan_pjsip_180_sdp.txt
M include/asterisk/res_pjsip.h
M res/res_pjsip/config_global.c
M res/res_pjsip/pjsip_config.xml
7 files changed, 94 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/51/18451/1
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 61c4cfb..d55bdf9 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1630,8 +1630,12 @@
if (channel->session->endpoint->inband_progress ||
(channel->session->inv_session && channel->session->inv_session->neg &&
pjmedia_sdp_neg_get_state(channel->session->inv_session->neg) == PJMEDIA_SDP_NEG_STATE_DONE)) {
- response_code = 183;
res = -1;
+ if (ast_sip_get_allow_sending_180_after_183()) {
+ response_code = 180;
+ } else {
+ response_code = 183;
+ }
} else {
response_code = 180;
}
diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index 2d93bd1..0303050 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -1311,6 +1311,12 @@
; creating an implicit subscription (see RFC 4488).
; (default: "yes")
+;allow_sending_180_after_183=yes ; Allow Asterisk to send 180 Ringing to an endpoint
+ ; after 183 Session Progress has been send.
+ ; If disabled Asterisk will instead send only a
+ ; 183 Session Progress to the endpoint.
+ ; (default: "no")
+
; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
;==========================ACL SECTION OPTIONS=========================
;[acl]
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
new file mode 100644
index 0000000..a671140
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py
@@ -0,0 +1,36 @@
+"""allow_sending_180_after_183
+
+Revision ID: 0bee61aa9425
+Revises: 8f72185e437f
+Create Date: 2022-04-07 13:51:33.400664
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+# revision identifiers, used by Alembic.
+revision = '0bee61aa9425'
+down_revision = '8f72185e437f'
+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_globals', sa.Column('allow_sending_180_after_183', ast_bool_values))
+
+
+def downgrade():
+ if op.get_context().bind.dialect.name == 'mssql':
+ op.drop_constraint('ck_ps_globals_allow_sending_180_after_183_ast_bool_values', 'ps_globals')
+ op.drop_column('ps_globals', 'allow_sending_180_after_183')
diff --git a/doc/CHANGES-staging/chan_pjsip_180_sdp.txt b/doc/CHANGES-staging/chan_pjsip_180_sdp.txt
new file mode 100644
index 0000000..ffd14af
--- /dev/null
+++ b/doc/CHANGES-staging/chan_pjsip_180_sdp.txt
@@ -0,0 +1,8 @@
+Subject: chan_pjsip
+
+added global config option "allow_sending_180_after_183"
+
+Allow Asterisk to send 180 Ringing to an endpoint
+after 183 Session Progress has been send.
+If disabled Asterisk will instead send only a
+183 Session Progress to the endpoint.
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 209cdbf..ba95c27 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -3066,6 +3066,13 @@
unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void);
/*!
+ * \brief Retrieve the global setting 'allow_sending_180_after_183'.
+ *
+ * \retval non zero if disable.
+ */
+unsigned int ast_sip_get_allow_sending_180_after_183(void);
+
+/*!
* \brief Retrieve the global setting 'use_callerid_contact'.
* \since 13.24.0
*
diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c
index 5bc1cc6..4620c3f 100644
--- a/res/res_pjsip/config_global.c
+++ b/res/res_pjsip/config_global.c
@@ -48,6 +48,7 @@
#define DEFAULT_MWI_TPS_QUEUE_HIGH AST_TASKPROCESSOR_HIGH_WATER_LEVEL
#define DEFAULT_MWI_TPS_QUEUE_LOW -1
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED 0
+#define DEFAULT_ALLOW_SENDING_180_AFTER_183 0
#define DEFAULT_IGNORE_URI_USER_OPTIONS 0
#define DEFAULT_USE_CALLERID_CONTACT 0
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION 0
@@ -92,6 +93,8 @@
unsigned int contact_expiration_check_interval;
/*! Nonzero to disable multi domain support */
unsigned int disable_multi_domain;
+ /*! Nonzero to disable changing 180/SDP to 183/SDP */
+ unsigned int allow_sending_180_after_183;
/*! The maximum number of unidentified requests per source IP address before a security event is logged */
unsigned int unidentified_request_count;
/*! The period during which unidentified requests are accumulated */
@@ -444,6 +447,21 @@
return disable_initial_unsolicited;
}
+unsigned int ast_sip_get_allow_sending_180_after_183(void)
+{
+ unsigned int allow_sending_180_after_183;
+ struct global_config *cfg;
+
+ cfg = get_global_cfg();
+ if (!cfg) {
+ return DEFAULT_ALLOW_SENDING_180_AFTER_183;
+ }
+
+ allow_sending_180_after_183 = cfg->allow_sending_180_after_183;
+ ao2_ref(cfg, -1);
+ return allow_sending_180_after_183;
+}
+
unsigned int ast_sip_get_ignore_uri_user_options(void)
{
unsigned int ignore_uri_user_options;
@@ -708,6 +726,9 @@
ast_sorcery_object_field_register(sorcery, "global", "mwi_disable_initial_unsolicited",
DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED ? "yes" : "no",
OPT_BOOL_T, 1, FLDSET(struct global_config, mwi.disable_initial_unsolicited));
+ ast_sorcery_object_field_register(sorcery, "global", "allow_sending_180_after_183",
+ DEFAULT_ALLOW_SENDING_180_AFTER_183 ? "yes" : "no",
+ OPT_BOOL_T, 1, FLDSET(struct global_config, allow_sending_180_after_183));
ast_sorcery_object_field_register(sorcery, "global", "ignore_uri_user_options",
DEFAULT_IGNORE_URI_USER_OPTIONS ? "yes" : "no",
OPT_BOOL_T, 1, FLDSET(struct global_config, ignore_uri_user_options));
diff --git a/res/res_pjsip/pjsip_config.xml b/res/res_pjsip/pjsip_config.xml
index 9a9ef48..84736d6 100644
--- a/res/res_pjsip/pjsip_config.xml
+++ b/res/res_pjsip/pjsip_config.xml
@@ -2348,6 +2348,17 @@
<configOption name="norefersub" default="yes">
<synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis>
</configOption>
+ <configOption name="allow_sending_180_after_183" default="no">
+ <synopsis>Allow 180 after 183</synopsis>
+ <description><para>
+ Allow Asterisk to send 180 Ringing to an endpoint
+ after 183 Session Progress has been send.
+ If disabled Asterisk will instead send only a
+ 183 Session Progress to the endpoint.
+ (default: "no")
+ </para>
+ </description>
+ </configOption>
</configObject>
</configFile>
</configInfo>
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18451
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18
Gerrit-Change-Number: 18451
Gerrit-PatchSet: 1
Gerrit-Owner: Mark Petersen <asterisk.org at zombie.dk>
Gerrit-CC: Mark Petersen <bugs.digium.com at zombie.dk>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220426/e7906232/attachment.html>
More information about the asterisk-code-review
mailing list