mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
chan_sip: notify dialog info ignores presentation indicator in callerid
The presentation indicator in a callerid (e.g. set by dialplan function Set(CALLERID(name-pres)= ...)) is not checked when SIP Dialog Info Notifies are generated during extension monitoring. Added a check to make sure the name and/or number presentations on the callee (remote identity) are set to allow. If they are restricted then "anonymous" is used instead. (closes issue AST-1175) Reported by: Thomas Arimont Review: https://reviewboard.asterisk.org/r/2976/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@402468 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -5768,6 +5768,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
|
|||||||
dialog->chanvars = copy_vars(peer->chanvars);
|
dialog->chanvars = copy_vars(peer->chanvars);
|
||||||
if (peer->fromdomainport)
|
if (peer->fromdomainport)
|
||||||
dialog->fromdomainport = peer->fromdomainport;
|
dialog->fromdomainport = peer->fromdomainport;
|
||||||
|
dialog->callingpres = peer->callingpres;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -13163,6 +13164,7 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
|
|||||||
case DIALOG_INFO_XML: /* SNOM subscribes in this format */
|
case DIALOG_INFO_XML: /* SNOM subscribes in this format */
|
||||||
ast_str_append(tmp, 0, "<?xml version=\"1.0\"?>\n");
|
ast_str_append(tmp, 0, "<?xml version=\"1.0\"?>\n");
|
||||||
ast_str_append(tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%u\" state=\"%s\" entity=\"%s\">\n", p->dialogver, full ? "full" : "partial", mto);
|
ast_str_append(tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%u\" state=\"%s\" entity=\"%s\">\n", p->dialogver, full ? "full" : "partial", mto);
|
||||||
|
|
||||||
if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
|
if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
|
||||||
/* Twice the extension length should be enough for XML encoding */
|
/* Twice the extension length should be enough for XML encoding */
|
||||||
char local_display[AST_MAX_EXTENSION * 2];
|
char local_display[AST_MAX_EXTENSION * 2];
|
||||||
@@ -13188,29 +13190,51 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
|
|||||||
struct ast_channel *caller;
|
struct ast_channel *caller;
|
||||||
|
|
||||||
if ((caller = ast_channel_callback(find_calling_channel, NULL, p, 0))) {
|
if ((caller = ast_channel_callback(find_calling_channel, NULL, p, 0))) {
|
||||||
|
static char *anonymous = "anonymous";
|
||||||
|
static char *invalid = "anonymous.invalid";
|
||||||
char *cid_num;
|
char *cid_num;
|
||||||
char *connected_num;
|
char *connected_num;
|
||||||
int need;
|
int need;
|
||||||
|
int cid_num_restricted, connected_num_restricted;
|
||||||
|
|
||||||
ast_channel_lock(caller);
|
ast_channel_lock(caller);
|
||||||
|
|
||||||
|
cid_num_restricted = (caller->caller.id.number.presentation &
|
||||||
|
AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED;
|
||||||
cid_num = S_COR(caller->caller.id.number.valid,
|
cid_num = S_COR(caller->caller.id.number.valid,
|
||||||
caller->caller.id.number.str, "");
|
S_COR(cid_num_restricted, anonymous,
|
||||||
need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
|
caller->caller.id.number.str), "");
|
||||||
|
|
||||||
|
need = strlen(cid_num) + (cid_num_restricted ? strlen(invalid) :
|
||||||
|
strlen(p->fromdomain)) + sizeof("sip:@");
|
||||||
|
|
||||||
remote_target = ast_alloca(need);
|
remote_target = ast_alloca(need);
|
||||||
snprintf(remote_target, need, "sip:%s@%s", cid_num, p->fromdomain);
|
snprintf(remote_target, need, "sip:%s@%s", cid_num,
|
||||||
|
cid_num_restricted ? invalid : p->fromdomain);
|
||||||
|
|
||||||
ast_xml_escape(S_COR(caller->caller.id.name.valid,
|
ast_xml_escape(S_COR(caller->caller.id.name.valid,
|
||||||
caller->caller.id.name.str, ""),
|
S_COR((caller->caller.id.name.presentation &
|
||||||
|
AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED, anonymous,
|
||||||
|
caller->caller.id.name.str), ""),
|
||||||
remote_display, sizeof(remote_display));
|
remote_display, sizeof(remote_display));
|
||||||
|
|
||||||
|
connected_num_restricted = (caller->connected.id.number.presentation &
|
||||||
|
AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED;
|
||||||
connected_num = S_COR(caller->connected.id.number.valid,
|
connected_num = S_COR(caller->connected.id.number.valid,
|
||||||
caller->connected.id.number.str, "");
|
S_COR(connected_num_restricted, anonymous,
|
||||||
need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@");
|
caller->connected.id.number.str), "");
|
||||||
|
|
||||||
|
need = strlen(connected_num) + (connected_num_restricted ? strlen(invalid) :
|
||||||
|
strlen(p->fromdomain)) + sizeof("sip:@");
|
||||||
local_target = ast_alloca(need);
|
local_target = ast_alloca(need);
|
||||||
snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain);
|
|
||||||
|
snprintf(local_target, need, "sip:%s@%s", connected_num,
|
||||||
|
connected_num_restricted ? invalid : p->fromdomain);
|
||||||
|
|
||||||
ast_xml_escape(S_COR(caller->connected.id.name.valid,
|
ast_xml_escape(S_COR(caller->connected.id.name.valid,
|
||||||
caller->connected.id.name.str, ""),
|
S_COR((caller->connected.id.name.presentation &
|
||||||
|
AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED, anonymous,
|
||||||
|
caller->connected.id.name.str), ""),
|
||||||
local_display, sizeof(local_display));
|
local_display, sizeof(local_display));
|
||||||
|
|
||||||
ast_channel_unlock(caller);
|
ast_channel_unlock(caller);
|
||||||
|
|||||||
Reference in New Issue
Block a user