summaryrefslogtreecommitdiff
path: root/lib/net.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-24 15:52:03 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-24 15:56:04 +0100
commit04632fd77f291f67753341d12d540f7dac341bd3 (patch)
tree94b319a0fe0e312539857e76e0b9d6982ce81555 /lib/net.h
parent70b90dde23a684c4d32aa53685f76a73ecba941d (diff)
Follow-up work on integration
Diffstat (limited to 'lib/net.h')
-rw-r--r--lib/net.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/net.h b/lib/net.h
index 9439c6db..b0ab2153 100644
--- a/lib/net.h
+++ b/lib/net.h
@@ -107,6 +107,17 @@ static inline void net_fill_ipa(net_addr *a, ip_addr prefix, uint pxlen)
net_fill_ip6(a, ipa_to_ip6(prefix), pxlen);
}
+static inline void net_fill_ip_host(net_addr *a, ip_addr prefix)
+{
+ if (ipa_is_ip4(prefix))
+ net_fill_ip4(a, ipa_to_ip4(prefix), IP4_MAX_PREFIX_LENGTH);
+ else
+ net_fill_ip6(a, ipa_to_ip6(prefix), IP6_MAX_PREFIX_LENGTH);
+}
+
+static inline int net_is_ip(const net_addr *a)
+{ return (a->type == NET_IP4) || (a->type == NET_IP6); }
+
static inline ip4_addr net4_prefix(const net_addr *a)
{ return ((net_addr_ip4 *) a)->prefix; }
@@ -199,20 +210,20 @@ static inline void net_copy_vpn6(net_addr_vpn6 *dst, const net_addr_vpn6 *src)
static inline u32 net_hash_ip4(const net_addr_ip4 *n)
-{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }
+{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); }
static inline u32 net_hash_ip6(const net_addr_ip6 *n)
-{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }
+{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); }
/* XXXX */
-static inline u32 u64_hash(u32 a)
+static inline u32 u64_hash(u64 a)
{ return u32_hash(a); }
static inline u32 net_hash_vpn4(const net_addr_vpn4 *n)
-{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
+{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
static inline u32 net_hash_vpn6(const net_addr_vpn6 *n)
-{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
+{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
static inline int net_validate_ip4(const net_addr_ip4 *n)