23 #define NAT66_EXPECTED_ARGUMENT "expected required argument(s)" 24 #define NAT66_PLUGIN_DISABLED "error plugin disabled" 26 #define CHECK_ENABLED() \ 29 if (PREDICT_FALSE (!nat66_main.enabled)) \ 31 return clib_error_return (0, NAT66_PLUGIN_DISABLED); \ 45 u8 enable_set = 0, enable = 0;
52 if (
unformat (line_input,
"outside-vrf %u", &outside_vrf))
57 if (
unformat (line_input,
"disable"))
59 else if (
unformat (line_input,
"enable"))
113 u32 *inside_sw_if_indices = 0;
114 u32 *outside_sw_if_indices = 0;
127 vec_add1 (inside_sw_if_indices, sw_if_index);
130 vec_add1 (outside_sw_if_indices, sw_if_index);
131 else if (
unformat (line_input,
"del"))
141 if (
vec_len (inside_sw_if_indices))
143 for (i = 0; i <
vec_len (inside_sw_if_indices); i++)
145 sw_if_index = inside_sw_if_indices[
i];
149 case VNET_API_ERROR_NO_SUCH_ENTRY:
155 case VNET_API_ERROR_VALUE_EXIST:
161 case VNET_API_ERROR_INVALID_VALUE:
162 case VNET_API_ERROR_INVALID_VALUE_2:
165 "%U NAT66 feature enable/disable failed.",
176 if (
vec_len (outside_sw_if_indices))
178 for (i = 0; i <
vec_len (outside_sw_if_indices); i++)
180 sw_if_index = outside_sw_if_indices[
i];
184 case VNET_API_ERROR_NO_SUCH_ENTRY:
190 case VNET_API_ERROR_VALUE_EXIST:
196 case VNET_API_ERROR_INVALID_VALUE:
197 case VNET_API_ERROR_INVALID_VALUE_2:
200 "%U NAT66 feature enable/disable failed.",
247 ip6_address_t l_addr, e_addr;
259 if (
unformat (line_input,
"local %U external %U",
263 else if (
unformat (line_input,
"vrf %u", &vrf_id))
265 else if (
unformat (line_input,
"del"))
279 case VNET_API_ERROR_NO_SUCH_ENTRY:
282 case VNET_API_ERROR_VALUE_EXIST:
342 .short_help =
"nat66 <enable [outside-vrf <vrf-id>]>|disable",
357 .path =
"set interface nat66",
358 .short_help =
"set interface nat66 in|out <intfc> [del]",
374 .path =
"show nat66 interfaces",
375 .short_help =
"show nat66 interfaces",
389 .path =
"nat66 add static mapping",
390 .short_help =
"nat66 add static mapping local <ip6-addr> external <ip6-addr>" 391 " [vfr <table-id>] [del]",
407 .path =
"show nat66 static mappings",
408 .short_help =
"show nat66 static mappings",
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Combined counter to hold both packets and byte differences.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * nat66_show_interfaces_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * nat66_show_static_mappings_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat66_interface_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define nat66_interface_is_inside(i)
#define clib_error_return(e, args...)
vnet_main_t * vnet_get_main(void)
static int nat66_cli_interface_walk(nat66_interface_t *i, void *ctx)
int nat66_plugin_disable()
format_function_t format_vnet_sw_interface_name
vl_api_interface_index_t sw_if_index
void nat66_static_mappings_walk(nat66_static_mapping_walk_fn_t fn, void *ctx)
counter_t packets
packet counter
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static clib_error_t * nat66_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int nat66_cli_static_mapping_walk(nat66_static_mapping_t *sm, void *ctx)
int nat66_interface_add_del(u32 sw_if_index, u8 is_inside, u8 is_add)
u32 ft_table_id
Table ID (hash key) for this FIB.
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
#define NAT66_EXPECTED_ARGUMENT
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
int nat66_plugin_enable(u32 outside_vrf)
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
counter_t bytes
byte counter
vlib_combined_counter_main_t session_counters
Session counters.
void nat66_interfaces_walk(nat66_interface_walk_fn_t fn, void *ctx)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
int nat66_static_mapping_add_del(ip6_address_t *l_addr, ip6_address_t *e_addr, u32 vrf_id, u8 is_add)
nat66_static_mapping_t * sm
Static mapping pool.
NAT66 global declarations.
static clib_error_t * nat66_add_del_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
A protocol Independent FIB table.