[asterisk-commits] twilson: branch 10 r344216 - in /branches/10: ./ channels/ channels/sip/ chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 9 14:07:41 CST 2011


Author: twilson
Date: Wed Nov  9 14:07:34 2011
New Revision: 344216

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=344216
Log:
Don't treat a host:port string as a domain

The domain matching code prior to 1.8 used to manually remove the port
from the host:port string when determining if an incoming request
matched the list of domains. When switching to the new parsing
functions, the documentation implied that the "domain" was being
returned by these functions, when instead it was returning the
"hostport" as defined by RFC 3261. This led to confusion and resulted
in 1.8+ rejecting an incoming request from x.x.x.x:xxxxx when
domain=x.x.x.x was set in sip.conf.

This patch renames the "domain" variables in the parsing functions to
"hostport" to more accurately describe what it is that they are
returning and also properly truncates the resulting hostport strings
when dealing with domain matching.

Review: https://reviewboard.asterisk.org/r/1574/
........

Merged revisions 344215 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/channels/chan_sip.c
    branches/10/channels/sip/include/reqresp_parser.h
    branches/10/channels/sip/include/sip.h
    branches/10/channels/sip/reqresp_parser.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_sip.c?view=diff&rev=344216&r1=344215&r2=344216
==============================================================================
--- branches/10/channels/chan_sip.c (original)
+++ branches/10/channels/chan_sip.c Wed Nov  9 14:07:34 2011
@@ -13889,9 +13889,9 @@
 }
 
 /*! \brief parse uri in a way that allows semicolon stripping if legacy mode is enabled */
-static int parse_uri_legacy_check(char *uri, const char *scheme, char **user, char **pass, char **domain, char **transport)
-{
-	int ret = parse_uri(uri, scheme, user, pass, domain, transport);
+static int parse_uri_legacy_check(char *uri, const char *scheme, char **user, char **pass, char **hostport, char **transport)
+{
+	int ret = parse_uri(uri, scheme, user, pass, hostport, transport);
 	if (sip_cfg.legacy_useroption_parsing) { /* if legacy mode is active, strip semis from the user field */
 		char *p;
 		if ((p = strchr(uri, (int)';'))) {
@@ -13903,7 +13903,7 @@
 
 static int __set_address_from_contact(const char *fullcontact, struct ast_sockaddr *addr, int tcp)
 {
-	char *domain, *transport;
+	char *hostport, *transport;
 	char contact_buf[256];
 	char *contact;
 
@@ -13918,7 +13918,7 @@
 	 * We still need to be able to send to the remote agent through the proxy.
 	 */
 
-	if (parse_uri_legacy_check(contact, "sip:,sips:", &contact, NULL, &domain,
+	if (parse_uri_legacy_check(contact, "sip:,sips:", &contact, NULL, &hostport,
 		      &transport)) {
 		ast_log(LOG_WARNING, "Invalid contact uri %s (missing sip: or sips:), attempting to use anyway\n", fullcontact);
 	}
@@ -13927,19 +13927,19 @@
 	/* We should only do this if it's a name, not an IP */
 	/* \todo - if there's no PORT number in contact - we are required to check NAPTR/SRV records
 		to find transport, port address and hostname. If there's a port number, we have to
-		assume that the domain part is a host name and only look for an A/AAAA record in DNS.
+		assume that the hostport part is a host name and only look for an A/AAAA record in DNS.
 	*/
 
-	/* If we took in an invalid URI, domain may not have been initialized */
-	/* ast_sockaddr_resolve requires an initialized domain string. */
-	if (ast_strlen_zero(domain)) {
-		ast_log(LOG_WARNING, "Invalid URI: parse_uri failed to acquire domain\n");
+	/* If we took in an invalid URI, hostport may not have been initialized */
+	/* ast_sockaddr_resolve requires an initialized hostport string. */
+	if (ast_strlen_zero(hostport)) {
+		ast_log(LOG_WARNING, "Invalid URI: parse_uri failed to acquire hostport\n");
 		return -1;
 	}
 
-	if (ast_sockaddr_resolve_first(addr, domain, 0)) {
+	if (ast_sockaddr_resolve_first(addr, hostport, 0)) {
 		ast_log(LOG_WARNING, "Invalid host name in Contact: (can't "
-			"resolve in DNS) : '%s'\n", domain);
+			"resolve in DNS) : '%s'\n", hostport);
 		return -1;
 	}
 
@@ -13976,7 +13976,7 @@
 	char data[SIPBUFSIZE];
 	const char *expires = sip_get_header(req, "Expires");
 	int expire = atoi(expires);
-	char *curi = NULL, *domain = NULL, *transport = NULL;
+	char *curi = NULL, *hostport = NULL, *transport = NULL;
 	int transport_type;
 	const char *useragent;
 	struct ast_sockaddr oldsin, testsa;
@@ -14054,7 +14054,7 @@
 	ast_string_field_build(pvt, our_contact, "<%s>", curi);
 
 	/* Make sure it's a SIP URL */
-	if (ast_strlen_zero(curi) || parse_uri_legacy_check(curi, "sip:,sips:", &curi, NULL, &domain, &transport)) {
+	if (ast_strlen_zero(curi) || parse_uri_legacy_check(curi, "sip:,sips:", &curi, NULL, &hostport, &transport)) {
 		ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sip:/sips:) trying to use anyway\n");
 	}
 
@@ -14082,15 +14082,15 @@
 		ast_debug(1, "Store REGISTER's Contact header for call routing.\n");
 		/* XXX This could block for a long time XXX */
 		/*! \todo Check NAPTR/SRV if we have not got a port in the URI */
-		if (ast_sockaddr_resolve_first(&testsa, domain, 0)) {
-			ast_log(LOG_WARNING, "Invalid domain '%s'\n", domain);
+		if (ast_sockaddr_resolve_first(&testsa, hostport, 0)) {
+			ast_log(LOG_WARNING, "Invalid hostport '%s'\n", hostport);
 			ast_string_field_set(peer, fullcontact, "");
 			ast_string_field_set(pvt, our_contact, "");
 			return PARSE_REGISTER_FAILED;
 		}
 
 		/* If we have a port number in the given URI, make sure we do remember to not check for NAPTR/SRV records.
-		   The domain part is actually a host. */
+		   The hostport part is actually a host. */
 		peer->portinuri = ast_sockaddr_port(&testsa) ? TRUE : FALSE;
 
 		if (!ast_sockaddr_port(&testsa)) {
@@ -14110,7 +14110,7 @@
 	/* Check that they're allowed to register at this IP */
 	if (ast_apply_ha(sip_cfg.contact_ha, &peer->addr) != AST_SENSE_ALLOW ||
 			ast_apply_ha(peer->contactha, &peer->addr) != AST_SENSE_ALLOW) {
-		ast_log(LOG_WARNING, "Domain '%s' disallowed by contact ACL (violating IP %s)\n", domain,
+		ast_log(LOG_WARNING, "Domain '%s' disallowed by contact ACL (violating IP %s)\n", hostport,
 			ast_sockaddr_stringify_addr(&testsa));
 		ast_string_field_set(peer, fullcontact, "");
 		ast_string_field_set(pvt, our_contact, "");
@@ -14732,6 +14732,18 @@
 	return uri;
 }
 
+/*! \brief Terminate a host:port at the ':'
+ * \param hostport The address of the hostport string
+ *
+ * \note In the case of a bracket-enclosed IPv6 address, the hostport variable
+ * will contain the non-bracketed host as a result of calling this function.
+ */
+static void extract_host_from_hostport(char **hostport)
+{
+	char *dont_care;
+	ast_sockaddr_split_hostport(*hostport, hostport, &dont_care, PARSE_PORT_IGNORE);
+}
+
 /*! \brief Verify registration of user
 	- Registration is done in several steps, first a REGISTER without auth
 	  to get a challenge (nonce) then a second one with auth
@@ -14761,6 +14773,8 @@
 
 	SIP_PEDANTIC_DECODE(name);
 	SIP_PEDANTIC_DECODE(domain);
+
+	extract_host_from_hostport(&domain);
 
 	/*! \todo XXX here too we interpret a missing @domain as a name-only
 	 * URI, whereas the RFC says this is a domain-only uri.
@@ -15332,6 +15346,9 @@
 
 	SIP_PEDANTIC_DECODE(domain);
 	SIP_PEDANTIC_DECODE(uri);
+
+	extract_host_from_hostport(&domain);
+
 	if (ast_strlen_zero(uri)) {
 		/*
 		 * Either there really was no extension found or the request
@@ -15357,6 +15374,8 @@
 
 		SIP_PEDANTIC_DECODE(from);
 		SIP_PEDANTIC_DECODE(domain);
+
+		extract_host_from_hostport(&domain);
 
 		ast_string_field_set(p, fromdomain, domain);
 	}
@@ -16158,6 +16177,8 @@
 		 * For backward compatibility, we keep this block, but it is
 		 * really a mistake and should go away.
 		 */
+
+		extract_host_from_hostport(&domain);
 		of = domain;
 	} else {
 		char *tmp = ast_strdupa(of);
@@ -24178,6 +24199,9 @@
 			ast_string_field_set(pvt, fromname, name);
 			if (strchr(location, ':')) { /* Must be a URI */
 				parse_uri(location, "sip:,sips:", &user, NULL, &domain, NULL);
+				SIP_PEDANTIC_DECODE(user);
+				SIP_PEDANTIC_DECODE(domain);
+				extract_host_from_hostport(&domain);
 				ast_string_field_set(pvt, fromuser, user);
 				ast_string_field_set(pvt, fromdomain, domain);
 			} else { /* Treat it as an exten/user */
@@ -27172,8 +27196,9 @@
 
 	AST_LIST_LOCK(&domain_list);
 	AST_LIST_TRAVERSE(&domain_list, d, list) {
-		if (strcasecmp(d->domain, domain))
+		if (strcasecmp(d->domain, domain)) {
 			continue;
+		}
 
 		if (len && !ast_strlen_zero(d->context))
 			ast_copy_string(context, d->context, len);

Modified: branches/10/channels/sip/include/reqresp_parser.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sip/include/reqresp_parser.h?view=diff&rev=344216&r1=344215&r2=344216
==============================================================================
--- branches/10/channels/sip/include/reqresp_parser.h (original)
+++ branches/10/channels/sip/include/reqresp_parser.h Wed Nov  9 14:07:34 2011
@@ -43,7 +43,7 @@
  * \endverbatim
  */
 int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass,
-	      char **domain, char **transport);
+	      char **hostport, char **transport);
 
 /*!
  * \brief parses a URI in to all of its components and any trailing residue
@@ -53,7 +53,7 @@
  *
  */
 int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
-		   char **domain, struct uriparams *params, char **headers,
+		   char **hostport, struct uriparams *params, char **headers,
 		   char **residue);
 
 /*!

Modified: branches/10/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sip/include/sip.h?view=diff&rev=344216&r1=344215&r2=344216
==============================================================================
--- branches/10/channels/sip/include/sip.h (original)
+++ branches/10/channels/sip/include/sip.h Wed Nov  9 14:07:34 2011
@@ -1758,7 +1758,7 @@
 	char *name;
 	char *user;
 	char *pass;
-	char *domain;
+	char *hostport;
 	struct uriparams params;
 	char *headers;
 	char *expires;

Modified: branches/10/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sip/reqresp_parser.c?view=diff&rev=344216&r1=344215&r2=344216
==============================================================================
--- branches/10/channels/sip/reqresp_parser.c (original)
+++ branches/10/channels/sip/reqresp_parser.c Wed Nov  9 14:07:34 2011
@@ -33,7 +33,7 @@
 
 /*! \brief * parses a URI in its components.*/
 int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
-		   char **domain, struct uriparams *params, char **headers,
+		   char **hostport, struct uriparams *params, char **headers,
 		   char **residue)
 {
 	char *userinfo = NULL;
@@ -53,8 +53,8 @@
 	if (pass) {
 		*pass = "";
 	}
-	if (domain) {
-		*domain = "";
+	if (hostport) {
+		*hostport = "";
 	}
 	if (headers) {
 		*headers = "";
@@ -85,8 +85,8 @@
 		}
 	}
 
-	if (!domain) {
-		/* if we don't want to split around domain, keep everything as a
+	if (!hostport) {
+		/* if we don't want to split around hostport, keep everything as a
 		 * userinfo - cos thats how old parse_uri operated*/
 		userinfo = uri;
 	} else {
@@ -102,7 +102,7 @@
 			userinfo = "";
 		}
 
-		*domain = dom;
+		*hostport = dom;
 	}
 
 	if (pass && (c = strchr(userinfo, ':'))) {	  /* user:password */
@@ -221,7 +221,7 @@
 {
 	int res = AST_TEST_PASS;
 	char uri[1024];
-	char *user, *pass, *domain, *headers, *residue;
+	char *user, *pass, *hostport, *headers, *residue;
 	struct uriparams params;
 
 	struct testdata {
@@ -229,13 +229,13 @@
 		char *uri;
 		char **userptr;
 		char **passptr;
-		char **domainptr;
+		char **hostportptr;
 		char **headersptr;
 		char **residueptr;
 		struct uriparams *paramsptr;
 		char *user;
 		char *pass;
-		char *domain;
+		char *hostport;
 		char *headers;
 		char *residue;
 		struct uriparams params;
@@ -252,13 +252,13 @@
 		.uri = "sip:user:secret at host:5060;param=discard;transport=tcp;param2=residue",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "param2=residue",
 		.params.transport = "tcp",
@@ -271,13 +271,13 @@
 		.uri = "sip:user:secret at host:5060;param=discard;transport=tcp;param2=discard2?header=blah&header2=blah2;param3=residue",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "header=blah&header2=blah2",
 		.residue = "param3=residue",
 		.params.transport = "tcp",
@@ -290,13 +290,13 @@
 		.uri = "sip:-_.!~*'()&=+$,;?/:secret at host:5060;transport=tcp",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "-_.!~*'()&=+$,;?/",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "",
 		.params.transport = "tcp",
@@ -309,13 +309,13 @@
 		.uri = "sip:user:-_.!~*'()&=+$, at host:5060;transport=tcp",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "-_.!~*'()&=+$,",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "",
 		.params.transport = "tcp",
@@ -328,13 +328,13 @@
 		.uri = "sip:user:secret at 1-1.a-1.:5060;transport=tcp",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "1-1.a-1.:5060",
+		.hostport = "1-1.a-1.:5060",
 		.headers = "",
 		.residue = "",
 		.params.transport = "tcp",
@@ -347,13 +347,13 @@
 		.uri = "sip:user:secret at host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$;transport=tcp",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "",
 		.params.transport = "tcp",
@@ -366,13 +366,13 @@
 		.uri = "sip:user:secret at host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$?header=blah&header2=blah2;-_.!~*'()[]/:&+$=residue",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "header=blah&header2=blah2",
 		.residue = "-_.!~*'()[]/:&+$=residue",
 		.params.transport = "",
@@ -385,13 +385,13 @@
 		.uri = "sip:user:secret at host:5060;param=discard;lr?header=blah",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "header=blah",
 		.residue = "",
 		.params.transport = "",
@@ -404,13 +404,13 @@
 		.uri = "sip:user:secret at host:5060;param=discard;lr=yes?header=blah",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "header=blah",
 		.residue = "",
 		.params.transport = "",
@@ -423,13 +423,13 @@
 		.uri = "sip:user:secret at host:5060;paramlr=lr;lr=no;lr=off;lr=0;lr=;=lr;lrextra;lrparam2=lr?header=blah",
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "header=blah",
 		.residue = "",
 		.params.transport = "",
@@ -464,19 +464,19 @@
 	}
 
 	AST_LIST_TRAVERSE(&testdatalist, testdataptr, list) {
-		user = pass = domain = headers = residue = NULL;
+		user = pass = hostport = headers = residue = NULL;
 		params.transport = params.user = params.method = params.ttl = params.maddr = NULL;
 		params.lr = 0;
 
 		ast_copy_string(uri,testdataptr->uri,sizeof(uri));
 		if (parse_uri_full(uri, "sip:,sips:", testdataptr->userptr,
-				   testdataptr->passptr, testdataptr->domainptr,
+				   testdataptr->passptr, testdataptr->hostportptr,
 				   testdataptr->paramsptr,
 				   testdataptr->headersptr,
 				   testdataptr->residueptr) ||
 			((testdataptr->userptr) && strcmp(testdataptr->user, user)) ||
 			((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) ||
-			((testdataptr->domainptr) && strcmp(testdataptr->domain, domain)) ||
+			((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) ||
 			((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) ||
 			((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) ||
 			((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) ||
@@ -494,13 +494,13 @@
 
 
 int parse_uri(char *uri, const char *scheme, char **user, char **pass,
-	      char **domain, char **transport) {
+	      char **hostport, char **transport) {
 	int ret;
 	char *headers;
 	struct uriparams params;
 
 	headers = NULL;
-	ret = parse_uri_full(uri, scheme, user, pass, domain, &params, &headers, NULL);
+	ret = parse_uri_full(uri, scheme, user, pass, hostport, &params, &headers, NULL);
 	if (transport) {
 		*transport=params.transport;
 	}
@@ -510,7 +510,7 @@
 AST_TEST_DEFINE(sip_parse_uri_test)
 {
 	int res = AST_TEST_PASS;
-	char *name, *pass, *domain, *transport;
+	char *name, *pass, *hostport, *transport;
 	char uri1[] = "sip:name at host";
 	char uri2[] = "sip:name at host;transport=tcp";
 	char uri3[] = "sip:name:secret at host;transport=tcp";
@@ -537,114 +537,114 @@
 	}
 
 	/* Test 1, simple URI */
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri1, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri1, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			strcmp(name, "name")        ||
 			!ast_strlen_zero(pass)      ||
-			strcmp(domain, "host")      ||
+			strcmp(hostport, "host")      ||
 			!ast_strlen_zero(transport)) {
 		ast_test_status_update(test, "Test 1: simple uri failed. \n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 2, add tcp transport */
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri2, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri2, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			strcmp(name, "name")        ||
 			!ast_strlen_zero(pass)      ||
-			strcmp(domain, "host")    ||
+			strcmp(hostport, "host")    ||
 			strcmp(transport, "tcp")) {
 		ast_test_status_update(test, "Test 2: uri with addtion of tcp transport failed. \n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 3, add secret */
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri3, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri3, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			strcmp(name, "name")        ||
 			strcmp(pass, "secret")      ||
-			strcmp(domain, "host")    ||
+			strcmp(hostport, "host")    ||
 			strcmp(transport, "tcp")) {
 		ast_test_status_update(test, "Test 3: uri with addition of secret failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 4, add port and unparsed header field*/
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri4, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri4, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			strcmp(name, "name")        ||
 			strcmp(pass, "secret")      ||
-			strcmp(domain, "host:port") ||
+			strcmp(hostport, "host:port") ||
 			strcmp(transport, "tcp")) {
 		ast_test_status_update(test, "Test 4: add port and unparsed header field failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 5, verify parse_uri does not crash when given a NULL uri */
-	name = pass = domain = transport = NULL;
-	if (!parse_uri(NULL, "sip:,sips:", &name, &pass, &domain, &transport)) {
+	name = pass = hostport = transport = NULL;
+	if (!parse_uri(NULL, "sip:,sips:", &name, &pass, &hostport, &transport)) {
 		ast_test_status_update(test, "Test 5: passing a NULL uri failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 6, verify parse_uri does not crash when given a NULL output parameters */
-	name = pass = domain = transport = NULL;
+	name = pass = hostport = transport = NULL;
 	if (parse_uri(uri6, "sip:,sips:", NULL, NULL, NULL, NULL)) {
 		ast_test_status_update(test, "Test 6: passing NULL output parameters failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
-	/* Test 7, verify parse_uri returns user:secret and domain when no port or secret output parameters are supplied. */
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri7, "sip:,sips:", &name, NULL, &domain, NULL) ||
+	/* Test 7, verify parse_uri returns user:secret and hostport when no port or secret output parameters are supplied. */
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri7, "sip:,sips:", &name, NULL, &hostport, NULL) ||
 			strcmp(name, "name:secret")        ||
-			strcmp(domain, "host:port")) {
+			strcmp(hostport, "host:port")) {
 
 		ast_test_status_update(test, "Test 7: providing no port and secret output parameters failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
-	/* Test 8, verify parse_uri can handle a domain only uri */
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri8, "sip:,sips:", &name, &pass, &domain, &transport) ||
-			strcmp(domain, "host") ||
+	/* Test 8, verify parse_uri can handle a hostport only uri */
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri8, "sip:,sips:", &name, &pass, &hostport, &transport) ||
+			strcmp(hostport, "host") ||
 			!ast_strlen_zero(name)) {
 		ast_test_status_update(test, "Test 8: add port and unparsed header field failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
-	/* Test 9, add port and unparsed header field with domain only uri*/
-	name = pass = domain = transport = NULL;
-	if (parse_uri(uri9, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	/* Test 9, add port and unparsed header field with hostport only uri*/
+	name = pass = hostport = transport = NULL;
+	if (parse_uri(uri9, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			!ast_strlen_zero(name)        ||
 			!ast_strlen_zero(pass)      ||
-			strcmp(domain, "host:port")    ||
+			strcmp(hostport, "host:port")    ||
 			strcmp(transport, "tcp")) {
-		ast_test_status_update(test, "Test 9: domain only uri failed \n");
+		ast_test_status_update(test, "Test 9: hostport only uri failed \n");
 		res = AST_TEST_FAIL;
 	}
 
 	/* Test 10, handle invalid/missing "sip:,sips:" scheme
 	 * we expect parse_uri to return an error, but still parse
 	 * the results correctly here */
-	name = pass = domain = transport = NULL;
-	if (!parse_uri(uri10, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (!parse_uri(uri10, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			!ast_strlen_zero(name)        ||
 			!ast_strlen_zero(pass)      ||
-			strcmp(domain, "host:port")    ||
+			strcmp(hostport, "host:port")    ||
 			strcmp(transport, "tcp")) {
 		ast_test_status_update(test, "Test 10: missing \"sip:sips:\" scheme failed\n");
 		res = AST_TEST_FAIL;
 	}
 
-	/* Test 11, simple domain only URI with missing scheme
+	/* Test 11, simple hostport only URI with missing scheme
 	 * we expect parse_uri to return an error, but still parse
 	 * the results correctly here */
-	name = pass = domain = transport = NULL;
-	if (!parse_uri(uri11, "sip:,sips:", &name, &pass, &domain, &transport) ||
+	name = pass = hostport = transport = NULL;
+	if (!parse_uri(uri11, "sip:,sips:", &name, &pass, &hostport, &transport) ||
 			!ast_strlen_zero(name)      ||
 			!ast_strlen_zero(pass)      ||
-			strcmp(domain, "host")      ||
+			strcmp(hostport, "host")      ||
 			!ast_strlen_zero(transport)) {
 		ast_test_status_update(test, "Test 11: simple uri with missing scheme failed. \n");
 		res = AST_TEST_FAIL;
@@ -848,7 +848,7 @@
 	char header[256];
 	char tmp_name[50] = { 0, };
 	char *tmp_number = NULL;
-	char *domain = NULL;
+	char *hostport = NULL;
 	char *dummy = NULL;
 
 	if (!name || !number || ast_strlen_zero(hdr)) {
@@ -866,7 +866,7 @@
 	tmp_number = get_in_brackets(header);
 
 	/* parse out the number here */
-	if (parse_uri(tmp_number, "sip:,sips:", &tmp_number, &dummy, &domain, NULL) || ast_strlen_zero(tmp_number)) {
+	if (parse_uri(tmp_number, "sip:,sips:", &tmp_number, &dummy, &hostport, NULL) || ast_strlen_zero(tmp_number)) {
 		ast_log(LOG_ERROR, "can not parse name and number from sip header.\n");
 		return -1;
 	}
@@ -1153,7 +1153,7 @@
 
 
 int parse_name_andor_addr(char *uri, const char *scheme, char **name,
-			  char **user, char **pass, char **domain,
+			  char **user, char **pass, char **hostport,
 			  struct uriparams *params, char **headers,
 			  char **residue)
 {
@@ -1170,7 +1170,7 @@
 		residue2 = NULL;
 	}
 
-	return parse_uri_full(uri, scheme, user, pass, domain, params, headers,
+	return parse_uri_full(uri, scheme, user, pass, hostport, params, headers,
 			      residue2);
 }
 
@@ -1178,7 +1178,7 @@
 {
 	int res = AST_TEST_PASS;
 	char uri[1024];
-	char *name, *user, *pass, *domain, *headers, *residue;
+	char *name, *user, *pass, *hostport, *headers, *residue;
 	struct uriparams params;
 
 	struct testdata {
@@ -1187,14 +1187,14 @@
 		char **nameptr;
 		char **userptr;
 		char **passptr;
-		char **domainptr;
+		char **hostportptr;
 		char **headersptr;
 		char **residueptr;
 		struct uriparams *paramsptr;
 		char *name;
 		char *user;
 		char *pass;
-		char *domain;
+		char *hostport;
 		char *headers;
 		char *residue;
 		struct uriparams params;
@@ -1211,14 +1211,14 @@
 		.nameptr = &name,
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.name =  "name :@ ",
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "tag=tag",
 		.params.transport = "tcp",
@@ -1232,14 +1232,14 @@
 		.nameptr = &name,
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.name = "givenname familyname",
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "expires=3600",
 		.params.transport = "tcp",
@@ -1253,14 +1253,14 @@
 		.nameptr = &name,
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.name = "",
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5060",
+		.hostport = "host:5060",
 		.headers = "",
 		.residue = "q=1",
 		.params.transport = "tcp",
@@ -1274,14 +1274,14 @@
 		.nameptr = &name,
 		.userptr = &user,
 		.passptr = &pass,
-		.domainptr = &domain,
+		.hostportptr = &hostport,
 		.headersptr = &headers,
 		.residueptr = &residue,
 		.paramsptr = &params,
 		.name = "",
 		.user = "",
 		.pass = "",
-		.domain = "host",
+		.hostport = "host",
 		.headers = "",
 		.residue = "",
 		.params.transport = "",
@@ -1310,7 +1310,7 @@
 	}
 
 	AST_LIST_TRAVERSE(&testdatalist, testdataptr, list) {
-		name = user = pass = domain = headers = residue = NULL;
+		name = user = pass = hostport = headers = residue = NULL;
 		params.transport = params.user = params.method = params.ttl = params.maddr = NULL;
 		params.lr = 0;
 	ast_copy_string(uri,testdataptr->uri,sizeof(uri));
@@ -1318,14 +1318,14 @@
 					  testdataptr->nameptr,
 					  testdataptr->userptr,
 					  testdataptr->passptr,
-					  testdataptr->domainptr,
+					  testdataptr->hostportptr,
 					  testdataptr->paramsptr,
 					  testdataptr->headersptr,
 					  testdataptr->residueptr) ||
 			((testdataptr->nameptr) && strcmp(testdataptr->name, name)) ||
 			((testdataptr->userptr) && strcmp(testdataptr->user, user)) ||
 			((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) ||
-			((testdataptr->domainptr) && strcmp(testdataptr->domain, domain)) ||
+			((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) ||
 			((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) ||
 			((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) ||
 			((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) ||
@@ -1396,7 +1396,7 @@
 
 		res = parse_name_andor_addr(contactheader, "sip:,sips:",
 					    &contact->name, &contact->user,
-					    &contact->pass, &contact->domain,
+					    &contact->pass, &contact->hostport,
 					    &contact->params, &contact->headers,
 					    &residue);
 		if (res == -1) {
@@ -1469,7 +1469,7 @@
 		.name = "name :@;?&,",
 		.user = "user",
 		.pass = "secret",
-		.domain = "host:5082",
+		.hostport = "host:5082",
 		.params.transport = "tcp",
 		.params.ttl = "",
 		.params.lr = 0,
@@ -1488,7 +1488,7 @@
 		.name = "",
 		.user = ",user1,",
 		.pass = ",secret1,",
-		.domain = "host1",
+		.hostport = "host1",
 		.params.transport = "",
 		.params.ttl = "7",
 		.params.lr = 0,
@@ -1500,7 +1500,7 @@
 		.name = "",
 		.user = "",
 		.pass = "",
-		.domain = "host2",
+		.hostport = "host2",
 		.params.transport = "",
 		.params.ttl = "",
 		.params.lr = 0,
@@ -1556,7 +1556,7 @@
 					strcmp(tdcontactptr->name, contactptr->name) ||
 					strcmp(tdcontactptr->user, contactptr->user) ||
 					strcmp(tdcontactptr->pass, contactptr->pass) ||
-					strcmp(tdcontactptr->domain, contactptr->domain) ||
+					strcmp(tdcontactptr->hostport, contactptr->hostport) ||
 					strcmp(tdcontactptr->headers, contactptr->headers) ||
 					strcmp(tdcontactptr->expires, contactptr->expires) ||
 					strcmp(tdcontactptr->q, contactptr->q) ||




More information about the asterisk-commits mailing list