]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_pjsip: add allow_sending_180_after_183 option
authorMark Petersen <bugs.digium.com@zombie.dk>
Mon, 21 Feb 2022 13:23:21 +0000 (14:23 +0100)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Tue, 26 Apr 2022 21:37:55 +0000 (16:37 -0500)
added new global config option "allow_sending_180_after_183"
that if enabled will preserve 180 after a 183

ASTERISK-29842

Change-Id: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18

channels/chan_pjsip.c
configs/samples/pjsip.conf.sample
contrib/ast-db-manage/config/versions/0bee61aa9425_allow_180_ringing_with_sdp.py [new file with mode: 0644]
doc/CHANGES-staging/chan_pjsip_180_sdp.txt [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/res_pjsip/config_global.c
res/res_pjsip/pjsip_config.xml

index 61c4cfb7e6a4b8d116c675900a8eb173defe4f1e..d55bdf9f2e2716443a6c89ddceeb3b9dcf80dc1f 100644 (file)
@@ -1630,8 +1630,12 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
                        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;
                        }
index 2d93bd1276409cc406f03afe459363b28e04be1e..0303050d8f4afcc02e8dc82f24daa9cd6d957282 100644 (file)
                     ; 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 (file)
index 0000000..a671140
--- /dev/null
@@ -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 (file)
index 0000000..ffd14af
--- /dev/null
@@ -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.
index 209cdbfba28e7b01797a511693c51a07cc98b73f..ba95c276f20489073626491cb655edec4a286836 100644 (file)
@@ -3065,6 +3065,13 @@ int ast_sip_get_mwi_tps_queue_low(void);
  */
 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
index 5bc1cc6704207dae321434aa3742771c3f5f517c..4620c3f544932132ced2ebd382bb71d57ad927b0 100644 (file)
@@ -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 @@ struct global_config {
        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 @@ unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void)
        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 @@ int ast_sip_initialize_sorcery_global(void)
        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));
index 9a9ef485bc6f473bd55810494a27a585f5029193..84736d6ce5008982aa07674deece01556272efc2 100644 (file)
                                <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>