[PATCH v0 3/9] ippool: Add prefixlen argument to __connman_ippool_new/deladdr()

Daniel Wagner wagi at monom.org
Thu Feb 9 02:25:47 PST 2012


From: Daniel Wagner <daniel.wagner at bmw-carit.de>

---
 src/connman.h      |    6 ++++--
 src/ipconfig.c     |    8 ++++----
 src/ippool.c       |    6 ++++--
 unit/test-ippool.c |    4 ++--
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index dcde0f3..56a0854 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -742,5 +742,7 @@ const char *__connman_ippool_get_subnet_mask(struct connman_ippool *pool);
 const char *__connman_ippool_get_start_ip(struct connman_ippool *pool);
 const char *__connman_ippool_get_end_ip(struct connman_ippool *pool);
 
-void __connman_ippool_newaddr(int index, const char *address);
-void __connman_ippool_deladdr(int index, const char *address);
+void __connman_ippool_newaddr(int index, const char *address,
+				unsigned char prefixlen);
+void __connman_ippool_deladdr(int index, const char *address,
+				unsigned char prefixlen);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 1f79d2e..e782fb1 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -807,7 +807,7 @@ void __connman_ipconfig_newaddr(int index, int family, const char *label,
 		ipdevice->ifname, address, prefixlen, label, family);
 
 	if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
-		__connman_ippool_newaddr(index, address);
+		__connman_ippool_newaddr(index, address, prefixlen);
 
 	if (ipdevice->config_ipv4 != NULL && family == AF_INET)
 		connman_ipaddress_copy(ipdevice->config_ipv4->system,
@@ -868,15 +868,15 @@ void __connman_ipconfig_deladdr(int index, int family, const char *label,
 	ipdevice->address_list = g_slist_remove(ipdevice->address_list,
 								ipaddress);
 
+	if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+		__connman_ippool_deladdr(index, address, prefixlen);
+
 	connman_ipaddress_clear(ipaddress);
 	g_free(ipaddress);
 
 	connman_info("%s {del} address %s/%u label %s", ipdevice->ifname,
 						address, prefixlen, label);
 
-	if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
-		__connman_ippool_deladdr(index, address);
-
 	if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
 		return;
 
diff --git a/src/ippool.c b/src/ippool.c
index a4819ee..f0952ff 100644
--- a/src/ippool.c
+++ b/src/ippool.c
@@ -196,7 +196,8 @@ static uint32_t find_free_block()
 	return 0;
 }
 
-void __connman_ippool_newaddr(int index, const char *address)
+void __connman_ippool_newaddr(int index, const char *address,
+				unsigned char prefixlen)
 {
 	struct connman_ippool *pool;
 	struct in_addr inp;
@@ -225,7 +226,8 @@ void __connman_ippool_newaddr(int index, const char *address)
 		pool->collision_cb(pool, pool->user_data);
 }
 
-void __connman_ippool_deladdr(int index, const char *address)
+void __connman_ippool_deladdr(int index, const char *address,
+				unsigned char prefixlen)
 {
 	struct in_addr inp;
 	uint32_t block;
diff --git a/unit/test-ippool.c b/unit/test-ippool.c
index 0794bde..7b4a91b 100644
--- a/unit/test-ippool.c
+++ b/unit/test-ippool.c
@@ -179,11 +179,11 @@ static void test_ippool_collision0(void)
 		"\tgateway %s broadcast %s mask %s", start_ip, end_ip,
 		gateway, broadcast, subnet_mask);
 
-	__connman_ippool_newaddr(23, start_ip);
+	__connman_ippool_newaddr(23, start_ip, 24);
 
 	g_assert(flag == 0);
 
-	__connman_ippool_newaddr(42, start_ip);
+	__connman_ippool_newaddr(42, start_ip, 24);
 
 	g_assert(flag == 1);
 
-- 
1.7.9.48.g85da4d




More information about the connman mailing list