[MERGED] openggsn[master]: lib/in46_addr: Add in46a_ntoa() function, similar to inet_nt...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Sep 5 21:06:03 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: lib/in46_addr: Add in46a_ntoa() function, similar to inet_ntoa()
......................................................................


lib/in46_addr: Add in46a_ntoa() function, similar to inet_ntoa()

Change-Id: I752b7033a106a74dc219047da5c3a7ad3cd3602e
---
M lib/in46_addr.c
M lib/in46_addr.h
2 files changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 	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 @@
 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);

-- 
To view, visit https://gerrit.osmocom.org/3838
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I752b7033a106a74dc219047da5c3a7ad3cd3602e
Gerrit-PatchSet: 3
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list