95 return sizeof (ip6_address_t);
186 return sizeof (ip6_address_t);
278 memcpy (&prefix->
fp_addr.ip4, &addr->
ip.ip4,
285 memcpy (&prefix->
fp_addr.ip6, &addr->
ip.ip6,
288 prefix->___fp___pad = 0;
316 mask =
pow2_mask (preflen) << (32 - preflen);
317 mask = clib_host_to_net_u32 (mask);
339 m = (
u32 *) & mask_6[0];
341 for (j = 0; j < i0; j++)
348 m[i0] = clib_host_to_net_u32 (
pow2_mask (i1) << (32 - i1));
351 for (j = 0; j <
sizeof (mask_6); j++)
353 ip6->as_u8[j] &= mask_6[j];
435 ip6_address_t ip6_addr, ip6_mask;
443 return (((ip6_addr.as_u64[0] & ip6_mask.as_u64[0]) == ip6_addr.as_u64[0]) &&
444 ((ip6_addr.as_u64[1] & ip6_mask.as_u64[1]) == ip6_addr.as_u64[1]));
468 ip4->
data_u32 &= clib_net_to_host_u32 (0xffffffff << (32 - preflen));
480 else if (preflen <= 64)
483 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - preflen));
488 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - preflen));
497 ip->
as_u32 = clib_host_to_net_u32 (~((1 << (32 - pref_len)) - 1));
513 not_mask = (1 << (32 - plen)) - 1;
514 res->
as_u32 = clib_net_to_host_u32 (ip->
as_u32) + not_mask;
525 else if (pref_len <= 64)
528 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - pref_len));
533 mask->as_u64[0] = 0xffffffffffffffffL;
535 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - pref_len));
546 res->as_u64[0] = 0xffffffffffffffffL;
547 res->as_u64[1] = 0xffffffffffffffffL;
551 not_mask = ((
u64) 1 << (64 - plen)) - 1;
552 res->as_u64[0] = clib_net_to_host_u64 (ip->as_u64[0]) + not_mask;
553 res->as_u64[1] = 0xffffffffffffffffL;
557 not_mask = ((
u64) 1 << (128 - plen)) - 1;
558 res->as_u64[1] = clib_net_to_host_u64 (ip->as_u64[1]) + not_mask;
565 if (mask->as_u64[1] != 0)
566 return 128 -
log2_first_set (clib_net_to_host_u64 (mask->as_u64[1]));
567 if (mask->as_u64[0] != 0)
568 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
void ip46_address_increment(ip46_type_t type, ip46_address_t *ip)
#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)
description fragment has unexpected format
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)
void ip_address_reset(ip_address_t *ip)
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)
void ip_address_increment(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)