[Asterisk-code-review] res_pjsip_messaging: Allow setting domain of recipient (asterisk[18])

Brian J. Murrell asteriskteam at digium.com
Tue Mar 9 06:33:42 CST 2021


Brian J. Murrell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15597 )


Change subject: res_pjsip_messaging: Allow setting domain of recipient
......................................................................

res_pjsip_messaging: Allow setting domain of recipient

Allow the recipient field of MessageSend() to contain a domain which
is used in the SIP To: when sending the message to the endpoint.  This
allows endpoints that use both the LHS *and* RHS of the recipient
address to identify remote senders to maintain consistency even when
that endpoint changes it's location (i.e. IP address).

This is a slight rework of a modification to my to my original patch
for this issue that was contributed to my open issue on this matter in
https://issues.asterisk.org/jira/browse/ASTERISK-28513.

ASTERISK-28513

Change-Id: I26fb8605d7cb200332a0442879fd9a5679a65022
---
M res/res_pjsip_messaging.c
1 file changed, 9 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/97/15597/1

diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 5378b8c..9cfc470 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -238,6 +238,15 @@
 			pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
 		}
 	}
+	/* assume it is 'sip:user[@domain]' format */
+	char *domain = strchr(to, '@');
+	if (domain) {
+		pjsip_sip_uri *uri;
+		pjsip_name_addr *name_addr =
+			(pjsip_name_addr *) PJSIP_MSG_TO_HDR(tdata->msg)->uri;
+		uri = pjsip_uri_get_uri(name_addr);
+		pj_strdup2(tdata->pool, &uri->host, domain + 1);
+	}
 }
 
 /*!

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15597
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: I26fb8605d7cb200332a0442879fd9a5679a65022
Gerrit-Change-Number: 15597
Gerrit-PatchSet: 1
Gerrit-Owner: Brian J. Murrell <brian at interlinx.bc.ca>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210309/7d4ef180/attachment-0001.html>


More information about the asterisk-code-review mailing list