aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/hicn/util/ip_address.h1
-rw-r--r--lib/src/util/ip_address.c14
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/includes/hicn/util/ip_address.h b/lib/includes/hicn/util/ip_address.h
index 728a9da90..542e6e4c6 100644
--- a/lib/includes/hicn/util/ip_address.h
+++ b/lib/includes/hicn/util/ip_address.h
@@ -135,6 +135,7 @@ int ip_address_empty(const ip_address_t * ip);
/* Prefix */
int ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix);
+int ip_prefix_ntop_short (const ip_prefix_t * ip_prefix, char *dst, size_t size);
int ip_prefix_ntop (const ip_prefix_t * ip_prefix, char *dst, size_t size);
int ip_prefix_len (const ip_prefix_t * prefix);
bool ip_prefix_empty (const ip_prefix_t * prefix);
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);