[asterisk-commits] oej: branch oej/sipdiversion r39226 - in /team/oej/sipdiversion: ./ channels/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Aug 7 13:46:30 MST 2006


Author: oej
Date: Mon Aug  7 15:46:29 2006
New Revision: 39226

URL: http://svn.digium.com/view/asterisk?rev=39226&view=rev
Log:
Update

Modified:
    team/oej/sipdiversion/   (props changed)
    team/oej/sipdiversion/channels/chan_sip.c
    team/oej/sipdiversion/doc/channelvariables.txt

Propchange: team/oej/sipdiversion/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Modified: team/oej/sipdiversion/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipdiversion/channels/chan_sip.c?rev=39226&r1=39225&r2=39226&view=diff
==============================================================================
--- team/oej/sipdiversion/channels/chan_sip.c (original)
+++ team/oej/sipdiversion/channels/chan_sip.c Mon Aug  7 15:46:29 2006
@@ -8041,70 +8041,54 @@
 /*! \brief Get referring dnis */
 static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq)
 {
-	char tmp[256], *c, *a;
-	char *params, *reason = NULL, *stop;
+	char tmp[256], *exten, *rexten, *rdomain;
+	char *params, *reason = NULL;
 	struct sip_request *req;
 	
-	req = oreq;
-	if (!req)
-		req = &p->initreq;
+	req = oreq ? oreq : &p->initreq;
+
 	ast_copy_string(tmp, get_header(req, "Diversion"), sizeof(tmp));
 	if (ast_strlen_zero(tmp))
 		return 0;
 
-	c = get_in_brackets(tmp);
-	if (strncmp(c, "sip:", 4)) {
-		ast_log(LOG_WARNING, "Huh?  Not an RDNIS SIP header (%s)?\n", c);
+	exten = get_in_brackets(tmp);
+	if (strncmp(exten, "sip:", 4)) {
+		ast_log(LOG_WARNING, "Huh?  Not an RDNIS SIP header (%s)?\n", exten);
 		return -1;
 	}
-	c += 4;
+	exten += 4;
 
 	/* Get diversion-reason param if present */
-	if (params = strchr(tmp, ';')) {
+	if ((params = strchr(tmp, ';'))) {
 		*params = '\0';	/* Cut off parameters  */
 		params++;
-		while (*params == ';' || *params == ' ') 
+		while (*params == ';' || *params == ' ')
 			params++;
 		/* Check if we have a reason parameter */
-		if (strncasecmp(params, "reason", strlen("reason")) == 0) {
-			reason = strchr(params, '=');
-			if (reason) {
-				reason++;
-				/* Remove enclosing double-quotes */
-				if (*reason == '"') {
-					reason++;
-					stop = reason;
-					while (*stop != '"') {
-						if (*stop == '\0') {
-							/* Missing end-quote */
-							*reason = '\0';
-							break;
-						}
-						stop++;
-					}
-					*stop = '\0';
-				} else {
-					stop = reason;
-					while (*stop && *stop != ';' && *stop != '"') 
-						stop++;
-					*stop = '\0';
-				}
-				if (*reason) {
-					sip_set_redirstr(p, reason);
-					pbx_builtin_setvar_helper(tmp, "__PRIREDIRECTREASON", p->redircause);
-					pbx_builtin_setvar_helper(tmp, "__SIPREDIRECTREASON", reason);
+		if ((reason = strcasestr(params, "reason="))) {
+			reason+=7;
+			/* Remove enclosing double-quotes */
+			if (*reason == '"') 
+				ast_strip_quoted(reason, "\"", "\"");
+			if (!ast_strlen_zero(reason)) {
+				sip_set_redirstr(p, reason);
+				if (p->owner) {
+					pbx_builtin_setvar_helper(p->owner, "__PRIREDIRECTREASON", p->redircause);
+					pbx_builtin_setvar_helper(p->owner, "__SIPREDIRECTREASON", reason);
 				}
 			}
 		}
 	}
 
-	a = c;
-	strsep(&a, "@;");	/* trim anything after @ or ; */
+	rdomain = exten;
+	rexten = strsep(&rdomain, "@");	/* trim anything after @ */
+	if (p->owner) 
+		pbx_builtin_setvar_helper(p->owner, "__SIPRDNISDOMAIN", rdomain);
 
 	if (sip_debug_test_pvt(p))
-		ast_verbose(" -- RDNIS for tis call is is %s (reason %s)\n", c, reason ? reason : "");
-
-	ast_string_field_set(p, rdnis, c);
+		ast_verbose("RDNIS for this call is is %s (reason %s)\n", exten, reason ? reason : "");
+
+	ast_string_field_set(p, rdnis, rexten);
 
 	return 0;
 }
@@ -16305,9 +16289,7 @@
 {
 	char *cdest;
 	char *extension, *host, *port;
-	char *tmp;
-	char tmp2[256];
-	char *reason;
+	char tmp[80];
 	
 	cdest = ast_strdupa(dest);
 	

Modified: team/oej/sipdiversion/doc/channelvariables.txt
URL: http://svn.digium.com/view/asterisk/team/oej/sipdiversion/doc/channelvariables.txt?rev=39226&r1=39225&r2=39226&view=diff
==============================================================================
--- team/oej/sipdiversion/doc/channelvariables.txt (original)
+++ team/oej/sipdiversion/doc/channelvariables.txt Mon Aug  7 15:46:29 2006
@@ -588,8 +588,10 @@
 ${LANGUAGE}	 	* Current language (Deprecated; use ${LANGUAGE()})
 ${LEN(VAR)}	 	* String length of VAR (integer)
 ${PRIORITY}	 	* Current priority in the dialplan
-${PRIREDIRECTREASON} 	Reason for redirect on PRI, if a call was directed
+${PRIREDIRECTREASON} 	Reason for redirect on PRI, if a call was directed (also set in SIP)
+${SIPREDIRECTREASON}	Reason for redirect on SIP (text string)
 ${RDNIS}         	* Redirected Dial Number ID Service (Deprecated; use ${CALLERID(rdnis)})
+${SIPRDNISDOMAIN}	RDNIS domain from a redirect in SIP.
 ${TIMESTAMP}	 	* Current date time in the format: YYYYMMDD-HHMMSS (Deprecated; use ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
 ${TRANSFER_CONTEXT} 	Context for transferred calls
 ${FORWARD_CONTEXT}     Context for forwarded calls



More information about the asterisk-commits mailing list