[Asterisk-code-review] res pjsip session : add a function to manipulating toHeader ... (asterisk[master])

Yasin CANER asteriskteam at digium.com
Thu Apr 27 01:01:55 CDT 2017


Yasin CANER has uploaded a new change for review. ( https://gerrit.asterisk.org/5545 )

Change subject: res_pjsip_session : add a function to manipulating toHeader number
......................................................................

res_pjsip_session : add a function to manipulating toHeader number

ASTERISK-26957 #close

Change-Id: I77261b6e6e7962f7371b91d78b8124af050cab61
---
M apps/app_dial.c
M res/res_pjsip_session.c
2 files changed, 32 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/45/5545/1

diff --git a/apps/app_dial.c b/apps/app_dial.c
index c8fcf46..71d3d7e 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -2602,6 +2602,9 @@
 		ast_party_redirecting_copy(ast_channel_redirecting(tc), ast_channel_redirecting(chan));
 
 		ast_channel_dialed(tc)->transit_network_select = ast_channel_dialed(chan)->transit_network_select;
+		if(ast_channel_dialed(chan)->number.str){
+			ast_party_dialed_copy(ast_channel_dialed(tc),ast_channel_dialed(chan));
+		}
 
 		ast_channel_req_accountcodes(tc, chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 		if (ast_strlen_zero(ast_channel_musicclass(tc))) {
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 3034652..63a60d1 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -877,6 +877,34 @@
 	}
 }
 
+static void set_to_header(struct ast_sip_session *session){
+
+        pj_pool_t *dlg_pool;
+        pjsip_fromto_hdr *dlg_info;
+        pjsip_name_addr *dlg_info_name_addr;
+        pjsip_sip_uri *dlg_info_uri;
+        struct ast_party_dialed dialed;
+
+        if (!session->channel) {
+                return;
+        }
+        ast_party_dialed_init(&dialed);
+        ast_party_dialed_set(&dialed, ast_channel_dialed(session->channel));
+        if(!dialed.number.str){
+                return;
+        }
+
+        dlg_pool = session->inv_session->dlg->pool;
+        dlg_info = session->inv_session->dlg->remote.info;
+        dlg_info_name_addr = (pjsip_name_addr *) dlg_info->uri;
+        dlg_info_uri = pjsip_uri_get_uri(dlg_info_name_addr);
+
+        pj_strdup2(dlg_pool, &dlg_info_uri->user,ast_channel_dialed(session->channel)->number.str);
+
+        return;
+
+}
+
 int ast_sip_session_refresh(struct ast_sip_session *session,
 		ast_sip_session_request_creation_cb on_request_creation,
 		ast_sip_session_sdp_creation_cb on_sdp_creation,
@@ -1244,7 +1272,7 @@
 	 * From in the initial INVITE will be wrong but the rest of the messages will be OK.
 	 */
 	set_from_header(session);
-
+	set_to_header(session);
 	if (pjsip_inv_invite(session->inv_session, tdata) != PJ_SUCCESS) {
 		return -1;
 	}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77261b6e6e7962f7371b91d78b8124af050cab61
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Yasin CANER <yasin.caner at netgsm.com.tr>



More information about the asterisk-code-review mailing list