[Asterisk-code-review] chan pjsip: Multidomain endpoint finding on call (asterisk[13])

Norbert Varga asteriskteam at digium.com
Tue Jan 31 07:57:15 CST 2017


Norbert Varga has uploaded a new change for review. ( https://gerrit.asterisk.org/4845 )

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

chan_pjsip: Multidomain endpoint finding on call

Regard multidomain setting, using original behaviour when disabled.

ASTERISK-26248

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


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

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 50174a8..a2b4bf5 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2078,34 +2078,54 @@
 
 	AST_NONSTANDARD_APP_ARGS(args, tmp, '/');
 
-	/* 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,
-		 * it's possible that it's a SIP trunk with a specified user (user at trunkname),
-		 * so extract the user before @ sign.
-		 */
+	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, '@'))) {
-			ast_log(LOG_VERBOSE, "Extract user portion from endpoint\n");
 			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;
-		}
-
-		if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
+		} 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, '@'))) {
+				ast_log(LOG_VERBOSE, "Extract user portion from endpoint\n");
+				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/4845
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I34bd6636e76f943a805e82ca7a3f247e8506f8be
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Norbert Varga <vnorbix at gmail.com>



More information about the asterisk-code-review mailing list