From: Debian Amtelco Date: Wed, 26 Aug 2015 21:58:04 +0000 (+0000) Subject: chan_pjsip: Add Referred-By header to the PJSIP REFER packet. X-Git-Tag: 14.0.0-beta1~645 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6b0d6026404dd2ca110d2ab871ba41b7bd24d38;p=thirdparty%2Fasterisk.git 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 --- diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index 153b2a33b3..523a015602 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)); }