]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_pjsip: add a flag to ignore 183 responses if no SDP present
authorTorrey Searle <torrey@voxbone.com>
Mon, 4 Mar 2019 07:50:18 +0000 (08:50 +0100)
committerSean Bright <sean.bright@gmail.com>
Fri, 8 Mar 2019 19:13:41 +0000 (13:13 -0600)
chan_sip will always ignore 183 responses that do not contain SDP
however, chan_pjsip will currently always translate it into a
183 with SDP.  This new flag allows chan_pjsip to have the same
behavior as chan_sip.

ASTERISK-28322 #close

Change-Id: If81cfaa17c11b6ac703e3d71696f259d86c6be4a

CHANGES
channels/chan_pjsip.c
configs/samples/pjsip.conf.sample
contrib/ast-db-manage/config/versions/80473bad3c16_ignore_183_without_sdp.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip/pjsip_configuration.c

diff --git a/CHANGES b/CHANGES
index 5de689adf712e77288c98d2bc1e6d04f9b06676f..4aa16299f99bcdd92f72834189f9d4f1ec96feb1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -43,6 +43,13 @@ res_pjsip
    RECOMMENDED), keep the current behavior, or trigger only on pjsip
    taskprocessor overloads.
 
+chan_pjsip
+------------------
+ * A new configuration parameter 'ignore_183_without_sdp' has been added
+   to the pjsip.conf "endpoints" section.  If enabled, will make chan_pjsip
+   discard 183s that do not contain an SDP body, which can resolve no
+   ringback tone issues as well as making the behavior match chan_sip.
+
 MWI
 ------------------
  * A new module "res_mwi_devstate" has been added that allows subscriptions
index 792b3fc4524597c85aad8110fc175a1d9aa70cd4..e5d5aea12b4cb530a6c331303b399a698054c431 100644 (file)
@@ -3020,7 +3020,14 @@ static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct
                ast_channel_unlock(session->channel);
                break;
        case 183:
-               ast_queue_control(session->channel, AST_CONTROL_PROGRESS);
+               if (session->endpoint->ignore_183_without_sdp) {
+                       pjsip_rdata_sdp_info *sdp = pjsip_rdata_get_sdp_info(rdata);
+                       if (sdp && sdp->body.ptr) {
+                               ast_queue_control(session->channel, AST_CONTROL_PROGRESS);
+                       }
+               } else {
+                       ast_queue_control(session->channel, AST_CONTROL_PROGRESS);
+               }
                break;
        case 200:
                ast_queue_control(session->channel, AST_CONTROL_ANSWER);
index cb3884ca93e08b517d4c12b8d618e63e34cc31f7..356606c9fc034b47688bcc2fa9c0122034d60941 100644 (file)
                            ; headers are received.  This option allows the
                            ; 'Q.850' Reason header to be suppressed.
                            ; (default: no)
+;ignore_183_without_sdp =
+                           ; Do not forward 183 when it doesn't contain SDP.
+                           ; Certain SS7 internetworking scenarios can result in
+                           ; a 183 to be generated for reasons other than early
+                           ; media.  Forwarding this 183 can cause loss of
+                           ; ringback tone.  This flag emulates the behavior of
+                           ; chan_sip and prevents these 183 responses from
+                           ; being forwarded.
+                           ; (default: no)
 
 ;==========================AUTH SECTION OPTIONS=========================
 ;[auth]
diff --git a/contrib/ast-db-manage/config/versions/80473bad3c16_ignore_183_without_sdp.py b/contrib/ast-db-manage/config/versions/80473bad3c16_ignore_183_without_sdp.py
new file mode 100644 (file)
index 0000000..d05e2d5
--- /dev/null
@@ -0,0 +1,38 @@
+"""ignore 183 without sdp
+
+Revision ID: 80473bad3c16
+Revises: f3c0b8695b66
+Create Date: 2019-03-04 08:30:51.592907
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '80473bad3c16'
+down_revision = 'f3c0b8695b66'
+
+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_endpoints', sa.Column('ignore_183_without_sdp', ast_bool_values))
+
+def downgrade():
+    if op.get_context().bind.dialect.name == 'mssql':
+        op.drop_constraint('ck_ps_endpoints_ignore_183_without_sdp_ast_bool_values', 'ps_endpoints')
+    op.drop_column('ps_endpoints', 'ignore_183_without_sdp')
+    pass
index b84983ecdaabc9610400bad62f33a77c15d081b6..ae6e715b4225717013bb2f6b182c146976f32725 100644 (file)
@@ -818,6 +818,8 @@ struct ast_sip_endpoint {
        unsigned int trust_connected_line;
        /*! Do we send connected line updates to this endpoint? */
        unsigned int send_connected_line;
+       /*! Ignore 183 if no SDP is present */
+       unsigned int ignore_183_without_sdp;
 };
 
 /*! URI parameter for symmetric transport */
index d71e0953aa869cd87c4e2ed5c83366c7a9462f59..459e01f27aa43472a42ed915aeb41156bd0e8e77 100644 (file)
                                                option allows the 'Q.850' Reason header to be suppressed.</para>
                                        </description>
                                </configOption>
+                               <configOption name="ignore_183_without_sdp" default="no">
+                                       <synopsis>Do not forward 183 when it doesn't contain SDP</synopsis>
+                                       <description><para>
+                                               Certain SS7 internetworking scenarios can result in a 183
+                                               to be generated for reasons other than early media.  Forwarding
+                                               this 183 can cause loss of ringback tone.  This flag emulates
+                                               the behavior of chan_sip and prevents these 183 responses from
+                                               being forwarded.</para>
+                                       </description>
+                               </configOption>
                        </configObject>
                        <configObject name="auth">
                                <synopsis>Authentication type</synopsis>
index 92dc46a0f73f54564bd7c3792d33a8b8e769ca0e..cc19603c11e963f6e6c39d713e56f1fa36132bc7 100644 (file)
@@ -1949,6 +1949,7 @@ int ast_res_pjsip_initialize_configuration(void)
        ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.follow_early_media_fork));
        ast_sorcery_object_field_register(sip_sorcery, "endpoint", "accept_multiple_sdp_answers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.accept_multiple_sdp_answers));
        ast_sorcery_object_field_register(sip_sorcery, "endpoint", "suppress_q850_reason_headers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, suppress_q850_reason_headers));
+       ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ignore_183_without_sdp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, ignore_183_without_sdp));
 
        if (ast_sip_initialize_sorcery_transport()) {
                ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");