[asterisk-commits] rmudgett: branch rmudgett/cid r263592 - in /team/rmudgett/cid: ./ apps/ chann...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 17 15:16:59 CDT 2010


Author: rmudgett
Date: Mon May 17 15:16:55 2010
New Revision: 263592

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=263592
Log:
Merged revisions 263457,263460,263541 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r263457 | lmadsen | 2010-05-17 09:37:35 -0500 (Mon, 17 May 2010) | 19 lines
  
  Recorded merge of revisions 263456 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r263456 | lmadsen | 2010-05-17 09:35:18 -0500 (Mon, 17 May 2010) | 11 lines
    
    Manager cookies are not compatible with RFC2109.
    
    The Version field in the cookies we're setting contain quotes around the version
    number which is not compatible with RFC2109 and breaks some implementations.
    
    (closes issue #17231)
    Reported by: ecarruda
    Patches:
          manager_rfc2109-trunk-v1.patch uploaded by ecarruda (license 559)
          manager_rfc2109-1.6.2-v1.patch uploaded by ecarruda (license 559)
    Tested by: ecarruda, russell
  ........
................
  r263460 | lmadsen | 2010-05-17 10:14:22 -0500 (Mon, 17 May 2010) | 7 lines
  
  Missing newlines added to Set-Cookie line in manager.c
  
  Sean Bright pointed out that we lost a set of newline characters in commit
  190349 on a line I had recently changed. Yay for code review on commits.
  
  (issue #17231, #10961)
................
  r263541 | mmichelson | 2010-05-17 10:36:31 -0500 (Mon, 17 May 2010) | 40 lines
  
  Enhancements to connected line and redirecting work.
  
  From reviewboard:
  
  Digium has a commercial customer who has made extensive use of the connected party and
  redirecting information present in later versions of Asterisk Business Edition and which
  is to be in the upcoming 1.8 release. Through their use of the feature, new problems and solutions
  have come about. This patch adds several enhancements to maximize usage of the connected party
  and redirecting information functionality.
  
  First, Asterisk trunk already had connected line interception macros. These macros allow you to
  manipulate connected line information before it was sent out to its target. This patch adds the
  same feature except for redirecting information instead.
  
  Second, the ast_callerid and ast_party_id structures have been enhanced to provide a "tag." This
  tag can be set with func_callerid, func_connectedline, func_redirecting, and in the case of DAHDI,
  mISDN, and SIP channels, can be set in a configuration file. The idea behind the callerid tag is
  that it can be set to whatever value the administrator likes. Later, when running connected line
  and redirecting macros, the admin can read the tag off the appropriate structure to determine what
  action to take. You can think of this sort of like a channel variable, except that instead of having
  the variable associated with a channel, the variable is associated with a specific identity within
  Asterisk.
  
  Third, app_dial has two new options, s and u. The s option lets a dialplan writer force a specific
  caller ID tag to be placed on the outgoing channel. The u option allows the dialplan writer to force
  a specific calling presentation value on the outgoing channel.
  
  Fourth, there is a new control frame subclass called AST_CONTROL_READ_ACTION added. This was added
  to correct a very specific situation. In the case of SIP semi-attended (blond) transfers, the party
  being transferred would not have the opportunity to run a connected line interception macro to
  possibly alter the transfer target's connected line information. The issue here was that during a
  blond transfer, the SIP transfer code has no bridged channel on which to queue the connected line
  update. The way this was corrected was to add this new control frame subclass. Now, we queue an
  AST_CONTROL_READ_ACTION frame on the channel on which the connected line interception macro should
  be run. When ast_read is called to read the frame, ast_read responds by calling a callback function
  associated with the specific read action the control frame describes. In this case, the action taken
  is to run the connected line interception macro on the transferee's channel.
  
  Review: https://reviewboard.asterisk.org/r/652/
................

Modified:
    team/rmudgett/cid/   (props changed)
    team/rmudgett/cid/apps/app_dial.c
    team/rmudgett/cid/apps/app_queue.c
    team/rmudgett/cid/channels/chan_dahdi.c
    team/rmudgett/cid/channels/chan_local.c
    team/rmudgett/cid/channels/chan_misdn.c
    team/rmudgett/cid/channels/chan_sip.c
    team/rmudgett/cid/channels/misdn/chan_misdn_config.h
    team/rmudgett/cid/channels/misdn/isdn_lib.h
    team/rmudgett/cid/channels/misdn_config.c
    team/rmudgett/cid/channels/sip/include/sip.h
    team/rmudgett/cid/configs/misdn.conf.sample
    team/rmudgett/cid/funcs/func_callerid.c
    team/rmudgett/cid/funcs/func_connectedline.c
    team/rmudgett/cid/funcs/func_redirecting.c
    team/rmudgett/cid/include/asterisk/channel.h
    team/rmudgett/cid/include/asterisk/frame.h
    team/rmudgett/cid/main/channel.c
    team/rmudgett/cid/main/dial.c
    team/rmudgett/cid/main/features.c
    team/rmudgett/cid/main/rtp_engine.c

Propchange: team/rmudgett/cid/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/rmudgett/cid/
------------------------------------------------------------------------------
--- cid-integrated (original)
+++ cid-integrated Mon May 17 15:16:55 2010
@@ -1,1 +1,1 @@
-/trunk:1-263519
+/trunk:1-263541

Modified: team/rmudgett/cid/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/apps/app_dial.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/apps/app_dial.c (original)
+++ team/rmudgett/cid/apps/app_dial.c Mon May 17 15:16:55 2010
@@ -335,6 +335,10 @@
 					<para>Hang up the call <replaceable>x</replaceable> seconds <emphasis>after</emphasis> the called party has
 					answered the call.</para>
 				</option>
+				<option name="s">
+					<argument name="x" required="true" />
+					<para>Force the outgoing callerid tag parameter to be set to the string <replaceable>x</replaceable></para>
+				</option>
 				<option name="t">
 					<para>Allow the called party to transfer the calling party by sending the
 					DTMF sequence defined in <filename>features.conf</filename>. This setting does not perform policy enforcement on
@@ -383,6 +387,21 @@
 						with this option. Also, pbx services are not run on the peer (called) channel,
 						so you will not be able to set timeouts via the TIMEOUT() function in this routine.</para>
 					</note>
+				</option>
+				<option name="u">
+					<argument name = "x" required="true">
+						<para>Force the outgoing callerid presentation indicator parameter to be set
+						to one of the values passed in <replaceable>x</replaceable>:
+						<literal>allowed_not_screened</literal>
+						<literal>allowed_passed_screen</literal>
+						<literal>allowed_failed_screen</literal>
+						<literal>allowed</literal>
+						<literal>prohib_not_screened</literal>
+						<literal>prohib_passed_screen</literal>
+						<literal>prohib_failed_screen</literal>
+						<literal>prohib</literal>
+						<literal>unavailable</literal></para>
+					</argument>
 				</option>
 				<option name="w">
 					<para>Allow the called party to enable recording of the call by sending
@@ -537,6 +556,8 @@
 #define OPT_PEER_H           ((uint64_t)1 << 35)
 #define OPT_CALLEE_GO_ON     ((uint64_t)1 << 36)
 #define OPT_CANCEL_TIMEOUT   ((uint64_t)1 << 37)
+#define OPT_FORCE_CID_TAG    ((uint64_t)1 << 38)
+#define OPT_FORCE_CID_PRES   ((uint64_t)1 << 39)
 
 enum {
 	OPT_ARG_ANNOUNCE = 0,
@@ -553,6 +574,8 @@
 	OPT_ARG_OPERMODE,
 	OPT_ARG_SCREEN_NOINTRO,
 	OPT_ARG_FORCECLID,
+	OPT_ARG_FORCE_CID_TAG,
+	OPT_ARG_FORCE_CID_PRES,
 	/* note: this entry _MUST_ be the last one in the enum */
 	OPT_ARG_ARRAY_SIZE,
 };
@@ -586,6 +609,8 @@
 	AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY),
 	AST_APP_OPTION_ARG('r', OPT_RINGBACK, OPT_ARG_RINGBACK),
 	AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
+	AST_APP_OPTION_ARG('s', OPT_FORCE_CID_TAG, OPT_ARG_FORCE_CID_TAG),
+	AST_APP_OPTION_ARG('u', OPT_FORCE_CID_PRES, OPT_ARG_FORCE_CID_PRES),
 	AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
 	AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
 	AST_APP_OPTION_ARG('U', OPT_CALLEE_GOSUB, OPT_ARG_CALLEE_GOSUB),
@@ -854,8 +879,20 @@
 			ast_string_field_set(c, accountcode, in->accountcode);
 		}
 		ast_party_connected_line_copy(&c->connected, &original->connected);
-
-		ast_channel_update_redirecting(in, &c->redirecting);
+		/*
+		 * We must unlock c before calling ast_channel_redirecting_macro, because
+		 * we put c into autoservice there. That is pretty much a guaranteed
+		 * deadlock. This is why the handling of c's lock may seem a bit unusual
+		 * here.
+		 */
+		ast_channel_unlock(c);
+		if (ast_channel_redirecting_macro(c, in, &c->redirecting, 1, 0)) {
+			while (ast_channel_trylock(c)) {
+				CHANNEL_DEADLOCK_AVOIDANCE(in);
+			}
+			ast_channel_update_redirecting(in, &c->redirecting);
+			ast_channel_unlock(c);
+		}
 
 		ast_clear_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE);
 		if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) {
@@ -863,7 +900,6 @@
 		}
 
 		ast_channel_unlock(in);
-		ast_channel_unlock(c);
 
 		if (ast_call(c, tmpchan, 0)) {
 			ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
@@ -1194,7 +1230,9 @@
 						ast_verb(3, "Redirecting update to %s prevented.\n", in->name);
 					} else {
 						ast_verb(3, "%s redirecting info has changed, passing it to %s\n", c->name, in->name);
-						ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen);
+						if (ast_channel_redirecting_macro(c, in, f, 1, 1)) {
+							ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen);
+						}
 						pa->sentringing = 0;
 					}
 					break;
@@ -1335,6 +1373,10 @@
 					if (ast_channel_connected_line_macro(in, outgoing->chan, f, 0, 1)) {
 						ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
 					}
+				} else if (f->subclass.integer == AST_CONTROL_REDIRECTING) {
+					if (ast_channel_redirecting_macro(in, outgoing->chan, f, 0, 1)) {
+						ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
+					}
 				}
 			}
 			ast_frfree(f);
@@ -1702,7 +1744,7 @@
 	struct cause_args num = { chan, 0, 0, 0 };
 	int cause;
 	char numsubst[256];
-	char *cid_num = NULL, *cid_name = NULL;
+	char *cid_num = NULL, *cid_name = NULL, *cid_tag = NULL, *cid_pres = NULL;
 
 	struct ast_bridge_config config = { { 0, } };
 	struct timeval calldurationlimit = { 0, };
@@ -1805,6 +1847,10 @@
 
 	if (ast_test_flag64(&opts, OPT_FORCECLID) && !ast_strlen_zero(opt_args[OPT_ARG_FORCECLID]))
 		ast_callerid_parse(opt_args[OPT_ARG_FORCECLID], &cid_name, &cid_num);
+	if (ast_test_flag64(&opts, OPT_FORCE_CID_TAG) && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_TAG]))
+		cid_tag = ast_strdupa(opt_args[OPT_ARG_FORCE_CID_TAG]);
+	if (ast_test_flag64(&opts, OPT_FORCE_CID_PRES) && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_PRES]))
+		cid_pres = ast_strdupa(opt_args[OPT_ARG_FORCE_CID_PRES]);
 	if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
 		ast_cdr_reset(chan->cdr, NULL);
 	if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
@@ -1993,11 +2039,20 @@
 
 		if (ast_test_flag64(peerflags, OPT_FORCECLID) && !ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) {
 			struct ast_party_connected_line connected;
+			int pres;
 
 			ast_party_connected_line_set_init(&connected, &tmp->chan->connected);
 			connected.id.number = cid_num;
 			connected.id.name = cid_name;
-			connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+			connected.id.tag = cid_tag;
+			if (cid_pres) {
+				pres = ast_parse_caller_presentation(cid_pres);
+				if (pres >= 0) {
+					connected.id.number_presentation = pres;
+				}
+			} else {
+				connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+			}
 			ast_channel_set_connected_line(tmp->chan, &connected);
 		} else {
 			ast_connected_line_copy_from_caller(&tc->connected, &chan->cid);

Modified: team/rmudgett/cid/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/apps/app_queue.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/apps/app_queue.c (original)
+++ team/rmudgett/cid/apps/app_queue.c Mon May 17 15:16:55 2010
@@ -3204,6 +3204,7 @@
 {
 	const char *queue = qe->parent->name;
 	struct callattempt *o, *start = NULL, *prev = NULL;
+	int res;
 	int status;
 	int numbusies = prebusies;
 	int numnochan = 0;
@@ -3373,7 +3374,21 @@
 						ast_party_caller_copy(&o->chan->cid, &in->cid);
 						ast_party_connected_line_copy(&o->chan->connected, &original->connected);
 
-						ast_channel_update_redirecting(in, &o->chan->redirecting);
+						/*
+						 * We must unlock o->chan before calling
+						 * ast_channel_redirecting_macro, because we put o->chan into
+						 * autoservice there.  That is pretty much a guaranteed
+						 * deadlock.  This is why the handling of o->chan's lock may
+						 * seem a bit unusual here.
+						 */
+						ast_channel_unlock(o->chan);
+						res = ast_channel_redirecting_macro(o->chan, in, &o->chan->redirecting, 1, 0);
+						while (ast_channel_trylock(o->chan)) {
+							CHANNEL_DEADLOCK_AVOIDANCE(in);
+						}
+						if (res) {
+							ast_channel_update_redirecting(in, &o->chan->redirecting);
+						}
 
 						update_connectedline = 1;
 
@@ -3486,7 +3501,9 @@
 								ast_verb(3, "Redirecting update to %s prevented\n", inchan_name);
 							} else {
 								ast_verb(3, "%s redirecting info has changed, passing it to %s\n", ochan_name, inchan_name);
-								ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen);
+								if (ast_channel_redirecting_macro(o->chan, in, f, 1, 1)) {
+									ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen);
+								}
 							}
 							break;
 						default:

Modified: team/rmudgett/cid/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/chan_dahdi.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/chan_dahdi.c (original)
+++ team/rmudgett/cid/channels/chan_dahdi.c Mon May 17 15:16:55 2010
@@ -1049,6 +1049,11 @@
 	int cid_ani2;
 	/*! \brief Caller ID number from an incoming call. */
 	char cid_num[AST_MAX_EXTENSION];
+	/*!
+	 * \brief Caller ID tag from incoming call
+	 * \note the "cid_tag" string read in from chan_dahdi.conf
+	 */
+	char cid_tag[AST_MAX_EXTENSION];
 	/*! \brief Caller ID Q.931 TON/NPI field values.  Set by PRI. Zero otherwise. */
 	int cid_ton;
 	/*! \brief Caller ID name from an incoming call. */
@@ -1386,6 +1391,7 @@
 			.context = "default",
 			.cid_num = "",
 			.cid_name = "",
+			.cid_tag = "",
 			.mohinterpret = "default",
 			.mohsuggest = "",
 			.parkinglot = "",
@@ -9024,6 +9030,7 @@
 	tmp->cid.cid_pres = i->callingpres;
 	tmp->cid.cid_ton = i->cid_ton;
 	tmp->cid.cid_ani2 = i->cid_ani2;
+	tmp->cid.cid_tag = ast_strdup(i->cid_tag);
 #if defined(HAVE_SS7)
 	tmp->transfercapability = transfercapability;
 	pbx_builtin_setvar_helper(tmp, "TRANSFERCAPABILITY", ast_transfercapability2str(transfercapability));
@@ -11995,6 +12002,7 @@
 			tmp->cid_num[0] = '\0';
 			tmp->cid_name[0] = '\0';
 		}
+		ast_copy_string(tmp->cid_tag, conf->chan.cid_tag, sizeof(tmp->cid_tag));
 		tmp->cid_subaddr[0] = '\0';
 		ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
 		if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {
@@ -16781,6 +16789,8 @@
 			ast_copy_string(confp->chan.cid_name, v->value, sizeof(confp->chan.cid_name));
 		} else if (!strcasecmp(v->name, "cid_number")) {
 			ast_copy_string(confp->chan.cid_num, v->value, sizeof(confp->chan.cid_num));
+		} else if (!strcasecmp(v->name, "cid_tag")) {
+			ast_copy_string(confp->chan.cid_tag, v->value, sizeof(confp->chan.cid_tag));
 		} else if (!strcasecmp(v->name, "useincomingcalleridondahditransfer")) {
 			confp->chan.dahditrcallerid = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "restrictcid")) {

Modified: team/rmudgett/cid/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/chan_local.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/chan_local.c (original)
+++ team/rmudgett/cid/channels/chan_local.c Mon May 17 15:16:55 2010
@@ -433,6 +433,9 @@
 		if (the_other_channel) {
 			unsigned char frame_data[1024];
 			if (condition == AST_CONTROL_CONNECTED_LINE) {
+				if (isoutbound) {
+					ast_connected_line_copy_to_caller(&the_other_channel->cid, &this_channel->connected);
+				}
 				f.datalen = ast_connected_line_build_data(frame_data, sizeof(frame_data), &this_channel->connected);
 			} else {
 				f.datalen = ast_redirecting_build_data(frame_data, sizeof(frame_data), &this_channel->redirecting);

Modified: team/rmudgett/cid/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/chan_misdn.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/chan_misdn.c (original)
+++ team/rmudgett/cid/channels/chan_misdn.c Mon May 17 15:16:55 2010
@@ -5978,6 +5978,10 @@
 		ast_mutex_init(&ch->overlap_tv_lock);
 	} /* ORIG MISDN END */
 
+	misdn_cfg_get(port, MISDN_CFG_INCOMING_CALLERID_TAG, bc->incoming_cid_tag, sizeof(bc->incoming_cid_tag));
+	if (!ast_strlen_zero(bc->incoming_cid_tag)) {
+		chan_misdn_log(1, port, " --> * Setting incoming caller id tag to \"%s\"\n", bc->incoming_cid_tag);
+	}
 	ch->overlap_dial_task = -1;
 
 	if (ch->faxdetect  || ch->ast_dsp) {
@@ -6003,10 +6007,11 @@
  * \param ast Current Asterisk channel
  * \param id Party id information to send to the other side
  * \param source Why are we sending this update
+ * \param cid_tag Caller ID tag to set in the connected line
  *
  * \return Nothing
  */
-static void misdn_queue_connected_line_update(struct ast_channel *ast, const struct misdn_party_id *id, enum AST_CONNECTED_LINE_UPDATE_SOURCE source)
+static void misdn_queue_connected_line_update(struct ast_channel *ast, const struct misdn_party_id *id, enum AST_CONNECTED_LINE_UPDATE_SOURCE source, char *cid_tag)
 {
 	struct ast_party_connected_line connected;
 
@@ -6016,6 +6021,7 @@
 		| misdn_to_ast_plan(id->number_plan);
 	connected.id.number_presentation = misdn_to_ast_pres(id->presentation)
 		| misdn_to_ast_screen(id->screening);
+	connected.id.tag = cid_tag;
 	connected.source = source;
 	ast_channel_queue_connected_line_update(ast, &connected);
 }
@@ -6168,10 +6174,11 @@
  *
  * \param ast Current Asterisk channel
  * \param redirect Associated B channel redirecting info
+ * \param tag Caller ID tag to set in the redirecting party fields
  *
  * \return Nothing
  */
-static void misdn_copy_redirecting_to_ast(struct ast_channel *ast, const struct misdn_party_redirecting *redirect)
+static void misdn_copy_redirecting_to_ast(struct ast_channel *ast, const struct misdn_party_redirecting *redirect, char *tag)
 {
 	struct ast_party_redirecting redirecting;
 
@@ -6184,6 +6191,7 @@
 	redirecting.from.number_presentation =
 		misdn_to_ast_pres(redirect->from.presentation)
 		| misdn_to_ast_screen(redirect->from.screening);
+	redirecting.from.tag = tag;
 
 	redirecting.to.number = (char *) redirect->to.number;
 	redirecting.to.number_type =
@@ -6192,6 +6200,7 @@
 	redirecting.to.number_presentation =
 		misdn_to_ast_pres(redirect->to.presentation)
 		| misdn_to_ast_screen(redirect->to.screening);
+	redirecting.to.tag = tag;
 
 	redirecting.reason = misdn_to_ast_reason(redirect->reason);
 	redirecting.count = redirect->count;
@@ -6281,6 +6290,7 @@
 	struct chan_list *ch;
 	struct misdn_bchannel *newbc;
 	char *dest_cp;
+	int append_msn = 0;
 
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(intf);	/* The interface token is discarded. */
@@ -6391,6 +6401,14 @@
 			ast_copy_string(newbc->caller.number, ast->connected.id.number, sizeof(newbc->caller.number));
 			chan_misdn_log(3, port, " --> * set caller:\"%s\" <%s>\n", newbc->caller.name, newbc->caller.number);
 		}
+
+		misdn_cfg_get(port, MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, &append_msn, sizeof(append_msn));
+		if (append_msn) {
+			strncat(newbc->incoming_cid_tag, "_", sizeof(newbc->incoming_cid_tag) - strlen(newbc->incoming_cid_tag) - 1);
+			strncat(newbc->incoming_cid_tag, newbc->caller.number, sizeof(newbc->incoming_cid_tag) - strlen(newbc->incoming_cid_tag) - 1);
+		}
+
+		ast->cid.cid_tag = ast_strdup(newbc->incoming_cid_tag);
 
 		misdn_cfg_get(port, MISDN_CFG_LOCALDIALPLAN, &number_type, sizeof(number_type));
 		if (number_type < 0) {
@@ -8791,7 +8809,7 @@
 				++bc->redirecting.count;
 				bc->redirecting.reason = mISDN_REDIRECTING_REASON_DEFLECTION;
 
-				misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting);
+				misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
 				ast_string_field_set(ch->ast, call_forward, bc->redirecting.to.number);
 
 				/* Send back positive ACK */
@@ -8855,7 +8873,7 @@
 				bc->redirecting.to.presentation = 1;/* restricted */
 				bc->redirecting.to.screening = 0;/* unscreened */
 			}
-			misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting);
+			misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
 			bc->div_leg_3_rx_wanted = 1;
 		}
 		break;
@@ -8900,7 +8918,7 @@
 					/* We have no place to put the OriginalCalled number */
 				}
 #endif
-				misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting);
+				misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
 			}
 			break;
 		default:
@@ -8950,7 +8968,7 @@
 			++bc->redirecting.count;
 			bc->redirecting.reason = mISDN_REDIRECTING_REASON_DEFLECTION;
 
-			misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting);
+			misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
 			ast_string_field_set(ch->ast, call_forward, bc->redirecting.to.number);
 
 			misdn_lib_send_event(bc, EVENT_DISCONNECT);
@@ -9072,7 +9090,8 @@
 			misdn_queue_connected_line_update(ch->ast, &party_id,
 				(bc->fac_in.u.EctInform.Status == 0 /* alerting */)
 					? AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING
-					: AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER);
+					: AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER,
+					bc->incoming_cid_tag);
 		}
 		break;
 #if 0	/* We don't handle this yet */
@@ -9707,6 +9726,7 @@
 		int exceed;
 		int ai;
 		int im;
+		int append_msn = 0;
 
 		if (ch) {
 			switch (ch->state) {
@@ -9780,12 +9800,22 @@
 
 		ast_set_callerid(chan, bc->caller.number, NULL, bc->caller.number);
 
+		misdn_cfg_get(bc->port, MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, &append_msn, sizeof(append_msn));
+		if (append_msn) {
+			strncat(bc->incoming_cid_tag, "_", sizeof(bc->incoming_cid_tag) - strlen(bc->incoming_cid_tag) - 1);
+			strncat(bc->incoming_cid_tag, bc->dialed.number, sizeof(bc->incoming_cid_tag) - strlen(bc->incoming_cid_tag) - 1);
+		}
+
+		ast_channel_lock(chan);
+		chan->cid.cid_tag = ast_strdup(bc->incoming_cid_tag);
+		ast_channel_unlock(chan);
+
 		if (!ast_strlen_zero(bc->redirecting.from.number)) {
 			/* Add configured prefix to redirecting.from.number */
 			misdn_add_number_prefix(bc->port, bc->redirecting.from.number_type, bc->redirecting.from.number, sizeof(bc->redirecting.from.number));
 
 			/* Update asterisk channel redirecting information */
-			misdn_copy_redirecting_to_ast(chan, &bc->redirecting);
+			misdn_copy_redirecting_to_ast(chan, &bc->redirecting, bc->incoming_cid_tag);
 		}
 
 		pbx_builtin_setvar_helper(chan, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
@@ -10124,11 +10154,13 @@
 		}
 #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 
-		/* Add configured prefix to connected.number */
-		misdn_add_number_prefix(bc->port, bc->connected.number_type, bc->connected.number, sizeof(bc->connected.number));
-
-		/* Update the connected line information on the other channel */
-		misdn_queue_connected_line_update(ch->ast, &bc->connected, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER);
+		if (!ast_strlen_zero(bc->connected.number)) {
+			/* Add configured prefix to connected.number */
+			misdn_add_number_prefix(bc->port, bc->connected.number_type, bc->connected.number, sizeof(bc->connected.number));
+
+			/* Update the connected line information on the other channel */
+			misdn_queue_connected_line_update(ch->ast, &bc->connected, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, bc->incoming_cid_tag);
+		}
 
 		ch->l3id = bc->l3_id;
 		ch->addr = bc->addr;
@@ -10511,7 +10543,7 @@
 						bc->redirecting.reason = mISDN_REDIRECTING_REASON_UNKNOWN;
 						break;
 					}
-					misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting);
+					misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
 					ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting);
 				}
 			}
@@ -10530,7 +10562,7 @@
 				bc->redirecting.to_changed = 0;
 				if (ch && ch->ast) {
 					misdn_queue_connected_line_update(ch->ast, &bc->redirecting.to,
-						AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING);
+						AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING, bc->incoming_cid_tag);
 				}
 			}
 			break;
@@ -10539,7 +10571,7 @@
 				bc->redirecting.to_changed = 0;
 				if (ch && ch->ast) {
 					misdn_queue_connected_line_update(ch->ast, &bc->redirecting.to,
-						AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER);
+						AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, bc->incoming_cid_tag);
 				}
 			}
 			break;

Modified: team/rmudgett/cid/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/chan_sip.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/chan_sip.c (original)
+++ team/rmudgett/cid/channels/chan_sip.c Mon May 17 15:16:55 2010
@@ -4741,6 +4741,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, cid_tag, peer->cid_tag);
 	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);
@@ -6281,6 +6282,7 @@
 	ast_channel_lock(tmp);
 	sip_pvt_lock(i);
 	ast_channel_cc_params_init(tmp, i->cc_params);
+	tmp->cid.cid_tag = ast_strdup(i->cid_tag);
 	ast_channel_unlock(tmp);
 
 	tmp->tech = ( ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INFO || ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_SHORTINFO) ?  &sip_tech_info : &sip_tech;
@@ -13395,7 +13397,11 @@
 			params++;
 		/* Check if we have a reason parameter */
 		if ((reason_param = strcasestr(params, "reason="))) {
+			char *end;
 			reason_param+=7;
+			if ((end = strchr(reason_param, ';'))) {
+				*end = '\0';
+			}
 			/* Remove enclosing double-quotes */
 			if (*reason_param == '"')
 				ast_strip_quoted(reason_param, "\"", "\"");
@@ -14118,6 +14124,8 @@
 			}
 			if (!ast_strlen_zero(peer->cid_name))
 				ast_string_field_set(p, cid_name, peer->cid_name);
+			if (!ast_strlen_zero(peer->cid_tag))
+				ast_string_field_set(p, cid_tag, peer->cid_tag);
 			if (peer->callingpres)
 				p->callingpres = peer->callingpres;
 		}
@@ -17527,6 +17535,7 @@
 		ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
 		redirecting->from.name = redirecting_from_name;
 	}
+	redirecting->from.tag = (char *) p->cid_tag;
 	if (!ast_strlen_zero(redirecting_to_number)) {
 		if (redirecting->to.number) {
 			ast_free(redirecting->to.number);
@@ -17541,6 +17550,7 @@
 		ast_debug(3, "Got redirecting to name %s\n", redirecting_from_number);
 		redirecting->to.name = redirecting_to_name;
 	}
+	redirecting->to.tag = (char *) p->cid_tag;
 	redirecting->reason = reason;
 }
 
@@ -17888,6 +17898,7 @@
 				ast_party_connected_line_init(&connected);
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
+				connected.id.tag = (char *) p->cid_tag;
 				connected.id.number_presentation = p->callingpres;
 				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 				ast_channel_queue_connected_line_update(p->owner, &connected);
@@ -17932,6 +17943,7 @@
 				ast_party_connected_line_init(&connected);
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
+				connected.id.tag = (char *) p->cid_tag;
 				connected.id.number_presentation = p->callingpres;
 				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 				ast_channel_queue_connected_line_update(p->owner, &connected);
@@ -17977,6 +17989,7 @@
 			ast_party_connected_line_init(&connected);
 			connected.id.number = (char *) p->cid_num;
 			connected.id.name = (char *) p->cid_name;
+			connected.id.tag = (char *) p->cid_tag;
 			connected.id.number_presentation = p->callingpres;
 			connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 			ast_channel_queue_connected_line_update(p->owner, &connected);
@@ -20121,6 +20134,7 @@
 		ast_party_connected_line_init(&connected);
 		connected.id.number = (char *) p->cid_num;
 		connected.id.name = (char *) p->cid_name;
+		connected.id.tag = (char *) p->cid_tag;
 		connected.id.number_presentation = p->callingpres;
 		connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		ast_channel_queue_connected_line_update(p->owner, &connected);
@@ -20448,6 +20462,7 @@
 				ast_party_connected_line_init(&connected);
 				connected.id.number = (char *) p->cid_num;
 				connected.id.name = (char *) p->cid_name;
+				connected.id.tag = (char *) p->cid_tag;
 				connected.id.number_presentation = p->callingpres;
 				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 				ast_channel_queue_connected_line_update(p->owner, &connected);
@@ -21073,11 +21088,30 @@
 			ast_channel_queue_connected_line_update(target.chan2, &connected_to_target);
 		} else {
 			/* Since target.chan1 isn't actually connected to another channel, there is no way for us
-			 * to queue a frame so that its connected line status will be updated. Instead, we have to
-			 * change it directly. Since we are not the channel thread, we cannot run a connected line
-			 * interception macro on target.chan1
+			 * to queue a frame so that its connected line status will be updated.
+			 *
+			 * Instead, we use the somewhat hackish approach of using a special control frame type that
+			 * instructs ast_read to perform a specific action. In this case, the frame we queue tells
+			 * ast_read to call the connected line interception macro configured for target.chan1.
 			 */
-			ast_channel_update_connected_line(target.chan1, &connected_to_target);
+			struct ast_control_read_action_payload *frame_payload;
+			int payload_size;
+			int frame_size;
+			unsigned char connected_line_data[1024];
+			payload_size = ast_connected_line_build_data(connected_line_data, sizeof(connected_line_data), &connected_to_target);
+			frame_size = payload_size + sizeof(*frame_payload);
+			if (payload_size != -1 && (frame_payload = alloca(frame_size))) {
+				frame_payload->payload_size = payload_size;
+				memcpy(frame_payload->payload, connected_line_data, payload_size);
+				frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
+				ast_queue_control_data(target.chan1, AST_CONTROL_READ_ACTION, frame_payload, frame_size);
+			}
+			/* In addition to queueing the read action frame so that target.chan1's connected line info
+			 * will be updated, we also are going to queue a plain old connected line update on target.chan1. This
+			 * way, either Dial or Queue can apply this connected line update to the outgoing ringing channel.
+			 */
+			ast_channel_queue_connected_line_update(target.chan1, &connected_to_transferee);
+
 		}
 		ast_channel_unref(current->chan1);
 	}
@@ -24718,6 +24752,7 @@
 	ast_string_field_set(peer, md5secret, "");
 	ast_string_field_set(peer, cid_num, "");
 	ast_string_field_set(peer, cid_name, "");
+	ast_string_field_set(peer, cid_tag, "");
 	ast_string_field_set(peer, fromdomain, "");
 	ast_string_field_set(peer, fromuser, "");
 	ast_string_field_set(peer, regexten, "");
@@ -24933,6 +24968,8 @@
 				ast_string_field_set(peer, cid_name, "");
 			} else if (!strcasecmp(v->name, "cid_number")) {
 				ast_string_field_set(peer, cid_num, v->value);
+			} else if (!strcasecmp(v->name, "cid_tag")) {
+				ast_string_field_set(peer, cid_tag, v->value);
 			} else if (!strcasecmp(v->name, "context")) {
 				ast_string_field_set(peer, context, v->value);
 				ast_set_flag(&peer->flags[1], SIP_PAGE2_HAVEPEERCONTEXT);

Modified: team/rmudgett/cid/channels/misdn/chan_misdn_config.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/misdn/chan_misdn_config.h?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/misdn/chan_misdn_config.h (original)
+++ team/rmudgett/cid/channels/misdn/chan_misdn_config.h Mon May 17 15:16:55 2010
@@ -42,6 +42,8 @@
 	MISDN_CFG_LANGUAGE,            /* char[] */
 	MISDN_CFG_MUSICCLASS,            /* char[] */
 	MISDN_CFG_CALLERID,            /* char[] */
+	MISDN_CFG_INCOMING_CALLERID_TAG, /* char[] */
+	MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, /* int (bool) */
 	MISDN_CFG_METHOD,              /* char[] */
 	MISDN_CFG_DIALPLAN,            /* int */
 	MISDN_CFG_LOCALDIALPLAN,       /* int */

Modified: team/rmudgett/cid/channels/misdn/isdn_lib.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/misdn/isdn_lib.h?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/misdn/isdn_lib.h (original)
+++ team/rmudgett/cid/channels/misdn/isdn_lib.h Mon May 17 15:16:55 2010
@@ -349,6 +349,11 @@
 	 */
 	struct misdn_party_id caller;
 
+	/*! \brief  Incoming Caller ID string tag for special purpose
+	 * \note The element can be set to "incoming_cid_tag" in /etc/asterisk/misdn.conf for incoming calls
+	 */
+	char incoming_cid_tag[MISDN_MAX_NAME_LEN];
+
 	/*! \brief Connected-Party/Connected-Line ID information struct
 	 * \note The number_type element can be set to "cpndialplan" in /etc/asterisk/misdn.conf for outgoing calls
 	 */

Modified: team/rmudgett/cid/channels/misdn_config.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/misdn_config.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/misdn_config.c (original)
+++ team/rmudgett/cid/channels/misdn_config.c Mon May 17 15:16:55 2010
@@ -134,6 +134,13 @@
 		"Sets the musiconhold class." },
 	{ "callerid", MISDN_CFG_CALLERID, MISDN_CTYPE_STR, "", NONE,
 		"Set the outgoing caller id to the value." },
+	{ "incoming_cid_tag", MISDN_CFG_INCOMING_CALLERID_TAG, MISDN_CTYPE_STR, "", NONE,
+		"Set the incoming caller id string tag to the value." },
+	{ "append_msn_to_cid_tag", MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, MISDN_CTYPE_BOOL, "no", NONE,
+		"Automatically appends incoming or outgoing MSN to the incoming caller\n"
+		"\tid string tag. An underscore '_' is used as delimiter. Incoming calls\n"
+		"\twill have the dialed number appended, and outgoing calls will have the\n"
+		"\tcaller number appended to the tag." },
 	{ "method", MISDN_CFG_METHOD, MISDN_CTYPE_STR, "standard", NONE,
 		"Set the method to use for channel selection:\n"
 		"\t  standard     - Use the first free channel starting from the lowest number.\n"

Modified: team/rmudgett/cid/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/channels/sip/include/sip.h?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/channels/sip/include/sip.h (original)
+++ team/rmudgett/cid/channels/sip/include/sip.h Mon May 17 15:16:55 2010
@@ -926,6 +926,7 @@
 		AST_STRING_FIELD(peermd5secret);
 		AST_STRING_FIELD(cid_num);      /*!< Caller*ID number */
 		AST_STRING_FIELD(cid_name);     /*!< Caller*ID name */
+		AST_STRING_FIELD(cid_tag);      /*!< Caller*ID tag */
 		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. */
@@ -1130,6 +1131,7 @@
 		AST_STRING_FIELD(fullcontact);  /*!< Contact registered with us (not in sip.conf) */
 		AST_STRING_FIELD(cid_num);      /*!< Caller ID num */
 		AST_STRING_FIELD(cid_name);     /*!< Caller ID name */
+		AST_STRING_FIELD(cid_tag);      /*!< Caller ID tag */
 		AST_STRING_FIELD(vmexten);      /*!< Dialplan extension for MWI notify message*/
 		AST_STRING_FIELD(language);     /*!<  Default language for prompts */
 		AST_STRING_FIELD(mohinterpret); /*!<  Music on Hold class */

Modified: team/rmudgett/cid/configs/misdn.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/configs/misdn.conf.sample?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/configs/misdn.conf.sample (original)
+++ team/rmudgett/cid/configs/misdn.conf.sample Mon May 17 15:16:55 2010
@@ -404,6 +404,19 @@
 presentation=-1
 screen=-1
 
+; Incoming calls will have a caller ID tag set to this value
+;
+;incoming_cid_tag = "asterisk"
+
+; With this set, you can automatically append the MSN of a party
+; to the cid_tag. Incoming calls have the dialed number appended
+; to the tag, and outgoing calls have the caller number appended
+; to the tag. An '_' is used to separate the tag from the
+; MSN.
+; Default is no.
+;
+;append_msn_to_cid_tag = no
+
 ; Select what to do with outgoing COLP information on this port.
 ;
 ; 0 - Send out COLP information unaltered. (default)

Modified: team/rmudgett/cid/funcs/func_callerid.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cid/funcs/func_callerid.c?view=diff&rev=263592&r1=263591&r2=263592
==============================================================================
--- team/rmudgett/cid/funcs/func_callerid.c (original)
+++ team/rmudgett/cid/funcs/func_callerid.c Mon May 17 15:16:55 2010
@@ -44,6 +44,7 @@
 					<enum name="all" />
 					<enum name="num" />
 					<enum name="name" />
+					<enum name="tag" />
 					<enum name="ANI" />
 					<enum name="DNID" />
 					<enum name="RDNIS" />
@@ -161,6 +162,10 @@
 			if (chan->cid.cid_name) {
 				ast_copy_string(buf, chan->cid.cid_name, len);
 			}
+		} else if (!strncasecmp("tag", data, 3)) {
+			if (chan->cid.cid_tag) {
+				ast_copy_string(buf, chan->cid.cid_tag, len);
+			}
 		} else if (!strncasecmp("num", data, 3)) {
 			/* also matches "number" */
 			if (chan->cid.cid_num) {
@@ -254,6 +259,13 @@
 		if (chan->cdr) {
 			ast_cdr_setcid(chan->cdr, chan);
 		}
+	} else if (!strncasecmp("tag", data, 3)) {
+		ast_channel_lock(chan);
+		if (chan->cid.cid_tag) {
+			ast_free(chan->cid.cid_tag);
+		}
+		chan->cid.cid_tag = ast_strdup(value);
+		ast_channel_unlock(chan);
 	} else if (!strncasecmp("ani", data, 3)) {
 		if (!strncasecmp(data + 3, "2", 1)) {
 			chan->cid.cid_ani2 = atoi(value);


[... 699 lines stripped ...]



More information about the asterisk-commits mailing list