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 && ip46_address->as_u64[1] == 1);
67 ip_copy (ip46_address_t * dst, ip46_address_t * src,
u8 is_ip4)
70 dst->ip4.as_u32 = src->ip4.as_u32;
76 ip_set (ip46_address_t * dst,
void *src,
u8 is_ip4)
158 ip4->
data_u32 &= clib_net_to_host_u32 (0xffffffff << (32 - preflen));
170 else if (preflen <= 64)
173 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - preflen));
178 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - preflen));
187 ip->
as_u32 = clib_host_to_net_u32 (~((1 << (32 - pref_len)) - 1));
203 not_mask = (1 << (32 - plen)) - 1;
204 res->
as_u32 = clib_net_to_host_u32 (ip->
as_u32) + not_mask;
215 else if (pref_len <= 64)
218 clib_host_to_net_u64 (0xffffffffffffffffL << (64 - pref_len));
224 clib_host_to_net_u64 (0xffffffffffffffffL << (128 - pref_len));
235 res->
as_u64[0] = 0xffffffffffffffffL;
236 res->
as_u64[1] = 0xffffffffffffffffL;
240 not_mask = ((
u64) 1 << (64 - plen)) - 1;
241 res->
as_u64[0] = clib_net_to_host_u64 (ip->
as_u64[0]) + not_mask;
242 res->
as_u64[1] = 0xffffffffffffffffL;
246 not_mask = ((
u64) 1 << (128 - plen)) - 1;
247 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)
u32 fib_node_index_t
A typedef of a node index.
u32 ip4_mask_to_preflen(ip4_address_t *mask)
enum fib_entry_flag_t_ fib_entry_flag_t
ip_lookup_main_t lookup_main
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
static uword ip6_address_is_link_local_unicast(ip6_address_t *a)
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)