Revision 04632fd7 lib/net.h
lib/net.h | ||
---|---|---|
107 | 107 |
net_fill_ip6(a, ipa_to_ip6(prefix), pxlen); |
108 | 108 |
} |
109 | 109 |
|
110 |
static inline void net_fill_ip_host(net_addr *a, ip_addr prefix) |
|
111 |
{ |
|
112 |
if (ipa_is_ip4(prefix)) |
|
113 |
net_fill_ip4(a, ipa_to_ip4(prefix), IP4_MAX_PREFIX_LENGTH); |
|
114 |
else |
|
115 |
net_fill_ip6(a, ipa_to_ip6(prefix), IP6_MAX_PREFIX_LENGTH); |
|
116 |
} |
|
117 |
|
|
118 |
static inline int net_is_ip(const net_addr *a) |
|
119 |
{ return (a->type == NET_IP4) || (a->type == NET_IP6); } |
|
120 |
|
|
110 | 121 |
|
111 | 122 |
static inline ip4_addr net4_prefix(const net_addr *a) |
112 | 123 |
{ return ((net_addr_ip4 *) a)->prefix; } |
... | ... | |
199 | 210 |
|
200 | 211 |
|
201 | 212 |
static inline u32 net_hash_ip4(const net_addr_ip4 *n) |
202 |
{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }
|
|
213 |
{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); } |
|
203 | 214 |
|
204 | 215 |
static inline u32 net_hash_ip6(const net_addr_ip6 *n) |
205 |
{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }
|
|
216 |
{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); } |
|
206 | 217 |
|
207 | 218 |
/* XXXX */ |
208 |
static inline u32 u64_hash(u32 a)
|
|
219 |
static inline u32 u64_hash(u64 a)
|
|
209 | 220 |
{ return u32_hash(a); } |
210 | 221 |
|
211 | 222 |
static inline u32 net_hash_vpn4(const net_addr_vpn4 *n) |
212 |
{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
|
|
223 |
{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); } |
|
213 | 224 |
|
214 | 225 |
static inline u32 net_hash_vpn6(const net_addr_vpn6 *n) |
215 |
{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
|
|
226 |
{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); } |
|
216 | 227 |
|
217 | 228 |
|
218 | 229 |
static inline int net_validate_ip4(const net_addr_ip4 *n) |
Also available in: Unified diff