summaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-21 12:02:35 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-21 16:02:15 +0200
commit2e6f86232a6735f563ba502f963b4dda80e06d4e (patch)
tree98a96f949c8fa615d7ce8ef62eab14d930bea02f /lib/src
parent7204bac00804448a797d4e76ced04a3b84d0d741 (diff)
[HICN-320] HICN Light only configuring the first entry on FIB
Change-Id: Ica111f54b23a9a56433e9b195a3fccd913952ad0 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/util/ip_address.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c
index 2cf2aaef3..7afd3e2a4 100644
--- a/lib/src/util/ip_address.c
+++ b/lib/src/util/ip_address.c
@@ -190,9 +190,9 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
char *addr = strdup (ip_address_str);
p = strchr (addr, '/');
- if (!p)
- ip_prefix->len = 0; // until we get the ip address family
- else {
+ if (!p) {
+ ip_prefix->len = ~0; // until we get the ip address family
+ } else {
ip_prefix->len = strtoul (p + 1, &eptr, 10);
*p = 0;
}
@@ -202,11 +202,15 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
switch (ip_prefix->family)
{
case AF_INET6:
+ if (ip_prefix->len == (u8)~0)
+ ip_prefix->len = IPV6_ADDR_LEN_BITS;
if (ip_prefix->len > IPV6_ADDR_LEN_BITS)
goto ERR;
pton_fd = inet_pton (AF_INET6, addr, &ip_prefix->address.buffer);
break;
case AF_INET:
+ if (ip_prefix->len == (u8)~0)
+ ip_prefix->len = IPV4_ADDR_LEN_BITS;
if (ip_prefix->len > IPV4_ADDR_LEN_BITS)
goto ERR;
pton_fd = inet_pton (AF_INET, addr, &ip_prefix->address.buffer);
@@ -220,6 +224,7 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
if (pton_fd <= 0)
goto ERR;
+ free(addr);
return 1;
ERR:
free (addr);