summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 9364a1158..d143dc138 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6240,6 +6240,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
if (peer->fromdomainport) {
dialog->fromdomainport = peer->fromdomainport;
}
+ dialog->callingpres = peer->callingpres;
return 0;
}
@@ -14756,29 +14757,51 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
callee = find_ringing_channel(data->device_state_info, p);
if (callee) {
+ static char *anonymous = "anonymous";
+ static char *invalid = "anonymous.invalid";
char *cid_num;
char *connected_num;
int need;
+ int cid_num_restricted, connected_num_restricted;
ast_channel_lock(callee);
+
+ cid_num_restricted = (ast_channel_caller(callee)->id.number.presentation &
+ AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED;
cid_num = S_COR(ast_channel_caller(callee)->id.number.valid,
- ast_channel_caller(callee)->id.number.str, "");
- need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
+ S_COR(cid_num_restricted, anonymous,
+ ast_channel_caller(callee)->id.number.str), "");
+
+ need = strlen(cid_num) + (cid_num_restricted ? strlen(invalid) :
+ strlen(p->fromdomain)) + sizeof("sip:@");
local_target = ast_alloca(need);
- snprintf(local_target, need, "sip:%s@%s", cid_num, p->fromdomain);
+
+ snprintf(local_target, need, "sip:%s@%s", cid_num,
+ cid_num_restricted ? invalid : p->fromdomain);
ast_xml_escape(S_COR(ast_channel_caller(callee)->id.name.valid,
- ast_channel_caller(callee)->id.name.str, ""),
+ S_COR((ast_channel_caller(callee)->id.name.presentation &
+ AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED, anonymous,
+ ast_channel_caller(callee)->id.name.str), ""),
local_display, sizeof(local_display));
+ connected_num_restricted = (ast_channel_connected(callee)->id.number.presentation &
+ AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED;
connected_num = S_COR(ast_channel_connected(callee)->id.number.valid,
- ast_channel_connected(callee)->id.number.str, "");
- need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@");
+ S_COR(connected_num_restricted, anonymous,
+ ast_channel_connected(callee)->id.number.str), "");
+
+ need = strlen(connected_num) + (connected_num_restricted ? strlen(invalid) :
+ strlen(p->fromdomain)) + sizeof("sip:@");
remote_target = ast_alloca(need);
- snprintf(remote_target, need, "sip:%s@%s", connected_num, p->fromdomain);
+
+ snprintf(remote_target, need, "sip:%s@%s", connected_num,
+ connected_num_restricted ? invalid : p->fromdomain);
ast_xml_escape(S_COR(ast_channel_connected(callee)->id.name.valid,
- ast_channel_connected(callee)->id.name.str, ""),
+ S_COR((ast_channel_connected(callee)->id.name.presentation &
+ AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED, anonymous,
+ ast_channel_connected(callee)->id.name.str), ""),
remote_display, sizeof(remote_display));
ast_channel_unlock(callee);