[Asterisk-code-review] res_pjsip.c: Support endpoints with domain info in username (asterisk[16])

Friendly Automation asteriskteam at digium.com
Wed May 26 10:30:39 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15896 )

Change subject: res_pjsip.c: Support endpoints with domain info in username
......................................................................

res_pjsip.c: Support endpoints with domain info in username

In multidomain environments, it is desirable to create
PJSIP endpoints with the domain info in the endpoint name
in pjsip_endpoint.conf.  This resulted in an error with
registrations, NOTIFY, and OPTIONS packet generation.

This commit will detect if there is an @ in the endpoint
identifier and generate the URI accordingly so NOTIFY and
OPTIONS From headers will generate correctly.

ASTERISK-28393

Change-Id: I96f8d01dfdd5573ba7a28299e46271dd4210b619
---
A doc/CHANGES-staging/res_pjsip.txt
M res/res_pjsip.c
2 files changed, 16 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/doc/CHANGES-staging/res_pjsip.txt b/doc/CHANGES-staging/res_pjsip.txt
new file mode 100644
index 0000000..ffbf13a
--- /dev/null
+++ b/doc/CHANGES-staging/res_pjsip.txt
@@ -0,0 +1,5 @@
+Subject: res_pjsip
+
+PJSIP support of registrations of endpoints in multidomain
+scenarios, where the endpoint contains the domain info
+in pjsip_endpoint.conf
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 36dd12a..0998fb3 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3518,6 +3518,17 @@
 		type |= PJSIP_TRANSPORT_IPV6;
 	}
 
+	/* In multidomain scenario, username may contain @ with domain info */
+	if (!ast_sip_get_disable_multi_domain() && strchr(user, '@')) {
+		from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
+		from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
+				"<sip:%s%s%s>",
+				user,
+				(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
+				(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
+		return 0;
+	}
+
 	if (!ast_strlen_zero(domain)) {
 		from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
 		from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I96f8d01dfdd5573ba7a28299e46271dd4210b619
Gerrit-Change-Number: 15896
Gerrit-PatchSet: 3
Gerrit-Owner: Joe <ynadiv at corpit.xyz>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210526/a844a859/attachment.html>


More information about the asterisk-code-review mailing list