92 return sizeof (ip6_address_t);
183 return sizeof (ip6_address_t);
276 mask =
pow2_mask (preflen) << (32 - preflen);
277 mask = clib_host_to_net_u32 (mask);
299 m = (
u32 *) & mask_6[0];
301 for (j = 0; j < i0; j++)
308 m[i0] = clib_host_to_net_u32 (
pow2_mask (i1) << (32 - i1));
311 for (j = 0; j <
sizeof (mask_6); j++)
313 ip6->as_u8[j] &= mask_6[j];
384 ip6_address_t ip6_addr, ip6_mask;
392 return (((ip6_addr.as_u64[0] & ip6_mask.as_u64[0]) == ip6_addr.as_u64[0]) &&
393 ((ip6_addr.as_u64[1] & ip6_mask.as_u64[1]) == ip6_addr.as_u64[1]));
417 ip4->
data_u32 &= clib_net_to_host_u32 (0xffffffff << (32 - preflen));
429 else if (preflen <= 64)
432 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - preflen));
437 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - preflen));
446 ip->
as_u32 = clib_host_to_net_u32 (~((1 << (32 - pref_len)) - 1));
462 not_mask = (1 << (32 - plen)) - 1;
463 res->
as_u32 = clib_net_to_host_u32 (ip->
as_u32) + not_mask;
474 else if (pref_len <= 64)
477 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - pref_len));
482 mask->as_u64[0] = 0xffffffffffffffffL;
484 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - pref_len));
495 res->as_u64[0] = 0xffffffffffffffffL;
496 res->as_u64[1] = 0xffffffffffffffffL;
500 not_mask = ((
u64) 1 << (64 - plen)) - 1;
501 res->as_u64[0] = clib_net_to_host_u64 (ip->as_u64[0]) + not_mask;
502 res->as_u64[1] = 0xffffffffffffffffL;
506 not_mask = ((
u64) 1 << (128 - plen)) - 1;
507 res->as_u64[1] = clib_net_to_host_u64 (ip->as_u64[1]) + not_mask;
515 if (mask->as_u64[0] == 0 && mask->as_u64[1] == 0)
#define ip_prefix_addr(_a)
static bool ip4_prefix_validate(const ip_prefix_t *ip)
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
bool ip_prefix_validate(const ip_prefix_t *ip)
static uword log2_first_set(uword x)
void ip6_preflen_to_mask(u8 pref_len, ip6_address_t *mask)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 ip4_mask_to_preflen(ip4_address_t *mask)
u16 ip_address_size(const ip_address_t *a)
#define ip_addr_version(_a)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define clib_memcpy(d, s, n)
void ip_prefix_copy(void *dst, void *src)
static uword pow2_mask(uword x)
static int ip46_address_cmp(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
void ip_prefix_normalize(ip_prefix_t *a)
void ip6_address_normalize(ip6_address_t *ip6, u8 preflen)
void ip6_prefix_max_address_host_order(ip6_address_t *ip, u8 plen, ip6_address_t *res)
u16 ip_version_to_size(ip_address_family_t af)
void ip_address_copy_addr(void *dst, const ip_address_t *src)
void ip4_preflen_to_mask(u8 pref_len, ip4_address_t *ip)
void ip4_prefix_max_address_host_order(ip4_address_t *ip, u8 plen, ip4_address_t *res)
void ip_address_from_46(const ip46_address_t *nh, fib_protocol_t fproto, ip_address_t *ip)
bool ip_address_is_zero(const ip_address_t *ip)
uword unformat_ip_address(unformat_input_t *input, va_list *args)
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
u8 * format_ip_prefix(u8 *s, va_list *args)
vnet_link_t ip_address_family_to_link_type(ip_address_family_t af)
#define clib_warning(format, args...)
u8 * format_ip_address(u8 *s, va_list *args)
fib_protocol_t ip_address_family_to_fib_proto(ip_address_family_t af)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
ip_address_family_t version
static bool ip6_prefix_validate(const ip_prefix_t *ip)
int ip_address_cmp(const ip_address_t *ip1, const ip_address_t *ip2)
u32 ip6_mask_to_preflen(ip6_address_t *mask)
enum ip_address_family_t_ ip_address_family_t
#define ip_prefix_len(_a)
#define ip_prefix_version(_a)
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
void ip4_address_normalize(ip4_address_t *ip4, u8 preflen)
static void ip_prefix_normalize_ip4(ip4_address_t *ip4, u8 preflen)
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
u8 * ip_addr_bytes(ip_address_t *ip)
static void ip_prefix_normalize_ip6(ip6_address_t *ip6, u8 preflen)
ip_address_family_t ip_address_family_from_fib_proto(fib_protocol_t fp)
int ip_prefix_cmp(ip_prefix_t *p1, ip_prefix_t *p2)