diff options
Diffstat (limited to 'lib/src')
-rw-r--r-- | lib/src/compat.c | 6 | ||||
-rw-r--r-- | lib/src/util/ip_address.c | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c index 9834b9d44..d76e17a6d 100644 --- a/lib/src/compat.c +++ b/lib/src/compat.c @@ -182,8 +182,10 @@ hicn_packet_get_header_length (hicn_format_t format, const hicn_header_t * h, int is_ipv4 = _is_ipv4 (format); int is_ipv6 = _is_ipv6 (format); // The signature payload is expressed as number of 32 bits words - *header_length += (is_ah * is_ipv4) * (h->v4ah.ah.payloadlen) << 2; - *header_length += (is_ah * is_ipv6) * (h->v6ah.ah.payloadlen) << 2; + if (is_ah && is_ipv4) + *header_length += (h->v4ah.ah.payloadlen) << 2; + else if(is_ah && is_ipv6) + *header_length += (h->v6ah.ah.payloadlen) << 2; return HICN_LIB_ERROR_NONE; } diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c index ea238167f..2cf2aaef3 100644 --- a/lib/src/util/ip_address.c +++ b/lib/src/util/ip_address.c @@ -227,7 +227,19 @@ ERR: } int -ip_prefix_ntop (const ip_prefix_t * ip_prefix, char *dst, size_t size) +ip_prefix_ntop_short(const ip_prefix_t * ip_prefix, char *dst, size_t size) +{ + char ip_s[MAXSZ_IP_ADDRESS]; + const char * s = inet_ntop (ip_prefix->family, ip_prefix->address.buffer, ip_s, MAXSZ_IP_ADDRESS); + if (!s) + return -1; + size_t n = snprintf(dst, size, "%s", ip_s); + + return (n > 0 ? 1 : -1); +} + +int +ip_prefix_ntop(const ip_prefix_t * ip_prefix, char *dst, size_t size) { char ip_s[MAXSZ_IP_ADDRESS]; const char * s = inet_ntop (ip_prefix->family, ip_prefix->address.buffer, ip_s, MAXSZ_IP_ADDRESS); |