diff options
author | 2019-10-21 14:38:53 +0000 | |
---|---|---|
committer | 2019-10-21 14:38:53 +0000 | |
commit | feb1b21f498e9bdf0aea7c83d2ef5468500574f3 (patch) | |
tree | 990beafbde124917672e06554234634e10d7c609 /lib | |
parent | 88706ad899f4605e7e768cc9d5d213785a392679 (diff) | |
parent | 2e6f86232a6735f563ba502f963b4dda80e06d4e (diff) |
Merge "[HICN-320] HICN Light only configuring the first entry on FIB"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/util/ip_address.c | 11 |
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); |