[asterisk-commits] chan pjsip: Multidomain endpoint finding on call (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 13 09:37:21 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4719 )

Change subject: chan_pjsip: Multidomain endpoint finding on call
......................................................................


chan_pjsip: Multidomain endpoint finding on call

When PJSIP tries to call an endpoint with a domain (e.g. 1000 at test.com),
the user part is stripped down as it would be a trunk with a specified user,
and only the host part is called as a PJSIP endpoint and can't be found.
This is not correct in the case of a multidomain SIP account, so the stripping
after the @ sign is done only if the whole endpoint (in multidomain case
1000 at test.com) can't be found.

ASTERISK-26248

Change-Id: I3a2dd6f57f3bd042df46b961eccd81d31ab202e6
---
M channels/chan_pjsip.c
1 file changed, 46 insertions(+), 15 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 6e3d087..8a1921c 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2078,22 +2078,53 @@
 
 	AST_NONSTANDARD_APP_ARGS(args, tmp, '/');
 
-	/* If a request user has been specified extract it from the endpoint name portion */
-	if ((endpoint_name = strchr(args.endpoint, '@'))) {
-		request_user = args.endpoint;
-		*endpoint_name++ = '\0';
-	} else {
-		endpoint_name = args.endpoint;
-	}
+	if (ast_sip_get_disable_multi_domain()) {
+		/* If a request user has been specified extract it from the endpoint name portion */
+		if ((endpoint_name = strchr(args.endpoint, '@'))) {
+			request_user = args.endpoint;
+			*endpoint_name++ = '\0';
+		} else {
+			endpoint_name = args.endpoint;
+		}
 
-	if (ast_strlen_zero(endpoint_name)) {
-		ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");
-		req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
-		return -1;
-	} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
-		ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);
-		req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
-		return -1;
+		if (ast_strlen_zero(endpoint_name)) {
+			ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");
+			req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+			return -1;
+		} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
+			ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);
+			req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
+			return -1;
+		}
+	} else {
+		/* First try to find an exact endpoint match, for single (user) or multi-domain (user at domain) */
+		endpoint_name = args.endpoint;
+		if (ast_strlen_zero(endpoint_name)) {
+			ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");
+			req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+			return -1;
+		} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
+			/* It seems it's not a multi-domain endpoint or single endpoint exact match,
+			 * it's possible that it's a SIP trunk with a specified user (user at trunkname),
+			 * so extract the user before @ sign.
+			 */
+			if ((endpoint_name = strchr(args.endpoint, '@'))) {
+				request_user = args.endpoint;
+				*endpoint_name++ = '\0';
+			}
+
+			if (ast_strlen_zero(endpoint_name)) {
+				ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");
+				req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+				return -1;
+			}
+
+			if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
+				ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);
+				req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
+				return -1;
+			}
+		}
 	}
 
 	if (!(session = ast_sip_session_create_outgoing(endpoint, NULL, args.aor, request_user, req_data->caps))) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3a2dd6f57f3bd042df46b961eccd81d31ab202e6
Gerrit-PatchSet: 4
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Norbert Varga <vnorbix at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Norbert Varga <vnorbix at gmail.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list