[asterisk-commits] mmichelson: branch group/issue8824 r167598 - in /team/group/issue8824: apps/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 7 17:10:02 CST 2009


Author: mmichelson
Date: Wed Jan  7 17:10:02 2009
New Revision: 167598

URL: http://svn.digium.com/view/asterisk?view=rev&rev=167598
Log:
This fix contains some fixes that I had made locally for connected
line and redirecting information. The changes to chan_sip.c mostly affect
redirecting information, while the other changes affect all calls.

AST-134
AST-146


Modified:
    team/group/issue8824/apps/app_dial.c
    team/group/issue8824/apps/app_queue.c
    team/group/issue8824/channels/chan_local.c
    team/group/issue8824/channels/chan_sip.c

Modified: team/group/issue8824/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_dial.c?view=diff&rev=167598&r1=167597&r2=167598
==============================================================================
--- team/group/issue8824/apps/app_dial.c (original)
+++ team/group/issue8824/apps/app_dial.c Wed Jan  7 17:10:02 2009
@@ -744,15 +744,18 @@
 		ast_string_field_set(c, accountcode, in->accountcode);
 		c->cdrflags = in->cdrflags;
 
-		ast_party_redirecting_copy(&o->chan->redirecting, apr);
-
-		S_REPLACE(c->cid.cid_rdnis, ast_strdup(S_OR(in->macroexten, in->exten)));
+		ast_set_redirecting(c, apr);
+		S_REPLACE(c->cid.cid_rdnis, ast_strdup(S_OR(original->cid.cid_rdnis), S_OR(in->macroexten, in->exten)));
+		
 		c->cid.cid_tns = in->cid.cid_tns;
 
 		ast_party_caller_copy(&c->cid, &in->cid);
 		ast_party_connected_line_copy(&c->connected, apc);
 
+		S_REPLACE(in->cid.cid_rdnis, ast_strdup(c->cid.cid_rdnis));
 		ast_redirecting_update(in, apr);
+
+		ast_clear_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE);
 
 		if (ast_call(c, tmpchan, 0)) {
 			ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);

Modified: team/group/issue8824/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_queue.c?view=diff&rev=167598&r1=167597&r2=167598
==============================================================================
--- team/group/issue8824/apps/app_queue.c (original)
+++ team/group/issue8824/apps/app_queue.c Wed Jan  7 17:10:02 2009
@@ -2816,6 +2816,7 @@
 				} else if (!ast_strlen_zero(o->chan->call_forward)) {
 					struct ast_party_redirecting *apr = &o->chan->redirecting;
 					struct ast_party_connected_line *apc = &o->chan->connected;
+					struct ast_channel *original = o->chan;
 					char tmpchan[256];
 					char *stuff;
 					char *tech;
@@ -2844,7 +2845,7 @@
 						ast_string_field_set(o->chan, accountcode, in->accountcode);
 						o->chan->cdrflags = in->cdrflags;
 
-						ast_party_redirecting_copy(&o->chan->redirecting, apr);
+						ast_set_redirecting(o->chan, apr);
 
 						if (o->chan->cid.cid_rdnis)
 							ast_free(o->chan->cid.cid_rdnis);
@@ -2856,6 +2857,12 @@
 						ast_party_connected_line_copy(&o->chan->connected, apc);
 
 						ast_redirecting_update(in, apr);
+						if (in->cid.cid_rdnis) {
+							ast_free(in->cid.cid_rdnis);
+						}
+						in->cid.cid_rdnis = ast_strdup(o->chan->cid.cid_rdnis);
+
+						update_connectedline = 1;
 
 						if (ast_call(o->chan, tmpchan, 0)) {
 							ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);

Modified: team/group/issue8824/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_local.c?view=diff&rev=167598&r1=167597&r2=167598
==============================================================================
--- team/group/issue8824/channels/chan_local.c (original)
+++ team/group/issue8824/channels/chan_local.c Wed Jan  7 17:10:02 2009
@@ -401,12 +401,31 @@
 		ast_moh_start(ast, data, NULL);
 	} else if (condition == AST_CONTROL_UNHOLD) {
 		ast_moh_stop(ast);
-	} else if (condition == AST_CONTROL_CONNECTED_LINE) {
-		/* We need to queue the actual channel's info, dawg */
+	} else if (condition == AST_CONTROL_CONNECTED_LINE || condition == AST_CONTROL_REDIRECTING) {
+		struct ast_channel *this_channel;
+		struct ast_channel *the_other_channel;
+		/* A connected line update frame may only contain a partial amount of data, such
+		 * as just a source, or just a ton, and not the full amount of information. However,
+		 * the collected information is all stored in the outgoing channel's connectedline
+		 * structure, so when receiving a connected line update on an outgoing local channel,
+		 * we need to transmit the collected connected line information instead of whatever
+		 * happens to be in this control frame. The same applies for redirecting information, which
+		 * is why it is handled here as well.*/
 		isoutbound = IS_OUTBOUND(ast, p);
-		if (isoutbound && p->owner) {
+		if (isoutbound) {
+			this_channel = p->chan;
+			the_other_channel = p->owner;
+		} else {
+			this_channel = p->owner;
+			the_other_channel = p->chan;
+		}
+		if (the_other_channel) {
 			/*XXX investigate later for potential deadlock issues */
-			ast_queue_connected_line_update(p->owner, &p->chan->connected);
+			if (condition == AST_CONTROL_CONNECTED_LINE) {
+				ast_queue_connected_line_update(the_other_channel, &this_channel->connected);
+			} else {
+				ast_queue_redirecting_update(the_other_channel, &this_channel->redirecting);
+			}
 		}
 	} else {
 		/* Queue up a frame representing the indication as a control frame */

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=167598&r1=167597&r2=167598
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Wed Jan  7 17:10:02 2009
@@ -10442,6 +10442,10 @@
 		return;
 	}
 
+	if (!ast_strlen_zero(p->owner->redirecting.to.number)) {
+		ast_string_field_set(p, exten, p->owner->redirecting.to.number);
+		build_contact(p);
+	}
 	respprep(&resp, p, "181 Call is being forwarded", &p->initreq);
 	add_diversion_header(&resp, p);
 	send_response(p, &resp, XMIT_UNRELIABLE, 0);
@@ -16307,7 +16311,7 @@
 /*! \brief update redirecting information for a channel based on headers
  *
  */
-static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting)
+static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting, int set_call_forward)
 {
 	char *redirecting_from_name = NULL;
 	char *redirecting_from_number = NULL;
@@ -16373,7 +16377,7 @@
 		dialplan (this is a request for a secure signalling path).
 		Note that transport=tls is deprecated, but we need to support it on incoming requests.
 */
-static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req, char **name, char **number)
+static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req, char **name, char **number, int set_call_forward)
 {
 	char contact[SIPBUFSIZE];
 	char *contact_name = NULL;
@@ -16422,7 +16426,7 @@
 	p->socket.fd = -1;
 	p->socket.type = transport;
 
-	if (ast_test_flag(&p->flags[0], SIP_PROMISCREDIR)) {
+	if (set_call_forward && ast_test_flag(&p->flags[0], SIP_PROMISCREDIR)) {
 		char *host = NULL;
 		if (!strncasecmp(contact_number, "sip:", 4))
 			contact_number += 4;
@@ -16460,11 +16464,13 @@
 			contact_number += 5;
 		separator = strchr(contact_number, ';');	/* And username ; parameters? */
 		if (separator)
-			*separator = '\0';	
-		ast_debug(2, "Received 302 Redirect to extension '%s' (domain %s)\n", contact_number, domain);
-		if (p->owner) {
-			pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain);
-			ast_string_field_set(p->owner, call_forward, contact_number);
+			*separator = '\0';
+		if (set_call_forward) {
+			ast_debug(2, "Received 302 Redirect to extension '%s' (domain %s)\n", contact_number, domain);
+			if (p->owner) {
+				pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain);
+				ast_string_field_set(p->owner, call_forward, contact_number);
+			}
 		}
 	}
 
@@ -16563,7 +16569,7 @@
 	/* RFC3261 says we must treat every 1xx response (but not 100)
 	   that we don't recognize as if it was 183.
 	*/
-	if (resp > 100 && resp < 200 && resp!=101 && resp != 180 && resp != 182 && resp != 183)
+	if (resp > 100 && resp < 200 && resp!=101 && resp != 180 && res != 181 && resp != 182 && resp != 183)
 		resp = 183;
 
  	/* Any response between 100 and 199 is PROCEEDING */
@@ -16620,8 +16626,9 @@
 		if (!req->ignore && (p->invitestate != INV_CANCELLED) && sip_cancel_destroy(p))
 			ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
 		if (!req->ignore && p->owner) {
-			change_redirecting_information(p, req, &p->owner->redirecting);
-			ast_queue_redirecting_update(p->owner, &p->owner->redirecting);
+			struct ast_party_redirecting redirecting = {{0,},};
+			change_redirecting_information(p, req, &redirecting, FALSE);
+			ast_queue_redirecting_update(p->owner, &redirecting);
 		}
 		check_pendings(p);
 		break;
@@ -17542,7 +17549,10 @@
 				case 301: /* Moved permanently */
 				case 302: /* Moved temporarily */
 				case 305: /* Use Proxy */
-					change_redirecting_information(p, req, &p->owner->redirecting);
+					{
+					struct ast_party_redirecting redirecting = {{0,},};
+					change_redirecting_information(p, req, &redirecting, TRUE);
+					ast_set_redirecting(p->owner, &redirecting);
 					/* Fall through */
 				case 486: /* Busy here */
 				case 600: /* Busy everywhere */
@@ -18996,7 +19006,7 @@
 			return 0;
 		}
 		gotdest = get_destination(p, NULL);	/* Get destination right away */
-		change_redirecting_information(p, req, &redirecting); /*Will return immediately if no Diversion header is present */
+		change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
 		extract_uri(p, req);			/* Get the Contact URI */
 		build_contact(p);			/* Build our contact header */
 
@@ -19040,10 +19050,11 @@
 			if (c) {
 				/* Pre-lock the call */
 				ast_channel_lock(c);
-				ast_party_redirecting_copy(&c->redirecting, &redirecting);
+				ast_set_redirecting(c, &redirecting);
 			}
 		}
 	} else {
+		struct ast_party_redirecting redirecting = {{0,},};
 		if (sipdebug) {
 			if (!req->ignore)
 				ast_debug(2, "Got a SIP re-invite for call %s\n", p->callid);
@@ -19053,7 +19064,10 @@
 		if (!req->ignore)
 			reinvite = 1;
 		c = p->owner;
-		change_redirecting_information(p, req, &c->redirecting); /*Will return immediately if no Diversion header is present */
+		change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
+		if (c) {
+			ast_set_redirecting(c, &redirecting);
+		}
 	}
 
 	/* Session-Timers */




More information about the asterisk-commits mailing list