[Asterisk-code-review] chan_pjsip: add a flag to ignore 183 responses if no SDP present (...asterisk[13])

Torrey Searle asteriskteam at digium.com
Mon Mar 4 01:54:50 CST 2019


Torrey Searle has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11086


Change subject: chan_pjsip: add a flag to ignore 183 responses if no SDP present
......................................................................

chan_pjsip: add a flag to ignore 183 responses if no SDP present

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
---
M channels/chan_pjsip.c
A contrib/ast-db-manage/config/versions/80473bad3c16_ignore_183_without_sdp.py
M include/asterisk/res_pjsip.h
M res/res_pjsip/pjsip_configuration.c
4 files changed, 49 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/11086/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 062fb7c..36cc0ad 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2742,7 +2742,14 @@
 		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);
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
index 0000000..d05e2d5
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/80473bad3c16_ignore_183_without_sdp.py
@@ -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
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 7854df7..65a0075 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -800,6 +800,8 @@
 	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 */
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 40948c3..4f7beb6 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1901,6 +1901,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, 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, 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");

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11086
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: If81cfaa17c11b6ac703e3d71696f259d86c6be4a
Gerrit-Change-Number: 11086
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190304/91abc9aa/attachment.html>


More information about the asterisk-code-review mailing list