diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-05-12 16:04:47 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-05-12 16:04:47 +0200 |
commit | 286e2011d22ea6914d5f2db5de3f11911a1fb663 (patch) | |
tree | 7caa6725f988f51fab0c3ba09a909c66c828b378 /lib | |
parent | 0c6dfe52369a59d7f3da8ee6bc7c505e3da5c064 (diff) |
Miscellaneous minor fixes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net.c | 8 | ||||
-rw-r--r-- | lib/net.h | 8 |
2 files changed, 13 insertions, 3 deletions
@@ -8,7 +8,9 @@ const char * const net_label[] = { [NET_IP4] = "ipv4", [NET_IP6] = "ipv6", [NET_VPN4] = "vpn4", - [NET_VPN6] = "vpn6" + [NET_VPN6] = "vpn6", + [NET_ROA4] = "roa4", + [NET_ROA6] = "roa6", }; const u16 net_addr_length[] = { @@ -34,8 +36,8 @@ const u16 net_max_text_length[] = { [NET_IP6] = 43, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */ [NET_VPN4] = 40, /* "4294967296:4294967296 255.255.255.255/32" */ [NET_VPN6] = 65, /* "4294967296:4294967296 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */ - [NET_ROA4] = 30, /* "255.255.255.255/32 AS4294967295" */ - [NET_ROA6] = 56, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128 AS4294967295" */ + [NET_ROA4] = 34, /* "255.255.255.255/32-32 AS4294967295" */ + [NET_ROA6] = 60, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128-128 AS4294967295" */ }; @@ -25,6 +25,8 @@ #define NB_IP6 (1 << NET_IP6) #define NB_VPN4 (1 << NET_VPN4) #define NB_VPN6 (1 << NET_VPN6) +#define NB_ROA4 (1 << NET_ROA4) +#define NB_ROA6 (1 << NET_ROA6) #define NB_IP (NB_IP4 | NB_IP6) #define NB_ANY 0xffffffff @@ -228,6 +230,12 @@ static inline int net_equal_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b) static inline int net_equal_roa6(const net_addr_roa6 *a, const net_addr_roa6 *b) { return !memcmp(a, b, sizeof(net_addr_roa6)); } +static inline int net_equal_prefix_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b) +{ return ip4_equal(a->prefix, b->prefix) && (a->pxlen == b->pxlen); } + +static inline int net_equal_prefix_roa6(const net_addr_roa6 *a, const net_addr_roa6 *b) +{ return ip6_equal(a->prefix, b->prefix) && (a->pxlen == b->pxlen); } + static inline int net_zero_ip4(const net_addr_ip4 *a) { return !a->pxlen && ip4_zero(a->prefix); } |