[Asterisk-code-review] res_pjsip: Added a norefersub configuration setting (...asterisk[16])

Dan Cropp asteriskteam at digium.com
Mon Apr 8 17:05:31 CDT 2019


Dan Cropp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11244


Change subject: res_pjsip:  Added a norefersub configuration setting
......................................................................

res_pjsip:  Added a norefersub configuration setting

Added a new PJSIP global setting called norefersub.
Default is yes to keep support working as before.

res_pjsip_refer:  Configures PJSIP norefersub capability accordingly.

Checks the PJSIP global setting value.
If it is no (disabled) it does not add the norefersub capability
to PJSIP.
If it is yes (default) it adds the norefersub capability to PJSIP.

This is useful for Cisco switches that do not follow RFC4488.

ASTERISK-12345 #close
Reported-by: Dan Cropp

Change-Id: I0b1c28ebc905d881f4a16e752715487a688b30e9
---
M configs/samples/pjsip.conf.sample
M include/asterisk/res_pjsip.h
M res/res_pjsip.c
M res/res_pjsip/config_global.c
M res/res_pjsip_refer.c
5 files changed, 41 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/11244/1

diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index 356606c..6a79104 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -1158,6 +1158,11 @@
                 ; with extreme caution and only to mitigate specific issues.
                 ; Under certain conditions they could make things worse.
 
+;norefersub=yes     ; Enable sending norefersub option tag in Supported header to advertise
+                    ; that the User Agent is capable of accepting a REFER request with
+                    ; creating an implicit subscription (see RFC 4488).
+                    ; (default: "yes")
+							    
 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
 ;==========================ACL SECTION OPTIONS=========================
 ;[acl]
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index ae6e715..ab05be2 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -2762,6 +2762,14 @@
 unsigned int ast_sip_get_use_callerid_contact(void);
 
 /*!
+ * \brief Retrieve the global setting 'norefersub'.
+ * \since 16.4.0
+ *
+ * \retval non zero if norefersub is to be sent in "Supported" Headers
+ */
+unsigned int ast_sip_get_norefersub(void);
+
+/*!
  * \brief Retrieve the global setting 'ignore_uri_user_options'.
  * \since 13.12.0
  *
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 459e01f..d5279bf 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1927,6 +1927,9 @@
 						</para></warning>
 					</description>
 				</configOption>
+				<configOption name="norefersub" default="yes">
+					<synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis>
+				</configOption>
 			</configObject>
 		</configFile>
 	</configInfo>
diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c
index 8f21e50..c7e0f89 100644
--- a/res/res_pjsip/config_global.c
+++ b/res/res_pjsip/config_global.c
@@ -52,6 +52,7 @@
 #define DEFAULT_USE_CALLERID_CONTACT 0
 #define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION 0
 #define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL
+#define DEFAULT_NOREFERSUB 1
 
 /*!
  * \brief Cached global config object
@@ -113,6 +114,8 @@
 	unsigned int send_contact_status_on_update_registration;
 	/*! Trigger the distributor should use to pause accepting new dialogs */
 	enum ast_sip_taskprocessor_overload_trigger overload_trigger;
+	/*! Nonzero if norefersub is to be sent in Supported header */
+	unsigned int norefersub;
 };
 
 static void global_destructor(void *obj)
@@ -501,6 +504,21 @@
 	return trigger;
 }
 
+unsigned int ast_sip_get_norefersub(void)
+{
+	unsigned int norefersub;
+	struct global_config *cfg;
+
+	cfg = get_global_cfg();
+	if (!cfg) {
+		return DEFAULT_NOREFERSUB;
+	}
+
+	norefersub = cfg->norefersub;
+	ao2_ref(cfg, -1);
+	return norefersub;
+}
+
 static int overload_trigger_handler(const struct aco_option *opt,
 	struct ast_variable *var, void *obj)
 {
@@ -704,6 +722,9 @@
 	ast_sorcery_object_field_register_custom(sorcery, "global", "taskprocessor_overload_trigger",
 		overload_trigger_map[DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER],
 		overload_trigger_handler, overload_trigger_to_str, NULL, 0, 0);
+        ast_sorcery_object_field_register(sorcery, "global", "norefersub",
+		DEFAULT_NOREFERSUB ? "yes" : "no",
+		OPT_BOOL_T, 1, FLDSET(struct global_config, norefersub));
 
 	if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
 		return -1;
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 3dfaabc..d53b76d 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -1230,7 +1230,10 @@
 
 	pjsip_replaces_init_module(ast_sip_get_pjsip_endpoint());
 	pjsip_xfer_init_module(ast_sip_get_pjsip_endpoint());
-	pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);
+
+	if (ast_sip_get_norefersub()) {
+		pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_SUPPORTED, NULL, 1, &str_norefersub);
+	}
 
 	ast_sip_register_service(&refer_progress_module);
 	ast_sip_session_register_supplement(&refer_supplement);

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I0b1c28ebc905d881f4a16e752715487a688b30e9
Gerrit-Change-Number: 11244
Gerrit-PatchSet: 1
Gerrit-Owner: Dan Cropp <dan at amtelco.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190408/5c4b1069/attachment-0001.html>


More information about the asterisk-code-review mailing list