[Asterisk-code-review] Modified the PJSIP Transfer REFER behavior to include the Re... (asterisk[master])

Dan Cropp asteriskteam at digium.com
Wed Aug 26 16:59:49 CDT 2015


Dan Cropp has uploaded a new change for review.

  https://gerrit.asterisk.org/1149

Change subject: Modified the PJSIP Transfer REFER behavior to include the Referred-By header.
......................................................................

Modified the PJSIP Transfer REFER behavior to include the Referred-By header.

Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
---
M channels/chan_pjsip.c
1 file changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/49/1149/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index d3ba0a2..c7e5ae5 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1435,6 +1435,10 @@
 	enum ast_control_transfer message = AST_TRANSFER_SUCCESS;
 	pj_str_t tmp;
 	pjsip_tx_data *packet;
+	pjsip_hdr *hdr;
+	const pj_str_t ref_by = { "Referred-By", 11 };
+	const char *ref_by_val;
+	pj_str_t tmp2;
 
 	if (pjsip_xfer_create_uac(session->inv_session->dlg, NULL, &sub) != PJ_SUCCESS) {
 		message = AST_TRANSFER_FAILED;
@@ -1451,6 +1455,15 @@
 		return;
 	}
 
+	/* Add Referred-By header to packet (channel variable SIPREFERREDBYHDR value or existing dialog's local info) */
+	ref_by_val = pbx_builtin_getvar_helper(session->channel, "SIPREFERREDBYHDR");
+	if (!ast_strlen_zero(ref_by_val)) {
+		hdr = (pjsip_hdr*)pjsip_generic_string_hdr_create(packet->pool, &ref_by, pj_cstr(&tmp2, ref_by_val));
+	} else {
+		hdr = (pjsip_hdr*)pjsip_generic_string_hdr_create(packet->pool, &ref_by, &session->inv_session->dlg->local.info_str);
+	}
+	pjsip_msg_add_hdr(packet->msg, hdr);
+
 	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: newchange
Gerrit-Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Dan Cropp <dan at amtelco.com>



More information about the asterisk-code-review mailing list