aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/util
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-08 15:11:40 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-08 15:11:40 +0200
commit3dc2973161d71060cbea62063d219077f531af8a (patch)
tree7b08c1077695c47c292a063cc926a05a2db75a39 /lib/src/util
parent1bc4aca90da898424da7609af59aec5ac4770f73 (diff)
[HICN-306] Wrong representation format in ip_prefix_ntop causes parsing issues
Change-Id: I16c8059ce537f338c15434acc87ac0e4baf87049 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/src/util')
-rw-r--r--lib/src/util/ip_address.c14
1 files changed, 13 insertions, 1 deletions
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);