summaryrefslogtreecommitdiff
path: root/lib/net.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-01-26 11:48:58 +0100
committerJan Moskyto Matejka <mq@ucw.cz>2016-02-01 10:28:50 +0100
commitf4a60a9bc429c28cb397402331dc01a789197450 (patch)
treee8cead76aa1c2aedfb76d7e3ceade2fc4a7214cf /lib/net.h
parent9f5782d9691f23296c4b1a68ef66630d9cc3a6cd (diff)
Channels - explicit links between protocols and tables
The patch adds support for channels, structures connecting protocols and tables and handling most interactions between them. The documentation is missing yet.
Diffstat (limited to 'lib/net.h')
-rw-r--r--lib/net.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/net.h b/lib/net.h
index dd6e597a..fbce2811 100644
--- a/lib/net.h
+++ b/lib/net.h
@@ -21,6 +21,15 @@
#define NET_ROA6 6
#define NET_MAX 7
+#define NB_IP4 (1 << NET_IP4)
+#define NB_IP6 (1 << NET_IP6)
+#define NB_VPN4 (1 << NET_VPN4)
+#define NB_VPN6 (1 << NET_VPN6)
+
+#define NB_IP (NB_IP4 | NB_IP6)
+#define NB_ANY 0xffffffff
+
+
typedef struct net_addr {
u8 type;
u8 pxlen;
@@ -88,6 +97,7 @@ typedef union net_addr_union {
} net_addr_union;
+extern const char * const net_label[];
extern const u16 net_addr_length[];
extern const u8 net_max_prefix_length[];
extern const u16 net_max_text_length[];
@@ -149,6 +159,13 @@ static inline void net_fill_ip_host(net_addr *a, ip_addr prefix)
net_fill_ip6(a, ipa_to_ip6(prefix), IP6_MAX_PREFIX_LENGTH);
}
+
+static inline int net_val_match(u8 type, u32 mask)
+{ return !!((1 << type) & mask); }
+
+static inline int net_type_match(const net_addr *a, u32 mask)
+{ return net_val_match(a->type, mask); }
+
static inline int net_is_ip(const net_addr *a)
{ return (a->type == NET_IP4) || (a->type == NET_IP6); }