[asterisk-commits] res pjsip: New endpoint option "refer blind progress" (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 1 10:05:54 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5610 )

Change subject: res_pjsip: New endpoint option "refer_blind_progress"
......................................................................


res_pjsip: New endpoint option "refer_blind_progress"

This option was added to turn off notifying the progress details
on Blind Transfer. If this option is not set then the chan_pjsip
will send NOTIFY "200 OK" immediately after "202 Accepted".

Some SIP phones like Mitel/Aastra or Snom keep the line busy until
receive "200 OK".

ASTERISK-26333 #close

Change-Id: Id606fbff2e02e967c02138457badc399144720f2
---
M CHANGES
M configs/samples/pjsip.conf.sample
A contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py
M include/asterisk/res_pjsip.h
M res/res_pjsip.c
M res/res_pjsip/pjsip_configuration.c
M res/res_pjsip_refer.c
7 files changed, 72 insertions(+), 2 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/CHANGES b/CHANGES
index 9c8ed5b..a881e75 100644
--- a/CHANGES
+++ b/CHANGES
@@ -21,6 +21,15 @@
 --- Functionality changes from Asterisk 14.4.0 to Asterisk 14.5.0 ------------
 ------------------------------------------------------------------------------
 
+res_pjsip
+------------------
+ * A new endpoint option "refer_blind_progress" was added to turn off notifying
+   the progress details on Blind Transfer. If this option is not set then
+   the chan_pjsip will send NOTIFY "200 OK" immediately after "202 Accepted".
+   On default is enabled.
+   Some SIP phones like Mitel/Aastra or Snom keep the line busy until
+   receive "200 OK".
+
 res_rtp_asterisk
 ------------------
  * Added the stun_blacklist option to rtp.conf.  Some multihomed servers have
diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index 612649e..a992ff8 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -770,6 +770,10 @@
                                 ; default is no.
 ;asymmetric_rtp_codec= ; Allow the sending and receiving codec to differ and
                        ; not be automatically matched (default: "no")
+;refer_blind_progress= ; Whether to notifies all the progress details on blind
+                       ; transfer (default: "yes"). The value "no" is useful
+                       ; for some SIP phones (Mitel/Aastra, Snom) which expect
+                       ; a sip/frag "200 OK" after REFER has been accepted.
 
 ;==========================AUTH SECTION OPTIONS=========================
 ;[auth]
diff --git a/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py b/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py
new file mode 100644
index 0000000..9b0f6d4
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py
@@ -0,0 +1,30 @@
+"""add ps_endpoints.refer_blind_progress
+
+Revision ID: 86bb1efa278d
+Revises: 1d0e332c32af
+Create Date: 2017-05-08 16:52:36.615161
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '86bb1efa278d'
+down_revision = '1d0e332c32af'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+YESNO_NAME = 'yesno_values'
+YESNO_VALUES = ['yes', 'no']
+
+def upgrade():
+    ############################# Enums ##############################
+
+    # yesno_values have already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
+
+    op.add_column('ps_endpoints', sa.Column('refer_blind_progress', yesno_values))
+
+def downgrade():
+    op.drop_column('ps_endpoints', 'refer_blind_progress')
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 6f44852..59f1710 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -767,6 +767,8 @@
 	unsigned int asymmetric_rtp_codec;
 	/*! Do we allow overlap dialling? */
 	unsigned int allow_overlap;
+	/*! Whether to notifies all the progress details on blind transfer */
+	unsigned int refer_blind_progress;
 };
 
 /*! URI parameter for symmetric transport */
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 9de2176..102bc39 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -963,6 +963,14 @@
 						since they mandate this option's use.
 					</para></description>
 				</configOption>
+				<configOption name="refer_blind_progress" default="yes">
+					<synopsis>Whether to notifies all the progress details on blind transfer</synopsis>
+					<description><para>
+						Some SIP phones (Mitel/Aastra, Snom) expect a sip/frag "200 OK"
+						after REFER has been accepted. If set to <literal>no</literal> then asterisk
+						will not send the progress details, but immediately will send "200 OK".
+					</para></description>
+				</configOption>
 			</configObject>
 			<configObject name="auth">
 				<synopsis>Authentication type</synopsis>
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 02562e7..679c883 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1939,6 +1939,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
 
 	if (ast_sip_initialize_sorcery_transport()) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 0f4a95c..4629538 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -61,6 +61,8 @@
 	char *transferee;
 	/*! \brief Non-zero if the 100 notify has been sent */
 	int sent_100;
+	/*! \brief Whether to notifies all the progress details on blind transfer */
+	unsigned int refer_blind_progress;
 };
 
 /*! \brief REFER Progress notification structure */
@@ -372,6 +374,8 @@
 	ast_debug(3, "Created progress monitor '%p' for transfer occurring from channel '%s' and endpoint '%s'\n",
 		progress, ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint));
 
+	(*progress)->refer_blind_progress = session->endpoint->refer_blind_progress;
+
 	(*progress)->framehook = -1;
 
 	/* To prevent a potential deadlock we need the dialog so we can lock/unlock */
@@ -563,6 +567,8 @@
 	pjsip_replaces_hdr *replaces;
 	/*! \brief Optional Refer-To header */
 	pjsip_sip_uri *refer_to;
+	/*! \brief Attended transfer flag */
+	unsigned int attended:1;
 };
 
 /*! \brief Blind transfer callback function */
@@ -577,8 +583,16 @@
 
 	pbx_builtin_setvar_helper(chan, "SIPTRANSFER", "yes");
 
-	/* If progress monitoring is being done attach a frame hook so we can monitor it */
-	if (refer->progress) {
+	if (refer->progress && !refer->attended && !refer->progress->refer_blind_progress) {
+		/* If blind transfer and endpoint doesn't want to receive all the progress details */
+		struct refer_progress_notification *notification = refer_progress_notification_alloc(refer->progress, 200,
+			PJSIP_EVSUB_STATE_TERMINATED);
+
+		if (notification) {
+			refer_progress_notify(notification);
+		}
+	} else if (refer->progress) {
+		/* If attended transfer and progress monitoring is being done attach a frame hook so we can monitor it */
 		struct ast_framehook_interface hook = {
 			.version = AST_FRAMEHOOK_INTERFACE_VERSION,
 			.event_cb = refer_progress_framehook,
@@ -785,6 +799,7 @@
 		refer.rdata = rdata;
 		refer.replaces = replaces;
 		refer.refer_to = target_uri;
+		refer.attended = 1;
 
 		if (ast_sip_session_defer_termination(session)) {
 			ast_log(LOG_ERROR, "Received REFER for remote session on channel '%s' from endpoint '%s' but could not defer termination, rejecting\n",
@@ -839,6 +854,7 @@
 	refer.progress = progress;
 	refer.rdata = rdata;
 	refer.refer_to = target;
+	refer.attended = 0;
 
 	if (ast_sip_session_defer_termination(session)) {
 		ast_log(LOG_ERROR, "Channel '%s' from endpoint '%s' attempted blind transfer but could not defer termination, rejecting\n",

-- 
To view, visit https://gerrit.asterisk.org/5610
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id606fbff2e02e967c02138457badc399144720f2
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list