aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 15:48:36 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 15:48:36 +0000
commitad58aa92a221bb6cd0a4133112672528a52fd4f8 (patch)
tree84df3fc1c9db428d5833e3eed3908a71e32cd513 /apps
parent3c0a99b844ba77d93d3bece0261d729bd5135a6a (diff)
ast_callerid restructuring
The purpose of this patch is to eliminate struct ast_callerid since it has turned into a miscellaneous collection of various party information. Eliminate struct ast_callerid and replace it with the following struct organization: struct ast_party_name { char *str; int char_set; int presentation; unsigned char valid; }; struct ast_party_number { char *str; int plan; int presentation; unsigned char valid; }; struct ast_party_subaddress { char *str; int type; unsigned char odd_even_indicator; unsigned char valid; }; struct ast_party_id { struct ast_party_name name; struct ast_party_number number; struct ast_party_subaddress subaddress; char *tag; }; struct ast_party_dialed { struct { char *str; int plan; } number; struct ast_party_subaddress subaddress; int transit_network_select; }; struct ast_party_caller { struct ast_party_id id; char *ani; int ani2; }; The new organization adds some new information as well. * The party name and number now have their own presentation value that can be manipulated independently. ISDN supplies the presentation value for the name and number at different times with the possibility that they could be different. * The party name and number now have a valid flag. Before this change the name or number string could be empty if the presentation were restricted. Most channel drivers assume that the name or number is then simply not available instead of indicating that the name or number was restricted. * The party name now has a character set value. SIP and Q.SIG have the ability to indicate what character set a name string is using so it could be presented properly. * The dialed party now has a numbering plan value that could be useful to have available. The various channel drivers will need to be updated to support the new core features as needed. They have simply been converted to supply current functionality at this time. The following items of note were either corrected or enhanced: * The CONNECTEDLINE() and REDIRECTING() dialplan functions were consolidated into func_callerid.c to share party id handling code. * CALLERPRES() is now deprecated because the name and number have their own presentation values. * Fixed app_alarmreceiver.c write_metadata(). The workstring[] could contain garbage. It also can only contain the caller id number so using ast_callerid_parse() on it is silly. There was also a typo in the CALLERNAME if test. * Fixed app_rpt.c using ast_callerid_parse() on the channel's caller id number string. ast_callerid_parse() alters the given buffer which in this case is the channel's caller id number string. Then using ast_shrink_phone_number() could alter it even more. * Fixed caller ID name and number memory leak in chan_usbradio.c. * Fixed uninitialized char arrays cid_num[] and cid_name[] in sig_analog.c. * Protected access to a caller channel with lock in chan_sip.c. * Clarified intent of code in app_meetme.c sla_ring_station() and dial_trunk(). Also made save all caller ID data instead of just the name and number strings. * Simplified cdr.c set_one_cid(). It hand coded the ast_callerid_merge() function. * Corrected some weirdness with app_privacy.c's use of caller presentation. Review: https://reviewboard.asterisk.org/r/702/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@276347 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_alarmreceiver.c48
-rw-r--r--apps/app_amd.c6
-rw-r--r--apps/app_dial.c113
-rw-r--r--apps/app_directed_pickup.c6
-rw-r--r--apps/app_disa.c18
-rw-r--r--apps/app_dumpchan.c8
-rw-r--r--apps/app_fax.c38
-rw-r--r--apps/app_followme.c5
-rw-r--r--apps/app_macro.c18
-rw-r--r--apps/app_meetme.c156
-rw-r--r--apps/app_minivm.c37
-rw-r--r--apps/app_osplookup.c10
-rw-r--r--apps/app_parkandannounce.c16
-rw-r--r--apps/app_privacy.c22
-rw-r--r--apps/app_queue.c102
-rw-r--r--apps/app_readexten.c16
-rw-r--r--apps/app_rpt.c51
-rw-r--r--apps/app_setcallerid.c4
-rw-r--r--apps/app_sms.c5
-rw-r--r--apps/app_stack.c11
-rw-r--r--apps/app_talkdetect.c3
-rw-r--r--apps/app_voicemail.c90
-rw-r--r--apps/app_while.c6
-rw-r--r--apps/app_zapateller.c6
24 files changed, 483 insertions, 312 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 22dd4af67..952ef722e 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -298,18 +298,22 @@ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_chan
int res = 0;
struct timeval t;
struct ast_tm now;
- char *cl,*cn;
+ char *cl;
+ char *cn;
char workstring[80];
char timestamp[80];
/* Extract the caller ID location */
- if (chan->cid.cid_num)
- ast_copy_string(workstring, chan->cid.cid_num, sizeof(workstring));
- workstring[sizeof(workstring) - 1] = '\0';
-
- ast_callerid_parse(workstring, &cn, &cl);
- if (cl)
- ast_shrink_phone_number(cl);
+ ast_copy_string(workstring,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
+ sizeof(workstring));
+ ast_shrink_phone_number(workstring);
+ if (ast_strlen_zero(workstring)) {
+ cl = "<unknown>";
+ } else {
+ cl = workstring;
+ }
+ cn = S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>");
/* Get the current time */
t = ast_tvnow();
@@ -319,27 +323,27 @@ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_chan
ast_strftime(timestamp, sizeof(timestamp), time_stamp_format, &now);
res = fprintf(logfile, "\n\n[metadata]\n\n");
-
- if (res >= 0)
+ if (res >= 0) {
res = fprintf(logfile, "PROTOCOL=%s\n", signalling_type);
-
- if (res >= 0)
- res = fprintf(logfile, "CALLINGFROM=%s\n", (!cl) ? "<unknown>" : cl);
-
- if (res >- 0)
- res = fprintf(logfile, "CALLERNAME=%s\n", (!cn) ? "<unknown>" : cn);
-
- if (res >= 0)
+ }
+ if (res >= 0) {
+ res = fprintf(logfile, "CALLINGFROM=%s\n", cl);
+ }
+ if (res >= 0) {
+ res = fprintf(logfile, "CALLERNAME=%s\n", cn);
+ }
+ if (res >= 0) {
res = fprintf(logfile, "TIMESTAMP=%s\n\n", timestamp);
-
- if (res >= 0)
+ }
+ if (res >= 0) {
res = fprintf(logfile, "[events]\n\n");
-
+ }
if (res < 0) {
ast_verb(3, "AlarmReceiver: can't write metadata\n");
ast_debug(1,"AlarmReceiver: can't write metadata\n");
- } else
+ } else {
res = 0;
+ }
return res;
}
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 928afee0b..f4eb78470 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -188,8 +188,10 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
AST_APP_ARG(argMaximumWordLength);
);
- ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name, chan->cid.cid_ani,
- chan->redirecting.from.number, ast_getformatname(chan->readformat));
+ ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name,
+ S_OR(chan->caller.ani, "(N/A)"),
+ S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, "(N/A)"),
+ ast_getformatname(chan->readformat));
/* Lets parse the arguments. */
if (!ast_strlen_zero(parse)) {
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 31e64ce4d..52ca6bd1d 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -722,13 +722,6 @@ static void handle_cause(int cause, struct cause_args *num)
}
}
-/*! \brief free the buffer if allocated, and set the pointer to the second arg */
-#define S_REPLACE(s, new_val) \
- do { \
- ast_free(s); \
- s = (new_val); \
- } while (0)
-
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
{
char rexten[2] = { exten, '\0' };
@@ -773,9 +766,11 @@ static void senddialevent(struct ast_channel *src, struct ast_channel *dst, cons
"UniqueID: %s\r\n"
"DestUniqueID: %s\r\n"
"Dialstring: %s\r\n",
- src->name, dst->name, S_OR(src->cid.cid_num, "<unknown>"),
- S_OR(src->cid.cid_name, "<unknown>"), src->uniqueid,
- dst->uniqueid, dialstring ? dialstring : "");
+ src->name, dst->name,
+ S_COR(src->caller.id.number.valid, src->caller.id.number.str, "<unknown>"),
+ S_COR(src->caller.id.name.valid, src->caller.id.name.str, "<unknown>"),
+ src->uniqueid, dst->uniqueid,
+ dialstring ? dialstring : "");
}
static void senddialendevent(struct ast_channel *src, const char *dialstatus)
@@ -859,28 +854,34 @@ static void do_forward(struct chanlist *o,
ast_rtp_instance_early_bridge_make_compatible(c, in);
}
- ast_channel_set_redirecting(c, &original->redirecting);
+ ast_channel_set_redirecting(c, &original->redirecting, NULL);
ast_channel_lock(c);
while (ast_channel_trylock(in)) {
CHANNEL_DEADLOCK_AVOIDANCE(c);
}
- if (ast_strlen_zero(c->redirecting.from.number)) {
+ if (!c->redirecting.from.number.valid
+ || ast_strlen_zero(c->redirecting.from.number.str)) {
/*
* The call was not previously redirected so it is
* now redirected from this number.
*/
- S_REPLACE(c->redirecting.from.number,
- ast_strdup(S_OR(in->macroexten, in->exten)));
+ ast_party_number_free(&c->redirecting.from.number);
+ ast_party_number_init(&c->redirecting.from.number);
+ c->redirecting.from.number.valid = 1;
+ c->redirecting.from.number.str =
+ ast_strdup(S_OR(in->macroexten, in->exten));
}
- c->cid.cid_tns = in->cid.cid_tns;
+ c->dialed.transit_network_select = in->dialed.transit_network_select;
if (ast_test_flag64(o, OPT_FORCECLID)) {
- S_REPLACE(c->cid.cid_num, ast_strdup(S_OR(in->macroexten, in->exten)));
- S_REPLACE(c->cid.cid_name, NULL);
+ ast_party_id_free(&c->caller.id);
+ ast_party_id_init(&c->caller.id);
+ c->caller.id.number.valid = 1;
+ c->caller.id.number.str = ast_strdup(S_OR(in->macroexten, in->exten));
ast_string_field_set(c, accountcode, c->accountcode);
} else {
- ast_party_caller_copy(&c->cid, &in->cid);
+ ast_party_caller_copy(&c->caller, &in->caller);
ast_string_field_set(c, accountcode, in->accountcode);
}
ast_party_connected_line_copy(&c->connected, &original->connected);
@@ -897,7 +898,7 @@ static void do_forward(struct chanlist *o,
while (ast_channel_trylock(c)) {
CHANNEL_DEADLOCK_AVOIDANCE(in);
}
- ast_channel_update_redirecting(in, &c->redirecting);
+ ast_channel_update_redirecting(in, &c->redirecting, NULL);
ast_channel_unlock(c);
}
@@ -985,10 +986,10 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (!ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(outgoing, DIAL_CALLERID_ABSENT)) {
ast_channel_lock(outgoing->chan);
- ast_connected_line_copy_from_caller(&connected_caller, &outgoing->chan->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &outgoing->chan->caller);
ast_channel_unlock(outgoing->chan);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_update_connected_line(in, &connected_caller);
+ ast_channel_update_connected_line(in, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
}
}
@@ -1045,14 +1046,14 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
if (o->pending_connected_update) {
if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
- ast_channel_update_connected_line(in, &o->connected);
+ ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
ast_channel_lock(c);
- ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &c->caller);
ast_channel_unlock(c);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_update_connected_line(in, &connected_caller);
+ ast_channel_update_connected_line(in, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
}
}
@@ -1115,14 +1116,14 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
if (o->pending_connected_update) {
if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
- ast_channel_update_connected_line(in, &o->connected);
+ ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
ast_channel_lock(c);
- ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &c->caller);
ast_channel_unlock(c);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_update_connected_line(in, &connected_caller);
+ ast_channel_update_connected_line(in, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
}
}
@@ -1240,7 +1241,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n", c->name, in->name);
ast_party_connected_line_set_init(&connected, &o->connected);
ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected);
- ast_party_connected_line_set(&o->connected, &connected);
+ ast_party_connected_line_set(&o->connected, &connected, NULL);
ast_party_connected_line_free(&connected);
o->pending_connected_update = 1;
} else {
@@ -1617,8 +1618,9 @@ static int setup_privacy_args(struct privacy_args *pa,
char *l;
int silencethreshold;
- if (!ast_strlen_zero(chan->cid.cid_num)) {
- l = ast_strdupa(chan->cid.cid_num);
+ if (chan->caller.id.number.valid
+ && !ast_strlen_zero(chan->caller.id.number.str)) {
+ l = ast_strdupa(chan->caller.id.number.str);
ast_shrink_phone_number(l);
if (ast_test_flag64(opts, OPT_PRIVACY) ) {
ast_verb(3, "Privacy DB is '%s', clid is '%s'\n", opt_args[OPT_ARG_PRIVACY], l);
@@ -2060,11 +2062,16 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
memset(&tc->whentohangup, 0, sizeof(tc->whentohangup));
/* If the new channel has no callerid, try to guess what it should be */
- if (ast_strlen_zero(tc->cid.cid_num)) {
- if (!ast_strlen_zero(chan->connected.id.number)) {
- ast_set_callerid(tc, chan->connected.id.number, chan->connected.id.name, chan->connected.ani);
- } else if (!ast_strlen_zero(chan->cid.cid_dnid)) {
- ast_set_callerid(tc, chan->cid.cid_dnid, NULL, NULL);
+ if (!tc->caller.id.number.valid) {
+ if (chan->connected.id.number.valid) {
+ struct ast_party_caller caller;
+
+ ast_party_caller_set_init(&caller, &tc->caller);
+ caller.id = chan->connected.id;
+ caller.ani = chan->connected.ani;
+ ast_channel_set_caller_event(tc, &caller, NULL);
+ } else if (!ast_strlen_zero(chan->dialed.number.str)) {
+ ast_set_callerid(tc, chan->dialed.number.str, NULL, NULL);
} else if (!ast_strlen_zero(S_OR(chan->macroexten, chan->exten))) {
ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), NULL, NULL);
}
@@ -2076,25 +2083,33 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
int pres;
ast_party_connected_line_set_init(&connected, &tmp->chan->connected);
- connected.id.number = cid_num;
- connected.id.name = cid_name;
- connected.id.tag = cid_tag;
if (cid_pres) {
pres = ast_parse_caller_presentation(cid_pres);
- if (pres >= 0) {
- connected.id.number_presentation = pres;
+ if (pres < 0) {
+ pres = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
}
} else {
- connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+ pres = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+ }
+ if (cid_num) {
+ connected.id.number.valid = 1;
+ connected.id.number.str = cid_num;
+ connected.id.number.presentation = pres;
}
- ast_channel_set_connected_line(tmp->chan, &connected);
+ if (cid_name) {
+ connected.id.name.valid = 1;
+ connected.id.name.str = cid_name;
+ connected.id.name.presentation = pres;
+ }
+ connected.id.tag = cid_tag;
+ ast_channel_set_connected_line(tmp->chan, &connected, NULL);
} else {
- ast_connected_line_copy_from_caller(&tc->connected, &chan->cid);
+ ast_connected_line_copy_from_caller(&tc->connected, &chan->caller);
}
ast_party_redirecting_copy(&tc->redirecting, &chan->redirecting);
- tc->cid.cid_tns = chan->cid.cid_tns;
+ tc->dialed.transit_network_select = chan->dialed.transit_network_select;
if (!ast_strlen_zero(chan->accountcode)) {
ast_string_field_set(tc, peeraccount, chan->accountcode);
@@ -2616,7 +2631,9 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
strcpy(peer->context, chan->context);
- if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
+ if (ast_test_flag64(&opts, OPT_PEER_H)
+ && ast_exists_extension(peer, peer->context, "h", 1,
+ S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) {
int autoloopflag;
int found;
int res9;
@@ -2626,8 +2643,12 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
- while ((res9 = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found, 1)) == 0)
+ while ((res9 = ast_spawn_extension(peer, peer->context, peer->exten,
+ peer->priority,
+ S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL),
+ &found, 1)) == 0) {
peer->priority++;
+ }
if (found && res9) {
/* Something bad happened, or a hangup has been requested. */
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index cb8505b56..bcefb0661 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -111,15 +111,15 @@ static int pickup_do(struct ast_channel *chan, struct ast_channel *target)
ast_party_connected_line_copy(&connected_caller, &target->connected);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
if (ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
- ast_channel_update_connected_line(chan, &connected_caller);
+ ast_channel_update_connected_line(chan, &connected_caller, NULL);
}
ast_party_connected_line_free(&connected_caller);
ast_channel_lock(chan);
- ast_connected_line_copy_from_caller(&connected_caller, &chan->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &chan->caller);
ast_channel_unlock(chan);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_queue_connected_line_update(chan, &connected_caller);
+ ast_channel_queue_connected_line_update(chan, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
if ((res = ast_answer(chan))) {
diff --git a/apps/app_disa.c b/apps/app_disa.c
index a64d05371..20c9ce48c 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -308,9 +308,11 @@ static int disa_exec(struct ast_channel *chan, const char *data)
}
} else {
if (j == '#') { /* end of extension .. maybe */
- if (i == 0 &&
- (ast_matchmore_extension(chan, args.context, "#", 1, chan->cid.cid_num) ||
- ast_exists_extension(chan, args.context, "#", 1, chan->cid.cid_num)) ) {
+ if (i == 0
+ && (ast_matchmore_extension(chan, args.context, "#", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
+ || ast_exists_extension(chan, args.context, "#", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) ) {
/* Let the # be the part of, or the entire extension */
} else {
break;
@@ -340,7 +342,8 @@ static int disa_exec(struct ast_channel *chan, const char *data)
}
/* if can do some more, do it */
- if (!ast_matchmore_extension(chan,args.context,exten,1, chan->cid.cid_num)) {
+ if (!ast_matchmore_extension(chan, args.context, exten, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
break;
}
}
@@ -352,13 +355,16 @@ static int disa_exec(struct ast_channel *chan, const char *data)
int recheck = 0;
struct ast_flags cdr_flags = { AST_CDR_FLAG_POSTED };
- if (!ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
+ if (!ast_exists_extension(chan, args.context, exten, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten);
exten[0] = 'i';
exten[1] = '\0';
recheck = 1;
}
- if (!recheck || ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
+ if (!recheck
+ || ast_exists_extension(chan, args.context, exten, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_playtones_stop(chan);
/* We're authenticated and have a target extension */
if (!ast_strlen_zero(args.cid)) {
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index d66661db6..feaeda29e 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -116,10 +116,10 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
c->name,
c->tech->type,
c->uniqueid,
- S_OR(c->cid.cid_num, "(N/A)"),
- S_OR(c->cid.cid_name, "(N/A)"),
- S_OR(c->cid.cid_dnid, "(N/A)"),
- S_OR(c->redirecting.from.number, "(N/A)"),
+ S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
+ S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
+ S_OR(c->dialed.number.str, "(N/A)"),
+ S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
c->parkinglot,
c->language,
ast_state2str(c->_state),
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 9b1972d97..54d22db16 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -251,25 +251,25 @@ static void phase_e_handler(t30_state_t *f, void *user_data, int result)
ast_debug(1, " Transfer Rate: %d\n", stat.bit_rate);
ast_manager_event(s->chan, EVENT_FLAG_CALL,
- s->direction ? "FaxSent" : "FaxReceived",
- "Channel: %s\r\n"
- "Exten: %s\r\n"
- "CallerID: %s\r\n"
- "RemoteStationID: %s\r\n"
- "LocalStationID: %s\r\n"
- "PagesTransferred: %d\r\n"
- "Resolution: %d\r\n"
- "TransferRate: %d\r\n"
- "FileName: %s\r\n",
- s->chan->name,
- s->chan->exten,
- S_OR(s->chan->cid.cid_num, ""),
- far_ident,
- local_ident,
- pages_transferred,
- stat.y_resolution,
- stat.bit_rate,
- s->file_name);
+ s->direction ? "FaxSent" : "FaxReceived",
+ "Channel: %s\r\n"
+ "Exten: %s\r\n"
+ "CallerID: %s\r\n"
+ "RemoteStationID: %s\r\n"
+ "LocalStationID: %s\r\n"
+ "PagesTransferred: %d\r\n"
+ "Resolution: %d\r\n"
+ "TransferRate: %d\r\n"
+ "FileName: %s\r\n",
+ s->chan->name,
+ s->chan->exten,
+ S_COR(s->chan->caller.id.number.valid, s->chan->caller.id.number.str, ""),
+ far_ident,
+ local_ident,
+ pages_transferred,
+ stat.y_resolution,
+ stat.bit_rate,
+ s->file_name);
}
/* === Helper functions to configure fax === */
diff --git a/apps/app_followme.c b/apps/app_followme.c
index b6ad76705..fcab992d3 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -838,7 +838,10 @@ static void findmeexec(struct fm_args *tpargs)
outbound = ast_request("Local", ast_best_codec(caller->nativeformats), caller, dialarg, &dg);
if (outbound) {
- ast_set_callerid(outbound, caller->cid.cid_num, caller->cid.cid_name, caller->cid.cid_num);
+ ast_set_callerid(outbound,
+ S_COR(caller->caller.id.number.valid, caller->caller.id.number.str, NULL),
+ S_COR(caller->caller.id.name.valid, caller->caller.id.name.str, NULL),
+ S_COR(caller->caller.id.number.valid, caller->caller.id.number.str, NULL));
ast_channel_inherit_variables(tpargs->chan, outbound);
ast_channel_datastore_inherit(tpargs->chan, outbound);
ast_string_field_set(outbound, language, tpargs->chan->language);
diff --git a/apps/app_macro.c b/apps/app_macro.c
index f3ff81db5..e5ab2bc21 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -298,7 +298,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
}
snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro);
- if (!ast_exists_extension(chan, fullmacro, "s", 1, chan->cid.cid_num)) {
+ if (!ast_exists_extension(chan, fullmacro, "s", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
if (!ast_context_find(fullmacro))
ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
else
@@ -370,7 +371,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
ast_channel_unlock(chan);
autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
- while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+ while (ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
struct ast_context *c;
struct ast_exten *e;
int foundx;
@@ -386,7 +388,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
if (ast_rdlock_context(c)) {
ast_log(LOG_WARNING, "Unable to lock context?\n");
} else {
- e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num);
+ e = find_matching_priority(c, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */
ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata));
@@ -402,7 +405,10 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
/* Reset the macro depth, if it was changed in the last iteration */
pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
- if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &foundx,1))) {
+ res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ &foundx, 1);
+ if (res) {
/* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
(res == '*') || (res == '#')) {
@@ -544,7 +550,9 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
normally if there is any problem */
if (sscanf(offsets, "%30d", &offset) == 1) {
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten,
+ chan->priority + offset + 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
chan->priority += offset;
}
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index b0b26ae30..5ef9718f1 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -1453,8 +1453,8 @@ static char *meetme_show_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
if (!concise) {
ast_cli(a->fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s %s %02d:%02d:%02d\n",
user->user_no,
- S_OR(user->chan->cid.cid_num, "<unknown>"),
- S_OR(user->chan->cid.cid_name, "<no name>"),
+ S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"),
user->chan->name,
ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "(Admin)" : "",
ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "(Listen only)" : "",
@@ -1464,8 +1464,8 @@ static char *meetme_show_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
} else {
ast_cli(a->fd, "%d!%s!%s!%s!%s!%s!%s!%s!%d!%02d:%02d:%02d\n",
user->user_no,
- S_OR(user->chan->cid.cid_num, ""),
- S_OR(user->chan->cid.cid_name, ""),
+ S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, ""),
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, ""),
user->chan->name,
ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "1" : "",
ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "1" : "",
@@ -2660,17 +2660,17 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
if (!sent_event) {
ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeJoin",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Meetme: %s\r\n"
- "Usernum: %d\r\n"
- "CallerIDnum: %s\r\n"
- "CallerIDname: %s\r\n",
- chan->name, chan->uniqueid, conf->confno,
- user->user_no,
- S_OR(user->chan->cid.cid_num, "<unknown>"),
- S_OR(user->chan->cid.cid_name, "<unknown>")
- );
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Meetme: %s\r\n"
+ "Usernum: %d\r\n"
+ "CallerIDnum: %s\r\n"
+ "CallerIDname: %s\r\n",
+ chan->name, chan->uniqueid, conf->confno,
+ user->user_no,
+ S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>")
+ );
sent_event = 1;
}
@@ -3697,18 +3697,18 @@ bailoutandtrynormal:
if (sent_event) {
ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Meetme: %s\r\n"
- "Usernum: %d\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "Duration: %ld\r\n",
- chan->name, chan->uniqueid, conf->confno,
- user->user_no,
- S_OR(user->chan->cid.cid_num, "<unknown>"),
- S_OR(user->chan->cid.cid_name, "<unknown>"),
- (long)(now.tv_sec - user->jointime));
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Meetme: %s\r\n"
+ "Usernum: %d\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Duration: %ld\r\n",
+ chan->name, chan->uniqueid, conf->confno,
+ user->user_no,
+ S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
+ (long)(now.tv_sec - user->jointime));
}
if (setusercount) {
@@ -4706,30 +4706,30 @@ static int action_meetmelist(struct mansession *s, const struct message *m)
while ((user = ao2_iterator_next(&user_iter))) {
total++;
astman_append(s,
- "Event: MeetmeList\r\n"
- "%s"
- "Conference: %s\r\n"
- "UserNumber: %d\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "Channel: %s\r\n"
- "Admin: %s\r\n"
- "Role: %s\r\n"
- "MarkedUser: %s\r\n"
- "Muted: %s\r\n"
- "Talking: %s\r\n"
- "\r\n",
- idText,
- cnf->confno,
- user->user_no,
- S_OR(user->chan->cid.cid_num, "<unknown>"),
- S_OR(user->chan->cid.cid_name, "<no name>"),
- user->chan->name,
- ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No",
- ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen",
- ast_test_flag64(&user->userflags, CONFFLAG_MARKEDUSER) ? "Yes" : "No",
- user->adminflags & ADMINFLAG_MUTED ? "By admin" : user->adminflags & ADMINFLAG_SELFMUTED ? "By self" : "No",
- user->talking > 0 ? "Yes" : user->talking == 0 ? "No" : "Not monitored");
+ "Event: MeetmeList\r\n"
+ "%s"
+ "Conference: %s\r\n"
+ "UserNumber: %d\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Channel: %s\r\n"
+ "Admin: %s\r\n"
+ "Role: %s\r\n"
+ "MarkedUser: %s\r\n"
+ "Muted: %s\r\n"
+ "Talking: %s\r\n"
+ "\r\n",
+ idText,
+ cnf->confno,
+ user->user_no,
+ S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"),
+ user->chan->name,
+ ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No",
+ ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen",
+ ast_test_flag64(&user->userflags, CONFFLAG_MARKEDUSER) ? "Yes" : "No",
+ user->adminflags & ADMINFLAG_MUTED ? "By admin" : user->adminflags & ADMINFLAG_SELFMUTED ? "By self" : "No",
+ user->talking > 0 ? "Yes" : user->talking == 0 ? "No" : "Not monitored");
ao2_ref(user, -1);
}
ao2_iterator_destroy(&user_iter);
@@ -5335,8 +5335,9 @@ static int sla_ring_station(struct sla_ringing_trunk *ringing_trunk, struct sla_
char *tech, *tech_data;
struct ast_dial *dial;
struct sla_ringing_station *ringing_station;
- const char *cid_name = NULL, *cid_num = NULL;
enum ast_dial_result res;
+ int caller_is_saved;
+ struct ast_party_caller caller;
if (!(dial = ast_dial_create()))
return -1;
@@ -5350,23 +5351,21 @@ static int sla_ring_station(struct sla_ringing_trunk *ringing_trunk, struct sla_
return -1;
}
- if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_name)) {
- cid_name = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_name);
- ast_free(ringing_trunk->trunk->chan->cid.cid_name);
- ringing_trunk->trunk->chan->cid.cid_name = NULL;
- }
- if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_num)) {
- cid_num = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_num);
- ast_free(ringing_trunk->trunk->chan->cid.cid_num);
- ringing_trunk->trunk->chan->cid.cid_num = NULL;
+ /* Do we need to save off the caller ID data? */
+ caller_is_saved = 0;
+ if (!sla.attempt_callerid) {
+ caller_is_saved = 1;
+ caller = ringing_trunk->trunk->chan->caller;
+ ast_party_caller_init(&ringing_trunk->trunk->chan->caller);
}
res = ast_dial_run(dial, ringing_trunk->trunk->chan, 1);
- if (cid_name)
- ringing_trunk->trunk->chan->cid.cid_name = ast_strdup(cid_name);
- if (cid_num)
- ringing_trunk->trunk->chan->cid.cid_num = ast_strdup(cid_num);
+ /* Restore saved caller ID */
+ if (caller_is_saved) {
+ ast_party_caller_free(&ringing_trunk->trunk->chan->caller);
+ ringing_trunk->trunk->chan->caller = caller;
+ }
if (res != AST_DIAL_RESULT_TRYING) {
struct sla_failed_station *failed_station;
@@ -5884,7 +5883,8 @@ static void *dial_trunk(void *data)
struct ast_conference *conf;
struct ast_flags64 conf_flags = { 0 };
struct sla_trunk_ref *trunk_ref = args->trunk_ref;
- const char *cid_name = NULL, *cid_num = NULL;
+ int caller_is_saved;
+ struct ast_party_caller caller;
if (!(dial = ast_dial_create())) {
ast_mutex_lock(args->cond_lock);
@@ -5903,23 +5903,21 @@ static void *dial_trunk(void *data)
return NULL;
}
- if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_name)) {
- cid_name = ast_strdupa(trunk_ref->chan->cid.cid_name);
- ast_free(trunk_ref->chan->cid.cid_name);
- trunk_ref->chan->cid.cid_name = NULL;
- }
- if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_num)) {
- cid_num = ast_strdupa(trunk_ref->chan->cid.cid_num);
- ast_free(trunk_ref->chan->cid.cid_num);
- trunk_ref->chan->cid.cid_num = NULL;
+ /* Do we need to save of the caller ID data? */
+ caller_is_saved = 0;
+ if (!sla.attempt_callerid) {
+ caller_is_saved = 1;
+ caller = trunk_ref->chan->caller;
+ ast_party_caller_init(&trunk_ref->chan->caller);
}
dial_res = ast_dial_run(dial, trunk_ref->chan, 1);
- if (cid_name)
- trunk_ref->chan->cid.cid_name = ast_strdup(cid_name);
- if (cid_num)
- trunk_ref->chan->cid.cid_num = ast_strdup(cid_num);
+ /* Restore saved caller ID */
+ if (caller_is_saved) {
+ ast_party_caller_free(&trunk_ref->chan->caller);
+ trunk_ref->chan->caller = caller;
+ }
if (dial_res != AST_DIAL_RESULT_TRYING) {
ast_mutex_lock(args->cond_lock);
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index b2ab3b82c..55373698c 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1731,7 +1731,10 @@ static void run_externnotify(struct ast_channel *chan, struct minivm_account *vm
snprintf(arguments, sizeof(arguments), "%s %s@%s %s %s&",
ast_strlen_zero(vmu->externnotify) ? global_externnotify : vmu->externnotify,
vmu->username, vmu->domain,
- chan->cid.cid_name, chan->cid.cid_num);
+ (chan->caller.id.name.valid && chan->caller.id.name.str)
+ ? chan->caller.id.name.str : "",
+ (chan->caller.id.number.valid && chan->caller.id.number.str)
+ ? chan->caller.id.number.str : "");
ast_debug(1, "Executing: %s\n", arguments);
ast_safe_system(arguments);
@@ -1917,6 +1920,10 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
ast_localtime(&now, &tm, NULL);
ast_strftime(timebuf, sizeof(timebuf), "%H:%M:%S", &tm);
+ ast_callerid_merge(callerid, sizeof(callerid),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ "Unknown");
snprintf(logbuf, sizeof(logbuf),
/* "Mailbox:domain:macrocontext:exten:priority:callerchan:callerid:origdate:origtime:duration:durationstatus:accountcode" */
"%s:%s:%s:%s:%d:%s:%s:%s:%s:%d:%s:%s\n",
@@ -1926,7 +1933,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
chan->exten,
chan->priority,
chan->name,
- ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"),
+ callerid,
date,
timebuf,
duration,
@@ -2118,7 +2125,10 @@ static int minivm_notify_exec(struct ast_channel *chan, const char *data)
duration_string = ast_strdupa(duration_string);
}
ast_channel_unlock(chan);
- res = notify_new_message(chan, template, vmu, filename, atoi(duration_string), format, chan->cid.cid_num, chan->cid.cid_name);
+ res = notify_new_message(chan, template, vmu, filename, atoi(duration_string),
+ format,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL));
}
pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", res == 0 ? "SUCCESS" : "FAILED");
@@ -2279,26 +2289,35 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
/* Check current or macro-calling context for special extensions */
if (ast_test_flag(vmu, MVM_OPERATOR)) {
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, vmu->exit, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->cid.cid_num)) {
+ } else if (ast_exists_extension(chan, chan->context, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num)) {
+ else if (!ast_strlen_zero(chan->macrocontext)
+ && ast_exists_extension(chan, chan->macrocontext, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ousemacro = 1;
}
}
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num))
+ if (ast_exists_extension(chan, vmu->exit, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num))
+ }
+ } else if (ast_exists_extension(chan, chan->context, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
+ } else if (!ast_strlen_zero(chan->macrocontext)
+ && ast_exists_extension(chan, chan->macrocontext, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
}
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 2ebea0cdf..ea20cee77 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -2257,7 +2257,10 @@ static int ospauth_exec(
ast_debug(1, "OSPAuth: source '%s'\n", source);
ast_debug(1, "OSPAuth: token size '%zd'\n", strlen(token));
- if ((res = osp_auth(provider, &handle, source, chan->cid.cid_num, chan->exten, token, &timelimit)) > 0) {
+ res = osp_auth(provider, &handle, source,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ chan->exten, token, &timelimit);
+ if (res > 0) {
status = AST_OSP_SUCCESS;
} else {
timelimit = OSP_DEF_TIMELIMIT;
@@ -2453,7 +2456,10 @@ static int osplookup_exec(
return OSP_AST_ERROR;
}
- if ((res = osp_lookup(provider, callidtypes, actualsrc, srcdev, chan->cid.cid_num, args.exten, snetid, &np, &div, cinfo, &results)) > 0) {
+ res = osp_lookup(provider, callidtypes, actualsrc, srcdev,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ args.exten, snetid, &np, &div, cinfo, &results);
+ if (res > 0) {
status = AST_OSP_SUCCESS;
} else {
results.tech[0] = '\0';
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index 4ae525101..5bb8b6594 100644
--- a/apps/app_parkandannounce.c
+++ b/apps/app_parkandannounce.c
@@ -126,10 +126,13 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
ast_parseable_goto(chan, args.return_context);
}
- ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n", chan->context, chan->exten, chan->priority, chan->cid.cid_num);
- if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+ ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n", chan->context, chan->exten,
+ chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
+ if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
- }
+ }
/* we are using masq_park here to protect * from touching the channel once we park it. If the channel comes out of timeout
before we are done announcing and the channel is messed with, Kablooeee. So we use Masq to prevent this. */
@@ -145,8 +148,11 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
snprintf(buf, sizeof(buf), "%d", lot);
oh.parent_channel = chan;
oh.vars = ast_variable_new("_PARKEDAT", buf, "");
- dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
-
+ dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000,
+ &outstate,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ &oh);
if (dchan) {
if (dchan->_state == AST_STATE_UP) {
ast_verb(4, "Channel %s was answered.\n", dchan->name);
diff --git a/apps/app_privacy.c b/apps/app_privacy.c
index e0c102d74..4b8f61c3f 100644
--- a/apps/app_privacy.c
+++ b/apps/app_privacy.c
@@ -96,8 +96,9 @@ static int privacy_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(checkcontext);
);
- if (!ast_strlen_zero(chan->cid.cid_num)) {
- ast_verb(3, "CallerID Present: Skipping\n");
+ if (chan->caller.id.number.valid
+ && !ast_strlen_zero(chan->caller.id.number.str)) {
+ ast_verb(3, "CallerID number present: Skipping\n");
} else {
/*Answer the channel if it is not already*/
if (chan->_state != AST_STATE_UP) {
@@ -181,14 +182,19 @@ static int privacy_exec(struct ast_channel *chan, const char *data)
res = ast_waitstream(chan, "");
}
- ast_set_callerid(chan, phone, "Privacy Manager", NULL);
-
- /* Clear the unavailable presence bit so if it came in on PRI
- * the caller id will now be passed out to other channels
+ /*
+ * This is a caller entered number that is going to be used locally.
+ * Therefore, the given number presentation is allowed and should
+ * be passed out to other channels. This is the point of the
+ * privacy application.
*/
- chan->cid.cid_pres &= (AST_PRES_UNAVAILABLE ^ 0xFF);
+ chan->caller.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
+ chan->caller.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
+ chan->caller.id.number.plan = 0;/* Unknown */
+
+ ast_set_callerid(chan, phone, "Privacy Manager", NULL);
- ast_verb(3, "Changed Caller*ID to '%s', callerpres to %d\n", phone, chan->cid.cid_pres);
+ ast_verb(3, "Changed Caller*ID number to '%s'\n", phone);
pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS");
} else {
diff --git a/apps/app_queue.c b/apps/app_queue.c
index e91e13a06..11de4d903 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2334,8 +2334,8 @@ static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *
ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Join",
"Channel: %s\r\nCallerIDNum: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n",
qe->chan->name,
- S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */
- S_OR(qe->chan->cid.cid_name, "unknown"),
+ S_COR(qe->chan->caller.id.number.valid, qe->chan->caller.id.number.str, "unknown"),/* XXX somewhere else it is <unknown> */
+ S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
q->name, qe->pos, q->count, qe->chan->uniqueid );
ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
}
@@ -2391,7 +2391,8 @@ static int valid_exit(struct queue_ent *qe, char digit)
return 0;
/* If the extension is bad, then reset the digits to blank */
- if (!ast_canmatch_extension(qe->chan, qe->context, qe->digits, 1, qe->chan->cid.cid_num)) {
+ if (!ast_canmatch_extension(qe->chan, qe->context, qe->digits, 1,
+ S_COR(qe->chan->caller.id.number.valid, qe->chan->caller.id.number.str, NULL))) {
qe->digits[0] = '\0';
return 0;
}
@@ -2893,12 +2894,16 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
memset(&tmp->chan->whentohangup, 0, sizeof(tmp->chan->whentohangup));
/* If the new channel has no callerid, try to guess what it should be */
- if (ast_strlen_zero(tmp->chan->cid.cid_num)) {
- if (!ast_strlen_zero(qe->chan->connected.id.number)) {
- ast_set_callerid(tmp->chan, qe->chan->connected.id.number, qe->chan->connected.id.name, qe->chan->connected.ani);
- tmp->chan->cid.cid_pres = qe->chan->connected.id.number_presentation;
- } else if (!ast_strlen_zero(qe->chan->cid.cid_dnid)) {
- ast_set_callerid(tmp->chan, qe->chan->cid.cid_dnid, NULL, NULL);
+ if (!tmp->chan->caller.id.number.valid) {
+ if (qe->chan->connected.id.number.valid) {
+ struct ast_party_caller caller;
+
+ ast_party_caller_set_init(&caller, &tmp->chan->caller);
+ caller.id = qe->chan->connected.id;
+ caller.ani = qe->chan->connected.ani;
+ ast_channel_set_caller_event(tmp->chan, &caller, NULL);
+ } else if (!ast_strlen_zero(qe->chan->dialed.number.str)) {
+ ast_set_callerid(tmp->chan, qe->chan->dialed.number.str, NULL, NULL);
} else if (!ast_strlen_zero(S_OR(qe->chan->macroexten, qe->chan->exten))) {
ast_set_callerid(tmp->chan, S_OR(qe->chan->macroexten, qe->chan->exten), NULL, NULL);
}
@@ -2907,9 +2912,9 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
ast_party_redirecting_copy(&tmp->chan->redirecting, &qe->chan->redirecting);
- tmp->chan->cid.cid_tns = qe->chan->cid.cid_tns;
+ tmp->chan->dialed.transit_network_select = qe->chan->dialed.transit_network_select;
- ast_connected_line_copy_from_caller(&tmp->chan->connected, &qe->chan->cid);
+ ast_connected_line_copy_from_caller(&tmp->chan->connected, &qe->chan->caller);
/* Inherit specially named variables from parent channel */
ast_channel_inherit_variables(qe->chan, tmp->chan);
@@ -2957,23 +2962,23 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
char vars[2048];
manager_event(EVENT_FLAG_AGENT, "AgentCalled",
- "Queue: %s\r\n"
- "AgentCalled: %s\r\n"
- "AgentName: %s\r\n"
- "ChannelCalling: %s\r\n"
- "DestinationChannel: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n"
- "Uniqueid: %s\r\n"
- "%s",
- qe->parent->name, tmp->interface, tmp->member->membername, qe->chan->name, tmp->chan->name,
- tmp->chan->cid.cid_num ? tmp->chan->cid.cid_num : "unknown",
- tmp->chan->cid.cid_name ? tmp->chan->cid.cid_name : "unknown",
- qe->chan->context, qe->chan->exten, qe->chan->priority, qe->chan->uniqueid,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
+ "Queue: %s\r\n"
+ "AgentCalled: %s\r\n"
+ "AgentName: %s\r\n"
+ "ChannelCalling: %s\r\n"
+ "DestinationChannel: %s\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Context: %s\r\n"
+ "Extension: %s\r\n"
+ "Priority: %d\r\n"
+ "Uniqueid: %s\r\n"
+ "%s",
+ qe->parent->name, tmp->interface, tmp->member->membername, qe->chan->name, tmp->chan->name,
+ S_COR(tmp->chan->caller.id.number.valid, tmp->chan->caller.id.number.str, "unknown"),
+ S_COR(tmp->chan->caller.id.name.valid, tmp->chan->caller.id.name.str, "unknown"),
+ qe->chan->context, qe->chan->exten, qe->chan->priority, qe->chan->uniqueid,
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
ast_verb(3, "Called %s\n", tmp->interface);
}
ast_channel_unlock(tmp->chan);
@@ -3332,14 +3337,14 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
if (update_connectedline) {
if (o->pending_connected_update) {
if (ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) {
- ast_channel_update_connected_line(in, &o->connected);
+ ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!o->dial_callerid_absent) {
ast_channel_lock(o->chan);
- ast_connected_line_copy_from_caller(&connected_caller, &o->chan->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &o->chan->caller);
ast_channel_unlock(o->chan);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_update_connected_line(in, &connected_caller);
+ ast_channel_update_connected_line(in, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
}
}
@@ -3400,20 +3405,23 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_string_field_set(o->chan, accountcode, in->accountcode);
- ast_channel_set_redirecting(o->chan, &original->redirecting);
- if (ast_strlen_zero(o->chan->redirecting.from.number)) {
+ ast_channel_set_redirecting(o->chan, &original->redirecting, NULL);
+ if (!o->chan->redirecting.from.number.valid
+ || ast_strlen_zero(o->chan->redirecting.from.number.str)) {
/*
* The call was not previously redirected so it is
* now redirected from this number.
*/
- ast_free(o->chan->redirecting.from.number);
- o->chan->redirecting.from.number =
+ ast_party_number_free(&o->chan->redirecting.from.number);
+ ast_party_number_init(&o->chan->redirecting.from.number);
+ o->chan->redirecting.from.number.valid = 1;
+ o->chan->redirecting.from.number.str =
ast_strdup(S_OR(in->macroexten, in->exten));
}
- o->chan->cid.cid_tns = in->cid.cid_tns;
+ o->chan->dialed.transit_network_select = in->dialed.transit_network_select;
- ast_party_caller_copy(&o->chan->cid, &in->cid);
+ ast_party_caller_copy(&o->chan->caller, &in->caller);
ast_party_connected_line_copy(&o->chan->connected, &original->connected);
/*
@@ -3429,7 +3437,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
CHANNEL_DEADLOCK_AVOIDANCE(in);
}
if (res) {
- ast_channel_update_redirecting(in, &o->chan->redirecting);
+ ast_channel_update_redirecting(in, &o->chan->redirecting, NULL);
}
update_connectedline = 1;
@@ -3459,14 +3467,14 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
if (update_connectedline) {
if (o->pending_connected_update) {
if (ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) {
- ast_channel_update_connected_line(in, &o->connected);
+ ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!o->dial_callerid_absent) {
ast_channel_lock(o->chan);
- ast_connected_line_copy_from_caller(&connected_caller, &o->chan->cid);
+ ast_connected_line_copy_from_caller(&connected_caller, &o->chan->caller);
ast_channel_unlock(o->chan);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_update_connected_line(in, &connected_caller);
+ ast_channel_update_connected_line(in, &connected_caller, NULL);
ast_party_connected_line_free(&connected_caller);
}
}
@@ -3538,7 +3546,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n", ochan_name, inchan_name);
ast_party_connected_line_set_init(&connected, &o->connected);
ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected);
- ast_party_connected_line_set(&o->connected, &connected);
+ ast_party_connected_line_set(&o->connected, &connected, NULL);
ast_party_connected_line_free(&connected);
o->pending_connected_update = 1;
} else {
@@ -5706,8 +5714,10 @@ static int queue_exec(struct ast_channel *chan, const char *data)
set_queue_result(chan, reason);
return 0;
}
- ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s|%d", S_OR(args.url, ""),
- S_OR(chan->cid.cid_num, ""), qe.opos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s|%d",
+ S_OR(args.url, ""),
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
+ qe.opos);
copy_rules(&qe, args.rule);
qe.pr = AST_LIST_FIRST(&qe.qe_rules);
check_turns:
@@ -7017,8 +7027,8 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
"%s"
"\r\n",
q->name, pos++, qe->chan->name, qe->chan->uniqueid,
- S_OR(qe->chan->cid.cid_num, "unknown"),
- S_OR(qe->chan->cid.cid_name, "unknown"),
+ S_COR(qe->chan->caller.id.number.valid, qe->chan->caller.id.number.str, "unknown"),
+ S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
(long) (now - qe->start), idText);
}
}
diff --git a/apps/app_readexten.c b/apps/app_readexten.c
index f8f4a1bfc..8049fc949 100644
--- a/apps/app_readexten.c
+++ b/apps/app_readexten.c
@@ -240,8 +240,11 @@ static int readexten_exec(struct ast_channel *chan, const char *data)
}
exten[x] = res;
- if (!ast_matchmore_extension(chan, arglist.context, exten, 1 /* priority */, chan->cid.cid_num)) {
- if (!ast_exists_extension(chan, arglist.context, exten, 1, chan->cid.cid_num) && res == '#') {
+ if (!ast_matchmore_extension(chan, arglist.context, exten, 1 /* priority */,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
+ if (!ast_exists_extension(chan, arglist.context, exten, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
+ && res == '#') {
exten[x] = '\0';
}
break;
@@ -251,7 +254,8 @@ static int readexten_exec(struct ast_channel *chan, const char *data)
if (!ast_strlen_zero(status))
break;
- if (ast_exists_extension(chan, arglist.context, exten, 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, arglist.context, exten, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_debug(3, "User entered valid extension '%s'\n", exten);
pbx_builtin_setvar_helper(chan, arglist.variable, exten);
status = "OK";
@@ -296,10 +300,12 @@ static int acf_isexten_exec(struct ast_channel *chan, const char *cmd, char *par
else
priority_int = atoi(args.priority);
- if (ast_exists_extension(chan, args.context, args.extension, priority_int, chan->cid.cid_num))
+ if (ast_exists_extension(chan, args.context, args.extension, priority_int,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_copy_string(buffer, "1", buflen);
- else
+ } else {
ast_copy_string(buffer, "0", buflen);
+ }
return 0;
}
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index a6be0e19f..a4d350d32 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -5454,14 +5454,14 @@ struct ast_channel *mychannel,*genchannel;
if(instr){
ast_callerid_parse(instr, &name, &loc);
if(loc){
- if(mychannel->cid.cid_num)
- ast_free(mychannel->cid.cid_num);
- mychannel->cid.cid_num = ast_strdup(loc);
+ mychannel->caller.id.number.valid = 1;
+ ast_free(mychannel->caller.id.number.str);
+ mychannel->caller.id.number.str = ast_strdup(loc);
}
if(name){
- if(mychannel->cid.cid_name)
- ast_free(mychannel->cid.cid_name);
- mychannel->cid.cid_name = ast_strdup(name);
+ mychannel->caller.id.name.valid = 1;
+ ast_free(mychannel->caller.id.name.str);
+ mychannel->caller.id.name.str = ast_strdup(name);
}
ast_free(instr);
}
@@ -5808,9 +5808,9 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
if (debug > 3)
ast_log(LOG_NOTICE, "rpt (remote) initiating call to %s/%s on %s\n",
deststr, tele, l->chan->name);
- if(l->chan->cid.cid_num)
- ast_free(l->chan->cid.cid_num);
- l->chan->cid.cid_num = ast_strdup(myrpt->name);
+ l->chan->caller.id.number.valid = 1;
+ ast_free(l->chan->caller.id.number.str);
+ l->chan->caller.id.number.str = ast_strdup(myrpt->name);
ast_call(l->chan,tele,999);
}
else {
@@ -10388,9 +10388,9 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
deststr, tele, l->chan->name);
- if(l->chan->cid.cid_num)
- ast_free(l->chan->cid.cid_num);
- l->chan->cid.cid_num = ast_strdup(myrpt->name);
+ l->chan->caller.id.number.valid = 1;
+ ast_free(l->chan->caller.id.number.str);
+ l->chan->caller.id.number.str = ast_strdup(myrpt->name);
ast_call(l->chan,tele,999);
}
@@ -13412,8 +13412,11 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
}
if(option_verbose > 2) {
- ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->cid.cid_num);
- if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+ ast_verbose(VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n",
+ chan->context, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
+ if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
}
}
@@ -13443,7 +13446,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
char hisip[100],nodeip[100],*val, *s, *s1, *s2, *s3, *b,*b1;
/* look at callerid to see what node this comes from */
- if (!chan->cid.cid_num) /* if doesn't have caller id */
+ b = S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
+ if (!b) /* if doesn't have caller id */
{
ast_log(LOG_WARNING, "Does not have callerid on %s\n",tmp);
return -1;
@@ -13467,7 +13471,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
return -1;
}
- ast_callerid_parse(chan->cid.cid_num,&b,&b1);
+ b1 = ast_strdupa(b);
ast_shrink_phone_number(b1);
if (!strcmp(myrpt->name,b1))
{
@@ -13564,13 +13568,14 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
return -1;
}
/* look at callerid to see what node this comes from */
- if (!chan->cid.cid_num) /* if doesn't have caller id */
+ b = S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
+ if (!b) /* if doesn't have caller id */
{
ast_log(LOG_WARNING, "Doesnt have callerid on %s\n",tmp);
return -1;
}
- ast_callerid_parse(chan->cid.cid_num,&b,&b1);
+ b1 = ast_strdupa(b);
ast_shrink_phone_number(b1);
if (!strcmp(myrpt->name,b1))
{
@@ -14036,11 +14041,12 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
ast_cli_command(nullfd,mycmd);
} else ast_cli_command(nullfd,mycmd);
/* look at callerid to see what node this comes from */
- if (!chan->cid.cid_num) /* if doesn't have caller id */
+ b = S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
+ if (!b) /* if doesn't have caller id */
{
b1 = "0";
} else {
- ast_callerid_parse(chan->cid.cid_num,&b,&b1);
+ b1 = ast_strdupa(b);
ast_shrink_phone_number(b1);
}
sprintf(mycmd,"CONNECT,%s",b1);
@@ -14546,11 +14552,12 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
char mycmd[100],*b,*b1;
/* look at callerid to see what node this comes from */
- if (!chan->cid.cid_num) /* if doesn't have caller id */
+ b = S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
+ if (!b) /* if doesn't have caller id */
{
b1 = "0";
} else {
- ast_callerid_parse(chan->cid.cid_num,&b,&b1);
+ b1 = ast_strdupa(b);
ast_shrink_phone_number(b1);
}
sprintf(mycmd,"DISCONNECT,%s",b1);
diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c
index 0e2ce485d..666e46ff4 100644
--- a/apps/app_setcallerid.c
+++ b/apps/app_setcallerid.c
@@ -105,7 +105,9 @@ static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
return 0;
}
- chan->cid.cid_pres = pres;
+ /* Set the combined caller id presentation. */
+ chan->caller.id.name.presentation = pres;
+ chan->caller.id.number.presentation = pres;
return 0;
}
diff --git a/apps/app_sms.c b/apps/app_sms.c
index 6a2b0c03f..aee2fa6c5 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1890,8 +1890,9 @@ static int sms_exec(struct ast_channel *chan, const char *data)
h.ipc0 = h.ipc1 = 20; /* phase for cosine */
h.dcs = 0xF1; /* default */
- if (chan->cid.cid_num)
- ast_copy_string(h.cli, chan->cid.cid_num, sizeof(h.cli));
+ ast_copy_string(h.cli,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
+ sizeof(h.cli));
if (ast_strlen_zero(sms_args.queue)) {
ast_log(LOG_ERROR, "Requires queue name\n");
diff --git a/apps/app_stack.c b/apps/app_stack.c
index ebca99490..dcf13a00d 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -413,7 +413,9 @@ static int gosub_exec(struct ast_channel *chan, const char *data)
return -1;
}
- if (!ast_exists_extension(chan, chan->context, chan->exten, ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority, chan->cid.cid_num)) {
+ if (!ast_exists_extension(chan, chan->context, chan->exten,
+ ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n",
chan->context, chan->exten, ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority);
ast_copy_string(chan->context, newframe->context, sizeof(chan->context));
@@ -588,12 +590,15 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
if (sscanf(argv[3], "%30d", &priority) != 1 || priority < 1) {
/* Lookup the priority label */
- if ((priority = ast_findlabel_extension(chan, argv[1], argv[2], argv[3], chan->cid.cid_num)) < 0) {
+ priority = ast_findlabel_extension(chan, argv[1], argv[2], argv[3],
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
+ if (priority < 0) {
ast_log(LOG_ERROR, "Priority '%s' not found in '%s@%s'\n", argv[3], argv[2], argv[1]);
ast_agi_send(agi->fd, chan, "200 result=-1 Gosub label not found\n");
return RESULT_FAILURE;
}
- } else if (!ast_exists_extension(chan, argv[1], argv[2], priority, chan->cid.cid_num)) {
+ } else if (!ast_exists_extension(chan, argv[1], argv[2], priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_agi_send(agi->fd, chan, "200 result=-1 Gosub label not found\n");
return RESULT_FAILURE;
}
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 0db0012bc..615929e94 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -175,7 +175,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
char t[2];
t[0] = fr->subclass.integer;
t[1] = '\0';
- if (ast_canmatch_extension(chan, chan->context, t, 1, chan->cid.cid_num)) {
+ if (ast_canmatch_extension(chan, chan->context, t, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
/* They entered a valid extension, or might be anyhow */
res = fr->subclass.integer;
ast_frfree(fr);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 6e2cc2a45..32c176019 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2203,7 +2203,10 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
imap_delete_old_greeting(fn, vms);
}
- make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, "INBOX", S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, introfn, fmt, duration, 1, chan, NULL, 1, flag);
+ make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, "INBOX",
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ fn, introfn, fmt, duration, 1, chan, NULL, 1, flag);
/* read mail file to memory */
len = ftell(p);
rewind(p);
@@ -5185,7 +5188,10 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i
res = -1;
}
ast_unlock_path(todir);
- notify_new_message(chan, recip, NULL, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag);
+ notify_new_message(chan, recip, NULL, recipmsgnum, duration, fmt,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ flag);
return res;
}
@@ -5513,25 +5519,34 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
/* Check current or macro-calling context for special extensions */
if (ast_test_flag(vmu, VM_OPERATOR)) {
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, vmu->exit, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->cid.cid_num)) {
+ } else if (ast_exists_extension(chan, chan->context, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
- } else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num)) {
+ } else if (!ast_strlen_zero(chan->macrocontext)
+ && ast_exists_extension(chan, chan->macrocontext, "o", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ousemacro = 1;
}
}
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num))
+ if (ast_exists_extension(chan, vmu->exit, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num))
+ }
+ } else if (ast_exists_extension(chan, chan->context, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
+ } else if (!ast_strlen_zero(chan->macrocontext)
+ && ast_exists_extension(chan, chan->macrocontext, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
}
@@ -5540,8 +5555,11 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
for (code = alldtmf; *code; code++) {
char e[2] = "";
e[0] = *code;
- if (strchr(ecodes, e[0]) == NULL && ast_canmatch_extension(chan, chan->context, e, 1, chan->cid.cid_num))
+ if (strchr(ecodes, e[0]) == NULL
+ && ast_canmatch_extension(chan, chan->context, e, 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1);
+ }
}
}
@@ -5721,13 +5739,33 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
snprintf(priority, sizeof(priority), "%d", chan->priority);
snprintf(origtime, sizeof(origtime), "%ld", (long) time(NULL));
get_date(date, sizeof(date));
- ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category, ""), "filename", tmptxtfile, SENTINEL);
+ ast_callerid_merge(callerid, sizeof(callerid),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ "Unknown");
+ ast_store_realtime("voicemail_data",
+ "origmailbox", ext,
+ "context", chan->context,
+ "macrocontext", chan->macrocontext,
+ "exten", chan->exten,
+ "priority", priority,
+ "callerchan", chan->name,
+ "callerid", callerid,
+ "origdate", date,
+ "origtime", origtime,
+ "category", S_OR(category, ""),
+ "filename", tmptxtfile,
+ SENTINEL);
}
/* Store information */
txt = fdopen(txtdes, "w+");
if (txt) {
get_date(date, sizeof(date));
+ ast_callerid_merge(callerid, sizeof(callerid),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ "Unknown");
fprintf(txt,
";\n"
"; Message Information file\n"
@@ -5748,10 +5786,11 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
chan->context,
chan->macrocontext,
chan->exten,
- S_OR(chan->redirecting.from.number, "unknown"),
+ S_COR(chan->redirecting.from.number.valid,
+ chan->redirecting.from.number.str, "unknown"),
chan->priority,
chan->name,
- ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"),
+ callerid,
date, (long) time(NULL),
category ? category : "");
} else {
@@ -5865,9 +5904,15 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
/* Notification needs to happen after the copy, though. */
if (ast_fileexists(fn, NULL, NULL)) {
#ifdef IMAP_STORAGE
- notify_new_message(chan, vmu, vms, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag);
+ notify_new_message(chan, vmu, vms, msgnum, duration, fmt,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ flag);
#else
- notify_new_message(chan, vmu, NULL, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag);
+ notify_new_message(chan, vmu, NULL, msgnum, duration, fmt,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ flag);
#endif
}
@@ -7053,7 +7098,12 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
myserveremail = vmtmp->serveremail;
attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
/* NULL category for IMAP storage */
- sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, dstvms->curbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vmstmp.fn, vmstmp.introfn, fmt, duration, attach_user_voicemail, chan, NULL, urgent_str);
+ sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox,
+ dstvms->curbox,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
+ vmstmp.fn, vmstmp.introfn, fmt, duration, attach_user_voicemail, chan,
+ NULL, urgent_str);
#else
copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir, urgent_str);
#endif
@@ -9376,15 +9426,16 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
return -1;
}
if (ast_strlen_zero(mailbox)) {
- if (chan->cid.cid_num) {
- ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size);
+ if (chan->caller.id.number.valid && chan->caller.id.number.str) {
+ ast_copy_string(mailbox, chan->caller.id.number.str, mailbox_size);
} else {
ast_verb(3, "Username not entered\n");
return -1;
}
} else if (mailbox[0] == '*') {
/* user entered '*' */
- if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, chan->context, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
return -1;
}
mailbox[0] = '\0';
@@ -9415,7 +9466,8 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
return -1;
} else if (password[0] == '*') {
/* user entered '*' */
- if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num)) {
+ if (ast_exists_extension(chan, chan->context, "a", 1,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
mailbox[0] = '*';
return -1;
}
diff --git a/apps/app_while.c b/apps/app_while.c
index e9a503aad..80359359e 100644
--- a/apps/app_while.c
+++ b/apps/app_while.c
@@ -163,7 +163,11 @@ static int find_matching_endwhile(struct ast_channel *chan)
/* This is the matching context we want */
int cur_priority = chan->priority + 1, level=1;
- for (e = find_matching_priority(c, chan->exten, cur_priority, chan->cid.cid_num); e; e = find_matching_priority(c, chan->exten, ++cur_priority, chan->cid.cid_num)) {
+ for (e = find_matching_priority(c, chan->exten, cur_priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
+ e;
+ e = find_matching_priority(c, chan->exten, ++cur_priority,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
if (!strcasecmp(ast_get_extension_app(e), "WHILE")) {
level++;
} else if (!strcasecmp(ast_get_extension_app(e), "ENDWHILE")) {
diff --git a/apps/app_zapateller.c b/apps/app_zapateller.c
index 4be09b59c..6af9b963c 100644
--- a/apps/app_zapateller.c
+++ b/apps/app_zapateller.c
@@ -103,8 +103,12 @@ static int zapateller_exec(struct ast_channel *chan, const char *data)
res = ast_safe_sleep(chan, 500);
}
- if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid)
+ if (nocallerid /* Zap caller if no caller id. */
+ && chan->caller.id.number.valid
+ && !ast_strlen_zero(chan->caller.id.number.str)) {
+ /* We have caller id. */
return res;
+ }
if (!res)
res = ast_tonepair(chan, 950, 0, 330, 0);