diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_agent.c | 13 | ||||
-rw-r--r-- | channels/chan_console.c | 4 | ||||
-rw-r--r-- | channels/chan_dahdi.c | 107 | ||||
-rw-r--r-- | channels/chan_gtalk.c | 8 | ||||
-rw-r--r-- | channels/chan_h323.c | 30 | ||||
-rw-r--r-- | channels/chan_iax2.c | 68 | ||||
-rw-r--r-- | channels/chan_jingle.c | 10 | ||||
-rw-r--r-- | channels/chan_local.c | 23 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 30 | ||||
-rw-r--r-- | channels/chan_misdn.c | 225 | ||||
-rw-r--r-- | channels/chan_oss.c | 18 | ||||
-rw-r--r-- | channels/chan_phone.c | 15 | ||||
-rw-r--r-- | channels/chan_sip.c | 300 | ||||
-rw-r--r-- | channels/chan_skinny.c | 72 | ||||
-rw-r--r-- | channels/chan_unistim.c | 27 | ||||
-rw-r--r-- | channels/chan_usbradio.c | 9 | ||||
-rw-r--r-- | channels/chan_vpb.cc | 21 | ||||
-rw-r--r-- | channels/sig_analog.c | 100 | ||||
-rw-r--r-- | channels/sig_analog.h | 4 | ||||
-rw-r--r-- | channels/sig_pri.c | 398 | ||||
-rw-r--r-- | channels/sig_ss7.c | 20 |
21 files changed, 961 insertions, 541 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index dfbf2284d..c12900582 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -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)); diff --git a/channels/chan_console.c b/channels/chan_console.c index 9d68e9f52..99b673b6c 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -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); diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index e035b4bfe..e807b957a 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -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) diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 1252bde19..4101d52f9 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -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); diff --git a/channels/chan_h323.c b/channels/chan_h323.c index a8aa9b7d0..1866ce038 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -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; diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index e6bce413d..97752f63a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -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); diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 560d3ec17..d57644cb1 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -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); diff --git a/channels/chan_local.c b/channels/chan_local.c index c3723947e..36dcc94c9 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -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); diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 63dcb936d..b0bd1cc97 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -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) diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index cddfd65cc..7e1f14af7 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -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; diff --git a/channels/chan_oss.c b/channels/chan_oss.c index aea48730f..b2776850d 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -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"); diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 389f30401..18eaf8fa1 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -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); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5d6d2f198..8dc4c5dbe 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -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); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 6ddc3f0cf..3a99fbbcd 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -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; diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index fdc969d86..3c307a682 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -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); } } diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c index 81c1afe55..f64a2cb10 100644 --- a/channels/chan_usbradio.c +++ b/channels/chan_usbradio.c @@ -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); diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index f6a3ae6a5..9914c59c3 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -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); diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 1f92d24d9..feb0d5fdb 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -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)); diff --git a/channels/sig_analog.h b/channels/sig_analog.h index bc9f9260d..3f75e5827 100644 --- a/channels/sig_analog.h +++ b/channels/sig_analog.h @@ -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; diff --git a/channels/sig_pri.c b/channels/sig_pri.c index e7b059fa7..6b6a25e6d 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -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; } - if (ast_connected.id.number) { + if (ast_connected.id.number.str) { /* Save number for Caller-ID update */ - ast_copy_string(pri->pvts[chanpos]->cid_num, ast_connected.id.number, - sizeof(pri->pvts[chanpos]->cid_num)); - pri->pvts[chanpos]->cid_ton = ast_connected.id.number_type; + ast_copy_string(pri->pvts[chanpos]->cid_num, + ast_connected.id.number.str, sizeof(pri->pvts[chanpos]->cid_num)); + pri->pvts[chanpos]->cid_ton = ast_connected.id.number.plan; caller_id_update = 1; } else { - ast_connected.id.number = ast_strdup(""); + ast_connected.id.number.valid = 1; + ast_connected.id.number.str = ast_strdup(""); } ast_connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; pri->pvts[chanpos]->cid_subaddr[0] = '\0'; #if defined(HAVE_PRI_SUBADDR) if (ast_connected.id.subaddress.valid) { - ast_party_subaddress_set(&owner->cid.subaddress, + ast_party_subaddress_set(&owner->caller.id.subaddress, &ast_connected.id.subaddress); if (ast_connected.id.subaddress.str) { ast_copy_string(pri->pvts[chanpos]->cid_subaddr, @@ -3510,17 +3643,17 @@ static void sig_pri_handle_subcmds(struct sig_pri_pri *pri, int chanpos, int eve #endif /* defined(HAVE_PRI_SUBADDR) */ if (caller_id_update) { pri->pvts[chanpos]->callingpres = - ast_connected.id.number_presentation; + ast_party_id_presentation(&ast_connected.id); sig_pri_set_caller_id(pri->pvts[chanpos]); - ast_set_callerid(owner, S_OR(ast_connected.id.number, NULL), - S_OR(ast_connected.id.name, NULL), - S_OR(ast_connected.id.number, NULL)); + ast_set_callerid(owner, S_OR(ast_connected.id.number.str, NULL), + S_OR(ast_connected.id.name.str, NULL), + S_OR(ast_connected.id.number.str, NULL)); } /* Update the connected line information on the other channel */ if (event_id != PRI_EVENT_RING) { /* This connected_line update was not from a SETUP message. */ - ast_channel_queue_connected_line_update(owner, &ast_connected); + ast_channel_queue_connected_line_update(owner, &ast_connected, NULL); } ast_party_connected_line_free(&ast_connected); @@ -3538,10 +3671,10 @@ static void sig_pri_handle_subcmds(struct sig_pri_pri *pri, int chanpos, int eve /*! \todo XXX Original called data can be put in a channel data store that is inherited. */ - ast_channel_set_redirecting(owner, &ast_redirecting); + ast_channel_set_redirecting(owner, &ast_redirecting, NULL); if (event_id != PRI_EVENT_RING) { /* This redirection was not from a SETUP message. */ - ast_channel_queue_redirecting_update(owner, &ast_redirecting); + ast_channel_queue_redirecting_update(owner, &ast_redirecting, NULL); } ast_party_redirecting_free(&ast_redirecting); @@ -3588,7 +3721,7 @@ static void sig_pri_handle_subcmds(struct sig_pri_pri *pri, int chanpos, int eve &owner->redirecting, pri); ast_redirecting.from.tag = ast_strdup(pri->pvts[chanpos]->user_tag); ast_redirecting.to.tag = ast_strdup(pri->pvts[chanpos]->user_tag); - ast_channel_set_redirecting(owner, &ast_redirecting); + ast_channel_set_redirecting(owner, &ast_redirecting, NULL); ast_party_redirecting_free(&ast_redirecting); /* @@ -4549,7 +4682,7 @@ static void *pri_dchannel(void *vpri) /* Set Calling Subaddress */ sig_pri_lock_owner(pri, chanpos); sig_pri_set_subaddress( - &pri->pvts[chanpos]->owner->cid.subaddress, + &pri->pvts[chanpos]->owner->caller.id.subaddress, &e->ring.calling.subaddress); if (!e->ring.calling.subaddress.type && !ast_strlen_zero( @@ -4564,7 +4697,7 @@ static void *pri_dchannel(void *vpri) /* Set Called Subaddress */ sig_pri_lock_owner(pri, chanpos); sig_pri_set_subaddress( - &pri->pvts[chanpos]->owner->cid.dialed_subaddress, + &pri->pvts[chanpos]->owner->dialed.subaddress, &e->ring.called_subaddress); if (!e->ring.called_subaddress.type && !ast_strlen_zero( @@ -4650,7 +4783,7 @@ static void *pri_dchannel(void *vpri) /* Set Calling Subaddress */ sig_pri_lock_owner(pri, chanpos); sig_pri_set_subaddress( - &pri->pvts[chanpos]->owner->cid.subaddress, + &pri->pvts[chanpos]->owner->caller.id.subaddress, &e->ring.calling.subaddress); if (!e->ring.calling.subaddress.type && !ast_strlen_zero( @@ -4665,7 +4798,7 @@ static void *pri_dchannel(void *vpri) /* Set Called Subaddress */ sig_pri_lock_owner(pri, chanpos); sig_pri_set_subaddress( - &pri->pvts[chanpos]->owner->cid.dialed_subaddress, + &pri->pvts[chanpos]->owner->dialed.subaddress, &e->ring.called_subaddress); if (!e->ring.called_subaddress.type && !ast_strlen_zero( @@ -5705,7 +5838,9 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i struct ast_flags opts; char *opt_args[OPT_ARG_ARRAY_SIZE]; - ast_log(LOG_DEBUG, "CALLING CID_NAME: %s CID_NUM:: %s\n", ast->cid.cid_name, ast->cid.cid_num); + ast_log(LOG_DEBUG, "CALLER NAME: %s 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, "")); if (!p->pri) { ast_log(LOG_ERROR, "Could not find pri on channel %d\n", p->channel); @@ -5764,9 +5899,9 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i l = NULL; n = NULL; if (!p->hidecallerid) { - l = ast->connected.id.number; + l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL; if (!p->hidecalleridname) { - n = ast->connected.id.name; + n = ast->connected.id.name.valid ? ast->connected.id.name.str : NULL; } } @@ -5938,7 +6073,8 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i snprintf(p->user_tag, sizeof(p->user_tag), "%s_%s", p->pri->initial_user_tag, p->pri->nodetype == PRI_NETWORK ? c + p->stripmsd + dp_strip - : S_OR(ast->connected.id.number, "")); + : S_COR(ast->connected.id.number.valid, + ast->connected.id.number.str, "")); } else { ast_copy_string(p->user_tag, p->pri->initial_user_tag, sizeof(p->user_tag)); } @@ -5947,8 +6083,8 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i * Replace the caller id tag from the channel creation * with the actual tag value. */ - ast_free(ast->cid.cid_tag); - ast->cid.cid_tag = ast_strdup(p->user_tag); + ast_free(ast->caller.id.tag); + ast->caller.id.tag = ast_strdup(p->user_tag); ldp_strip = 0; prilocaldialplan = p->pri->localdialplan - 1; @@ -6024,7 +6160,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i } } pri_sr_set_caller(sr, l ? (l + ldp_strip) : NULL, n, prilocaldialplan, - p->use_callingpres ? ast->connected.id.number_presentation : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE)); + p->use_callingpres ? ast->connected.id.number.presentation : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE)); #if defined(HAVE_PRI_SUBADDR) if (ast->connected.id.subaddress.valid) { diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c index e3c0278ef..7325b874b 100644 --- a/channels/sig_ss7.c +++ b/channels/sig_ss7.c @@ -124,16 +124,22 @@ static void sig_ss7_set_caller_id(struct sig_ss7_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.ani = p->cid_ani; caller.ani2 = p->cid_ani2; p->calls->set_callerid(p->chan_pvt, &caller); @@ -1255,7 +1261,7 @@ int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest) } if (!p->hidecallerid) { - l = ast->connected.id.number; + l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL; } else { l = NULL; } @@ -1301,8 +1307,8 @@ int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest) } } isup_set_calling(p->ss7call, l ? (l + calling_nai_strip) : NULL, ss7_calling_nai, - p->use_callingpres ? cid_pres2ss7pres(ast->connected.id.number_presentation) : (l ? SS7_PRESENTATION_ALLOWED : SS7_PRESENTATION_RESTRICTED), - p->use_callingpres ? cid_pres2ss7screen(ast->connected.id.number_presentation) : SS7_SCREENING_USER_PROVIDED ); + p->use_callingpres ? cid_pres2ss7pres(ast->connected.id.number.presentation) : (l ? SS7_PRESENTATION_ALLOWED : SS7_PRESENTATION_RESTRICTED), + p->use_callingpres ? cid_pres2ss7screen(ast->connected.id.number.presentation) : SS7_SCREENING_USER_PROVIDED); isup_set_oli(p->ss7call, ast->connected.ani2); isup_init_call(p->ss7->ss7, p->ss7call, p->cic, p->dpc); |