summaryrefslogtreecommitdiff
path: root/lib/net.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-10 13:18:36 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-10 13:18:36 +0100
commit67a2eb9177fe0b8a6854775a4fad1f7768f6a94a (patch)
tree301cd4d9bd6b5b897235f06f38f2c00caf6eea4b /lib/net.c
parenta32a7b58cebc2838de2ffd94e679d3e1ec9d493a (diff)
Lib: Check size of nets
Diffstat (limited to 'lib/net.c')
-rw-r--r--lib/net.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/net.c b/lib/net.c
index a00ff272..9335b78f 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -288,3 +288,21 @@ net_in_netX(const net_addr *a, const net_addr *n)
return (net_pxlen(n) <= net_pxlen(a)) && ipa_in_netX(net_prefix(a), n);
}
+
+#define CHECK_NET(T,S) \
+ ({ if (sizeof(T) != S) die("sizeof %s is %d/%d", #T, (int) sizeof(T), S); })
+
+void
+net_init(void)
+{
+ CHECK_NET(net_addr, 24);
+ CHECK_NET(net_addr_ip4, 8);
+ CHECK_NET(net_addr_ip6, 20);
+ CHECK_NET(net_addr_vpn4, 16);
+ CHECK_NET(net_addr_vpn6, 32);
+ CHECK_NET(net_addr_roa4, 16);
+ CHECK_NET(net_addr_roa6, 28);
+ CHECK_NET(net_addr_flow4, 8);
+ CHECK_NET(net_addr_flow6, 20);
+ CHECK_NET(net_addr_mpls, 8);
+}