ippool: Add IPv6 support to IP pool implementation

Extend the IP pool implementation to be able to manage both pools
of 32bit addresses (IPv4) as well as pools of 128bit addresses (IPv6)

Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8
diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c
index dbe5a9f..458ac27 100644
--- a/ggsn/gtp-kernel.c
+++ b/ggsn/gtp-kernel.c
@@ -70,17 +70,6 @@
 	printf("\n");
 }
 
-static int mask2prefix(struct in_addr *mask)
-{
-	uint32_t tmp = ntohl(mask->s_addr);
-	int k;
-
-	for (k=0; tmp > 0; k++)
-		tmp = (tmp << 1);
-
-	return k;
-}
-
 static struct {
 	int			genl_id;
 	struct mnl_socket	*nl;
@@ -91,7 +80,7 @@
 #define GTP_DEVNAME	"gtp0"
 
 int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
-		    struct in_addr *mask,
+		    size_t prefixlen,
 		    struct gengetopt_args_info *args_info)
 {
 	if (!args_info->gtp_linux_given)
@@ -126,7 +115,7 @@
 	DEBUGP(DGGSN, "Setting route to reach %s via %s\n",
 	       args_info->net_arg, GTP_DEVNAME);
 
-	if (gtp_dev_config(GTP_DEVNAME, net, mask2prefix(mask)) < 0) {
+	if (gtp_dev_config(GTP_DEVNAME, net, prefixlen) < 0) {
 		SYS_ERR(DGGSN, LOGL_ERROR, 0,
 			"Cannot add route to reach network %s\n",
 			args_info->net_arg);