[svn-commits] mmichelson: branch mmichelson/acl-v6 r276486 - /team/mmichelson/acl-v6/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 14 15:38:31 CDT 2010


Author: mmichelson
Date: Wed Jul 14 15:38:20 2010
New Revision: 276486

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276486
Log:
* Fix documentation of map_mask
* Make map_mask code more uniform


Modified:
    team/mmichelson/acl-v6/main/acl.c

Modified: team/mmichelson/acl-v6/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/acl-v6/main/acl.c?view=diff&rev=276486&r1=276485&r2=276486
==============================================================================
--- team/mmichelson/acl-v6/main/acl.c (original)
+++ team/mmichelson/acl-v6/main/acl.c Wed Jul 14 15:38:20 2010
@@ -308,9 +308,10 @@
  *
  * \details
  * ast_ha uses IPv6 internally for its rules, even though IPv4
- * addresses can be specified in a rule. With netmasks, we need
- * to pad the first 96 bits of the IPv6 address with all ones to
- * achieve our goal.
+ * addresses can be specified in a rule. To accomplish this, we
+ * will map the mask into an IPv6 address. The exception is if
+ * an all 0s IPv4 netmask is specified. In this case, we make
+ * an all 0s IPv6 netmask.
  *
  * \param input The IPv4 netmask to convert
  * \param output The resulting IPv6 netmask
@@ -319,16 +320,13 @@
 static void map_mask(struct ast_sockaddr *input, struct ast_sockaddr *output)
 {
 	struct sockaddr_in6 sin6 = {0,};
-
+	if (!ast_sockaddr_is_any(input)) {
+		make_v4_mapped(input, output);
+		return;
+	}
+	memset(&sin6, 0, sizeof(sin6));
 	sin6.sin6_family = AF_INET6;
-	if (ast_sockaddr_is_any(input)) {
-		memset(&sin6.sin6_addr, 0x00, 16);
-	} else {
-		memset(&sin6.sin6_addr, 0x00, 8);
-		V6_WORD(&sin6, 2) = (uint32_t)htonl(0x0000FFFF);
-		V6_WORD(&sin6, 3) = (uint32_t)htonl(ast_sockaddr_ipv4(input));
-	}
-
+	memset(&sin6.sin6_addr, 0x00, 16);
 	memcpy(&output->ss, &sin6, sizeof(sin6));
 	output->len = sizeof(sin6);
 }
@@ -472,7 +470,7 @@
 	}
 
 	if (!mask) {
-		parse_cidr_mask(&ha->netmask, addr_is_v4, addr_is_v4 ? 32 : 128);
+		parse_cidr_mask(&ha->netmask, addr_is_v4, addr_is_v4 ? "32" : "128");
 	} else if (strchr(mask, ':') || strchr(mask, '.')) {
 		int mask_is_v4;
 		struct ast_sockaddr mask_sock;




More information about the svn-commits mailing list