[Asterisk-code-review] chan pjsip: Add Referred-By header to the PJSIP REFER packet. (asterisk[master])

Matt Jordan asteriskteam at digium.com
Mon Oct 5 21:40:13 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: chan_pjsip: Add Referred-By header to the PJSIP REFER packet.
......................................................................


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
---
M channels/chan_pjsip.c
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved



diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 153b2a3..523a015 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1435,6 +1435,8 @@
 	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 @@
 		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));
 }

-- 
To view, visit https://gerrit.asterisk.org/1149
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
Gerrit-PatchSet: 6
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Dan Cropp <dan at amtelco.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list