aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-17 15:36:31 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-17 15:36:31 +0000
commit82c8ef7415d9fa1cab877da20d671ba9093c8895 (patch)
treee0f98e5d12f079b7d8f94c031808eaea340b8065 /funcs
parent17d3dd99a4716c14fe7a9ee5835049cdf2c6855a (diff)
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/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@263541 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_callerid.c12
-rw-r--r--funcs/func_connectedline.c9
-rw-r--r--funcs/func_redirecting.c13
3 files changed, 32 insertions, 2 deletions
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index 3de69950e..357055c8c 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<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 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
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 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
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);
diff --git a/funcs/func_connectedline.c b/funcs/func_connectedline.c
index 936d49047..95bcb23af 100644
--- a/funcs/func_connectedline.c
+++ b/funcs/func_connectedline.c
@@ -58,6 +58,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<enum name = "all" />
<enum name = "num" />
<enum name = "name" />
+ <enum name = "tag" />
<enum name = "ton" />
<enum name = "pres" />
<enum name = "subaddr[-valid]|[-type]|[-odd]">
@@ -99,6 +100,10 @@ static int connectedline_read(struct ast_channel *chan, const char *cmd, char *d
if (chan->connected.id.number) {
ast_copy_string(buf, chan->connected.id.number, len);
}
+ } else if (!strncasecmp("tag", data, 3)) {
+ if (chan->connected.id.tag) {
+ ast_copy_string(buf, chan->connected.id.tag, len);
+ }
} else if (!strncasecmp("ton", data, 3)) {
snprintf(buf, len, "%d", chan->connected.id.number_type);
} else if (!strncasecmp("pres", data, 4)) {
@@ -179,6 +184,10 @@ static int connectedline_write(struct ast_channel *chan, const char *cmd, char *
connected.id.number = ast_strdupa(value);
ast_trim_blanks(connected.id.number);
set_it(chan, &connected);
+ } else if (!strncasecmp("tag", data, 3)) {
+ connected.id.tag = ast_strdupa(value);
+ ast_trim_blanks(connected.id.tag);
+ set_it(chan, &connected);
} else if (!strncasecmp("ton", data, 3)) {
val = ast_strdupa(value);
ast_trim_blanks(val);
diff --git a/funcs/func_redirecting.c b/funcs/func_redirecting.c
index 87fc41abe..2f38c2f3b 100644
--- a/funcs/func_redirecting.c
+++ b/funcs/func_redirecting.c
@@ -68,11 +68,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<enum name = "from-all" />
<enum name = "from-num" />
<enum name = "from-name" />
+ <enum name = "from-tag" />
<enum name = "from-ton" />
<enum name = "from-pres" />
<enum name = "to-all" />
<enum name = "to-num" />
<enum name = "to-name" />
+ <enum name = "to-tag" />
<enum name = "to-ton" />
<enum name = "to-pres" />
<enum name = "reason" />
@@ -144,6 +146,10 @@ static enum ID_FIELD_STATUS redirecting_id_read(char *buf, size_t len, char *dat
if (id->number) {
ast_copy_string(buf, id->number, len);
}
+ } else if (!strncasecmp("tag", data, 3)) {
+ if (id->tag) {
+ ast_copy_string(buf, id->tag, len);
+ }
} else if (!strncasecmp("ton", data, 3)) {
snprintf(buf, len, "%d", id->number_type);
} else if (!strncasecmp("pres", data, 4)) {
@@ -257,6 +263,9 @@ static enum ID_FIELD_STATUS redirecting_id_write(struct ast_party_id *id, char *
} else if (!strncasecmp("num", data, 3)) {
id->number = ast_strdup(value);
ast_trim_blanks(id->number);
+ } else if (!strncasecmp("tag", data, 3)) {
+ id->tag = ast_strdup(value);
+ ast_trim_blanks(id->tag);
} else if (!strncasecmp("ton", data, 3)) {
val = ast_strdupa(value);
ast_trim_blanks(val);
@@ -347,7 +356,6 @@ static int redirecting_write(struct ast_channel *chan, const char *cmd, char *da
switch (redirecting_id_write(&redirecting.from, data + 5, value)) {
case ID_FIELD_VALID:
set_it(chan, &redirecting);
- ast_party_redirecting_free(&redirecting);
break;
case ID_FIELD_INVALID:
@@ -357,11 +365,11 @@ static int redirecting_write(struct ast_channel *chan, const char *cmd, char *da
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
+ ast_party_redirecting_free(&redirecting);
} else if (!strncasecmp("to-", data, 3)) {
switch (redirecting_id_write(&redirecting.to, data + 3, value)) {
case ID_FIELD_VALID:
set_it(chan, &redirecting);
- ast_party_redirecting_free(&redirecting);
break;
case ID_FIELD_INVALID:
@@ -371,6 +379,7 @@ static int redirecting_write(struct ast_channel *chan, const char *cmd, char *da
ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
break;
}
+ ast_party_redirecting_free(&redirecting);
} else if (!strncasecmp("pres", data, 4)) {
int pres;