[asterisk-commits] mmichelson: trunk r370691 - in /trunk: ./ channels/ channels/sip/include/ con...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 31 17:28:21 CDT 2012


Author: mmichelson
Date: Tue Jul 31 17:28:16 2012
New Revision: 370691

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370691
Log:
Add headers from SIPAddHeader to outbound REFER requests.

This is a patch from kkm from review board.

This is useful for adding headers to REFER requests that
emanate from a Transfer() dialplan application call.

This also fixes some uses of the Referred-by header, removing
an extra set of angle brackets.

I've modified the reporter's original patch to not require
any additions to the sip_refer header and to just remove the
referred_by_name from sip_refer since it is no longer needed
or used.

(closes Issue ASTERISK-17639)
reported by Kirill Katsnelson
Patches:
	019059-sip-refer-addheaders-trunk-353549.diff
	uploaded by Kirill Katsnelson (license #5845)

Review: https://reviewboard.asterisk.org/r/1159


Modified:
    trunk/CHANGES
    trunk/channels/chan_sip.c
    trunk/channels/sip/include/sip.h
    trunk/configs/sip.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=370691&r1=370690&r2=370691
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Jul 31 17:28:16 2012
@@ -642,6 +642,11 @@
    the source tree.  If the variable is not set, it defaults to the current
    behavior and uses the current working directory.
 
+
+SIP changes
+--------------------------
+ * Extra headers specified with SIPAddHeader are sent with the REFER message
+   when using Transfer application. See refer_addheaders in sip.conf.sample.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=370691&r1=370690&r2=370691
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Jul 31 17:28:16 2012
@@ -795,6 +795,7 @@
 static int global_store_sip_cause;    /*!< Whether the MASTER_CHANNEL(HASH(SIP_CAUSE,[chan_name])) var should be set */
 
 static int global_dynamic_exclude_static = 0; /*!< Exclude static peers from contact registrations */
+static unsigned char global_refer_addheaders; /*!< Add extra headers to outgoing REFER */
 /*@}*/
 
 /*!
@@ -13334,17 +13335,11 @@
 	}
 	add_date(&req);
 	if (sipmethod == SIP_REFER && p->refer) {	/* Call transfer */
-		char buf[SIPBUFSIZE];
-
 		if (!ast_strlen_zero(p->refer->refer_to)) {
 			add_header(&req, "Refer-To", p->refer->refer_to);
 		}
 		if (!ast_strlen_zero(p->refer->referred_by)) {
-			snprintf(buf, sizeof(buf), "%s%s%s",
-				p->refer->referred_by_name,
-				!ast_strlen_zero(p->refer->referred_by_name) ? " " : "",
-				p->refer->referred_by);
-			add_header(&req, "Referred-By", buf);
+			add_header(&req, "Referred-By", p->refer->referred_by);
 		}
 	} else if (sipmethod == SIP_SUBSCRIBE) {
 		if (p->subscribed == MWI_NOTIFICATION) {
@@ -13383,7 +13378,8 @@
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	add_supported(p, &req);
 
-	if (p->options && p->options->addsipheaders && p->owner) {
+	if (p->owner && ((p->options && p->options->addsipheaders)
+				  || (p->refer && global_refer_addheaders))) {
 		struct ast_channel *chan = p->owner; /* The owner channel */
 		struct varshead *headp;
 	
@@ -14662,9 +14658,6 @@
 */
 static int transmit_refer(struct sip_pvt *p, const char *dest)
 {
-	struct sip_request req = {
-		.headers = 0,
-	};
 	char from[256];
 	const char *of;
 	char *c;
@@ -14711,17 +14704,7 @@
 	ast_string_field_set(p->refer, referred_by, p->our_contact);
 	p->refer->status = REFER_SENT;   /* Set refer status */
 
-	reqprep(&req, p, SIP_REFER, 0, 1);
-
-	add_header(&req, "Refer-To", referto);
-	add_header(&req, "Allow", ALLOWED_METHODS);
-	add_supported(p, &req);
-	if (!ast_strlen_zero(p->our_contact)) {
-		add_header(&req, "Referred-By", p->our_contact);
-	}
-
-	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
-
+	return transmit_invite(p, SIP_REFER, FALSE, 0, NULL);
 	/* We should propably wait for a NOTIFY here until we ack the transfer */
 	/* Maybe fork a new thread and wait for a STATUS of REFER_200OK on the refer status before returning to app_transfer */
 
@@ -16896,12 +16879,6 @@
 
 	if (!ast_strlen_zero(p_referred_by)) {
 		h_referred_by = ast_strdupa(p_referred_by);
-
-		/* Store referrer's caller ID name */
-		ast_string_field_set(refer, referred_by_name, h_referred_by);
-		if ((ptr = strchr(refer->referred_by_name, '<')) > refer->referred_by_name) {
-			*(ptr - 1) = '\0'; /* Space */
-		}
 
 		referred_by_uri = get_in_brackets(h_referred_by);
 
@@ -30347,6 +30324,7 @@
 	global_qualifyfreq = DEFAULT_QUALIFYFREQ;
 	global_t38_maxdatagram = -1;
 	global_shrinkcallerid = 1;
+	global_refer_addheaders = TRUE;
 	authlimit = DEFAULT_AUTHLIMIT;
 	authtimeout = DEFAULT_AUTHTIMEOUT;
 	global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE;
@@ -30904,6 +30882,8 @@
 			ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_ICE_SUPPORT);
 		} else if (!strcasecmp(v->name, "parkinglot")) {
 			ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot));
+		} else if (!strcasecmp(v->name, "refer_addheaders")) {
+			global_refer_addheaders = ast_true(v->value);
 		}
 	}
 

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=370691&r1=370690&r2=370691
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Tue Jul 31 17:28:16 2012
@@ -926,7 +926,6 @@
 		AST_STRING_FIELD(refer_to_urioption);   /*!< Place to store REFER-TO uri options */
 		AST_STRING_FIELD(refer_to_context);     /*!< Place to store REFER-TO context */
 		AST_STRING_FIELD(referred_by);          /*!< Place to store REFERRED-BY extension */
-		AST_STRING_FIELD(referred_by_name);     /*!< Place to store REFERRED-BY extension */
 		AST_STRING_FIELD(refer_contact);        /*!< Place to store Contact info from a REFER extension */
 		AST_STRING_FIELD(replaces_callid);      /*!< Replace info: callid */
 		AST_STRING_FIELD(replaces_callid_totag);   /*!< Replace info: to-tag */

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=370691&r1=370690&r2=370691
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Tue Jul 31 17:28:16 2012
@@ -501,6 +501,14 @@
 
 ;use_q850_reason = no ; Default "no"
                       ; Set to yes add Reason header and use Reason header if it is available.
+
+; When the Transfer() application sends a REFER SIP message, extra headers specified in
+; the dialplan by way of SIPAddHeader are sent out with that message. 1.8 and earlier did not
+; add the extra headers. To revert to 1.8- behavior, call SIPRemoveHeader with no arguments
+; before calling Transfer() to remove all additional headers from the channel. The setting
+; below is for transitional compatibility only.
+;
+;refer_addheaders=yes	; on by default
 
 ;autocreatepeers=no             ; Allow any not exsplicitly defined here UAC to register
                                 ; WITHOUT AUTHENTICATION. Enabling this options poses a high




More information about the asterisk-commits mailing list