From 2e6f86232a6735f563ba502f963b4dda80e06d4e Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Mon, 21 Oct 2019 12:02:35 +0200 Subject: [HICN-320] HICN Light only configuring the first entry on FIB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ica111f54b23a9a56433e9b195a3fccd913952ad0 Signed-off-by: Jordan Augé --- lib/src/util/ip_address.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') 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); -- cgit 1.2.3-korg