92 return sizeof (ip6_address_t);
183 return sizeof (ip6_address_t);
275 memcpy (&prefix->
fp_addr.ip4, &addr->
ip.ip4,
282 memcpy (&prefix->
fp_addr.ip6, &addr->
ip.ip6,
285 prefix->___fp___pad = 0;
300 mask =
pow2_mask (preflen) << (32 - preflen);
301 mask = clib_host_to_net_u32 (mask);
323 m = (
u32 *) & mask_6[0];
325 for (j = 0; j < i0; j++)
332 m[i0] = clib_host_to_net_u32 (
pow2_mask (i1) << (32 - i1));
335 for (j = 0; j <
sizeof (mask_6); j++)
337 ip6->as_u8[j] &= mask_6[j];
419 ip6_address_t ip6_addr, ip6_mask;
427 return (((ip6_addr.as_u64[0] & ip6_mask.as_u64[0]) == ip6_addr.as_u64[0]) &&
428 ((ip6_addr.as_u64[1] & ip6_mask.as_u64[1]) == ip6_addr.as_u64[1]));
452 ip4->
data_u32 &= clib_net_to_host_u32 (0xffffffff << (32 - preflen));
464 else if (preflen <= 64)
467 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - preflen));
472 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - preflen));
481 ip->
as_u32 = clib_host_to_net_u32 (~((1 << (32 - pref_len)) - 1));
497 not_mask = (1 << (32 - plen)) - 1;
498 res->
as_u32 = clib_net_to_host_u32 (ip->
as_u32) + not_mask;
509 else if (pref_len <= 64)
512 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - pref_len));
517 mask->as_u64[0] = 0xffffffffffffffffL;
519 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - pref_len));
530 res->as_u64[0] = 0xffffffffffffffffL;
531 res->as_u64[1] = 0xffffffffffffffffL;
535 not_mask = ((
u64) 1 << (64 - plen)) - 1;
536 res->as_u64[0] = clib_net_to_host_u64 (ip->as_u64[0]) + not_mask;
537 res->as_u64[1] = 0xffffffffffffffffL;
541 not_mask = ((
u64) 1 << (128 - plen)) - 1;
542 res->as_u64[1] = clib_net_to_host_u64 (ip->as_u64[1]) + not_mask;
549 if (mask->as_u64[1] != 0)
550 return 128 -
log2_first_set (clib_net_to_host_u64 (mask->as_u64[1]));
551 if (mask->as_u64[0] != 0)
552 return 64 -
log2_first_set (clib_net_to_host_u64 (mask->as_u64[0]));
fib_protocol_t fp_proto
protocol type
void ip_prefix_to_fib_prefix(const ip_prefix_t *ip_prefix, fib_prefix_t *fib_prefix)
convert from a LISP to a FIB prefix
#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)
Aggregate type for a prefix.
void ip_prefix_normalize(ip_prefix_t *a)
void ip_address_to_fib_prefix(const ip_address_t *addr, fib_prefix_t *prefix)
convert from a IP address to a FIB prefix
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 fp_len
The mask length.
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)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
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)