summaryrefslogtreecommitdiff
path: root/channels/chan_pjsip.c
diff options
context:
space:
mode:
authorDebian Amtelco <dan@amtelco.com>2015-08-26 21:58:04 +0000
committerDebian Amtelco <dan@amtelco.com>2015-10-05 21:45:24 +0000
commitc6b0d6026404dd2ca110d2ab871ba41b7bd24d38 (patch)
tree3582dcb83b993fcd58a34f5c7314990b223567aa /channels/chan_pjsip.c
parent89dec7675d0df2db273a5f3450b0d78732ed0b63 (diff)
chan_pjsip: Add Referred-By header to the PJSIP REFER packet.
Some systems require the REFER packet to include a Referred-By header. If the channel variable SIPREFERREDBYHDR is set, it passes that value as the Referred-By header value. Otherwise, it adds the current dialog’s local info. Reported by: Dan Cropp Tested by: Dan Cropp Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
Diffstat (limited to 'channels/chan_pjsip.c')
-rw-r--r--channels/chan_pjsip.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 153b2a33b..523a01560 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1435,6 +1435,8 @@ static void transfer_refer(struct ast_sip_session *session, const char *target)
enum ast_control_transfer message = AST_TRANSFER_SUCCESS;
pj_str_t tmp;
pjsip_tx_data *packet;
+ const char *ref_by_val;
+ char local_info[pj_strlen(&session->inv_session->dlg->local.info_str) + 1];
if (pjsip_xfer_create_uac(session->inv_session->dlg, NULL, &sub) != PJ_SUCCESS) {
message = AST_TRANSFER_FAILED;
@@ -1451,6 +1453,14 @@ static void transfer_refer(struct ast_sip_session *session, const char *target)
return;
}
+ ref_by_val = pbx_builtin_getvar_helper(session->channel, "SIPREFERREDBYHDR");
+ if (!ast_strlen_zero(ref_by_val)) {
+ ast_sip_add_header(packet, "Referred-By", ref_by_val);
+ } else {
+ ast_copy_pj_str(local_info, &session->inv_session->dlg->local.info_str, sizeof(local_info));
+ ast_sip_add_header(packet, "Referred-By", local_info);
+ }
+
pjsip_xfer_send_request(sub, packet);
ast_queue_control_data(session->channel, AST_CONTROL_TRANSFER, &message, sizeof(message));
}