[asterisk-commits] mmichelson: branch mmichelson/acl-v6 r276211 - /team/mmichelson/acl-v6/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 13 17:12:52 CDT 2010


Author: mmichelson
Date: Tue Jul 13 17:12:41 2010
New Revision: 276211

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276211
Log:
Yay! It compiles!

Guess it's time to merge...

Nah, I'll test first.


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=276211&r1=276210&r2=276211
==============================================================================
--- team/mmichelson/acl-v6/main/acl.c (original)
+++ team/mmichelson/acl-v6/main/acl.c Tue Jul 13 17:12:41 2010
@@ -271,7 +271,7 @@
 	return ret;                             /* Return start of list */
 }
 
-#define V6_WORD(sin6, index) ((uint32_t *)&((sin6)->sin_addr))[(index)]
+#define V6_WORD(sin6, index) ((uint32_t *)&((sin6)->sin6_addr))[(index)]
 
 /*!
  * \brief
@@ -287,7 +287,7 @@
  * \param[out] output The resulting IPv4-mapped IPv6 address.
  * \retval void
  */
-void make_v4_mapped(struct ast_sockaddr *input, struct ast_sockaddr *output)
+static void make_v4_mapped(struct ast_sockaddr *input, struct ast_sockaddr *output)
 {
 	struct sockaddr_in6 sin6;
 	static const uint32_t prefix = 0x0000FFFF;
@@ -316,12 +316,12 @@
  * \param output The resulting IPv6 netmask
  * \retval void
  */ 
-void map_mask(struct ast_sockaddr *input, struct ast_sockaddr *output)
+static void map_mask(struct ast_sockaddr *input, struct ast_sockaddr *output)
 {
 	struct sockaddr_in6 sin6;
 
 	sin6.sin6_family = AF_INET6;
-	memset(&sin6->s6_addr, 96, 0xFF);
+	memset(&sin6.sin6_addr, 0xFF, 12);
 	V6_WORD(&sin6, 3) = htonl(ast_sockaddr_ipv4(input));
 
 	memcpy(&output->ss, &sin6, sizeof(sin6));
@@ -336,22 +336,23 @@
  * logical and operation. Furthermore, the incoming address may be an IPv4 address
  * and need to be mapped properly before attempting to apply a rule.
  */
-void apply_netmask(struct ast_sockaddr *addr, struct ast_sockaddr *netmask,
+static void apply_netmask(struct ast_sockaddr *addr, struct ast_sockaddr *netmask,
 		struct ast_sockaddr *result)
 {
-	struct sockaddr_in6 addr6;
-	struct sockaddr_in6 mask6 = (struct sockaddr_in6)addr->ss;
+	struct sockaddr_in6 *addr6;
+	struct sockaddr_in6 *mask6 = (struct sockaddr_in6 *) &addr->ss;
 	struct sockaddr_in6 result6;
+	int i;
 
 	if (ast_sockaddr_is_ipv4(addr)) {
 		make_v4_mapped(addr, addr);
 	}
 
-	addr6 = (struct sockaddr_in6)addr->ss;
+	addr6 = (struct sockaddr_in6 *) &addr->ss;
 
 	result6.sin6_family = AF_INET6;
 	for (i = 0; i < 4; ++i) {
-		V6_WORD(&result6, i) = V6_WORD(&addr6, i) & V6_WORD(&mask6, i);
+		V6_WORD(&result6, i) = V6_WORD(addr6, i) & V6_WORD(mask6, i);
 	}
 	memcpy(&result->ss, &result6, sizeof(result6));
 	result->len = sizeof(result6);
@@ -371,10 +372,11 @@
  * \param is_v4 Tells if the address we are masking is IPv4.
  * \param mask_str The CIDR mask to convert
  */
-int parse_cidr_mask(struct ast_sockaddr *addr, int is_v4, const char *mask_str)
+static int parse_cidr_mask(struct ast_sockaddr *addr, int is_v4, const char *mask_str)
 {
 	int mask;
 	struct sockaddr_in6 sin6;
+	int i;
 
 	if (sscanf(mask_str, "%30d", &mask) != 1) {
 		return -1;
@@ -395,7 +397,7 @@
 		if (mask >= 32) {
 			V6_WORD(&sin6, i) = htonl(0xFFFFFFFF);
 			mask -= 32;
-		else if (mask > 0) {
+		} else if (mask > 0) {
 			V6_WORD(&sin6, i) = htonl(0xFFFFFFFF << (32 - mask));
 			/* Set mask to 0 so the remaining parts of the address
 			 * Get filled in properly with zeros
@@ -416,15 +418,12 @@
 struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
 {
 	struct ast_ha *ha;
-	char *nm;
 	struct ast_ha *prev = NULL;
 	struct ast_ha *ret;
-	int x;
 	char *tmp = ast_strdupa(stuff);
 	char *address = NULL, *mask = NULL;
-	struct ast_sockaddr addr_sock, mask_sock;
+	struct ast_sockaddr addr_sock;
 	int addr_is_v4;
-	int mask_is_v4;
 
 	ret = path;
 	while (path) {
@@ -466,7 +465,7 @@
 			ast_free_ha(ha);
 			return ret;
 		}
-		mask_is_v4 = ast_sockadddr_is_ipv4(&mask_sock);
+		mask_is_v4 = ast_sockaddr_is_ipv4(&mask_sock);
 		if (addr_is_v4 ^ mask_is_v4) {
 			ast_log(LOG_WARNING, "Address and mask are not using same address scheme.\n");
 			ast_free_ha(ha);
@@ -491,7 +490,7 @@
 		ret = ha;
 	}
 
-	ast_debug(1, "%s/%s sense %d appended to acl for peer\n", ast_strdupa(ast_inet_ntoa(ha->netaddr)), ast_strdupa(ast_inet_ntoa(ha->netmask)), ha->sense);
+	ast_debug(1, "%s/%s sense %d appended to acl for peer\n", ast_strdupa(ast_sockaddr_stringify(&ha->addr)), ast_strdupa(ast_sockaddr_stringify(&ha->netmask)), ha->sense);
 
 	return ret;
 }




More information about the asterisk-commits mailing list