[asterisk-commits] app dial.c: Force COLP update if outgoing channel name changed. (asterisk[certified/13.1])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 29 07:26:15 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: app_dial.c: Force COLP update if outgoing channel name changed.
......................................................................


app_dial.c: Force COLP update if outgoing channel name changed.

* When a call is answered and the outgoing channel name has changed then
force a connected line update because the channel is no longer the same.
The channel was masqueraded into by another channel.  This is usually
because of a call pickup.

Note: Forwarded calls are handled in a controlled manner so the original
channel name is replaced with the forwarded channel.

ASTERISK-25423
Reported by: John Hardin

Change-Id: I2e01f7a698fbbc8c26344a59c2be40c6cd98b00c
---
M apps/app_dial.c
1 file changed, 30 insertions(+), 6 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/apps/app_dial.c b/apps/app_dial.c
index 86167a1..e492cd9 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -704,6 +704,8 @@
 	const char *tech;
 	/*! Channel device addressing.  (Stored in stuff[]) */
 	const char *number;
+	/*! Original channel name.  Must be freed.  Could be NULL if allocation failed. */
+	char *orig_chan_name;
 	uint64_t flags;
 	/*! Saved connected party info from an AST_CONTROL_CONNECTED_LINE. */
 	struct ast_party_connected_line connected;
@@ -722,6 +724,7 @@
 {
 	ast_party_connected_line_free(&outgoing->connected);
 	ast_aoc_destroy_decoded(outgoing->aoc_s_rate_list);
+	ast_free(outgoing->orig_chan_name);
 	ast_free(outgoing);
 }
 
@@ -1167,7 +1170,14 @@
 			if (ast_test_flag64(o, DIAL_STILLGOING) && ast_channel_state(c) == AST_STATE_UP) {
 				if (!peer) {
 					ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
-					if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
+					if (o->orig_chan_name
+						&& strcmp(o->orig_chan_name, ast_channel_name(c))) {
+						/*
+						 * The channel name changed so we must generate COLP update.
+						 * Likely because a call pickup channel masqueraded in.
+						 */
+						update_connected_line_from_peer(in, c, 1);
+					} else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
 						if (o->pending_connected_update) {
 							if (ast_channel_connected_line_sub(c, in, &o->connected, 0) &&
 								ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
@@ -1229,10 +1239,14 @@
 				do_forward(o, &num, peerflags, single, caller_entertained, &orig,
 					forced_clid, stored_clid);
 
-				if (single && o->chan
-					&& !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)
-					&& !ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
-					update_connected_line_from_peer(in, o->chan, 1);
+				if (o->chan) {
+					ast_free(o->orig_chan_name);
+					o->orig_chan_name = ast_strdup(ast_channel_name(o->chan));
+					if (single
+						&& !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)
+						&& !ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
+						update_connected_line_from_peer(in, o->chan, 1);
+					}
 				}
 				continue;
 			}
@@ -1256,7 +1270,14 @@
 					/* This is our guy if someone answered. */
 					if (!peer) {
 						ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
-						if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
+						if (o->orig_chan_name
+							&& strcmp(o->orig_chan_name, ast_channel_name(c))) {
+							/*
+							 * The channel name changed so we must generate COLP update.
+							 * Likely because a call pickup channel masqueraded in.
+							 */
+							update_connected_line_from_peer(in, c, 1);
+						} else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
 							if (o->pending_connected_update) {
 								if (ast_channel_connected_line_sub(c, in, &o->connected, 0) &&
 									ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
@@ -2501,6 +2522,9 @@
 
 		ast_channel_stage_snapshot_done(tc);
 
+		/* Save the original channel name to detect call pickup masquerading in. */
+		tmp->orig_chan_name = ast_strdup(ast_channel_name(tc));
+
 		ast_channel_unlock(tc);
 		ast_channel_unlock(chan);
 

-- 
To view, visit https://gerrit.asterisk.org/1326
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e01f7a698fbbc8c26344a59c2be40c6cd98b00c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list