aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/in46_addr.c10
-rw-r--r--lib/in46_addr.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/in46_addr.c b/lib/in46_addr.c
index 8f5cc09..4e7cbcd 100644
--- a/lib/in46_addr.c
+++ b/lib/in46_addr.c
@@ -69,6 +69,16 @@ const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size
return inet_ntop(af, (const void *) &in->v4, dst, dst_size);
}
+/* like inet_ntoa() */
+const char *in46a_ntoa(const struct in46_addr *in46)
+{
+ static char addrstr_buf[256];
+ if (in46a_ntop(in46, addrstr_buf, sizeof(addrstr_buf)) < 0)
+ return "INVALID";
+ else
+ return addrstr_buf;
+}
+
/*! Determine if two in46_addr are equal or not
* \returns 1 in case they are equal; 0 otherwise */
int in46a_equal(const struct in46_addr *a, const struct in46_addr *b)
diff --git a/lib/in46_addr.h b/lib/in46_addr.h
index 0afd2b4..1614c1d 100644
--- a/lib/in46_addr.h
+++ b/lib/in46_addr.h
@@ -17,6 +17,7 @@ struct in46_addr {
extern int in46a_to_af(const struct in46_addr *in);
extern int in46a_to_sas(struct sockaddr_storage *out, const struct in46_addr *in);
extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size);
+extern const char *in46a_ntoa(const struct in46_addr *in46);
extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b);
extern int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b);
extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen);