[MERGED] openggsn[master]: lib/in46_addr: Add 'struct in46_prefix' to represent addr + ...

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 'struct in46_prefix' to represent addr + prefix
......................................................................


lib/in46_addr: Add 'struct in46_prefix' to represent addr + prefix

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

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



diff --git a/lib/in46_addr.c b/lib/in46_addr.c
index 4e7cbcd..6864c64 100644
--- a/lib/in46_addr.c
+++ b/lib/in46_addr.c
@@ -79,6 +79,13 @@
 		return addrstr_buf;
 }
 
+const char *in46p_ntoa(const struct in46_prefix *in46p)
+{
+	static char addrstr_buf[256];
+	snprintf(addrstr_buf, sizeof(addrstr_buf), "%s/%u", in46a_ntoa(&in46p->addr), in46p->prefixlen);
+	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 1614c1d..ce2df14 100644
--- a/lib/in46_addr.h
+++ b/lib/in46_addr.h
@@ -14,10 +14,16 @@
 	};
 };
 
+struct in46_prefix {
+	struct in46_addr addr;
+	uint8_t prefixlen;
+};
+
 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 const char *in46p_ntoa(const struct in46_prefix *in46p);
 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/3839
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I797d105117e81951732bcfc2cc26a8d00fd69443
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



More information about the gerrit-log mailing list