aboutsummaryrefslogtreecommitdiffstats
path: root/lib/in46_addr.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/in46_addr.h')
-rw-r--r--lib/in46_addr.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/in46_addr.h b/lib/in46_addr.h
new file mode 100644
index 0000000..f28fd8e
--- /dev/null
+++ b/lib/in46_addr.h
@@ -0,0 +1,19 @@
+#pragma once
+#include <stdint.h>
+#include <netinet/in.h>
+
+/* a simple wrapper around an in6_addr to also contain the length of the address,
+ * thereby implicitly indicating the address family of the address */
+struct in46_addr {
+ uint8_t len;
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ };
+};
+
+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 int in46a_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);