ast_callerid restructuring
authorRichard Mudgett <rmudgett@digium.com>
Wed, 14 Jul 2010 15:48:36 +0000 (15:48 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 14 Jul 2010 15:48:36 +0000 (15:48 +0000)
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: https://origsvn.digium.com/svn/asterisk/trunk@276347 65c4cc65-6c06-0410-ace0-fbb531ad65f3

69 files changed:
UPGRADE.txt
addons/chan_ooh323.c
apps/app_alarmreceiver.c
apps/app_amd.c
apps/app_dial.c
apps/app_directed_pickup.c
apps/app_disa.c
apps/app_dumpchan.c
apps/app_fax.c
apps/app_followme.c
apps/app_macro.c
apps/app_meetme.c
apps/app_minivm.c
apps/app_osplookup.c
apps/app_parkandannounce.c
apps/app_privacy.c
apps/app_queue.c
apps/app_readexten.c
apps/app_rpt.c
apps/app_setcallerid.c
apps/app_sms.c
apps/app_stack.c
apps/app_talkdetect.c
apps/app_voicemail.c
apps/app_while.c
apps/app_zapateller.c
channels/chan_agent.c
channels/chan_console.c
channels/chan_dahdi.c
channels/chan_gtalk.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_jingle.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_misdn.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
channels/chan_usbradio.c
channels/chan_vpb.cc
channels/sig_analog.c
channels/sig_analog.h
channels/sig_pri.c
channels/sig_ss7.c
funcs/func_blacklist.c
funcs/func_callerid.c
funcs/func_connectedline.c [deleted file]
funcs/func_dialplan.c
funcs/func_redirecting.c [deleted file]
include/asterisk/callerid.h
include/asterisk/channel.h
main/app.c
main/callerid.c
main/ccss.c
main/cdr.c
main/cel.c
main/channel.c
main/cli.c
main/dial.c
main/features.c
main/file.c
main/manager.c
main/pbx.c
res/res_agi.c
res/snmp/agent.c
tests/test_substitution.c

index ff8d359..1ac0b75 100644 (file)
@@ -82,6 +82,9 @@ From 1.6.2 to 1.8:
   of a Mailbox or Password, will, if it exists, jump to the 'a' extension in
   the current dialplan context.
 
+* The CALLERPRES() dialplan function is deprecated in favor of
+  CALLERID(num-pres) and CALLERID(name-pres).
+
 * Environment variables that start with "AST_" are reserved to the system and
   may no longer be set from the dialplan.
 
index 6b8596c..0375a13 100644 (file)
@@ -922,24 +922,23 @@ static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
        }
        ast_mutex_lock(&p->lock);
        ast_set_flag(p, H323_OUTGOING);
-       if (ast->connected.id.number) {
-               if(p->callerid_num)   free(p->callerid_num);
-               p->callerid_num = strdup(ast->connected.id.number);
-       }
-
-       if (ast->connected.id.name) {
-               if(p->callerid_name)
-                       free(p->callerid_name);
-               p->callerid_name = strdup(ast->connected.id.name);
-       } else if (ast->connected.id.number) {
-               if(p->callerid_name)
-                       free(p->callerid_name);
-               p->callerid_name = strdup(ast->connected.id.number);
+       if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+               free(p->callerid_num);
+               p->callerid_num = strdup(ast->connected.id.number.str);
+       }
+
+       if (ast->connected.id.name.valid && ast->connected.id.name.str) {
+               free(p->callerid_name);
+               p->callerid_name = strdup(ast->connected.id.name.str);
+       } else if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+               free(p->callerid_name);
+               p->callerid_name = strdup(ast->connected.id.number.str);
        } else {
-               ast->connected.id.name = strdup(gCallerID);
-               if(p->callerid_name)
-                       free(p->callerid_name);
-               p->callerid_name = strdup(ast->connected.id.name);
+               ast->connected.id.name.valid = 1;
+               free(ast->connected.id.name.str);
+               ast->connected.id.name.str = strdup(gCallerID);
+               free(p->callerid_name);
+               p->callerid_name = strdup(ast->connected.id.name.str);
        }
 
        /* Retrieve vars */
@@ -1241,13 +1240,15 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
        case AST_CONTROL_SRCCHANGE:
                ast_rtp_instance_change_source(p->rtp);
                break;
-               case AST_CONTROL_CONNECTED_LINE:
-               if (!ast_strlen_zero(ast->connected.id.name)) {
-                       if (gH323Debug)
-                               ast_log(LOG_DEBUG, "Sending connected line info for %s (%s)\n",
-                               callToken, ast->connected.id.name);
-                       ooSetANI(callToken, ast->connected.id.name);
+       case AST_CONTROL_CONNECTED_LINE:
+               if (!ast->connected.id.name.valid
+                       || ast_strlen_zero(ast->connected.id.name.str)) {
+                       break;
                }
+               if (gH323Debug)
+                       ast_log(LOG_DEBUG, "Sending connected line info for %s (%s)\n",
+                               callToken, ast->connected.id.name.str);
+               ooSetANI(callToken, ast->connected.id.name.str);
                break;
 
       case AST_CONTROL_T38_PARAMETERS:
@@ -1539,10 +1540,15 @@ int onAlerting(ooCallData *call)
 
        if (call->remoteDisplayName) {
                struct ast_party_connected_line connected;
+               struct ast_set_party_connected_line update_connected;
+
+               memset(&update_connected, 0, sizeof(update_connected));
+               update_connected.id.name = 1;
                ast_party_connected_line_init(&connected);
-               connected.id.name = (char *) call->remoteDisplayName;
+               connected.id.name.valid = 1;
+               connected.id.name.str = (char *) call->remoteDisplayName;
                connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-               ast_channel_queue_connected_line_update(c, &connected);
+               ast_channel_queue_connected_line_update(c, &connected, &update_connected);
        }
        if (c->_state != AST_STATE_UP)
                ast_setstate(c, AST_STATE_RINGING);
@@ -1590,10 +1596,15 @@ int onProgress(ooCallData *call)
 
        if (call->remoteDisplayName) {
                struct ast_party_connected_line connected;
+               struct ast_set_party_connected_line update_connected;
+
+               memset(&update_connected, 0, sizeof(update_connected));
+               update_connected.id.name = 1;
                ast_party_connected_line_init(&connected);
-               connected.id.name = (char *) call->remoteDisplayName;
+               connected.id.name.valid = 1;
+               connected.id.name.str = (char *) call->remoteDisplayName;
                connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-               ast_channel_queue_connected_line_update(c, &connected);
+               ast_channel_queue_connected_line_update(c, &connected, &update_connected);
        }
        if (c->_state != AST_STATE_UP)
                ast_setstate(c, AST_STATE_RINGING);
@@ -1983,10 +1994,15 @@ int onCallEstablished(ooCallData *call)
 
                        if (call->remoteDisplayName) {
                                struct ast_party_connected_line connected;
+                               struct ast_set_party_connected_line update_connected;
+
+                               memset(&update_connected, 0, sizeof(update_connected));
+                               update_connected.id.name = 1;
                                ast_party_connected_line_init(&connected);
-                               connected.id.name = (char *) call->remoteDisplayName;
+                               connected.id.name.valid = 1;
+                               connected.id.name.str = (char *) call->remoteDisplayName;
                                connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-                               ast_channel_queue_connected_line_update(c, &connected);
+                               ast_channel_queue_connected_line_update(c, &connected, &update_connected);
                        }
 
                        ast_queue_control(c, AST_CONTROL_ANSWER);
index 22dd4af..952ef72 100644 (file)
@@ -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;
 }
index 928afee..f4eb784 100644 (file)
@@ -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)) {
index 31e64ce..52ca6bd 100644 (file)
@@ -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. */
index cb8505b..bcefb06 100644 (file)
@@ -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))) {
index a64d053..20c9ce4 100644 (file)
@@ -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)) {
index d66661d..feaeda2 100644 (file)
@@ -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),
index 9b1972d..54d22db 100644 (file)
@@ -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 === */
index b6ad767..fcab992 100644 (file)
@@ -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);
index f3ff81d..e5ab2bc 100644 (file)
@@ -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;
                                        }
                                }
index b0b26ae..5ef9718 100644 (file)
@@ -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);
index b2ab3b8..5537369 100644 (file)
@@ -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;
        }
index 2ebea0c..ea20cee 100644 (file)
@@ -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';
index 4ae5251..5bb8b65 100644 (file)
@@ -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);
index e0c102d..4b8f61c 100644 (file)
@@ -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 {
index e91e13a..11de4d9 100644 (file)
@@ -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);
                        }
                }
index f8f4a1b..8049fc9 100644 (file)
@@ -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;
 }
index a6be0e1..a4d350d 100644 (file)
@@ -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);
index 0e2ce48..666e46f 100644 (file)
@@ -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;
 }
 
index 6a2b0c0..aee2fa6 100644 (file)
@@ -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");
index ebca994..dcf13a0 100644 (file)
@@ -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;
        }
index 0db0012..615929e 100644 (file)
@@ -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);
index 6e2cc2a..32c1760 100644 (file)
@@ -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;
                                }
index e9a503a..8035935 100644 (file)
@@ -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")) {
index 4be09b5..6af9b96 100644 (file)
@@ -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);
index dfbf228..c129005 100644 (file)
@@ -1510,16 +1510,17 @@ static int action_agents(struct mansession *s, const struct message *m)
                if (p->chan) {
                        loginChan = ast_strdupa(p->chan->name);
                        if (p->owner && p->owner->_bridge) {
-                               talkingto = p->chan->cid.cid_num;
+                               talkingto = S_COR(p->chan->caller.id.number.valid,
+                                       p->chan->caller.id.number.str, "n/a");
                                if (ast_bridged_channel(p->owner))
                                        talkingtoChan = ast_strdupa(ast_bridged_channel(p->owner)->name);
                                else
                                        talkingtoChan = "n/a";
-                               status = "AGENT_ONCALL";
+                               status = "AGENT_ONCALL";
                        } else {
                                talkingto = "n/a";
                                talkingtoChan = "n/a";
-                               status = "AGENT_IDLE";
+                               status = "AGENT_IDLE";
                        }
                } else {
                        loginChan = "n/a";
@@ -2169,10 +2170,12 @@ static int agentmonitoroutgoing_exec(struct ast_channel *chan, const char *data)
                if (strchr(data, 'c'))
                        changeoutgoing = 1;
        }
-       if (chan->cid.cid_num) {
+       if (chan->caller.id.number.valid
+               && !ast_strlen_zero(chan->caller.id.number.str)) {
                const char *tmp;
                char agentvar[AST_MAX_BUF];
-               snprintf(agentvar, sizeof(agentvar), "%s_%s", GETAGENTBYCALLERID, chan->cid.cid_num);
+               snprintf(agentvar, sizeof(agentvar), "%s_%s", GETAGENTBYCALLERID,
+                       chan->caller.id.number.str);
                if ((tmp = pbx_builtin_getvar_helper(NULL, agentvar))) {
                        struct agent_pvt *p;
                        ast_copy_string(agent, tmp, sizeof(agent));
index 9d68e9f..99b673b 100644 (file)
@@ -566,7 +566,9 @@ static int console_call(struct ast_channel *c, char *dest, int timeout)
        enum ast_control_frame_type ctrl;
 
        ast_verb(1, V_BEGIN "Call to device '%s' on console from '%s' <%s>" V_END,
-               dest, c->cid.cid_name, c->cid.cid_num);
+               dest,
+               S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
+               S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""));
 
        console_pvt_lock(pvt);
 
index e035b4b..e807b95 100644 (file)
@@ -1887,7 +1887,7 @@ static int my_callwait(void *pvt)
        return 0;
 }
 
-static int my_send_callerid(void *pvt, int cwcid, struct ast_callerid *cid)
+static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *caller)
 {
        struct dahdi_pvt *p = pvt;
 
@@ -1900,11 +1900,17 @@ static int my_send_callerid(void *pvt, int cwcid, struct ast_callerid *cid)
 
        if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) {
                if (cwcid == 0) {
-                       p->cidlen = ast_callerid_generate(p->cidspill, cid->cid_name, cid->cid_num, AST_LAW(p));
+                       p->cidlen = ast_callerid_generate(p->cidspill,
+                               caller->id.name.str,
+                               caller->id.number.str,
+                               AST_LAW(p));
                } else {
                        p->callwaitcas = 0;
                        p->cidcwexpire = 0;
-                       p->cidlen = ast_callerid_callwaiting_generate(p->cidspill, cid->cid_name, cid->cid_num, AST_LAW(p));
+                       p->cidlen = ast_callerid_callwaiting_generate(p->cidspill,
+                               caller->id.name.str,
+                               caller->id.number.str,
+                               AST_LAW(p));
                        p->cidlen += READ_SIZE * 4;
                }
                p->cidpos = 0;
@@ -2015,7 +2021,8 @@ static void my_handle_dtmfup(void *pvt, struct ast_channel *ast, enum analog_sub
                                 */
                                ast_mutex_unlock(&p->lock);
                                ast_channel_unlock(ast);
-                               if (ast_exists_extension(ast, target_context, "fax", 1, ast->cid.cid_num)) {
+                               if (ast_exists_extension(ast, target_context, "fax", 1,
+                                       S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
                                        ast_channel_lock(ast);
                                        ast_mutex_lock(&p->lock);
                                        ast_verb(3, "Redirecting %s to fax extension\n", ast->name);
@@ -2910,16 +2917,20 @@ static void my_set_callerid(void *pvt, const struct ast_party_caller *caller)
 {
        struct dahdi_pvt *p = pvt;
 
-       ast_copy_string(p->cid_num, S_OR(caller->id.number, ""), sizeof(p->cid_num));
-       ast_copy_string(p->cid_name, S_OR(caller->id.name, ""), sizeof(p->cid_name));
+       ast_copy_string(p->cid_num,
+               S_COR(caller->id.number.valid, caller->id.number.str, ""),
+               sizeof(p->cid_num));
+       ast_copy_string(p->cid_name,
+               S_COR(caller->id.name.valid, caller->id.name.str, ""),
+               sizeof(p->cid_name));
        if (caller->id.subaddress.valid) {
                ast_copy_string(p->cid_subaddr, S_OR(caller->id.subaddress.str, ""),
                        sizeof(p->cid_subaddr));
        } else {
                p->cid_subaddr[0] = '\0';
        }
-       p->cid_ton = caller->id.number_type;
-       p->callingpres = caller->id.number_presentation;
+       p->cid_ton = caller->id.number.plan;
+       p->callingpres = ast_party_id_presentation(&caller->id);
        if (caller->id.tag) {
                ast_copy_string(p->cid_tag, caller->id.tag, sizeof(p->cid_tag));
        }
@@ -5137,7 +5148,7 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
                        c = "";
                }
                if (!p->hidecallerid) {
-                       l = ast->cid.cid_num;
+                       l = ast->caller.id.number.valid ? ast->caller.id.number.str : NULL;
                } else {
                        l = NULL;
                }
@@ -7386,7 +7397,8 @@ static void dahdi_handle_dtmfup(struct ast_channel *ast, int idx, struct ast_fra
                                 */
                                ast_mutex_unlock(&p->lock);
                                ast_channel_unlock(ast);
-                               if (ast_exists_extension(ast, target_context, "fax", 1, ast->cid.cid_num)) {
+                               if (ast_exists_extension(ast, target_context, "fax", 1,
+                                       S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
                                        ast_channel_lock(ast);
                                        ast_mutex_lock(&p->lock);
                                        ast_verb(3, "Redirecting %s to fax extension\n", ast->name);
@@ -8023,10 +8035,16 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        cid_num[0] = 0;
                                        cid_name[0] = 0;
                                        if (p->dahditrcallerid && p->owner) {
-                                               if (p->owner->cid.cid_num)
-                                                       ast_copy_string(cid_num, p->owner->cid.cid_num, sizeof(cid_num));
-                                               if (p->owner->cid.cid_name)
-                                                       ast_copy_string(cid_name, p->owner->cid.cid_name, sizeof(cid_name));
+                                               if (p->owner->caller.id.number.valid
+                                                       && p->owner->caller.id.number.str) {
+                                                       ast_copy_string(cid_num, p->owner->caller.id.number.str,
+                                                               sizeof(cid_num));
+                                               }
+                                               if (p->owner->caller.id.name.valid
+                                                       && p->owner->caller.id.name.str) {
+                                                       ast_copy_string(cid_name, p->owner->caller.id.name.str,
+                                                               sizeof(cid_name));
+                                               }
                                        }
                                        /* XXX This section needs much more error checking!!! XXX */
                                        /* Start a 3-way call if feasible */
@@ -8168,8 +8186,11 @@ winkflashdone:
                case SIG_FEATDMF_TA:
                        switch (p->whichwink) {
                        case 0:
-                               ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
-                               snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+                               ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->caller.ani2,
+                                       S_OR(p->owner->caller.ani, ""));
+                               snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#",
+                                       p->owner->caller.ani2,
+                                       S_OR(p->owner->caller.ani, ""));
                                break;
                        case 1:
                                ast_copy_string(p->dop.dialstr, p->finaldial, sizeof(p->dop.dialstr));
@@ -9169,25 +9190,29 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
                tmp->adsicpe = AST_ADSI_UNAVAILABLE;
        if (!ast_strlen_zero(i->exten))
                ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
-       if (!ast_strlen_zero(i->rdnis))
-               tmp->redirecting.from.number = ast_strdup(i->rdnis);
-       if (!ast_strlen_zero(i->dnid))
-               tmp->cid.cid_dnid = ast_strdup(i->dnid);
+       if (!ast_strlen_zero(i->rdnis)) {
+               tmp->redirecting.from.number.valid = 1;
+               tmp->redirecting.from.number.str = ast_strdup(i->rdnis);
+       }
+       if (!ast_strlen_zero(i->dnid)) {
+               tmp->dialed.number.str = ast_strdup(i->dnid);
+       }
 
        /* Don't use ast_set_callerid() here because it will
         * generate a needless NewCallerID event */
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
        if (!ast_strlen_zero(i->cid_ani))
-               tmp->cid.cid_ani = ast_strdup(i->cid_ani);
+               tmp->caller.ani = ast_strdup(i->cid_ani);
        else
-               tmp->cid.cid_ani = ast_strdup(i->cid_num);
+               tmp->caller.ani = ast_strdup(i->cid_num);
 #else
-       tmp->cid.cid_ani = ast_strdup(i->cid_num);
+       tmp->caller.ani = ast_strdup(i->cid_num);
 #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
-       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);
+       tmp->caller.id.name.presentation = i->callingpres;
+       tmp->caller.id.number.presentation = i->callingpres;
+       tmp->caller.id.number.plan = i->cid_ton;
+       tmp->caller.ani2 = i->cid_ani2;
+       tmp->caller.id.tag = ast_strdup(i->cid_tag);
        /* clear the fake event in case we posted one before we had ast_channel */
        i->fake_event = 0;
        /* Assure there is no confmute on this channel */
@@ -9576,7 +9601,8 @@ static void *analog_ss_thread(void *data)
                        }
                }
 
-               if (ast_exists_extension(chan, chan->context, exten, 1, chan->cid.cid_num)) {
+               if (ast_exists_extension(chan, chan->context, exten, 1,
+                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                        ast_copy_string(chan->exten, exten, sizeof(chan->exten));
                        if (p->dsp) ast_dsp_digitreset(p->dsp);
                        res = ast_pbx_run(chan);
@@ -9727,12 +9753,10 @@ static void *analog_ss_thread(void *data)
                                ast_verb(3, "Disabling Caller*ID on %s\n", chan->name);
                                /* Disable Caller*ID if enabled */
                                p->hidecallerid = 1;
-                               if (chan->cid.cid_num)
-                                       ast_free(chan->cid.cid_num);
-                               chan->cid.cid_num = NULL;
-                               if (chan->cid.cid_name)
-                                       ast_free(chan->cid.cid_name);
-                               chan->cid.cid_name = NULL;
+                               ast_party_number_free(&chan->caller.id.number);
+                               ast_party_number_init(&chan->caller.id.number);
+                               ast_party_name_free(&chan->caller.id.name);
+                               ast_party_name_init(&chan->caller.id.name);
                                res = tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_DIALRECALL);
                                if (res) {
                                        ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",
@@ -9782,12 +9806,6 @@ static void *analog_ss_thread(void *data)
                                ast_verb(3, "Enabling Caller*ID on %s\n", chan->name);
                                /* Enable Caller*ID if enabled */
                                p->hidecallerid = 0;
-                               if (chan->cid.cid_num)
-                                       ast_free(chan->cid.cid_num);
-                               chan->cid.cid_num = NULL;
-                               if (chan->cid.cid_name)
-                                       ast_free(chan->cid.cid_name);
-                               chan->cid.cid_name = NULL;
                                ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);
                                res = tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_DIALRECALL);
                                if (res) {
@@ -9833,9 +9851,12 @@ static void *analog_ss_thread(void *data)
                                        ast_hangup(chan);
                                        goto quit;
                                }
-                       } else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
-                                                       ((exten[0] != '*') || (strlen(exten) > 2))) {
-                               ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+                       } else if (!ast_canmatch_extension(chan, chan->context, exten, 1,
+                               S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
+                               && ((exten[0] != '*') || (strlen(exten) > 2))) {
+                               ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
+                                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<Unknown Caller>"),
+                                       chan->context);
                                break;
                        }
                        if (!timeout)
index 1252bde..4101d52 100644 (file)
@@ -1051,7 +1051,8 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
 
        tmp->callgroup = client->callgroup;
        tmp->pickupgroup = client->pickupgroup;
-       tmp->cid.cid_pres = client->callingpres;
+       tmp->caller.id.name.presentation = client->callingpres;
+       tmp->caller.id.number.presentation = client->callingpres;
        if (!ast_strlen_zero(client->accountcode))
                ast_string_field_set(tmp, accountcode, client->accountcode);
        if (client->amaflags)
@@ -1067,8 +1068,9 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
        ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
 
-       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
-               tmp->cid.cid_dnid = ast_strdup(i->exten);
+       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
+               tmp->dialed.number.str = ast_strdup(i->exten);
+       }
        tmp->priority = 1;
        if (i->rtp)
                ast_jb_configure(tmp, &global_jbconf);
index a8aa9b7..1866ce0 100644 (file)
@@ -609,18 +609,20 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
        /* make sure null terminated */
        called_addr[sizeof(called_addr) - 1] = '\0';
 
-       if (c->connected.id.number)
-               ast_copy_string(pvt->options.cid_num, c->connected.id.number, sizeof(pvt->options.cid_num));
+       if (c->connected.id.number.valid && c->connected.id.number.str) {
+               ast_copy_string(pvt->options.cid_num, c->connected.id.number.str, sizeof(pvt->options.cid_num));
+       }
 
-       if (c->connected.id.name)
-               ast_copy_string(pvt->options.cid_name, c->connected.id.name, sizeof(pvt->options.cid_name));
+       if (c->connected.id.name.valid && c->connected.id.name.str) {
+               ast_copy_string(pvt->options.cid_name, c->connected.id.name.str, sizeof(pvt->options.cid_name));
+       }
 
-       if (c->redirecting.from.number) {
-               ast_copy_string(pvt->options.cid_rdnis, c->redirecting.from.number, sizeof(pvt->options.cid_rdnis));
+       if (c->redirecting.from.number.valid && c->redirecting.from.number.str) {
+               ast_copy_string(pvt->options.cid_rdnis, c->redirecting.from.number.str, sizeof(pvt->options.cid_rdnis));
        }
 
-       pvt->options.presentation = c->connected.id.number_presentation;
-       pvt->options.type_of_number = c->connected.id.number_type;
+       pvt->options.presentation = ast_party_id_presentation(c->connected.id);
+       pvt->options.type_of_number = c->connected.id.number.plan;
 
        if ((addr = pbx_builtin_getvar_helper(c, "PRIREDIRECTREASON"))) {
                if (!strcasecmp(addr, "UNKNOWN"))
@@ -1080,17 +1082,19 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
 
                /* Don't use ast_set_callerid() here because it will
                 * generate a needless NewCallerID event */
-               ch->cid.cid_ani = ast_strdup(cid_num);
+               ch->caller.ani = ast_strdup(cid_num);
 
                if (pvt->cd.redirect_reason >= 0) {
-                       ch->redirecting.from.number = ast_strdup(pvt->cd.redirect_number);
+                       ch->redirecting.from.number.valid = 1;
+                       ch->redirecting.from.number.str = ast_strdup(pvt->cd.redirect_number);
                        pbx_builtin_setvar_helper(ch, "PRIREDIRECTREASON", redirectingreason2str(pvt->cd.redirect_reason));
                }
-               ch->cid.cid_pres = pvt->cd.presentation;
-               ch->cid.cid_ton = pvt->cd.type_of_number;
+               ch->caller.id.name.presentation = pvt->cd.presentation;
+               ch->caller.id.number.presentation = pvt->cd.presentation;
+               ch->caller.id.number.plan = pvt->cd.type_of_number;
 
                if (!ast_strlen_zero(pvt->exten) && strcmp(pvt->exten, "s")) {
-                       ch->cid.cid_dnid = ast_strdup(pvt->exten);
+                       ch->dialed.number.str = ast_strdup(pvt->exten);
                }
                if (pvt->cd.transfer_capability >= 0)
                        ch->transfercapability = pvt->cd.transfer_capability;
index e6bce41..97752f6 100644 (file)
@@ -4938,8 +4938,8 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
        if (pds.port)
                sin.sin_port = htons(atoi(pds.port));
 
-       l = c->connected.id.number;
-       n = c->connected.id.name;
+       l = c->connected.id.number.valid ? c->connected.id.number.str : NULL;
+       n = c->connected.id.name.valid ? c->connected.id.name.str : NULL;
 
        /* Now build request */ 
        memset(&ied, 0, sizeof(ied));
@@ -4957,16 +4957,17 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
 
        if (l) {
                iax_ie_append_str(&ied, IAX_IE_CALLING_NUMBER, l);
-               iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES, c->connected.id.number_presentation);
+               iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES,
+                       ast_party_id_presentation(&c->connected.id));
+       } else if (n) {
+               iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES,
+                       ast_party_id_presentation(&c->connected.id));
        } else {
-               if (n)
-                       iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES, c->connected.id.number_presentation);
-               else
-                       iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES, AST_PRES_NUMBER_NOT_AVAILABLE);
+               iax_ie_append_byte(&ied, IAX_IE_CALLINGPRES, AST_PRES_NUMBER_NOT_AVAILABLE);
        }
 
-       iax_ie_append_byte(&ied, IAX_IE_CALLINGTON, c->connected.id.number_type);
-       iax_ie_append_short(&ied, IAX_IE_CALLINGTNS, c->cid.cid_tns);
+       iax_ie_append_byte(&ied, IAX_IE_CALLINGTON, c->connected.id.number.plan);
+       iax_ie_append_short(&ied, IAX_IE_CALLINGTNS, c->dialed.transit_network_select);
 
        if (n)
                iax_ie_append_str(&ied, IAX_IE_CALLING_NAME, n);
@@ -4975,10 +4976,13 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
 
        if (!ast_strlen_zero(c->language))
                iax_ie_append_str(&ied, IAX_IE_LANGUAGE, c->language);
-       if (!ast_strlen_zero(c->cid.cid_dnid))
-               iax_ie_append_str(&ied, IAX_IE_DNID, c->cid.cid_dnid);
-       if (!ast_strlen_zero(c->redirecting.from.number))
-               iax_ie_append_str(&ied, IAX_IE_RDNIS, c->redirecting.from.number);
+       if (!ast_strlen_zero(c->dialed.number.str)) {
+               iax_ie_append_str(&ied, IAX_IE_DNID, c->dialed.number.str);
+       }
+       if (c->redirecting.from.number.valid
+               && !ast_strlen_zero(c->redirecting.from.number.str)) {
+               iax_ie_append_str(&ied, IAX_IE_RDNIS, c->redirecting.from.number.str);
+       }
 
        if (pds.context)
                iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, pds.context);
@@ -5599,15 +5603,18 @@ static struct ast_channel *ast_iax2_new(int callno, int state, format_t capabili
                ast_string_field_set(tmp, parkinglot, i->parkinglot);
        /* Don't use ast_set_callerid() here because it will
         * generate a NewCallerID event before the NewChannel event */
-       if (!ast_strlen_zero(i->ani))
-               tmp->cid.cid_ani = ast_strdup(i->ani);
-       else
-               tmp->cid.cid_ani = ast_strdup(i->cid_num);
-       tmp->cid.cid_dnid = ast_strdup(i->dnid);
-       tmp->redirecting.from.number = ast_strdup(i->rdnis);
-       tmp->cid.cid_pres = i->calling_pres;
-       tmp->cid.cid_ton = i->calling_ton;
-       tmp->cid.cid_tns = i->calling_tns;
+       if (!ast_strlen_zero(i->ani)) {
+               tmp->caller.ani = ast_strdup(i->ani);
+       } else {
+               tmp->caller.ani = ast_strdup(i->cid_num);
+       }
+       tmp->dialed.number.str = ast_strdup(i->dnid);
+       tmp->redirecting.from.number.valid = 1;
+       tmp->redirecting.from.number.str = ast_strdup(i->rdnis);
+       tmp->caller.id.name.presentation = i->calling_pres;
+       tmp->caller.id.number.presentation = i->calling_pres;
+       tmp->caller.id.number.plan = i->calling_ton;
+       tmp->dialed.transit_network_select = i->calling_tns;
        if (!ast_strlen_zero(i->language))
                ast_string_field_set(tmp, language, i->language);
        if (!ast_strlen_zero(i->accountcode))
@@ -11321,16 +11328,21 @@ immediatedial:
 
                /* Initialize defaults */
                ast_party_connected_line_init(&connected);
-               connected.id.number_presentation = iaxs[fr->callno]->calling_pres;
+               connected.id.number.presentation = iaxs[fr->callno]->calling_pres;
+               connected.id.name.presentation = iaxs[fr->callno]->calling_pres;
 
                if (!ast_connected_line_parse_data(f.data.ptr, f.datalen, &connected)) {
-                       ast_string_field_set(iaxs[fr->callno], cid_num, connected.id.number);
-                       ast_string_field_set(iaxs[fr->callno], cid_name, connected.id.name);
-                       iaxs[fr->callno]->calling_pres = connected.id.number_presentation;
+                       ast_string_field_set(iaxs[fr->callno], cid_num, connected.id.number.str);
+                       ast_string_field_set(iaxs[fr->callno], cid_name, connected.id.name.str);
+                       iaxs[fr->callno]->calling_pres = ast_party_id_presentation(&connected.id);
 
                        if (iaxs[fr->callno]->owner) {
-                               ast_set_callerid(iaxs[fr->callno]->owner, S_OR(connected.id.number, ""), S_OR(connected.id.name, ""), NULL);
-                               iaxs[fr->callno]->owner->cid.cid_pres = connected.id.number_presentation;
+                               ast_set_callerid(iaxs[fr->callno]->owner,
+                                       S_COR(connected.id.number.valid, connected.id.number.str, ""),
+                                       S_COR(connected.id.name.valid, connected.id.name.str, ""),
+                                       NULL);
+                               iaxs[fr->callno]->owner->caller.id.number.presentation = connected.id.number.presentation;
+                               iaxs[fr->callno]->owner->caller.id.name.presentation = connected.id.name.presentation;
                        }
                }
                ast_party_connected_line_free(&connected);
index 560d3ec..d57644c 100644 (file)
@@ -853,7 +853,8 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
 
        tmp->callgroup = client->callgroup;
        tmp->pickupgroup = client->pickupgroup;
-       tmp->cid.cid_pres = client->callingpres;
+       tmp->caller.id.name.presentation = client->callingpres;
+       tmp->caller.id.number.presentation = client->callingpres;
        if (!ast_strlen_zero(client->accountcode))
                ast_string_field_set(tmp, accountcode, client->accountcode);
        if (client->amaflags)
@@ -867,9 +868,10 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
        ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
        /* Don't use ast_set_callerid() here because it will
         * generate an unnecessary NewCallerID event  */
-       tmp->cid.cid_ani = ast_strdup(i->cid_num);
-       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
-               tmp->cid.cid_dnid = ast_strdup(i->exten);
+       tmp->caller.ani = ast_strdup(i->cid_num);
+       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
+               tmp->dialed.number.str = ast_strdup(i->exten);
+       }
        tmp->priority = 1;
        if (i->rtp)
                ast_jb_configure(tmp, &global_jbconf);
index c372394..36dcc94 100644 (file)
@@ -457,11 +457,11 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
                        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);
+                                       ast_connected_line_copy_to_caller(&the_other_channel->caller, &this_channel->connected);
                                }
-                               f.datalen = ast_connected_line_build_data(frame_data, sizeof(frame_data), &this_channel->connected);
+                               f.datalen = ast_connected_line_build_data(frame_data, sizeof(frame_data), &this_channel->connected, NULL);
                        } else {
-                               f.datalen = ast_redirecting_build_data(frame_data, sizeof(frame_data), &this_channel->redirecting);
+                               f.datalen = ast_redirecting_build_data(frame_data, sizeof(frame_data), &this_channel->redirecting, NULL);
                        }
                        f.subclass.integer = condition;
                        f.data.ptr = frame_data;
@@ -604,18 +604,10 @@ start_over:
         */
        ast_party_redirecting_copy(&p->chan->redirecting, &p->owner->redirecting);
 
-       ast_free(p->chan->cid.cid_dnid);
-       p->chan->cid.cid_dnid = ast_strdup(p->owner->cid.cid_dnid);
-       if (!p->chan->cid.cid_dnid && p->owner->cid.cid_dnid) {
-               /* Allocation failure */
-               ast_mutex_unlock(&p->lock);
-               ast_channel_unlock(p->chan);
-               return -1;
-       }
-       p->chan->cid.cid_tns = p->owner->cid.cid_tns;
+       ast_party_dialed_copy(&p->chan->dialed, &p->owner->dialed);
 
-       ast_connected_line_copy_to_caller(&p->chan->cid, &p->owner->connected);
-       ast_connected_line_copy_from_caller(&p->chan->connected, &p->owner->cid);
+       ast_connected_line_copy_to_caller(&p->chan->caller, &p->owner->connected);
+       ast_connected_line_copy_from_caller(&p->chan->connected, &p->owner->caller);
 
        ast_string_field_set(p->chan, language, p->owner->language);
        ast_string_field_set(p->chan, accountcode, p->owner->accountcode);
@@ -624,7 +616,8 @@ start_over:
 
        ast_channel_cc_params_init(p->chan, ast_channel_get_cc_config_params(p->owner));
 
-       if (!ast_exists_extension(NULL, p->chan->context, p->chan->exten, 1, p->owner->cid.cid_num)) {
+       if (!ast_exists_extension(NULL, p->chan->context, p->chan->exten, 1,
+               S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
                ast_log(LOG_NOTICE, "No such extension/context %s@%s while calling Local channel\n", p->chan->exten, p->chan->context);
                ast_mutex_unlock(&p->lock);
                ast_channel_unlock(p->chan);
index 63dcb93..b0bd1cc 100644 (file)
@@ -898,7 +898,9 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout)
                        transmit_modify_request(sub->next);
                }
 
-               transmit_notify_request_with_callerid(sub, tone, ast->connected.id.number, ast->connected.id.name);
+               transmit_notify_request_with_callerid(sub, tone,
+                       S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""),
+                       S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""));
                ast_setstate(ast, AST_STATE_RINGING);
 
                if (sub->next->owner && !ast_strlen_zero(sub->next->cxident) && !ast_strlen_zero(sub->next->callid)) {
@@ -918,6 +920,7 @@ static int mgcp_hangup(struct ast_channel *ast)
 {
        struct mgcp_subchannel *sub = ast->tech_pvt;
        struct mgcp_endpoint *p = sub->parent;
+       struct ast_channel *bridged;
 
        ast_debug(1, "mgcp_hangup(%s)\n", ast->name);
        if (!ast->tech_pvt) {
@@ -967,7 +970,10 @@ static int mgcp_hangup(struct ast_channel *ast)
                if (p->hookstate == MGCP_OFFHOOK) {
                        if (sub->next->owner && ast_bridged_channel(sub->next->owner)) {
                                /* ncs fix! */
-                               transmit_notify_request_with_callerid(p->sub, (p->ncs ? "L/wt1" : "L/wt"), ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
+                               bridged = ast_bridged_channel(sub->next->owner);
+                               transmit_notify_request_with_callerid(p->sub, (p->ncs ? "L/wt1" : "L/wt"),
+                                       S_COR(bridged->caller.id.number.valid, bridged->caller.id.number.str, ""),
+                                       S_COR(bridged->caller.id.name.valid, bridged->caller.id.name.str, ""));
                        }
                } else {
                        /* set our other connection as the primary and swith over to it */
@@ -975,7 +981,10 @@ static int mgcp_hangup(struct ast_channel *ast)
                        p->sub->cxmode = MGCP_CX_RECVONLY;
                        transmit_modify_request(p->sub);
                        if (sub->next->owner && ast_bridged_channel(sub->next->owner)) {
-                               transmit_notify_request_with_callerid(p->sub, "L/rg", ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
+                               bridged = ast_bridged_channel(sub->next->owner);
+                               transmit_notify_request_with_callerid(p->sub, "L/rg",
+                                       S_COR(bridged->caller.id.number.valid, bridged->caller.id.number.str, ""),
+                                       S_COR(bridged->caller.id.name.valid, bridged->caller.id.name.str, ""));
                        }
                }
 
@@ -1524,7 +1533,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
 
                /* Don't use ast_set_callerid() here because it will
                 * generate a needless NewCallerID event */
-               tmp->cid.cid_ani = ast_strdup(i->cid_num);
+               tmp->caller.ani = ast_strdup(i->cid_num);
 
                if (!i->adsi) {
                        tmp->adsicpe = AST_ADSI_UNAVAILABLE;
@@ -2988,12 +2997,12 @@ static void *mgcp_ss(void *data)
                                        /*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
                                        ast_indicate(chan, -1);
                                        ast_copy_string(chan->exten, p->dtmf_buf, sizeof(chan->exten));
-                                       chan->cid.cid_dnid = ast_strdup(p->dtmf_buf);
+                                       chan->dialed.number.str = ast_strdup(p->dtmf_buf);
                                        memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
                                        ast_set_callerid(chan,
                                                p->hidecallerid ? "" : p->cid_num,
                                                p->hidecallerid ? "" : p->cid_name,
-                                               chan->cid.cid_ani ? NULL : p->cid_num);
+                                               chan->caller.ani ? NULL : p->cid_num);
                                        ast_setstate(chan, AST_STATE_RING);
                                        /*dahdi_enable_ec(p);*/
                                        if (p->dtmfmode & MGCP_DTMF_HYBRID) {
@@ -3121,9 +3130,12 @@ static void *mgcp_ss(void *data)
                        len = 0;
                        memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
                        timeout = firstdigittimeout;
-               } else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1, chan->cid.cid_num) &&
-                               ((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
-                       ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+               } else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1,
+                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
+                       && ((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
+                       ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf,
+                               S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<Unknown Caller>"),
+                               chan->context);
                        break;
                }
                if (!timeout)
index cddfd65..7e1f14a 100644 (file)
@@ -4121,8 +4121,10 @@ static void print_bc_info(int fd, struct chan_list *help, struct misdn_bchannel
                bc->nt ? "NT" : "TE",
                help->originator == ORG_AST ? "*" : "I",
                ast ? ast->exten : "",
-               (ast && ast->cid.cid_name) ? ast->cid.cid_name : "",
-               (ast && ast->cid.cid_num) ? ast->cid.cid_num : "",
+               (ast && ast->caller.id.name.valid && ast->caller.id.name.str)
+                       ? ast->caller.id.name.str : "",
+               (ast && ast->caller.id.number.valid && ast->caller.id.number.str)
+                       ? ast->caller.id.number.str : "",
                bc->redirecting.from.name,
                bc->redirecting.from.number,
                bc->redirecting.to.name,
@@ -4216,13 +4218,15 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st
                                        " --> hold_channel: %d\n",
                                        help->l3id,
                                        ast->exten,
-                                       ast->cid.cid_name ? ast->cid.cid_name : "",
-                                       ast->cid.cid_num ? ast->cid.cid_num : "",
+                                       S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
+                                       S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
                                        help->hold.port,
                                        help->hold.channel
                                        );
                        } else {
-                               ast_cli(a->fd, "* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n", ast->exten, ast->cid.cid_num);
+                               ast_cli(a->fd, "* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n",
+                                       ast->exten,
+                                       S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""));
                        }
                }
        }
@@ -5706,12 +5710,12 @@ static void update_config(struct chan_list *ch)
        chan_misdn_log(2, port, " --> pres: %d screen: %d\n", pres, screen);
 
        if (pres < 0 || screen < 0) {
-               chan_misdn_log(2, port, " --> pres: %x\n", ast->connected.id.number_presentation);
+               chan_misdn_log(2, port, " --> pres: %x\n", ast->connected.id.number.presentation);
 
-               bc->caller.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
+               bc->caller.presentation = ast_to_misdn_pres(ast->connected.id.number.presentation);
                chan_misdn_log(2, port, " --> PRES: %s(%d)\n", misdn_to_str_pres(bc->caller.presentation), bc->caller.presentation);
 
-               bc->caller.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
+               bc->caller.screening = ast_to_misdn_screen(ast->connected.id.number.presentation);
                chan_misdn_log(2, port, " --> SCREEN: %s(%d)\n", misdn_to_str_screen(bc->caller.screening), bc->caller.screening);
        } else {
                bc->caller.screening = screen;
@@ -6014,16 +6018,20 @@ static int read_config(struct chan_list *ch)
 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;
+       struct ast_set_party_connected_line update_connected;
 
        ast_party_connected_line_init(&connected);
-       connected.id.number = (char *) id->number;
-       connected.id.number_type = misdn_to_ast_ton(id->number_type)
+       memset(&update_connected, 0, sizeof(update_connected));
+       update_connected.id.number = 1;
+       connected.id.number.valid = 1;
+       connected.id.number.str = (char *) id->number;
+       connected.id.number.plan = misdn_to_ast_ton(id->number_type)
                | misdn_to_ast_plan(id->number_plan);
-       connected.id.number_presentation = misdn_to_ast_pres(id->presentation)
+       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);
+       ast_channel_queue_connected_line_update(ast, &connected, &update_connected);
 }
 
 /*!
@@ -6043,16 +6051,26 @@ static void misdn_get_connected_line(struct ast_channel *ast, struct misdn_bchan
        if (originator == ORG_MISDN) {
                /* ORIGINATOR MISDN (incoming call) */
 
-               ast_copy_string(bc->connected.name, S_OR(ast->connected.id.name, ""), sizeof(bc->connected.name));
-               ast_copy_string(bc->connected.number, S_OR(ast->connected.id.number, ""), sizeof(bc->connected.number));
-               bc->connected.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
-               bc->connected.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
+               ast_copy_string(bc->connected.name,
+                       S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
+                       sizeof(bc->connected.name));
+               if (ast->connected.id.number.valid) {
+                       ast_copy_string(bc->connected.number, S_OR(ast->connected.id.number.str, ""),
+                               sizeof(bc->connected.number));
+                       bc->connected.presentation = ast_to_misdn_pres(ast->connected.id.number.presentation);
+                       bc->connected.screening = ast_to_misdn_screen(ast->connected.id.number.presentation);
+                       bc->connected.number_type = ast_to_misdn_ton(ast->connected.id.number.plan);
+                       bc->connected.number_plan = ast_to_misdn_plan(ast->connected.id.number.plan);
+               } else {
+                       bc->connected.number[0] = '\0';
+                       bc->connected.presentation = 0;/* Allowed */
+                       bc->connected.screening = 0;/* Unscreened */
+                       bc->connected.number_type = NUMTYPE_UNKNOWN;
+                       bc->connected.number_plan = NUMPLAN_UNKNOWN;
+               }
 
                misdn_cfg_get(bc->port, MISDN_CFG_CPNDIALPLAN, &number_type, sizeof(number_type));
-               if (number_type < 0) {
-                       bc->connected.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
-                       bc->connected.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
-               } else {
+               if (0 <= number_type) {
                        /* Force us to send in CONNECT message */
                        bc->connected.number_type = number_type;
                        bc->connected.number_plan = NUMPLAN_ISDN;
@@ -6061,16 +6079,26 @@ static void misdn_get_connected_line(struct ast_channel *ast, struct misdn_bchan
        } else {
                /* ORIGINATOR Asterisk (outgoing call) */
 
-               ast_copy_string(bc->caller.name, S_OR(ast->connected.id.name, ""), sizeof(bc->caller.name));
-               ast_copy_string(bc->caller.number, S_OR(ast->connected.id.number, ""), sizeof(bc->caller.number));
-               bc->caller.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
-               bc->caller.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
+               ast_copy_string(bc->caller.name,
+                       S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
+                       sizeof(bc->caller.name));
+               if (ast->connected.id.number.valid) {
+                       ast_copy_string(bc->caller.number, S_OR(ast->connected.id.number.str, ""),
+                               sizeof(bc->caller.number));
+                       bc->caller.presentation = ast_to_misdn_pres(ast->connected.id.number.presentation);
+                       bc->caller.screening = ast_to_misdn_screen(ast->connected.id.number.presentation);
+                       bc->caller.number_type = ast_to_misdn_ton(ast->connected.id.number.plan);
+                       bc->caller.number_plan = ast_to_misdn_plan(ast->connected.id.number.plan);
+               } else {
+                       bc->caller.number[0] = '\0';
+                       bc->caller.presentation = 0;/* Allowed */
+                       bc->caller.screening = 0;/* Unscreened */
+                       bc->caller.number_type = NUMTYPE_UNKNOWN;
+                       bc->caller.number_plan = NUMPLAN_UNKNOWN;
+               }
 
                misdn_cfg_get(bc->port, MISDN_CFG_LOCALDIALPLAN, &number_type, sizeof(number_type));
-               if (number_type < 0) {
-                       bc->caller.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
-                       bc->caller.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
-               } else {
+               if (0 <= number_type) {
                        /* Force us to send in SETUP message */
                        bc->caller.number_type = number_type;
                        bc->caller.number_plan = NUMPLAN_ISDN;
@@ -6150,19 +6178,41 @@ static void misdn_update_connected_line(struct ast_channel *ast, struct misdn_bc
  */
 static void misdn_copy_redirecting_from_ast(struct misdn_bchannel *bc, struct ast_channel *ast)
 {
-       ast_copy_string(bc->redirecting.from.name, S_OR(ast->redirecting.from.name, ""), sizeof(bc->redirecting.from.name));
-       ast_copy_string(bc->redirecting.from.number, S_OR(ast->redirecting.from.number, ""), sizeof(bc->redirecting.from.number));
-       bc->redirecting.from.presentation = ast_to_misdn_pres(ast->redirecting.from.number_presentation);
-       bc->redirecting.from.screening = ast_to_misdn_screen(ast->redirecting.from.number_presentation);
-       bc->redirecting.from.number_type = ast_to_misdn_ton(ast->redirecting.from.number_type);
-       bc->redirecting.from.number_plan = ast_to_misdn_plan(ast->redirecting.from.number_type);
-
-       ast_copy_string(bc->redirecting.to.name, S_OR(ast->redirecting.to.name, ""), sizeof(bc->redirecting.to.name));
-       ast_copy_string(bc->redirecting.to.number, S_OR(ast->redirecting.to.number, ""), sizeof(bc->redirecting.to.number));
-       bc->redirecting.to.presentation = ast_to_misdn_pres(ast->redirecting.to.number_presentation);
-       bc->redirecting.to.screening = ast_to_misdn_screen(ast->redirecting.to.number_presentation);
-       bc->redirecting.to.number_type = ast_to_misdn_ton(ast->redirecting.to.number_type);
-       bc->redirecting.to.number_plan = ast_to_misdn_plan(ast->redirecting.to.number_type);
+       ast_copy_string(bc->redirecting.from.name,
+               S_COR(ast->redirecting.from.name.valid, ast->redirecting.from.name.str, ""),
+               sizeof(bc->redirecting.from.name));
+       if (ast->redirecting.from.number.valid) {
+               ast_copy_string(bc->redirecting.from.number, S_OR(ast->redirecting.from.number.str, ""),
+                       sizeof(bc->redirecting.from.number));
+               bc->redirecting.from.presentation = ast_to_misdn_pres(ast->redirecting.from.number.presentation);
+               bc->redirecting.from.screening = ast_to_misdn_screen(ast->redirecting.from.number.presentation);
+               bc->redirecting.from.number_type = ast_to_misdn_ton(ast->redirecting.from.number.plan);
+               bc->redirecting.from.number_plan = ast_to_misdn_plan(ast->redirecting.from.number.plan);
+       } else {
+               bc->redirecting.from.number[0] = '\0';
+               bc->redirecting.from.presentation = 0;/* Allowed */
+               bc->redirecting.from.screening = 0;/* Unscreened */
+               bc->redirecting.from.number_type = NUMTYPE_UNKNOWN;
+               bc->redirecting.from.number_plan = NUMPLAN_UNKNOWN;
+       }
+
+       ast_copy_string(bc->redirecting.to.name,
+               S_COR(ast->redirecting.to.name.valid, ast->redirecting.to.name.str, ""),
+               sizeof(bc->redirecting.to.name));
+       if (ast->redirecting.to.number.valid) {
+               ast_copy_string(bc->redirecting.to.number, S_OR(ast->redirecting.to.number.str, ""),
+                       sizeof(bc->redirecting.to.number));
+               bc->redirecting.to.presentation = ast_to_misdn_pres(ast->redirecting.to.number.presentation);
+               bc->redirecting.to.screening = ast_to_misdn_screen(ast->redirecting.to.number.presentation);
+               bc->redirecting.to.number_type = ast_to_misdn_ton(ast->redirecting.to.number.plan);
+               bc->redirecting.to.number_plan = ast_to_misdn_plan(ast->redirecting.to.number.plan);
+       } else {
+               bc->redirecting.to.number[0] = '\0';
+               bc->redirecting.to.presentation = 0;/* Allowed */
+               bc->redirecting.to.screening = 0;/* Unscreened */
+               bc->redirecting.to.number_type = NUMTYPE_UNKNOWN;
+               bc->redirecting.to.number_plan = NUMPLAN_UNKNOWN;
+       }
 
        bc->redirecting.reason = ast_to_misdn_reason(ast->redirecting.reason);
        bc->redirecting.count = ast->redirecting.count;
@@ -6181,23 +6231,29 @@ static void misdn_copy_redirecting_from_ast(struct misdn_bchannel *bc, struct as
 static void misdn_copy_redirecting_to_ast(struct ast_channel *ast, const struct misdn_party_redirecting *redirect, char *tag)
 {
        struct ast_party_redirecting redirecting;
+       struct ast_set_party_redirecting update_redirecting;
 
        ast_party_redirecting_set_init(&redirecting, &ast->redirecting);
+       memset(&update_redirecting, 0, sizeof(update_redirecting));
 
-       redirecting.from.number = (char *) redirect->from.number;
-       redirecting.from.number_type =
+       update_redirecting.from.number = 1;
+       redirecting.from.number.valid = 1;
+       redirecting.from.number.str = (char *) redirect->from.number;
+       redirecting.from.number.plan =
                misdn_to_ast_ton(redirect->from.number_type)
                | misdn_to_ast_plan(redirect->from.number_plan);
-       redirecting.from.number_presentation =
+       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 =
+       update_redirecting.to.number = 1;
+       redirecting.to.number.valid = 1;
+       redirecting.to.number.str = (char *) redirect->to.number;
+       redirecting.to.number.plan =
                misdn_to_ast_ton(redirect->to.number_type)
                | misdn_to_ast_plan(redirect->to.number_plan);
-       redirecting.to.number_presentation =
+       redirecting.to.number.presentation =
                misdn_to_ast_pres(redirect->to.presentation)
                | misdn_to_ast_screen(redirect->to.screening);
        redirecting.to.tag = tag;
@@ -6205,7 +6261,7 @@ static void misdn_copy_redirecting_to_ast(struct ast_channel *ast, const struct
        redirecting.reason = misdn_to_ast_reason(redirect->reason);
        redirecting.count = redirect->count;
 
-       ast_channel_set_redirecting(ast, &redirecting);
+       ast_channel_set_redirecting(ast, &redirecting, &update_redirecting);
 }
 
 /*!
@@ -6393,12 +6449,16 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
                ast_copy_string(ast->exten, args.ext, sizeof(ast->exten));
                ast_copy_string(newbc->dialed.number, args.ext, sizeof(newbc->dialed.number));
 
-               if (ast_strlen_zero(newbc->caller.name) && !ast_strlen_zero(ast->connected.id.name)) {
-                       ast_copy_string(newbc->caller.name, ast->connected.id.name, sizeof(newbc->caller.name));
+               if (ast_strlen_zero(newbc->caller.name)
+                       && ast->connected.id.name.valid
+                       && !ast_strlen_zero(ast->connected.id.name.str)) {
+                       ast_copy_string(newbc->caller.name, ast->connected.id.name.str, sizeof(newbc->caller.name));
                        chan_misdn_log(3, port, " --> * set caller:\"%s\" <%s>\n", newbc->caller.name, newbc->caller.number);
                }
-               if (ast_strlen_zero(newbc->caller.number) && !ast_strlen_zero(ast->connected.id.number)) {
-                       ast_copy_string(newbc->caller.number, ast->connected.id.number, sizeof(newbc->caller.number));
+               if (ast_strlen_zero(newbc->caller.number)
+                       && ast->connected.id.number.valid
+                       && !ast_strlen_zero(ast->connected.id.number.str)) {
+                       ast_copy_string(newbc->caller.number, ast->connected.id.number.str, sizeof(newbc->caller.number));
                        chan_misdn_log(3, port, " --> * set caller:\"%s\" <%s>\n", newbc->caller.name, newbc->caller.number);
                }
 
@@ -6408,12 +6468,17 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
                        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);
+               ast->caller.id.tag = ast_strdup(newbc->incoming_cid_tag);
 
                misdn_cfg_get(port, MISDN_CFG_LOCALDIALPLAN, &number_type, sizeof(number_type));
                if (number_type < 0) {
-                       newbc->caller.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
-                       newbc->caller.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
+                       if (ast->connected.id.number.valid) {
+                               newbc->caller.number_type = ast_to_misdn_ton(ast->connected.id.number.plan);
+                               newbc->caller.number_plan = ast_to_misdn_plan(ast->connected.id.number.plan);
+                       } else {
+                               newbc->caller.number_type = NUMTYPE_UNKNOWN;
+                               newbc->caller.number_plan = NUMPLAN_ISDN;
+                       }
                } else {
                        /* Force us to send in SETUP message */
                        newbc->caller.number_type = number_type;
@@ -6921,8 +6986,10 @@ static int misdn_hangup(struct ast_channel *ast)
                bc->pid,
                ast->context,
                ast->exten,
-               ast->cid.cid_name ? ast->cid.cid_name : "",
-               ast->cid.cid_num ? ast->cid.cid_num : "",
+               (ast->caller.id.name.valid && ast->caller.id.name.str)
+                       ? ast->caller.id.name.str : "",
+               (ast->caller.id.number.valid && ast->caller.id.number.str)
+                       ? ast->caller.id.number.str : "",
                misdn_get_ch_state(p));
        chan_misdn_log(3, bc->port, " --> l3id:%x\n", p->l3id);
        chan_misdn_log(3, bc->port, " --> cause:%d\n", bc->cause);
@@ -7056,7 +7123,8 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
                                        char context_tmp[BUFFERSIZE];
                                        misdn_cfg_get(tmp->bc->port, MISDN_CFG_FAXDETECT_CONTEXT, &context_tmp, sizeof(context_tmp));
                                        context = ast_strlen_zero(context_tmp) ? (ast_strlen_zero(ast->macrocontext) ? ast->context : ast->macrocontext) : context_tmp;
-                                       if (ast_exists_extension(ast, context, "fax", 1, ast->cid.cid_num)) {
+                                       if (ast_exists_extension(ast, context, "fax", 1,
+                                               S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
                                                ast_verb(3, "Redirecting %s to fax extension (context:%s)\n", ast->name, context);
                                                /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
                                                pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast->exten);
@@ -7256,7 +7324,9 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
                if (!ch->dropped_frame_cnt) {
                        chan_misdn_log(5, ch->bc->port,
                                "BC not active (nor bridged) dropping: %d frames addr:%x exten:%s cid:%s ch->state:%s bc_state:%d l3id:%x\n",
-                               frame->samples, ch->bc->addr, ast->exten, ast->cid.cid_num, misdn_get_ch_state(ch), ch->bc->bc_state, ch->bc->l3_id);
+                               frame->samples, ch->bc->addr, ast->exten,
+                               S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
+                               misdn_get_ch_state(ch), ch->bc->bc_state, ch->bc->l3_id);
                }
 
                if (++ch->dropped_frame_cnt > 100) {
@@ -7871,7 +7941,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
                if (callerid) {
                        /* Don't use ast_set_callerid() here because it will
                         * generate a needless NewCallerID event */
-                       tmp->cid.cid_ani = ast_strdup(cid_num);
+                       tmp->caller.ani = ast_strdup(cid_num);
                }
 
                if (pipe(chlist->pipe) < 0) {
@@ -8162,8 +8232,10 @@ static void release_chan(struct chan_list *ch, struct misdn_bchannel *bc)
                        bc->pid,
                        ast->context,
                        ast->exten,
-                       ast->cid.cid_name ? ast->cid.cid_name : "",
-                       ast->cid.cid_num ? ast->cid.cid_num : "");
+                       (ast->caller.id.name.valid && ast->caller.id.name.str)
+                               ? ast->caller.id.name.str : "",
+                       (ast->caller.id.number.valid && ast->caller.id.number.str)
+                               ? ast->caller.id.number.str : "");
 
                if (ast->_state != AST_STATE_RESERVED) {
                        chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
@@ -8313,8 +8385,10 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch,
                "* Starting Ast context:%s dialed:%s caller:\"%s\" <%s> with 's' extension\n",
                ast->context,
                ast->exten,
-               ast->cid.cid_name ? ast->cid.cid_name : "",
-               ast->cid.cid_num ? ast->cid.cid_num : "");
+               (ast->caller.id.name.valid && ast->caller.id.name.str)
+                       ? ast->caller.id.name.str : "",
+               (ast->caller.id.number.valid && ast->caller.id.number.str)
+                       ? ast->caller.id.number.str : "");
 
        strcpy(ast->exten, "s");
 
@@ -8596,10 +8670,8 @@ static void misdn_cc_pbx_notify(long record_id, const struct misdn_cc_notify *no
                return;
        }
        chan->priority = notify->priority;
-       if (chan->cid.cid_dnid) {
-               ast_free(chan->cid.cid_dnid);
-       }
-       chan->cid.cid_dnid = ast_strdup(notify->exten);
+       ast_free(chan->dialed.number.str);
+       chan->dialed.number.str = ast_strdup(notify->exten);
 
        if (ast_pbx_start(chan)) {
                ast_log(LOG_WARNING, "Unable to start pbx channel %s!\n", chan->name);
@@ -8933,11 +9005,11 @@ static void misdn_facility_ie_handler(enum event_e event, struct misdn_bchannel
                        bc->div_leg_3_rx_wanted = 0;
 
                        if (ch && ch->ast) {
-                               ch->ast->redirecting.to.number_presentation =
+                               ch->ast->redirecting.to.number.presentation =
                                        bc->fac_in.u.DivertingLegInformation3.PresentationAllowedIndicator
                                        ? AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED
                                        : AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED;
-                               ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting);
+                               ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting, NULL);
                        }
                }
                break;
@@ -9790,12 +9862,12 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                /* Update asterisk channel caller information */
                chan_misdn_log(2, bc->port, " --> TON: %s(%d)\n", misdn_to_str_ton(bc->caller.number_type), bc->caller.number_type);
                chan_misdn_log(2, bc->port, " --> PLAN: %s(%d)\n", misdn_to_str_plan(bc->caller.number_plan), bc->caller.number_plan);
-               chan->cid.cid_ton = misdn_to_ast_ton(bc->caller.number_type)
+               chan->caller.id.number.plan = misdn_to_ast_ton(bc->caller.number_type)
                        | misdn_to_ast_plan(bc->caller.number_plan);
 
                chan_misdn_log(2, bc->port, " --> PRES: %s(%d)\n", misdn_to_str_pres(bc->caller.presentation), bc->caller.presentation);
                chan_misdn_log(2, bc->port, " --> SCREEN: %s(%d)\n", misdn_to_str_screen(bc->caller.screening), bc->caller.screening);
-               chan->cid.cid_pres = misdn_to_ast_pres(bc->caller.presentation)
+               chan->caller.id.number.presentation = misdn_to_ast_pres(bc->caller.presentation)
                        | misdn_to_ast_screen(bc->caller.screening);
 
                ast_set_callerid(chan, bc->caller.number, NULL, bc->caller.number);
@@ -9807,7 +9879,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                }
 
                ast_channel_lock(chan);
-               chan->cid.cid_tag = ast_strdup(bc->incoming_cid_tag);
+               chan->caller.id.tag = ast_strdup(bc->incoming_cid_tag);
                ast_channel_unlock(chan);
 
                if (!ast_strlen_zero(bc->redirecting.from.number)) {
@@ -10108,9 +10180,9 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        bc->div_leg_3_rx_wanted = 0;
 
                        if (ch->ast) {
-                               ch->ast->redirecting.to.number_presentation =
+                               ch->ast->redirecting.to.number.presentation =
                                        AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED;
-                               ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting);
+                               ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting, NULL);
                        }
                }
 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
@@ -10544,7 +10616,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                                                break;
                                        }
                                        misdn_copy_redirecting_to_ast(ch->ast, &bc->redirecting, bc->incoming_cid_tag);
-                                       ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting);
+                                       ast_channel_queue_redirecting_update(ch->ast, &ch->ast->redirecting,
+                                               NULL);
                                }
                        }
                        break;
index aea4873..b277685 100644 (file)
@@ -602,7 +602,11 @@ static int oss_call(struct ast_channel *c, char *dest, int timeout)
        AST_NONSTANDARD_APP_ARGS(args, parse, '/');
 
        ast_verbose(" << Call to device '%s' dnid '%s' rdnis '%s' on console from '%s' <%s> >>\n",
-               dest, c->cid.cid_dnid, c->redirecting.from.number, c->cid.cid_name, c->cid.cid_num);
+               dest,
+               S_OR(c->dialed.number.str, ""),
+               S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, ""),
+               S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
+               S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""));
        if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "answer") == 0) {
                f.subclass.integer = AST_CONTROL_ANSWER;
                ast_queue_frame(c, &f);
@@ -803,9 +807,10 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
                ast_string_field_set(c, language, o->language);
        /* Don't use ast_set_callerid() here because it will
         * generate a needless NewCallerID event */
-       c->cid.cid_ani = ast_strdup(o->cid_num);
-       if (!ast_strlen_zero(ext))
-               c->cid.cid_dnid = ast_strdup(ext);
+       c->caller.ani = ast_strdup(o->cid_num);
+       if (!ast_strlen_zero(ext)) {
+               c->dialed.number.str = ast_strdup(ext);
+       }
 
        o->owner = c;
        ast_module_ref(ast_module_info->self);
@@ -1181,9 +1186,10 @@ static char *console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_a
        tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
        if (ctx == NULL)                        /* supply default context if needed */
                ctx = o->owner->context;
-       if (!ast_exists_extension(b, ctx, ext, 1, b->cid.cid_num))
+       if (!ast_exists_extension(b, ctx, ext, 1,
+               S_COR(b->caller.id.number.valid, b->caller.id.number.str, NULL))) {
                ast_cli(a->fd, "No such extension exists\n");
-       else {
+       } else {
                ast_cli(a->fd, "Whee, transferring %s to %s@%s.\n", b->name, ext, ctx);
                if (ast_async_goto(b, ctx, ext, 1))
                        ast_cli(a->fd, "Failed to transfer :(\n");
index 389f304..18eaf8f 100644 (file)
@@ -303,13 +303,16 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
                snprintf(cid.min, sizeof(cid.min),     "%02d", tm.tm_min);
        }
        /* the standard format of ast->callerid is:  "name" <number>, but not always complete */
-       if (ast_strlen_zero(ast->connected.id.name))
+       if (!ast->connected.id.name.valid
+               || ast_strlen_zero(ast->connected.id.name.str)) {
                strcpy(cid.name, DEFAULT_CALLER_ID);
-       else
-               ast_copy_string(cid.name, ast->connected.id.name, sizeof(cid.name));
+       } else {
+               ast_copy_string(cid.name, ast->connected.id.name.str, sizeof(cid.name));
+       }
 
-       if (ast->connected.id.number) 
-               ast_copy_string(cid.number, ast->connected.id.number, sizeof(cid.number));
+       if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+               ast_copy_string(cid.number, ast->connected.id.number.str, sizeof(cid.number));
+       }
 
        p = ast->tech_pvt;
 
@@ -885,7 +888,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
 
                /* Don't use ast_set_callerid() here because it will
                 * generate a NewCallerID event before the NewChannel event */
-               tmp->cid.cid_ani = ast_strdup(i->cid_num);
+               tmp->caller.ani = ast_strdup(i->cid_num);
 
                i->owner = tmp;
                ast_module_ref(ast_module_info->self);
index 5d6d2f1..8dc4c5d 100644 (file)
@@ -1457,7 +1457,6 @@ static int get_msg_text(char *buf, int len, struct sip_request *req, int addnewl
 static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout);
 static void update_connectedline(struct sip_pvt *p, const void *data, size_t datalen);
 static void update_redirecting(struct sip_pvt *p, const void *data, size_t datalen);
-static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting, int set_call_forward);
 static int get_domain(const char *str, char *domain, int len);
 static void get_realm(struct sip_pvt *p, const struct sip_request *req);
 
@@ -5073,7 +5072,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
                ast->hangupcause = AST_CAUSE_USER_BUSY;
                return res;
        }
-       p->callingpres = ast->cid.cid_pres;
+       p->callingpres = ast_party_id_presentation(&ast->caller.id);
        p->jointcapability = ast_rtp_instance_available_formats(p->rtp, p->capability, p->prefcodec);
        p->jointnoncodeccapability = p->noncodeccapability;
 
@@ -6390,7 +6389,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        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);
+       tmp->caller.id.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;
@@ -6491,7 +6490,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
 
        tmp->callgroup = i->callgroup;
        tmp->pickupgroup = i->pickupgroup;
-       tmp->cid.cid_pres = i->callingpres;
+       tmp->caller.id.name.presentation = i->callingpres;
+       tmp->caller.id.number.presentation = i->callingpres;
        if (!ast_strlen_zero(i->parkinglot))
                ast_string_field_set(tmp, parkinglot, i->parkinglot);
        if (!ast_strlen_zero(i->accountcode))
@@ -6513,12 +6513,15 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
 
        /* Don't use ast_set_callerid() here because it will
         * generate an unnecessary NewCallerID event  */
-       tmp->cid.cid_ani = ast_strdup(i->cid_num);
-       if (!ast_strlen_zero(i->rdnis))
-               tmp->redirecting.from.number = ast_strdup(i->rdnis);
-       
-       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
-               tmp->cid.cid_dnid = ast_strdup(i->exten);
+       tmp->caller.ani = ast_strdup(i->cid_num);
+       if (!ast_strlen_zero(i->rdnis)) {
+               tmp->redirecting.from.number.valid = 1;
+               tmp->redirecting.from.number.str = ast_strdup(i->rdnis);
+       }
+
+       if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
+               tmp->dialed.number.str = ast_strdup(i->exten);
+       }
 
        tmp->priority = 1;
        if (!ast_strlen_zero(i->uri))
@@ -6817,7 +6820,8 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
                if (strcmp(ast->exten, "fax")) {
                        const char *target_context = S_OR(ast->macrocontext, ast->context);
                        ast_channel_unlock(ast);
-                       if (ast_exists_extension(ast, target_context, "fax", 1, ast->cid.cid_num)) {
+                       if (ast_exists_extension(ast, target_context, "fax", 1,
+                               S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
                                ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to CNG detection\n", ast->name);
                                pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
                                if (ast_async_goto(ast, target_context, "fax", 1)) {
@@ -6826,11 +6830,11 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
                                fr = &ast_null_frame;
                        } else {
                                ast_log(LOG_NOTICE, "FAX CNG detected but no fax extension\n");
-                        }
+                       }
                } else {
                        ast_channel_unlock(ast);
-                }
-        }
+               }
+       }
 
        /* Only allow audio through if they sent progress with SDP, or if the channel is actually answered */
        if (fr && fr->frametype == AST_FRAME_VOICE && p->invitestate != INV_EARLY_MEDIA && ast->_state != AST_STATE_UP) {
@@ -8228,7 +8232,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                        if (strcmp(p->owner->exten, "fax")) {
                                                const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
                                                ast_channel_unlock(p->owner);
-                                               if (ast_exists_extension(p->owner, target_context, "fax", 1, p->owner->cid.cid_num)) {
+                                               if (ast_exists_extension(p->owner, target_context, "fax", 1,
+                                                       S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
                                                        ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", p->owner->name);
                                                        pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
                                                        if (ast_async_goto(p->owner, target_context, "fax", 1)) {
@@ -9691,11 +9696,15 @@ static int add_rpid(struct sip_request *req, struct sip_pvt *p)
                return 0;
        }
 
-       if (p->owner && p->owner->connected.id.number)
-               lid_num = p->owner->connected.id.number;
-       if (p->owner && p->owner->connected.id.name)
-               lid_name = p->owner->connected.id.name;
-       lid_pres = (p->owner) ? p->owner->connected.id.number_presentation : AST_PRES_NUMBER_NOT_AVAILABLE;
+       if (p->owner && p->owner->connected.id.number.valid
+               && p->owner->connected.id.number.str) {
+               lid_num = p->owner->connected.id.number.str;
+       }
+       if (p->owner && p->owner->connected.id.name.valid
+               && p->owner->connected.id.name.str) {
+               lid_name = p->owner->connected.id.name.str;
+       }
+       lid_pres = (p->owner) ? ast_party_id_presentation(&p->owner->connected.id) : AST_PRES_NUMBER_NOT_AVAILABLE;
 
        if (ast_strlen_zero(lid_num))
                return 0;
@@ -10700,14 +10709,16 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
        snprintf(p->lastmsg, sizeof(p->lastmsg), "Init: %s", sip_methods[sipmethod].text);
 
        d = S_OR(p->fromdomain, ast_sockaddr_stringify_host(&p->ourip));
-       if (p->owner && (p->owner->connected.id.number_presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
-               l = p->owner->connected.id.number;
-               n = p->owner->connected.id.name;
-       } else if (p->owner && (p->owner->connected.id.number_presentation & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED && (!ast_test_flag(&p->flags[0], SIP_SENDRPID))) {
-               /* if we are not sending RPID and user wants his callerid restricted */         
-               l = CALLERID_UNKNOWN;
-               n = l;
-               d = FROMDOMAIN_INVALID;
+       if (p->owner) {
+               if ((ast_party_id_presentation(&p->owner->connected.id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
+                       l = p->owner->connected.id.number.valid ? p->owner->connected.id.number.str : NULL;
+                       n = p->owner->connected.id.name.valid ? p->owner->connected.id.name.str : NULL;
+               } else if (!ast_test_flag(&p->flags[0], SIP_SENDRPID)) {
+                       /* if we are not sending RPID and user wants his callerid restricted */         
+                       l = CALLERID_UNKNOWN;
+                       n = l;
+                       d = FROMDOMAIN_INVALID;
+               }
        }
 
        /* Hey, it's a NOTIFY! See if they've configured a mwi_from.
@@ -10845,16 +10856,18 @@ static void add_diversion_header(struct sip_request *req, struct sip_pvt *pvt)
                return;
        }
 
-       diverting_number = pvt->owner->redirecting.from.number;
-       diverting_name = pvt->owner->redirecting.from.name;
-       reason = sip_reason_code_to_str(pvt->owner->redirecting.reason);
-
-       if (ast_strlen_zero(diverting_number)) {
+       diverting_number = pvt->owner->redirecting.from.number.str;
+       if (!pvt->owner->redirecting.from.number.valid
+               || ast_strlen_zero(diverting_number)) {
                return;
        }
 
+       reason = sip_reason_code_to_str(pvt->owner->redirecting.reason);
+
        /* We at least have a number to place in the Diversion header, which is enough */
-       if (ast_strlen_zero(diverting_name)) {
+       diverting_name = pvt->owner->redirecting.from.name.str;
+       if (!pvt->owner->redirecting.from.name.valid
+               || ast_strlen_zero(diverting_name)) {
                snprintf(header_text, sizeof(header_text), "<sip:%s@%s>;reason=%s", diverting_number,
                                ast_sockaddr_stringify_host(&pvt->ourip), reason);
        } else {
@@ -11291,11 +11304,17 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
                                struct ast_channel *caller;
 
                                if ((caller = ast_channel_callback(find_calling_channel, NULL, p, 0))) {
-                                       int need = strlen(caller->cid.cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
-                                       local_target = alloca(need);
+                                       char *cid_num;
+                                       int need;
+
                                        ast_channel_lock(caller);
-                                       snprintf(local_target, need, "sip:%s@%s", caller->cid.cid_num, p->fromdomain);
-                                       local_display = ast_strdupa(caller->cid.cid_name);
+                                       cid_num = S_COR(caller->caller.id.number.valid,
+                                               caller->caller.id.number.str, "");
+                                       need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
+                                       local_target = alloca(need);
+                                       snprintf(local_target, need, "sip:%s@%s", cid_num, p->fromdomain);
+                                       local_display = ast_strdupa(S_COR(caller->caller.id.name.valid,
+                                               caller->caller.id.name.str, ""));
                                        ast_channel_unlock(caller);
                                        caller = ast_channel_unref(caller);
                                }
@@ -11599,10 +11618,15 @@ static void update_connectedline(struct sip_pvt *p, const void *data, size_t dat
 
        if (!ast_test_flag(&p->flags[0], SIP_SENDRPID))
                return;
-       if (ast_strlen_zero(p->owner->connected.id.number))
+       if (!p->owner->connected.id.number.valid
+               || ast_strlen_zero(p->owner->connected.id.number.str)) {
                return;
+       }
 
-       append_history(p, "ConnectedLine", "%s party is now %s <%s>", ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "Calling" : "Called", p->owner->connected.id.name, p->owner->connected.id.number);
+       append_history(p, "ConnectedLine", "%s party is now %s <%s>",
+               ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "Calling" : "Called",
+               S_COR(p->owner->connected.id.name.valid, p->owner->connected.id.name.str, ""),
+               S_COR(p->owner->connected.id.number.valid, p->owner->connected.id.number.str, ""));
 
        if (p->owner->_state == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                struct sip_request req;
@@ -13551,7 +13575,8 @@ static int get_pai(struct sip_pvt *p, struct sip_request *req)
 
        if (p->owner) {
                ast_set_callerid(p->owner, cid_num, cid_name, NULL);
-               p->owner->cid.cid_pres = callingpres;
+               p->owner->caller.id.name.presentation = callingpres;
+               p->owner->caller.id.number.presentation = callingpres;
        }
 
        return 1;
@@ -13650,7 +13675,8 @@ static int get_rpid(struct sip_pvt *p, struct sip_request *oreq)
 
        if (p->owner) {
                ast_set_callerid(p->owner, cid_num, cid_name, NULL);
-               p->owner->cid.cid_pres = callingpres;
+               p->owner->caller.id.name.presentation = callingpres;
+               p->owner->caller.id.number.presentation = callingpres;
        }
 
        return 1;
@@ -17811,7 +17837,9 @@ static struct ast_custom_function sipchaninfo_function = {
 /*! \brief update redirecting information for a channel based on headers
  *
  */
-static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting, int set_call_forward)
+static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req,
+       struct ast_party_redirecting *redirecting,
+       struct ast_set_party_redirecting *update_redirecting, int set_call_forward)
 {
        char *redirecting_from_name = NULL;
        char *redirecting_from_number = NULL;
@@ -17841,42 +17869,38 @@ static void change_redirecting_information(struct sip_pvt *p, struct sip_request
        }
 
        if (!ast_strlen_zero(redirecting_from_number)) {
-               if (redirecting->from.number) {
-                       ast_free(redirecting->from.number);
-               }
                ast_debug(3, "Got redirecting from number %s\n", redirecting_from_number);
-               redirecting->from.number = redirecting_from_number;
+               update_redirecting->from.number = 1;
+               redirecting->from.number.valid = 1;
+               ast_free(redirecting->from.number.str);
+               redirecting->from.number.str = redirecting_from_number;
        }
        if (!ast_strlen_zero(redirecting_from_name)) {
-               if (redirecting->from.name) {
-                       ast_free(redirecting->from.name);
-               }
                ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
-               redirecting->from.name = redirecting_from_name;
+               update_redirecting->from.name = 1;
+               redirecting->from.name.valid = 1;
+               ast_free(redirecting->from.name.str);
+               redirecting->from.name.str = redirecting_from_name;
        }
        if (!ast_strlen_zero(p->cid_tag)) {
-               if (redirecting->from.tag) {
-                       ast_free(redirecting->from.tag);
-               }
+               ast_free(redirecting->from.tag);
                redirecting->from.tag = ast_strdup(p->cid_tag);
-               if (redirecting->to.tag) {
-                       ast_free(redirecting->to.tag);
-               }
+               ast_free(redirecting->to.tag);
                redirecting->to.tag = ast_strdup(p->cid_tag);
        }
        if (!ast_strlen_zero(redirecting_to_number)) {
-               if (redirecting->to.number) {
-                       ast_free(redirecting->to.number);
-               }
                ast_debug(3, "Got redirecting to number %s\n", redirecting_to_number);
-               redirecting->to.number = redirecting_to_number;
+               update_redirecting->to.number = 1;
+               redirecting->to.number.valid = 1;
+               ast_free(redirecting->to.number.str);
+               redirecting->to.number.str = redirecting_to_number;
        }
        if (!ast_strlen_zero(redirecting_to_name)) {
-               if (redirecting->to.name) {
-                       ast_free(redirecting->to.name);
-               }
                ast_debug(3, "Got redirecting to name %s\n", redirecting_from_number);
-               redirecting->to.name = redirecting_to_name;
+               update_redirecting->to.name = 1;
+               redirecting->to.name.valid = 1;
+               ast_free(redirecting->to.name.str);
+               redirecting->to.name.str = redirecting_to_name;
        }
        redirecting->reason = reason;
 }
@@ -18169,6 +18193,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
        char *p_hdrval;
        int rtn;
        struct ast_party_connected_line connected;
+       struct ast_set_party_connected_line update_connected;
 
        if (reinvite)
                ast_debug(4, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
@@ -18224,12 +18249,23 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                if (!req->ignore && p->owner) {
                        if (get_rpid(p, req)) {
                                ast_party_connected_line_init(&connected);
-                               connected.id.number = (char *) p->cid_num;
-                               connected.id.name = (char *) p->cid_name;
+                               memset(&update_connected, 0, sizeof(update_connected));
+                               if (p->cid_num) {
+                                       update_connected.id.number = 1;
+                                       connected.id.number.valid = 1;
+                                       connected.id.number.str = (char *) p->cid_num;
+                                       connected.id.number.presentation = p->callingpres;
+                               }
+                               if (p->cid_name) {
+                                       update_connected.id.name = 1;
+                                       connected.id.name.valid = 1;
+                                       connected.id.name.str = (char *) p->cid_name;
+                                       connected.id.name.presentation = p->callingpres;
+                               }
                                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);
+                               ast_channel_queue_connected_line_update(p->owner, &connected,
+                                       &update_connected);
                        }
                        sip_handle_cc(p, req, AST_CC_CCNR);
                        ast_queue_control(p->owner, AST_CONTROL_RINGING);
@@ -18254,9 +18290,15 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                if (!req->ignore && (p->invitestate != INV_CANCELLED) && sip_cancel_destroy(p))
                        ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
                if (!req->ignore && p->owner) {
-                       struct ast_party_redirecting redirecting = {{0,},};
-                       change_redirecting_information(p, req, &redirecting, FALSE);
-                       ast_channel_queue_redirecting_update(p->owner, &redirecting);
+                       struct ast_party_redirecting redirecting;
+                       struct ast_set_party_redirecting update_redirecting;
+
+                       ast_party_redirecting_init(&redirecting);
+                       memset(&update_redirecting, 0, sizeof(update_redirecting));
+                       change_redirecting_information(p, req, &redirecting, &update_redirecting,
+                               FALSE);
+                       ast_channel_queue_redirecting_update(p->owner, &redirecting,
+                               &update_redirecting);
                        ast_party_redirecting_free(&redirecting);
                        sip_handle_cc(p, req, AST_CC_CCNR);
                }
@@ -18270,12 +18312,23 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                        if (get_rpid(p, req)) {
                                /* Queue a connected line update */
                                ast_party_connected_line_init(&connected);
-                               connected.id.number = (char *) p->cid_num;
-                               connected.id.name = (char *) p->cid_name;
+                               memset(&update_connected, 0, sizeof(update_connected));
+                               if (p->cid_num) {
+                                       update_connected.id.number = 1;
+                                       connected.id.number.valid = 1;
+                                       connected.id.number.str = (char *) p->cid_num;
+                                       connected.id.number.presentation = p->callingpres;
+                               }
+                               if (p->cid_name) {
+                                       update_connected.id.name = 1;
+                                       connected.id.name.valid = 1;
+                                       connected.id.name.str = (char *) p->cid_name;
+                                       connected.id.name.presentation = p->callingpres;
+                               }
                                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);
+                               ast_channel_queue_connected_line_update(p->owner, &connected,
+                                       &update_connected);
                        }
                        sip_handle_cc(p, req, AST_CC_CCNR);
                }
@@ -18316,12 +18369,23 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                if (!req->ignore && p->owner && (get_rpid(p, req) || !reinvite)) {
                        /* Queue a connected line update */
                        ast_party_connected_line_init(&connected);
-                       connected.id.number = (char *) p->cid_num;
-                       connected.id.name = (char *) p->cid_name;
+                       memset(&update_connected, 0, sizeof(update_connected));
+                       if (p->cid_num) {
+                               update_connected.id.number = 1;
+                               connected.id.number.valid = 1;
+                               connected.id.number.str = (char *) p->cid_num;
+                               connected.id.number.presentation = p->callingpres;
+                       }
+                       if (p->cid_name) {
+                               update_connected.id.name = 1;
+                               connected.id.name.valid = 1;
+                               connected.id.name.str = (char *) p->cid_name;
+                               connected.id.name.presentation = p->callingpres;
+                       }
                        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);
+                       ast_channel_queue_connected_line_update(p->owner, &connected,
+                               &update_connected);
                }
 
                /* Parse contact header for continued conversation */
@@ -19234,9 +19298,14 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc
                                case 302: /* Moved temporarily */
                                case 305: /* Use Proxy */
                                if (p->owner) {
-                                       struct ast_party_redirecting redirecting = {{0,},};
-                                       change_redirecting_information(p, req, &redirecting, TRUE);
-                                       ast_channel_set_redirecting(p->owner, &redirecting);
+                                       struct ast_party_redirecting redirecting;
+                                       struct ast_set_party_redirecting update_redirecting;
+
+                                       ast_party_redirecting_init(&redirecting);
+                                       change_redirecting_information(p, req, &redirecting,
+                                               &update_redirecting, TRUE);
+                                       ast_channel_set_redirecting(p->owner, &redirecting,
+                                               &update_redirecting);
                                        ast_party_redirecting_free(&redirecting);
                                }
                                        /* Fall through */
@@ -20454,13 +20523,24 @@ static int handle_request_update(struct sip_pvt *p, struct sip_request *req)
        }
        if (get_rpid(p, req)) {
                struct ast_party_connected_line connected;
+               struct ast_set_party_connected_line update_connected;
                ast_party_connected_line_init(&connected);
-               connected.id.number = (char *) p->cid_num;
-               connected.id.name = (char *) p->cid_name;
+               memset(&update_connected, 0, sizeof(update_connected));
+               if (p->cid_num) {
+                       update_connected.id.number = 1;
+                       connected.id.number.valid = 1;
+                       connected.id.number.str = (char *) p->cid_num;
+                       connected.id.number.presentation = p->callingpres;
+               }
+               if (p->cid_name) {
+                       update_connected.id.name = 1;
+                       connected.id.name.valid = 1;
+                       connected.id.name.str = (char *) p->cid_name;
+                       connected.id.name.presentation = p->callingpres;
+               }
                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);
+               ast_channel_queue_connected_line_update(p->owner, &connected, &update_connected);
        }
        transmit_response(p, "200 OK", req);
        return 0;
@@ -20486,6 +20566,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
        struct sip_peer *authpeer = NULL;       /* Matching Peer */
        int reinvite = 0;
        int rtn;
+       struct ast_party_redirecting redirecting;
+       struct ast_set_party_redirecting update_redirecting;
 
        const char *p_uac_se_hdr;       /* UAC's Session-Expires header string                      */
        const char *p_uac_min_se;       /* UAC's requested Min-SE interval (char string)            */
@@ -20783,14 +20865,26 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                        ast_clear_flag(&p->flags[0], SIP_OUTGOING);     /* This is now an inbound dialog */
                        if (get_rpid(p, req)) {
                                struct ast_party_connected_line connected;
+                               struct ast_set_party_connected_line update_connected;
 
                                ast_party_connected_line_init(&connected);
-                               connected.id.number = (char *) p->cid_num;
-                               connected.id.name = (char *) p->cid_name;
+                               memset(&update_connected, 0, sizeof(update_connected));
+                               if (p->cid_num) {
+                                       update_connected.id.number = 1;
+                                       connected.id.number.valid = 1;
+                                       connected.id.number.str = (char *) p->cid_num;
+                                       connected.id.number.presentation = p->callingpres;
+                               }
+                               if (p->cid_name) {
+                                       update_connected.id.name = 1;
+                                       connected.id.name.valid = 1;
+                                       connected.id.name.str = (char *) p->cid_name;
+                                       connected.id.name.presentation = p->callingpres;
+                               }
                                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);
+                               ast_channel_queue_connected_line_update(p->owner, &connected,
+                                       &update_connected);
                        }
                        /* Handle SDP here if we already have an owner */
                        if (find_sdp(req)) {
@@ -20958,16 +21052,19 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                        build_route(p, req, 0);
 
                        if (c) {
-                               struct ast_party_redirecting redirecting = { { 0, }, };
+                               ast_party_redirecting_init(&redirecting);
+                               memset(&update_redirecting, 0, sizeof(update_redirecting));
                                /* Pre-lock the call */
                                ast_channel_lock(c);
-                               change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
-                               ast_channel_set_redirecting(c, &redirecting);
+                               change_redirecting_information(p, req, &redirecting, &update_redirecting,
+                                       FALSE); /*Will return immediately if no Diversion header is present */
+                               ast_channel_set_redirecting(c, &redirecting, &update_redirecting);
                                ast_party_redirecting_free(&redirecting);
                        }
                }
        } else {
-               struct ast_party_redirecting redirecting = {{0,},};
+               ast_party_redirecting_init(&redirecting);
+               memset(&update_redirecting, 0, sizeof(update_redirecting));
                if (sipdebug) {
                        if (!req->ignore)
                                ast_debug(2, "Got a SIP re-invite for call %s\n", p->callid);
@@ -20977,9 +21074,9 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                if (!req->ignore)
                        reinvite = 1;
                c = p->owner;
-               change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
+               change_redirecting_information(p, req, &redirecting, &update_redirecting, FALSE); /*Will return immediately if no Diversion header is present */
                if (c) {
-                       ast_channel_set_redirecting(c, &redirecting);
+                       ast_channel_set_redirecting(c, &redirecting, &update_redirecting);
                }
                ast_party_redirecting_free(&redirecting);
        }
@@ -21448,8 +21545,8 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
                ast_indicate(target.chan1, AST_CONTROL_UNHOLD);
 
                if (target.chan2) {
-                       ast_channel_queue_connected_line_update(target.chan1, &connected_to_transferee);
-                       ast_channel_queue_connected_line_update(target.chan2, &connected_to_target);
+                       ast_channel_queue_connected_line_update(target.chan1, &connected_to_transferee, NULL);
+                       ast_channel_queue_connected_line_update(target.chan2, &connected_to_target, NULL);
                } 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.
@@ -21462,7 +21559,8 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
                        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);
+                       payload_size = ast_connected_line_build_data(connected_line_data,
+                               sizeof(connected_line_data), &connected_to_target, NULL);
                        frame_size = payload_size + sizeof(*frame_payload);
                        if (payload_size != -1 && (frame_payload = alloca(frame_size))) {
                                frame_payload->payload_size = payload_size;
@@ -21474,7 +21572,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
                         * 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_queue_connected_line_update(target.chan1, &connected_to_transferee, NULL);
 
                }
                ast_channel_unref(current->chan1);
index 6ddc3f0..3a99fbb 100644 (file)
@@ -2674,21 +2674,33 @@ static void update_connectedline(struct skinny_subchannel *sub, const void *data
        struct skinny_line *l = sub->parent;
        struct skinny_device *d = l->device;
 
-       if (ast_strlen_zero(c->cid.cid_num) || ast_strlen_zero(c->connected.id.number))
+       if (!c->caller.id.number.valid
+               || ast_strlen_zero(c->caller.id.number.str)
+               || !c->connected.id.number.valid
+               || ast_strlen_zero(c->connected.id.number.str))
                return;
 
        if (sub->owner->_state == AST_STATE_UP) {
                transmit_callstate(d, l->instance, sub->callid, SKINNY_CONNECTED);
                transmit_displaypromptstatus(d, "Connected", 0, l->instance, sub->callid);
                if (sub->outgoing)
-                       transmit_callinfo(d, c->connected.id.name, c->connected.id.number, l->cid_name, l->cid_num, l->instance, sub->callid, 1);
+                       transmit_callinfo(d,
+                               S_COR(c->connected.id.name.valid, c->connected.id.name.str, ""),
+                               c->connected.id.number.str,
+                               l->cid_name, l->cid_num, l->instance, sub->callid, 1);
                else
-                       transmit_callinfo(d, l->cid_name, l->cid_num, c->connected.id.name, c->connected.id.number, l->instance, sub->callid, 2);
+                       transmit_callinfo(d, l->cid_name, l->cid_num,
+                               S_COR(c->connected.id.name.valid, c->connected.id.name.str, ""),
+                               c->connected.id.number.str,
+                               l->instance, sub->callid, 2);
        } else {
                if (sub->outgoing) {
                        transmit_callstate(d, l->instance, sub->callid, SKINNY_RINGIN);
                        transmit_displaypromptstatus(d, "Ring-In", 0, l->instance, sub->callid);
-                       transmit_callinfo(d, c->connected.id.name, c->connected.id.number, l->cid_name, l->cid_num, l->instance, sub->callid, 1);
+                       transmit_callinfo(d,
+                               S_COR(c->connected.id.name.valid, c->connected.id.name.str, ""),
+                               c->connected.id.number.str,
+                               l->cid_name, l->cid_num, l->instance, sub->callid, 1);
                } else {
                        if (!sub->ringing) {
                                transmit_callstate(d, l->instance, sub->callid, SKINNY_RINGOUT);
@@ -2700,7 +2712,10 @@ static void update_connectedline(struct skinny_subchannel *sub, const void *data
                                sub->progress = 1;
                        }
 
-                       transmit_callinfo(d, l->cid_name, l->cid_num, c->connected.id.name, c->connected.id.number, l->instance, sub->callid, 2);
+                       transmit_callinfo(d, l->cid_name, l->cid_num,
+                               S_COR(c->connected.id.name.valid, c->connected.id.name.str, ""),
+                               c->connected.id.number.str,
+                               l->instance, sub->callid, 2);
                }
        }
 }
@@ -3759,9 +3774,15 @@ static void *skinny_newcall(void *data)
        ast_set_callerid(c,
                l->hidecallerid ? "" : l->cid_num,
                l->hidecallerid ? "" : l->cid_name,
-               c->cid.cid_ani ? NULL : l->cid_num);
-       c->connected.id.number = ast_strdup(c->exten);
-       c->connected.id.name = NULL;
+               c->caller.ani ? NULL : l->cid_num);
+#if 1  /* XXX This code is probably not necessary */
+       ast_party_number_free(&c->connected.id.number);
+       ast_party_number_init(&c->connected.id.number);
+       c->connected.id.number.valid = 1;
+       c->connected.id.number.str = ast_strdup(c->exten);
+       ast_party_name_free(&c->connected.id.name);
+       ast_party_name_init(&c->connected.id.name);
+#endif
        ast_setstate(c, AST_STATE_RING);
        if (!sub->rtp) {
                start_rtp(sub);
@@ -3852,9 +3873,12 @@ static void *skinny_ss(void *data)
                                ast_hangup(c);
                        }
                        return NULL;
-               } else if (!ast_canmatch_extension(c, c->context, d->exten, 1, c->cid.cid_num) &&
-                          ((d->exten[0] != '*') || (!ast_strlen_zero(d->exten) > 2))) {
-                       ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", d->exten, c->cid.cid_num ? c->cid.cid_num : "<Unknown Caller>", c->context);
+               } else if (!ast_canmatch_extension(c, c->context, d->exten, 1,
+                       S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))
+                       && ((d->exten[0] != '*') || (!ast_strlen_zero(d->exten) > 2))) {
+                       ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", d->exten,
+                               S_COR(c->caller.id.number.valid, c->caller.id.number.str, "<Unknown Caller>"),
+                               c->context);
                        memset(d->exten, 0, sizeof(d->exten));
                        if (l->hookstate == SKINNY_OFFHOOK) {
                                transmit_start_tone(d, SKINNY_REORDER, l->instance, sub->callid);
@@ -3925,7 +3949,10 @@ static int skinny_call(struct ast_channel *ast, char *dest, int timeout)
        transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_RINGIN);
        transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGIN);
        transmit_displaypromptstatus(d, "Ring-In", 0, l->instance, sub->callid);
-       transmit_callinfo(d, ast->connected.id.name, ast->connected.id.number, l->cid_name, l->cid_num, l->instance, sub->callid, 1);
+       transmit_callinfo(d,
+               S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
+               S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""),
+               l->cid_name, l->cid_num, l->instance, sub->callid, 1);
        transmit_lamp_indication(d, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK);
        transmit_ringer_mode(d, SKINNY_RING_INSIDE);
 
@@ -4058,7 +4085,10 @@ static int skinny_answer(struct ast_channel *ast)
        /* order matters here...
           for some reason, transmit_callinfo must be before transmit_callstate,
           or you won't get keypad messages in some situations. */
-       transmit_callinfo(d, ast->connected.id.name, ast->connected.id.number, l->lastnumberdialed, l->lastnumberdialed, l->instance, sub->callid, 2);
+       transmit_callinfo(d,
+               S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
+               S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""),
+               l->lastnumberdialed, l->lastnumberdialed, l->instance, sub->callid, 2);
        transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_CONNECTED);
        transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_CONNECTED);
        transmit_dialednumber(d, l->lastnumberdialed, l->instance, sub->callid);
@@ -4368,7 +4398,12 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s
                                transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_RINGOUT);
                                transmit_dialednumber(d, l->lastnumberdialed, l->instance, sub->callid);
                                transmit_displaypromptstatus(d, "Ring Out", 0, l->instance, sub->callid);
-                               transmit_callinfo(d, ast->cid.cid_name, ast->cid.cid_num, S_OR(ast->connected.id.name, l->lastnumberdialed), S_OR(ast->connected.id.number, l->lastnumberdialed), l->instance, sub->callid, 2); /* 2 = outgoing from phone */
+                               transmit_callinfo(d,
+                                       S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
+                                       S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
+                                       S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, l->lastnumberdialed),
+                                       S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, l->lastnumberdialed),
+                                       l->instance, sub->callid, 2); /* 2 = outgoing from phone */
                                sub->ringing = 1;
                                if (!d->earlyrtp) {
                                        break;
@@ -4409,7 +4444,12 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s
                        }
                        transmit_callstate(d, sub->parent->instance, sub->callid, SKINNY_PROGRESS);
                        transmit_displaypromptstatus(d, "Call Progress", 0, l->instance, sub->callid);
-                       transmit_callinfo(d, ast->cid.cid_name, ast->cid.cid_num, S_OR(ast->connected.id.name, l->lastnumberdialed), S_OR(ast->connected.id.number, l->lastnumberdialed), l->instance, sub->callid, 2); /* 2 = outgoing from phone */
+                       transmit_callinfo(d,
+                               S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
+                               S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
+                               S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, l->lastnumberdialed),
+                               S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, l->lastnumberdialed),
+                               l->instance, sub->callid, 2); /* 2 = outgoing from phone */
                        sub->progress = 1;
                        if (!d->earlyrtp) {
                                break;
@@ -4533,7 +4573,7 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state, const ch
 
                /* Don't use ast_set_callerid() here because it will
                 * generate a needless NewCallerID event */
-               tmp->cid.cid_ani = ast_strdup(l->cid_num);
+               tmp->caller.ani = ast_strdup(l->cid_num);
 
                tmp->priority = 1;
                tmp->adsicpe = AST_ADSI_UNAVAILABLE;
index fdc969d..3c307a6 100644 (file)
@@ -2313,7 +2313,6 @@ static void handle_dial_page(struct unistimsession *pte)
                        send_text(TEXT_LINE1, TEXT_NORMAL, pte, "and press Call");
                }
                send_text_status(pte, "Call   Redial BackSpcErase");
-
        }
 
        if (pte->device->height == 1) {
@@ -2792,7 +2791,6 @@ static void key_dial_page(struct unistimsession *pte, char keycode)
                                send_text(TEXT_LINE2, TEXT_NORMAL, pte, "previous call.");
                        }
                        send_text_status(pte, "Hangup Transf");
-
                } else
                        show_main_page(pte);
                break;
@@ -3736,13 +3734,14 @@ static int unistim_call(struct ast_channel *ast, char *dest, int timeout)
        Sendicon(TEXT_LINE0, FAV_ICON_NONE, session);
 
        if (sub->owner) {
-               if (sub->owner->connected.id.number) {
+               if (sub->owner->connected.id.number.valid
+                       && sub->owner->connected.id.number.str) {
                        if (session->device->height == 1) {
-                               send_text(TEXT_LINE0, TEXT_NORMAL, session, sub->owner->connected.id.number);
+                               send_text(TEXT_LINE0, TEXT_NORMAL, session, sub->owner->connected.id.number.str);
                        } else {
-                               send_text(TEXT_LINE1, TEXT_NORMAL, session, sub->owner->connected.id.number);
+                               send_text(TEXT_LINE1, TEXT_NORMAL, session, sub->owner->connected.id.number.str);
                        }
-                       change_callerid(session, 0, sub->owner->connected.id.number);
+                       change_callerid(session, 0, sub->owner->connected.id.number.str);
                } else {
                        if (session->device->height == 1) {
                                send_text(TEXT_LINE0, TEXT_NORMAL, session, DEFAULTCALLERID);
@@ -3751,15 +3750,15 @@ static int unistim_call(struct ast_channel *ast, char *dest, int timeout)
                        }
                        change_callerid(session, 0, DEFAULTCALLERID);
                }
-               if (sub->owner->connected.id.name) {
-                       send_text(TEXT_LINE0, TEXT_NORMAL, session, sub->owner->connected.id.name);
-                       change_callerid(session, 1, sub->owner->connected.id.name);
+               if (sub->owner->connected.id.name.valid
+                       && sub->owner->connected.id.name.str) {
+                       send_text(TEXT_LINE0, TEXT_NORMAL, session, sub->owner->connected.id.name.str);
+                       change_callerid(session, 1, sub->owner->connected.id.name.str);
                } else {
                        send_text(TEXT_LINE0, TEXT_NORMAL, session, DEFAULTCALLERNAME);
                        change_callerid(session, 1, DEFAULTCALLERNAME);
                }
        }
-
        send_text(TEXT_LINE2, TEXT_NORMAL, session, "is calling you.");
        send_text_status(session, "Accept              Ignore");
 
@@ -4567,8 +4566,12 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
                instr = ast_strdup(l->cid_num);
                if (instr) {
                        ast_callerid_parse(instr, &name, &loc);
-                       tmp->cid.cid_num = ast_strdup(loc);
-                       tmp->cid.cid_name = ast_strdup(name);
+                       tmp->caller.id.number.valid = 1;
+                       ast_free(tmp->caller.id.number.str);
+                       tmp->caller.id.number.str = ast_strdup(loc);
+                       tmp->caller.id.name.valid = 1;
+                       ast_free(tmp->caller.id.name.str);
+                       tmp->caller.id.name.str = ast_strdup(name);
                        ast_free(instr);
                }
        }
index 81c1afe..f64a2cb 100644 (file)
@@ -2201,11 +2201,10 @@ static struct ast_channel *usbradio_new(struct chan_usbradio_pvt *o, char *ext,
                ast_string_field_set(c, language, o->language);
        /* Don't use ast_set_callerid() here because it will
         * generate a needless NewCallerID event */
-       c->cid.cid_num = ast_strdup(o->cid_num);
-       c->cid.cid_ani = ast_strdup(o->cid_num);
-       c->cid.cid_name = ast_strdup(o->cid_name);
-       if (!ast_strlen_zero(ext))
-               c->cid.cid_dnid = ast_strdup(ext);
+       c->caller.ani = ast_strdup(o->cid_num);
+       if (!ast_strlen_zero(ext)) {
+               c->dialed.number.str = ast_strdup(ext);
+       }
 
        o->owner = c;
        ast_module_ref(ast_module_info->self);
index f6a3ae6..9914c59 100644 (file)
@@ -693,7 +693,9 @@ static void get_callerid(struct vpb_pvt *p)
                                        strcpy(p->cid_num, cli_struct->cldn);
                                        strcpy(p->cid_name, cli_struct->cn);
                                }
-                               ast_verb(4, "CID record - got [%s] [%s]\n", owner->cid.cid_num, owner->cid.cid_name);
+                               ast_verb(4, "CID record - got [%s] [%s]\n",
+                                       S_COR(owner->caller.id.number.valid, owner->caller.id.number.str, ""),
+                                       S_COR(owner->caller.id.name.valid, owner->caller.id.name.str, ""));
                                snprintf(p->callerid, sizeof(p->callerid), "%s %s", cli_struct->cldn, cli_struct->cn);
                        } else {
                                ast_log(LOG_ERROR, "CID record - No caller id avalable on %s \n", p->dev);
@@ -778,19 +780,15 @@ static void get_callerid_ast(struct vpb_pvt *p)
        } else {
                ast_log(LOG_ERROR, "%s: Failed to create Caller ID struct\n", p->dev);
        }
-       if (owner->cid.cid_num) {
-               ast_free(owner->cid.cid_num);
-               owner->cid.cid_num = NULL;
-       }
-       if (owner->cid.cid_name) {
-               ast_free(owner->cid.cid_name);
-               owner->cid.cid_name = NULL;
-       }
+       ast_party_number_free(&owner->caller.id.number);
+       ast_party_number_init(&owner->caller.id.number);
+       ast_party_name_free(&owner->caller.id.name);
+       ast_party_name_init(&owner->caller.id.name);
        if (number)
                ast_shrink_phone_number(number);
        ast_set_callerid(owner,
                number, name,
-               owner->cid.cid_ani ? NULL : number);
+               owner->caller.ani ? NULL : number);
        if (!ast_strlen_zero(name)){
                snprintf(p->callerid, sizeof(p->callerid), "%s %s", number, name);
        } else {
@@ -901,7 +899,8 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
                                if (strcmp(p->owner->exten, "fax")) {
                                        const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
 
-                                       if (ast_exists_extension(p->owner, target_context, "fax", 1, p->owner->cid.cid_num)) {
+                                       if (ast_exists_extension(p->owner, target_context, "fax", 1,
+                                               S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
                                                ast_verb(3, "Redirecting %s to fax extension\n", p->owner->name);
                                                /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
                                                pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
index 1f92d24..feb0d5f 100644 (file)
@@ -351,16 +351,18 @@ static int analog_unalloc_sub(struct analog_pvt *p, enum analog_sub x)
        return 0;
 }
 
-static int analog_send_callerid(struct analog_pvt *p, int cwcid, struct ast_callerid *cid)
+static int analog_send_callerid(struct analog_pvt *p, int cwcid, struct ast_party_caller *caller)
 {
-       ast_debug(1, "Sending callerid.  CID_NAME: '%s' CID_NUM: '%s'\n", cid->cid_name, cid->cid_num);
+       ast_debug(1, "Sending callerid.  CID_NAME: '%s' CID_NUM: '%s'\n",
+               caller->id.name.str,
+               caller->id.number.str);
 
        if (cwcid) {
                p->callwaitcas = 0;
        }
 
        if (p->calls->send_callerid) {
-               return p->calls->send_callerid(p->chan_pvt, cwcid, cid);
+               return p->calls->send_callerid(p->chan_pvt, cwcid, caller);
        }
        return 0;
 }
@@ -860,7 +862,9 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
        char *c, *n, *l;
        char dest[256]; /* must be same length as p->dialdest */
 
-       ast_log(LOG_DEBUG, "CALLING CID_NAME: %s CID_NUM:: %s\n", ast->connected.id.name, ast->connected.id.number);
+       ast_log(LOG_DEBUG, "CALLING CID_NAME: %s CID_NUM:: %s\n",
+               S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
+               S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""));
 
        ast_copy_string(dest, rdest, sizeof(dest));
        ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
@@ -916,13 +920,13 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
                        }
                        analog_set_dialing(p, 1);
                } else {
-                       if (ast->connected.id.number) {
-                               ast_copy_string(p->callwait_num, ast->connected.id.number, sizeof(p->callwait_num));
+                       if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+                               ast_copy_string(p->callwait_num, ast->connected.id.number.str, sizeof(p->callwait_num));
                        } else {
                                p->callwait_num[0] = '\0';
                        }
-                       if (ast->connected.id.name) {
-                               ast_copy_string(p->callwait_name, ast->connected.id.name, sizeof(p->callwait_name));
+                       if (ast->connected.id.name.valid && ast->connected.id.name.str) {
+                               ast_copy_string(p->callwait_name, ast->connected.id.name.str, sizeof(p->callwait_name));
                        } else {
                                p->callwait_name[0] = '\0';
                        }
@@ -937,8 +941,8 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
                        }
 
                }
-               n = ast->connected.id.name;
-               l = ast->connected.id.number;
+               n = ast->connected.id.name.valid ? ast->connected.id.name.str : NULL;
+               l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
                if (l) {
                        ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
                } else {
@@ -951,8 +955,8 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
                }
 
                if (p->use_callerid) {
-                       p->cid.cid_name = p->lastcid_name;
-                       p->cid.cid_num = p->lastcid_num;
+                       p->caller.id.name.str = p->lastcid_name;
+                       p->caller.id.number.str = p->lastcid_num;
                }
 
                ast_setstate(ast, AST_STATE_RINGING);
@@ -1025,7 +1029,7 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
 
                switch (mysig) {
                case ANALOG_SIG_FEATD:
-                       l = ast->connected.id.number;
+                       l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
                        if (l) {
                                snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c);
                        } else {
@@ -1033,7 +1037,7 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int
                        }
                        break;
                case ANALOG_SIG_FEATDMF:
-                       l = ast->connected.id.number;
+                       l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
                        if (l) {
                                snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c);
                        } else {
@@ -1408,9 +1412,9 @@ void analog_handle_dtmfup(struct analog_pvt *p, struct ast_channel *ast, enum an
        if (p->callwaitcas) {
                if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
                        ast_debug(1, "Got some DTMF, but it's for the CAS\n");
-                       p->cid.cid_name = p->callwait_name;
-                       p->cid.cid_num = p->callwait_num;
-                       analog_send_callerid(p, 1, &p->cid);
+                       p->caller.id.name.str = p->callwait_name;
+                       p->caller.id.number.str = p->callwait_num;
+                       analog_send_callerid(p, 1, &p->caller);
                }
                if (analog_handles_digit(f))
                        p->callwaitcas = 0;
@@ -1820,7 +1824,8 @@ static void *__analog_ss_thread(void *data)
 
                analog_dsp_set_digitmode(p, ANALOG_DIGITMODE_DTMF);
 
-               if (ast_exists_extension(chan, chan->context, exten, 1, chan->cid.cid_num)) {
+               if (ast_exists_extension(chan, chan->context, exten, 1,
+                       chan->caller.id.number.valid ? chan->caller.id.number.str : NULL)) {
                        ast_copy_string(chan->exten, exten, sizeof(chan->exten));
                        analog_dsp_reset_and_flush_digits(p);
                        res = ast_pbx_run(chan);
@@ -1976,14 +1981,10 @@ static void *__analog_ss_thread(void *data)
                                ast_verb(3, "Disabling Caller*ID on %s\n", chan->name);
                                /* Disable Caller*ID if enabled */
                                p->hidecallerid = 1;
-                               if (chan->cid.cid_num) {
-                                       free(chan->cid.cid_num);
-                               }
-                               chan->cid.cid_num = NULL;
-                               if (chan->cid.cid_name) {
-                                       free(chan->cid.cid_name);
-                               }
-                               chan->cid.cid_name = NULL;
+                               ast_party_number_free(&chan->caller.id.number);
+                               ast_party_number_init(&chan->caller.id.number);
+                               ast_party_name_free(&chan->caller.id.name);
+                               ast_party_name_init(&chan->caller.id.name);
                                res = analog_play_tone(p, index, ANALOG_TONE_DIALRECALL);
                                if (res) {
                                        ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",
@@ -2055,14 +2056,6 @@ static void *__analog_ss_thread(void *data)
                                ast_verb(3, "Enabling Caller*ID on %s\n", chan->name);
                                /* Enable Caller*ID if enabled */
                                p->hidecallerid = 0;
-                               if (chan->cid.cid_num) {
-                                       free(chan->cid.cid_num);
-                               }
-                               chan->cid.cid_num = NULL;
-                               if (chan->cid.cid_name) {
-                                       free(chan->cid.cid_name);
-                               }
-                               chan->cid.cid_name = NULL;
                                ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);
                                res = analog_play_tone(p, index, ANALOG_TONE_DIALRECALL);
                                if (res) {
@@ -2108,9 +2101,13 @@ static void *__analog_ss_thread(void *data)
                                        ast_hangup(chan);
                                        goto quit;
                                }
-                       } else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
-                                                       ((exten[0] != '*') || (strlen(exten) > 2))) {
-                               ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+                       } else if (!ast_canmatch_extension(chan, chan->context, exten, 1,
+                               chan->caller.id.number.valid ? chan->caller.id.number.str : NULL)
+                               && ((exten[0] != '*') || (strlen(exten) > 2))) {
+                               ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
+                                       chan->caller.id.number.valid && chan->caller.id.number.str
+                                               ? chan->caller.id.number.str : "<Unknown Caller>",
+                                       chan->context);
                                break;
                        }
                        if (!timeout) {
@@ -2799,7 +2796,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                if (p->inalarm) break;
                ast->rings++;
                if (ast->rings == p->cidrings) {
-                       analog_send_callerid(p, 0, &p->cid);
+                       analog_send_callerid(p, 0, &p->caller);
                }
 
                if (ast->rings > p->cidrings) {
@@ -2869,20 +2866,26 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                }
                                ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
                        } else if (!p->subs[ANALOG_SUB_THREEWAY].owner) {
-                               char cid_num[256];
-                               char cid_name[256];
-
                                if (!p->threewaycalling) {
                                        /* Just send a flash if no 3-way calling */
                                        ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_FLASH);
                                        goto winkflashdone;
                                } else if (!analog_check_for_conference(p)) {
+                                       char cid_num[256];
+                                       char cid_name[256];
+
+                                       cid_num[0] = '\0';
+                                       cid_name[0] = '\0';
                                        if (p->dahditrcallerid && p->owner) {
-                                               if (p->owner->cid.cid_num) {
-                                                       ast_copy_string(cid_num, p->owner->cid.cid_num, sizeof(cid_num));
+                                               if (p->owner->caller.id.number.valid
+                                                       && p->owner->caller.id.number.str) {
+                                                       ast_copy_string(cid_num, p->owner->caller.id.number.str,
+                                                               sizeof(cid_num));
                                                }
-                                               if (p->owner->cid.cid_name) {
-                                                       ast_copy_string(cid_name, p->owner->cid.cid_name, sizeof(cid_name));
+                                               if (p->owner->caller.id.name.valid
+                                                       && p->owner->caller.id.name.str) {
+                                                       ast_copy_string(cid_name, p->owner->caller.id.name.str,
+                                                               sizeof(cid_name));
                                                }
                                        }
                                        /* XXX This section needs much more error checking!!! XXX */
@@ -3035,8 +3038,11 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                case ANALOG_SIG_FEATDMF_TA:
                        switch (p->whichwink) {
                        case 0:
-                               ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
-                               snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+                               ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->caller.ani2,
+                                       S_OR(p->owner->caller.ani, ""));
+                               snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#",
+                                       p->owner->caller.ani2,
+                                       S_OR(p->owner->caller.ani, ""));
                                break;
                        case 1:
                                ast_copy_string(p->dop.dialstr, p->finaldial, sizeof(p->dop.dialstr));
index bc9f926..3f75e58 100644 (file)
@@ -156,7 +156,7 @@ struct analog_callback {
        int (* const train_echocanceller)(void *pvt);
        int (* const dsp_set_digitmode)(void *pvt, enum analog_dsp_digitmode mode);
        int (* const dsp_reset_and_flush_digits)(void *pvt);
-       int (* const send_callerid)(void *pvt, int cwcid, struct ast_callerid *cid);
+       int (* const send_callerid)(void *pvt, int cwcid, struct ast_party_caller *caller);
        /* Returns 0 if CID received.  Returns 1 if event received, and -1 if error.  name and num are size ANALOG_MAX_CID */
        int (* const get_callerid)(void *pvt, char *name, char *num, enum analog_event *ev, size_t timeout);
        /* Start CID detection */
@@ -298,7 +298,7 @@ struct analog_pvt {
        char callwait_name[AST_MAX_EXTENSION];
        char lastcid_num[AST_MAX_EXTENSION];
        char lastcid_name[AST_MAX_EXTENSION];
-       struct ast_callerid cid;
+       struct ast_party_caller caller;
        int cidrings;                                   /*!< Which ring to deliver CID on */
        char echorest[20];
        int polarity;
index e7b059f..6b6a25e 100644 (file)
@@ -206,16 +206,22 @@ static void sig_pri_set_caller_id(struct sig_pri_chan *p)
 
        if (p->calls->set_callerid) {
                ast_party_caller_init(&caller);
-               caller.id.number = p->cid_num;
-               caller.id.name = p->cid_name;
+
+               caller.id.name.str = p->cid_name;
+               caller.id.name.presentation = p->callingpres;
+               caller.id.name.valid = 1;
+
+               caller.id.number.str = p->cid_num;
+               caller.id.number.plan = p->cid_ton;
+               caller.id.number.presentation = p->callingpres;
+               caller.id.number.valid = 1;
+
                if (!ast_strlen_zero(p->cid_subaddr)) {
                        caller.id.subaddress.valid = 1;
                        //caller.id.subaddress.type = 0;/* nsap */
                        //caller.id.subaddress.odd_even_indicator = 0;
                        caller.id.subaddress.str = p->cid_subaddr;
                }
-               caller.id.number_type = p->cid_ton;
-               caller.id.number_presentation = p->callingpres;
                caller.id.tag = p->user_tag;
                caller.ani = p->cid_ani;
                caller.ani2 = p->cid_ani2;
@@ -454,76 +460,102 @@ static int ast_to_pri_presentation(int ast_presentation)
 
 /*!
  * \internal
- * \brief Determine the overall presentation value for the given party.
+ * \brief Convert PRI name char_set to asterisk version.
  * \since 1.8
  *
- * \param id Party to determine the overall presentation value.
+ * \param pri_char_set PRI name char_set.
  *
- * \return Overall presentation value for the given party converted to ast values.
+ * \return Equivalent asterisk name char_set value.
  */
-static int overall_ast_presentation(const struct pri_party_id *id)
-{
-       int number_priority;
-       int number_value;
-       int number_screening;
-       int name_priority;
-       int name_value;
-
-       /* Determine name presentation priority. */
-       if (!id->name.valid) {
-               name_value = PRI_PRES_UNAVAILABLE;
-               name_priority = 3;
-       } else {
-               name_value = id->name.presentation & PRI_PRES_RESTRICTION;
-               switch (name_value) {
-               case PRI_PRES_RESTRICTED:
-                       name_priority = 0;
-                       break;
-               case PRI_PRES_ALLOWED:
-                       name_priority = 1;
-                       break;
-               case PRI_PRES_UNAVAILABLE:
-                       name_priority = 2;
-                       break;
-               default:
-                       name_value = PRI_PRES_UNAVAILABLE;
-                       name_priority = 3;
-                       break;
-               }
-       }
+static enum AST_PARTY_CHAR_SET pri_to_ast_char_set(int pri_char_set)
+{
+       enum AST_PARTY_CHAR_SET ast_char_set;
 
-       /* Determine number presentation priority. */
-       if (!id->number.valid) {
-               number_screening = PRI_PRES_USER_NUMBER_UNSCREENED;
-               number_value = PRI_PRES_UNAVAILABLE;
-               number_priority = 3;
-       } else {
-               number_screening = id->number.presentation & PRI_PRES_NUMBER_TYPE;
-               number_value = id->number.presentation & PRI_PRES_RESTRICTION;
-               switch (number_value) {
-               case PRI_PRES_RESTRICTED:
-                       number_priority = 0;
-                       break;
-               case PRI_PRES_ALLOWED:
-                       number_priority = 1;
-                       break;
-               case PRI_PRES_UNAVAILABLE:
-                       number_priority = 2;
-                       break;
-               default:
-                       number_screening = PRI_PRES_USER_NUMBER_UNSCREENED;
-                       number_value = PRI_PRES_UNAVAILABLE;
-                       number_priority = 3;
-                       break;
-               }
+       switch (pri_char_set) {
+       default:
+       case PRI_CHAR_SET_UNKNOWN:
+               ast_char_set = AST_PARTY_CHAR_SET_UNKNOWN;
+               break;
+       case PRI_CHAR_SET_ISO8859_1:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_1;
+               break;
+       case PRI_CHAR_SET_WITHDRAWN:
+               ast_char_set = AST_PARTY_CHAR_SET_WITHDRAWN;
+               break;
+       case PRI_CHAR_SET_ISO8859_2:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_2;
+               break;
+       case PRI_CHAR_SET_ISO8859_3:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_3;
+               break;
+       case PRI_CHAR_SET_ISO8859_4:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_4;
+               break;
+       case PRI_CHAR_SET_ISO8859_5:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_5;
+               break;
+       case PRI_CHAR_SET_ISO8859_7:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO8859_7;
+               break;
+       case PRI_CHAR_SET_ISO10646_BMPSTRING:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO10646_BMPSTRING;
+               break;
+       case PRI_CHAR_SET_ISO10646_UTF_8STRING:
+               ast_char_set = AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING;
+               break;
        }
 
-       /* Select the wining presentation value. */
-       if (name_priority < number_priority) {
-               number_value = name_value;
+       return ast_char_set;
+}
+
+/*!
+ * \internal
+ * \brief Convert asterisk name char_set to PRI version.
+ * \since 1.8
+ *
+ * \param ast_char_set Asterisk name char_set.
+ *
+ * \return Equivalent PRI name char_set value.
+ */
+static int ast_to_pri_char_set(enum AST_PARTY_CHAR_SET ast_char_set)
+{
+       int pri_char_set;
+
+       switch (ast_char_set) {
+       default:
+       case AST_PARTY_CHAR_SET_UNKNOWN:
+               pri_char_set = PRI_CHAR_SET_UNKNOWN;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_1:
+               pri_char_set = PRI_CHAR_SET_ISO8859_1;
+               break;
+       case AST_PARTY_CHAR_SET_WITHDRAWN:
+               pri_char_set = PRI_CHAR_SET_WITHDRAWN;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_2:
+               pri_char_set = PRI_CHAR_SET_ISO8859_2;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_3:
+               pri_char_set = PRI_CHAR_SET_ISO8859_3;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_4:
+               pri_char_set = PRI_CHAR_SET_ISO8859_4;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_5:
+               pri_char_set = PRI_CHAR_SET_ISO8859_5;
+               break;
+       case AST_PARTY_CHAR_SET_ISO8859_7:
+               pri_char_set = PRI_CHAR_SET_ISO8859_7;
+               break;
+       case AST_PARTY_CHAR_SET_ISO10646_BMPSTRING:
+               pri_char_set = PRI_CHAR_SET_ISO10646_BMPSTRING;
+               break;
+       case AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING:
+               pri_char_set = PRI_CHAR_SET_ISO10646_UTF_8STRING;
+               break;
        }
 
-       return pri_to_ast_presentation(number_value | number_screening);
+       return pri_char_set;
 }
 
 #if defined(HAVE_PRI_SUBADDR)
@@ -690,6 +722,56 @@ static void sig_pri_party_subaddress_from_ast(struct pri_party_subaddress *pri_s
 
 /*!
  * \internal
+ * \brief Fill in the PRI party name from the given asterisk party name.
+ * \since 1.8
+ *
+ * \param pri_name PRI party name structure.
+ * \param ast_name Asterisk party name structure.
+ *
+ * \return Nothing
+ *
+ * \note Assumes that pri_name has been previously memset to zero.
+ */
+static void sig_pri_party_name_from_ast(struct pri_party_name *pri_name, const struct ast_party_name *ast_name)
+{
+       if (!ast_name->valid) {
+               return;
+       }
+       pri_name->valid = 1;
+       pri_name->presentation = ast_to_pri_presentation(ast_name->presentation);
+       pri_name->char_set = ast_to_pri_char_set(ast_name->char_set);
+       if (!ast_strlen_zero(ast_name->str)) {
+               ast_copy_string(pri_name->str, ast_name->str, sizeof(pri_name->str));
+       }
+}
+
+/*!
+ * \internal
+ * \brief Fill in the PRI party number from the given asterisk party number.
+ * \since 1.8
+ *
+ * \param pri_number PRI party number structure.
+ * \param ast_number Asterisk party number structure.
+ *
+ * \return Nothing
+ *
+ * \note Assumes that pri_number has been previously memset to zero.
+ */
+static void sig_pri_party_number_from_ast(struct pri_party_number *pri_number, const struct ast_party_number *ast_number)
+{
+       if (!ast_number->valid) {
+               return;
+       }
+       pri_number->valid = 1;
+       pri_number->presentation = ast_to_pri_presentation(ast_number->presentation);
+       pri_number->plan = ast_number->plan;
+       if (!ast_strlen_zero(ast_number->str)) {
+               ast_copy_string(pri_number->str, ast_number->str, sizeof(pri_number->str));
+       }
+}
+
+/*!
+ * \internal
  * \brief Fill in the PRI party id from the given asterisk party id.
  * \since 1.8
  *
@@ -702,21 +784,8 @@ static void sig_pri_party_subaddress_from_ast(struct pri_party_subaddress *pri_s
  */
 static void sig_pri_party_id_from_ast(struct pri_party_id *pri_id, const struct ast_party_id *ast_id)
 {
-       int presentation;
-
-       presentation = ast_to_pri_presentation(ast_id->number_presentation);
-       if (!ast_strlen_zero(ast_id->name)) {
-               pri_id->name.valid = 1;
-               pri_id->name.presentation = presentation;
-               pri_id->name.char_set = PRI_CHAR_SET_ISO8859_1;
-               ast_copy_string(pri_id->name.str, ast_id->name, sizeof(pri_id->name.str));
-       }
-       if (!ast_strlen_zero(ast_id->number)) {
-               pri_id->number.valid = 1;
-               pri_id->number.presentation = presentation;
-               pri_id->number.plan = ast_id->number_type;
-               ast_copy_string(pri_id->number.str, ast_id->number, sizeof(pri_id->number.str));
-       }
+       sig_pri_party_name_from_ast(&pri_id->name, &ast_id->name);
+       sig_pri_party_number_from_ast(&pri_id->number, &ast_id->number);
 #if defined(HAVE_PRI_SUBADDR)
        sig_pri_party_subaddress_from_ast(&pri_id->subaddress, &ast_id->subaddress);
 #endif /* defined(HAVE_PRI_SUBADDR) */
@@ -1488,10 +1557,8 @@ static void *pri_ss_thread(void *data)
                exten[0] = 's';
                exten[1] = '\0';
        } else {
-               if (chan->cid.cid_dnid) {
-                       ast_free(chan->cid.cid_dnid);
-               }
-               chan->cid.cid_dnid = ast_strdup(exten);
+               ast_free(chan->dialed.number.str);
+               chan->dialed.number.str = ast_strdup(exten);
 
                if (p->pri->append_msn_to_user_tag && p->pri->nodetype != PRI_NETWORK) {
                        /*
@@ -1500,8 +1567,8 @@ static void *pri_ss_thread(void *data)
                         */
                        snprintf(p->user_tag, sizeof(p->user_tag), "%s_%s", p->pri->initial_user_tag,
                                exten);
-                       ast_free(chan->cid.cid_tag);
-                       chan->cid.cid_tag = ast_strdup(p->user_tag);
+                       ast_free(chan->caller.id.tag);
+                       chan->caller.id.tag = ast_strdup(p->user_tag);
                }
        }
        sig_pri_play_tone(p, -1);
@@ -1556,6 +1623,52 @@ void pri_event_noalarm(struct sig_pri_pri *pri, int index, int before_start_pri)
 
 /*!
  * \internal
+ * \brief Convert libpri party name into asterisk party name.
+ * \since 1.8
+ *
+ * \param ast_name Asterisk party name structure to fill.  Must already be set initialized.
+ * \param pri_name libpri party name structure containing source information.
+ *
+ * \note The filled in ast_name structure needs to be destroyed by
+ * ast_party_name_free() when it is no longer needed.
+ *
+ * \return Nothing
+ */
+static void sig_pri_party_name_convert(struct ast_party_name *ast_name, const struct pri_party_name *pri_name)
+{
+       ast_name->str = ast_strdup(pri_name->str);
+       ast_name->char_set = pri_to_ast_char_set(pri_name->char_set);
+       ast_name->presentation = pri_to_ast_presentation(pri_name->presentation);
+       ast_name->valid = 1;
+}
+
+/*!
+ * \internal
+ * \brief Convert libpri party number into asterisk party number.
+ * \since 1.8
+ *
+ * \param ast_number Asterisk party number structure to fill.  Must already be set initialized.
+ * \param pri_number libpri party number structure containing source information.
+ * \param pri Span controlling structure.
+ *
+ * \note The filled in ast_number structure needs to be destroyed by
+ * ast_party_number_free() when it is no longer needed.
+ *
+ * \return Nothing
+ */
+static void sig_pri_party_number_convert(struct ast_party_number *ast_number, const struct pri_party_number *pri_number, struct sig_pri_pri *pri)
+{
+       char number[AST_MAX_EXTENSION];
+
+       apply_plan_to_number(number, sizeof(number), pri, pri_number->str, pri_number->plan);
+       ast_number->str = ast_strdup(number);
+       ast_number->plan = pri_number->plan;
+       ast_number->presentation = pri_to_ast_presentation(pri_number->presentation);
+       ast_number->valid = 1;
+}
+
+/*!
+ * \internal
  * \brief Convert libpri party id into asterisk party id.
  * \since 1.8
  *
@@ -1568,22 +1681,13 @@ void pri_event_noalarm(struct sig_pri_pri *pri, int index, int before_start_pri)
  *
  * \return Nothing
  */
-static void sig_pri_party_id_convert(struct ast_party_id *ast_id,
-       const struct pri_party_id *pri_id, struct sig_pri_pri *pri)
+static void sig_pri_party_id_convert(struct ast_party_id *ast_id, const struct pri_party_id *pri_id, struct sig_pri_pri *pri)
 {
-       char number[AST_MAX_EXTENSION];
-
        if (pri_id->name.valid) {
-               ast_id->name = ast_strdup(pri_id->name.str);
+               sig_pri_party_name_convert(&ast_id->name, &pri_id->name);
        }
        if (pri_id->number.valid) {
-               apply_plan_to_number(number, sizeof(number), pri, pri_id->number.str,
-                       pri_id->number.plan);
-               ast_id->number = ast_strdup(number);
-               ast_id->number_type = pri_id->number.plan;
-       }
-       if (pri_id->name.valid || pri_id->number.valid) {
-               ast_id->number_presentation = overall_ast_presentation(pri_id);
+               sig_pri_party_number_convert(&ast_id->number, &pri_id->number, pri);
        }
 #if defined(HAVE_PRI_SUBADDR)
        if (pri_id->subaddress.valid) {
@@ -1667,13 +1771,41 @@ static int sig_pri_msn_match(const char *msn_patterns, const char *exten)
  */
 static void sig_pri_event_party_id(struct ast_str **msg, const char *prefix, struct ast_party_id *party)
 {
-       ast_str_append(msg, 0, "%sPres: %d (%s)\r\n", prefix,
-               party->number_presentation,
-               ast_describe_caller_presentation(party->number_presentation));
-       ast_str_append(msg, 0, "%sNum: %s\r\n", prefix, S_OR(party->number, ""));
-       ast_str_append(msg, 0, "%ston: %d\r\n", prefix, party->number_type);
-       ast_str_append(msg, 0, "%sName: %s\r\n", prefix, S_OR(party->name, ""));
+       int pres;
+
+       /* Combined party presentation */
+       pres = ast_party_id_presentation(party);
+       ast_str_append(msg, 0, "%sPres: %d (%s)\r\n", prefix, pres,
+               ast_describe_caller_presentation(pres));
+
+       /* Party number */
+       ast_str_append(msg, 0, "%sNumValid: %d\r\n", prefix,
+               (unsigned) party->number.valid);
+       ast_str_append(msg, 0, "%sNum: %s\r\n", prefix,
+               S_COR(party->number.valid, party->number.str, ""));
+       ast_str_append(msg, 0, "%ston: %d\r\n", prefix, party->number.plan);
+       if (party->number.valid) {
+               ast_str_append(msg, 0, "%sNumPlan: %d\r\n", prefix, party->number.plan);
+               ast_str_append(msg, 0, "%sNumPres: %d (%s)\r\n", prefix,
+                       party->number.presentation,
+                       ast_describe_caller_presentation(party->number.presentation));
+       }
+
+       /* Party name */
+       ast_str_append(msg, 0, "%sNameValid: %d\r\n", prefix,
+               (unsigned) party->name.valid);
+       ast_str_append(msg, 0, "%sName: %s\r\n", prefix,
+               S_COR(party->name.valid, party->name.str, ""));
+       if (party->name.valid) {
+               ast_str_append(msg, 0, "%sNameCharSet: %s\r\n", prefix,
+                       ast_party_name_charset_describe(party->name.char_set));
+               ast_str_append(msg, 0, "%sNamePres: %d (%s)\r\n", prefix,
+                       party->name.presentation,
+                       ast_describe_caller_presentation(party->name.presentation));
+       }
+
 #if defined(HAVE_PRI_SUBADDR)
+       /* Party subaddress */
        if (party->subaddress.valid) {
                static const char subaddress[] = "Subaddr";
 
@@ -3479,27 +3611,28 @@ static void sig_pri_handle_subcmds(struct sig_pri_pri *pri, int chanpos, int eve
                                ast_connected.id.tag = ast_strdup(pri->pvts[chanpos]->user_tag);
 
                                caller_id_update = 0;
-                               if (ast_connected.id.name) {
+                               if (ast_connected.id.name.str) {
                                        /* Save name for Caller-ID update */
                                        ast_copy_string(pri->pvts[chanpos]->cid_name,
-                                               ast_connected.id.name, sizeof(pri->pvts[chanpos]->cid_name));
+                                               ast_connected.id.name.str, sizeof(pri->pvts[chanpos]->cid_name));
                                        caller_id_update = 1;
     &nbs