[asterisk-commits] file: trunk r404620 - in /trunk: ./ res/res_pjsip_endpoint_identifier_ip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 31 16:21:09 CST 2013


Author: file
Date: Tue Dec 31 16:21:07 2013
New Revision: 404620

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404620
Log:
res_pjsip_endpoint_identifier_ip: Accept hostnames in the 'match' field.

Hostnames specified in the 'match' field will be resolved and all addresses
returned. Each address will be added to the endpoint identifier for the
matching process.

Reported by: Rob Thomas
........

Merged revisions 404613 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip_endpoint_identifier_ip.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Dec 31 16:21:07 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592,404605
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592,404605,404613

Modified: trunk/res/res_pjsip_endpoint_identifier_ip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_endpoint_identifier_ip.c?view=diff&rev=404620&r1=404619&r2=404620
==============================================================================
--- trunk/res/res_pjsip_endpoint_identifier_ip.c (original)
+++ trunk/res/res_pjsip_endpoint_identifier_ip.c Tue Dec 31 16:21:07 2013
@@ -156,12 +156,29 @@
 static int ip_identify_match_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
 {
 	struct ip_identify_match *identify = obj;
-	int error = 0;
-
-	/* We deny what we actually want to match because there is an implicit permit all rule for ACLs */
-	if (!(identify->matches = ast_append_ha("d", var->value, identify->matches, &error))) {
-		return -1;
-	}
+	int num_addrs = 0, error = 0, i;
+	struct ast_sockaddr *addrs;
+
+	num_addrs = ast_sockaddr_resolve(&addrs, var->value, PARSE_PORT_FORBID, AST_AF_UNSPEC);
+	if (!num_addrs) {
+		ast_log(LOG_ERROR, "Address '%s' provided on ip endpoint identifier '%s' did not resolve to any address\n",
+			var->value, ast_sorcery_object_get_id(obj));
+		return -1;
+	}
+
+	for (i = 0; i < num_addrs; ++i) {
+		/* We deny what we actually want to match because there is an implicit permit all rule for ACLs */
+		identify->matches = ast_append_ha("d", ast_sockaddr_stringify_addr(&addrs[i]), identify->matches, &error);
+
+		if (!identify->matches || error) {
+			ast_log(LOG_ERROR, "Failed to add address '%s' to ip endpoint identifier '%s'\n",
+				ast_sockaddr_stringify_addr(&addrs[i]), ast_sorcery_object_get_id(obj));
+			error = -1;
+			break;
+		}
+	}
+
+	ast_free(addrs);
 
 	return error;
 }




More information about the asterisk-commits mailing list