[asterisk-commits] mmichelson: trunk r187560 - in /trunk: channels/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 9 16:06:30 CDT 2009


Author: mmichelson
Date: Thu Apr  9 16:06:26 2009
New Revision: 187560

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=187560
Log:
Add a new option, mwi_from, to sip.conf.

This allows for you to change the From header for outgoing MWI
NOTIFY requests. Prior to this, the best you could do was to
set a callerid in the general section of sip.conf. The problem
was that this was used for all outbound requests, not just
MWI NOTIFY requests.

AST-201


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

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=187560&r1=187559&r2=187560
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Apr  9 16:06:26 2009
@@ -1030,6 +1030,7 @@
 #define DEFAULT_MOHSUGGEST      ""
 #define DEFAULT_VMEXTEN 	"asterisk"	/*!< Default voicemail extension */
 #define DEFAULT_CALLERID 	"asterisk"	/*!< Default caller ID */
+#define DEFAULT_MWI_FROM ""
 #define DEFAULT_NOTIFYMIME 	"application/simple-message-summary"
 #define DEFAULT_ALLOWGUEST	TRUE
 #define DEFAULT_RTPKEEPALIVE	0		/*!< Default RTPkeepalive setting */
@@ -1072,6 +1073,7 @@
 /*@{*/ 
 static char default_language[MAX_LANGUAGE];
 static char default_callerid[AST_MAX_EXTENSION];
+static char default_mwi_from[80];
 static char default_fromdomain[AST_MAX_EXTENSION];
 static char default_notifymime[AST_MAX_EXTENSION];
 static int default_qualify;		/*!< Default Qualify= setting */
@@ -1663,6 +1665,7 @@
 		AST_STRING_FIELD(peermd5secret);
 		AST_STRING_FIELD(cid_num);	/*!< Caller*ID number */
 		AST_STRING_FIELD(cid_name);	/*!< Caller*ID name */
+		AST_STRING_FIELD(mwi_from); /*!< Name to place in the From header in outgoing NOTIFY requests */
 		AST_STRING_FIELD(fullcontact);	/*!< The Contact: that the UA registers with us */
 			/* we only store the part in <brackets> in this field. */
 		AST_STRING_FIELD(our_contact);	/*!< Our contact header */
@@ -1902,6 +1905,7 @@
 		AST_STRING_FIELD(mohsuggest);		/*!<  Music on Hold class */
 		AST_STRING_FIELD(parkinglot);		/*!<  Parkinglot */
 		AST_STRING_FIELD(useragent);		/*!<  User agent in SIP request (saved from registration) */
+		AST_STRING_FIELD(mwi_from);         /*!< Name to place in From header for outgoing NOTIFY requests */
 		AST_STRING_FIELD(engine);               /*!<  RTP Engine to use */
 		);
 	struct sip_socket socket;	/*!< Socket used for this peer */
@@ -4889,6 +4893,7 @@
 	ast_string_field_set(dialog, context, peer->context);
 	ast_string_field_set(dialog, cid_num, peer->cid_num);
 	ast_string_field_set(dialog, cid_name, peer->cid_name);
+	ast_string_field_set(dialog, mwi_from, peer->mwi_from);
 	ast_string_field_set(dialog, parkinglot, peer->parkinglot);
 	ast_string_field_set(dialog, engine, peer->engine);
 	ref_proxy(dialog, obproxy_get(dialog, peer));
@@ -9962,6 +9967,17 @@
 		l = p->owner->connected.id.number; 
 		n = p->owner->connected.id.name;
 	}
+
+	/* Hey, it's a NOTIFY! See if they've configured a mwi_from.
+	 * XXX Right now, this logic works because the only place that mwi_from
+	 * is set on the sip_pvt is in sip_send_mwi_to_peer. If things changed, then
+	 * we might end up putting the mwi_from setting into other types of NOTIFY
+	 * messages as well.
+	 */
+	if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->mwi_from)) {
+		l = p->mwi_from;
+	}
+
 	if (ast_strlen_zero(l))
 		l = default_callerid;
 	if (ast_strlen_zero(n))
@@ -21819,6 +21835,11 @@
 		build_via(p);
 		ao2_t_unlink(dialogs, p, "About to change the callid -- remove the old name");
 		build_callid_pvt(p);
+		if (!ast_strlen_zero(peer->mwi_from)) {
+			ast_string_field_set(p, mwi_from, peer->mwi_from);
+		} else if (!ast_strlen_zero(default_mwi_from)) {
+			ast_string_field_set(p, mwi_from, default_mwi_from);
+		}
 		ao2_t_link(dialogs, p, "Linking in under new name");
 		/* Destroy this session after 32 secs */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -23267,6 +23288,8 @@
 			ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
 			ast_string_field_set(peer, cid_name, cid_name);
 			ast_string_field_set(peer, cid_num, cid_num);
+		} else if (!strcasecmp(v->name, "mwi_from")) {
+			ast_string_field_set(peer, mwi_from, v->value);
 		} else if (!strcasecmp(v->name, "fullname")) {
 			ast_string_field_set(peer, cid_name, v->value);
 		} else if (!strcasecmp(v->name, "cid_number")) {
@@ -23800,6 +23823,7 @@
 	ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
 	ast_copy_string(sip_cfg.realm, S_OR(ast_config_AST_SYSTEM_NAME, DEFAULT_REALM), sizeof(sip_cfg.realm));
 	ast_copy_string(default_callerid, DEFAULT_CALLERID, sizeof(default_callerid));
+	ast_copy_string(default_mwi_from, DEFAULT_MWI_FROM, sizeof(default_mwi_from));
 	sip_cfg.compactheaders = DEFAULT_COMPACTHEADERS;
 	global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
 	global_regattempts_max = 0;
@@ -24041,6 +24065,8 @@
 			sip_cfg.regextenonqualify = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "callerid")) {
 			ast_copy_string(default_callerid, v->value, sizeof(default_callerid));
+		} else if (!strcasecmp(v->name, "mwi_from")) {
+			ast_copy_string(default_mwi_from, v->value, sizeof(default_mwi_from));
 		} else if (!strcasecmp(v->name, "fromdomain")) {
 			ast_copy_string(default_fromdomain, v->value, sizeof(default_fromdomain));
 		} else if (!strcasecmp(v->name, "outboundproxy")) {

Modified: trunk/configs/sip.conf.sample
URL: http://svn.digium.com/svn-view/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=187560&r1=187559&r2=187560
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Thu Apr  9 16:06:26 2009
@@ -179,6 +179,11 @@
 ;buggymwi=no                    ; Cisco SIP firmware doesn't support the MWI RFC
                                 ; fully. Enable this option to not get error messages
                                 ; when sending MWI to phones with this bug.
+;mwi_from=asterisk              ; When sending MWI NOTIFY requests, use this setting in
+                                ; the From: header as the "name" portion. Also fill the
+						        ; "user" portion of the URI in the From: header with this
+						        ; value if no fromuser is set
+						        ; Default: empty
 ;vmexten=voicemail              ; dialplan extension to reach mailbox sets the 
                                 ; Message-Account in the MWI notify message 
                                 ; defaults to "asterisk"




More information about the asterisk-commits mailing list