30 int dst_address_length = 128 -
i;
57 clib_bihash_add_del_24_8 (&table->
ip_hash, &kv, 1 );
88 if (clib_bihash_search_24_8 (&table->
ip_hash, &kv, &val))
92 clib_bihash_add_del_24_8 (&table->
ip_hash, &kv, 0 );
115 kv.
key[0] = addr->ip4.as_u32;
120 kv.
key[0] = addr->as_u64[0];
121 kv.
key[1] = addr->as_u64[1];
131 int dst_address_length =
133 ip6_address_t *
mask = &table->
ip_masks[dst_address_length];
135 ASSERT (dst_address_length >= 0 && dst_address_length <= 128);
137 kv.
key[0] &= mask->as_u64[0];
138 kv.
key[1] &= mask->as_u64[1];
139 kv.
key[2] = ((
u64) af << 32) | dst_address_length;
140 rv = clib_bihash_search_inline_2_24_8 (&table->
ip_hash, &kv, &val);
152 u32 af = kv->
key[2] >> 32;
188 ip6_address_t
ip6 = { {0} };
226 .path =
"cnat snat with",
227 .short_help =
"cnat snat with [<ip4-address>][<ip6-address>][sw_if_index]",
267 .path =
"cnat snat exclude",
268 .short_help =
"cnat snat exclude [ip]",
282 format_bihash_24_8, &table->
ip_hash, 1);
289 .path =
"show cnat snat",
290 .short_help =
"show cnat snat",
308 for (j = 0; j < i0; j++)
313 clib_host_to_net_u32 (
pow2_mask (i1) << (32 - i1));
315 clib_bihash_init_24_8 (&table->
ip_hash,
"snat prefixes",
317 clib_bihash_set_kvp_format_fn_24_8 (&table->
ip_hash,
static void cnat_compute_prefix_lengths_in_search_order(cnat_snat_pfx_table_t *table, ip_address_family_t af)
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
vnet_main_t * vnet_get_main(void)
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static clib_error_t * cnat_show_snat(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
unformat_function_t unformat_vnet_sw_interface
int cnat_add_snat_prefix(ip_prefix_t *pfx)
void cnat_set_snat(ip4_address_t *ip4, ip6_address_t *ip6, u32 sw_if_index)
static clib_error_t * cnat_set_snat_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
int cnat_del_snat_prefix(ip_prefix_t *pfx)
void cnat_translation_watch_addr(index_t cti, u64 opaque, cnat_endpoint_t *ep, cnat_addr_resol_type_t type)
Add an address resolution request.
#define VLIB_INIT_FUNCTION(x)
static uword pow2_mask(uword x)
clib_bihash_24_8_t ip_hash
description fragment has unexpected format
#define clib_error_return(e, args...)
void cnat_translation_unwatch_addr(u32 cti, cnat_addr_resol_type_t type)
Cleanup matching addr resolution requests.
static clib_error_t * cnat_snat_exclude(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_cnat_endpoint(u8 *s, va_list *args)
int cnat_search_snat_prefix(ip46_address_t *addr, ip_address_family_t af)
sll srl srl sll sra u16x4 i
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
cnat_snat_pfx_table_t snat_pfx_table
enum ip_address_family_t_ ip_address_family_t
ip6_address_t ip_masks[129]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
u8 * format_cnat_snat_prefix(u8 *s, va_list *args)
#define ip_prefix_version(_a)
static clib_error_t * cnat_snat_init(vlib_main_t *vm)
cnat_snat_pfx_table_meta_t meta[2]
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
u8 cnat_resolve_ep(cnat_endpoint_t *ep)
Resolve endpoint address.
void cnat_lazy_init()
Lazy initialization when first adding a translation or using snat.
vl_api_interface_index_t sw_if_index