27 u32 in_plen, out_plen;
44 else if (
unformat (line_input,
"del"))
80 vlib_cli_output (vm,
" in %U/%d out %U/%d\n",
81 format_ip4_address, &mp->in_addr, mp->in_plen,
82 format_ip4_address, &mp->out_addr, mp->out_plen);
83 vlib_cli_output (vm,
" outside address sharing ratio: %d\n",
85 vlib_cli_output (vm,
" number of ports per inside host: %d\n",
87 vlib_cli_output (vm,
" sessions number: %d\n", mp->ses_num);
160 if (out_port < 1024 || out_port > 65535)
194 vec_foreach_index (i, mp->sessions)
196 ses = vec_elt_at_index (mp->sessions, i);
198 vlib_cli_output (vm,
" %U", format_det_map_ses, mp, ses, &i);
212 u32 out_port, ext_port;
223 if (
unformat (line_input,
"%U:%d %U:%d",
265 u32 in_port, ext_port;
276 if (
unformat (line_input,
"%U:%d %U:%d",
326 if (
unformat (line_input,
"udp %u", &timeouts.
udp));
327 else if (
unformat (line_input,
"tcp established %u",
329 else if (
unformat (line_input,
"tcp transitory %u",
331 else if (
unformat (line_input,
"icmp %u", &timeouts.
icmp));
332 else if (
unformat (line_input,
"reset"))
378 u8 enable = 0, is_set = 0;
387 if (!is_set &&
unformat (line_input,
"enable"))
393 else if (!is_set &&
unformat (line_input,
"disable"));
440 vnm, &e.sw_if_index))
446 vnm, &e.sw_if_index))
451 else if (
unformat (line_input,
"del"))
467 is_del ?
"del" :
"add",
468 p->is_inside ?
"inside" :
"outside",
470 vnm, p->sw_if_index);
492 vlib_cli_output (vm,
" %U %s", format_vnet_sw_if_index_name, vnm,
494 (det44_interface_is_inside(i) &&
495 det44_interface_is_outside(i)) ?
"in out" :
496 (det44_interface_is_inside(i) ?
"in" :
"out"));
516 .short_help =
"det44 add in <addr>/<plen> out <addr>/<plen> [del]",
533 .path =
"show det44 mappings",
534 .short_help =
"show det44 mappings",
548 .path =
"det44 forward",
549 .short_help =
"det44 forward <addr>",
563 .path =
"det44 reverse",
564 .short_help =
"det44 reverse <addr>:<port>",
580 .path =
"show det44 sessions",
581 .short_help =
"show det44 sessions",
594 .path =
"det44 close session out",
595 .short_help =
"det44 close session out " 596 "<out_addr>:<out_port> <ext_addr>:<ext_port>",
609 .path =
"det44 close session in",
610 .short_help =
"det44 close session in " 611 "<in_addr>:<in_port> <ext_addr>:<ext_port>",
627 .path =
"set det44 timeouts",.short_help =
628 "set det44 timeouts <[udp <sec>] [tcp established <sec>] " 629 "[tcp transitory <sec>] [icmp <sec>]|reset>",.function =
645 .path =
"show det44 timeouts",.short_help =
656 .path =
"det44 plugin",.short_help =
657 "det44 plugin <enable [inside vrf] [outside vrf]|disable>",.function =
672 .path =
"set interface det44",.short_help =
673 "set interface det44 inside <intfc> outside <intfc> [del]",.function =
688 .path =
"show det44 interfaces",.short_help =
static clib_error_t * det44_forward_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static_always_inline snat_det_session_t * snat_det_get_ses_by_out(snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
int det44_plugin_enable(det44_config_t c)
int det44_plugin_disable()
static_always_inline void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
vnet_main_t * vnet_get_main(void)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Deterministic NAT (CGN) definitions.
static clib_error_t * det44_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * det44_reverse_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_vnet_sw_interface
struct nat_timeouts_s::@74 tcp
format_function_t format_vnet_sw_if_index_name
static clib_error_t * det44_close_session_in_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ip4_address_t ext_host_addr
nat_timeouts_t det44_get_timeouts()
static_always_inline snat_det_session_t * snat_det_find_ses_by_in(snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t out_key)
static_always_inline snat_det_map_t * snat_det_map_by_out(ip4_address_t *out_addr)
#define clib_error_return(e, args...)
void det44_reset_timeouts()
snat_det_map_t * det_maps
static_always_inline void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
static clib_error_t * det44_close_session_out_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static_always_inline void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
#define VLIB_CLI_COMMAND(x,...)
int det44_set_timeouts(nat_timeouts_t *timeouts)
static clib_error_t * det44_set_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int snat_det_add_map(ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
Add/delete deterministic NAT mapping.
static clib_error_t * det44_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * det44_plugin_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
det44_interface_t * interfaces
static clib_error_t * det44_show_interfaces_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * det44_show_mappings_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int det44_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
#define vec_foreach(var, vec)
Vector iterator.
static clib_error_t * det44_show_sessions_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static_always_inline snat_det_map_t * snat_det_map_by_user(ip4_address_t *user_addr)
static clib_error_t * det44_show_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)