23 return (ip46_address->ip4.as_u32 == 0);
25 return (ip46_address->as_u64[0] == 0 && ip46_address->as_u64[1] == 0);
32 return (ip46_address->ip4.as_u8[0] == 127);
34 return (ip46_address->as_u64[0] == 0 &&
35 clib_net_to_host_u64 (ip46_address->as_u64[1]) == 1);
41 return (ip4_address->
as_u8[0] == 127);
47 return (ip6_address->
as_u64[0] == 0 &&
48 clib_net_to_host_u64 (ip6_address->
as_u64[1]) == 1);
81 ip_copy (ip46_address_t * dst, ip46_address_t * src,
u8 is_ip4)
84 dst->ip4.as_u32 = src->ip4.as_u32;
90 ip_set (ip46_address_t * dst,
void *src,
u8 is_ip4)
172 ip4->
data_u32 &= clib_net_to_host_u32 (0xffffffff << (32 - preflen));
184 else if (preflen <= 64)
187 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - preflen));
192 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - preflen));
201 ip->
as_u32 = clib_host_to_net_u32 (~((1 << (32 - pref_len)) - 1));
217 not_mask = (1 << (32 - plen)) - 1;
218 res->
as_u32 = clib_net_to_host_u32 (ip->
as_u32) + not_mask;
229 else if (pref_len <= 64)
232 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - pref_len));
238 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - pref_len));
249 res->
as_u64[0] = 0xffffffffffffffffL;
250 res->
as_u64[1] = 0xffffffffffffffffL;
254 not_mask = ((
u64) 1 << (64 - plen)) - 1;
255 res->
as_u64[0] = clib_net_to_host_u64 (ip->
as_u64[0]) + not_mask;
256 res->
as_u64[1] = 0xffffffffffffffffL;
260 not_mask = ((
u64) 1 << (128 - plen)) - 1;
261 res->
as_u64[1] = clib_net_to_host_u64 (ip->
as_u64[1]) + not_mask;
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
fib_protocol_t fp_proto
protocol type
void ip6_preflen_to_mask(u8 pref_len, ip6_address_t *mask)
void ip4_preflen_to_mask(u8 pref_len, ip4_address_t *ip)
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
static uword log2_first_set(uword x)
u8 ip_is_local(u32 fib_index, ip46_address_t *ip46_address, u8 is_ip4)
Checks that an ip is local to the requested fib.
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
u8 ip_interface_has_address(u32 sw_if_index, ip46_address_t *ip, u8 is_ip4)
ip_lookup_main_t lookup_main
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
void ip6_prefix_max_address_host_order(ip6_address_t *ip, u8 plen, ip6_address_t *res)
void ip4_address_normalize(ip4_address_t *ip4, u8 preflen)
Aggregrate type for a prefix.
u16 fp_len
The mask length.
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
void ip6_address_normalize(ip6_address_t *ip6, u8 preflen)
int ip6_address_compare(ip6_address_t *a1, ip6_address_t *a2)
u32 ip6_mask_to_preflen(ip6_address_t *mask)
int ip4_address_compare(ip4_address_t *a1, ip4_address_t *a2)
#define clib_memcpy(a, b, c)
u8 ip4_is_local_host(ip4_address_t *ip4_address)
u32 fib_node_index_t
A typedef of a node index.
u32 ip4_mask_to_preflen(ip4_address_t *mask)
u8 ip6_is_local_host(ip6_address_t *ip6_address)
enum fib_entry_flag_t_ fib_entry_flag_t
ip_lookup_main_t lookup_main
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
void ip4_prefix_max_address_host_order(ip4_address_t *ip, u8 plen, ip4_address_t *res)
u8 ip_is_local_host(ip46_address_t *ip46_address, u8 is_ip4)
ip4_main_t ip4_main
Global ip4 main structure.
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
fib_entry_flag_t fib_entry_get_flags(fib_node_index_t fib_entry_index)