FD.io VPP  v16.09
Vector Packet Processing
snat.c File Reference
+ Include dependency graph for snat.c:

Go to the source code of this file.

Macros

#define vl_typedefs
 
#define vl_endianfun
 
#define vl_print(handle, ...)   vlib_cli_output (handle, __VA_ARGS__)
 
#define vl_api_version(n, v)   static u32 api_version=(v);
 
#define FINISH
 
#define REPLY_MACRO(t)
 
#define VALIDATE_SW_IF_INDEX(mp)
 
#define BAD_SW_IF_INDEX_LABEL
 
#define VALIDATE_RX_SW_IF_INDEX(mp)
 
#define BAD_RX_SW_IF_INDEX_LABEL
 
#define VALIDATE_TX_SW_IF_INDEX(mp)
 
#define BAD_TX_SW_IF_INDEX_LABEL
 
#define foreach_snat_plugin_api_msg
 

Functions

 VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_in2out, static)
 
 VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_out2in, static)
 
clib_error_tvlib_plugin_register (vlib_main_t *vm, vnet_plugin_handoff_t *h, int from_early_init)
 
void snat_add_address (snat_main_t *sm, ip4_address_t *addr)
 
static void increment_v4_address (ip4_address_t *a)
 
static void vl_api_snat_add_address_range_t_handler (vl_api_snat_add_address_range_t *mp)
 
static void * vl_api_snat_add_address_range_t_print (vl_api_snat_add_address_range_t *mp, void *handle)
 
static void vl_api_snat_interface_add_del_feature_t_handler (vl_api_snat_interface_add_del_feature_t *mp)
 
static void * vl_api_snat_interface_add_del_feature_t_print (vl_api_snat_interface_add_del_feature_t *mp, void *handle)
 
static clib_error_tsnat_plugin_api_hookup (vlib_main_t *vm)
 
static void plugin_custom_dump_configure (snat_main_t *sm)
 
static clib_error_tsnat_init (vlib_main_t *vm)
 
void snat_free_outside_address_and_port (snat_main_t *sm, snat_session_key_t *k, u32 address_index)
 
int snat_alloc_outside_address_and_port (snat_main_t *sm, snat_session_key_t *k, u32 *address_indexp)
 
static clib_error_tadd_address_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_feature_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tsnat_config (vlib_main_t *vm, unformat_input_t *input)
 
u8format_snat_key (u8 *s, va_list *args)
 
u8format_snat_session (u8 *s, va_list *args)
 
u8format_snat_user (u8 *s, va_list *args)
 
static clib_error_tshow_snat_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 

Variables

snat_main_t snat_main
 
static vlib_cli_command_t add_address_command
 (constructor) VLIB_CLI_COMMAND (add_address_command) More...
 
static vlib_cli_command_t set_interface_snat_command
 (constructor) VLIB_CLI_COMMAND (set_interface_snat_command) More...
 
static vlib_cli_command_t show_snat_command
 (constructor) VLIB_CLI_COMMAND (show_snat_command) More...
 

Macro Definition Documentation

#define BAD_RX_SW_IF_INDEX_LABEL
Value:
do { \
bad_rx_sw_if_index: \
; \
} while (0);

Definition at line 142 of file snat.c.

#define BAD_SW_IF_INDEX_LABEL
Value:
do { \
bad_sw_if_index: \
; \
} while (0);

Definition at line 126 of file snat.c.

#define BAD_TX_SW_IF_INDEX_LABEL
Value:
do { \
bad_tx_sw_if_index: \
; \
} while (0);

Definition at line 158 of file snat.c.

#define FINISH
Value:
vec_add1 (s, 0); \
vl_print (handle, (char *)s); \
vec_free (s); \
return handle;
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:300
#define vl_print(handle,...)
Definition: snat.c:42

Definition at line 50 of file snat.c.

#define foreach_snat_plugin_api_msg
Value:
_(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range) \
_(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature)

Definition at line 300 of file snat.c.

#define REPLY_MACRO (   t)
Value:
do { \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
vl_msg_api_send_shmem (q, (u8 *)&rmp); \
} while(0);
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
struct _unix_shared_memory_queue unix_shared_memory_queue_t

Definition at line 64 of file snat.c.

#define VALIDATE_RX_SW_IF_INDEX (   mp)
Value:
do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__rx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_rx_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 132 of file snat.c.

#define VALIDATE_SW_IF_INDEX (   mp)
Value:
do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 116 of file snat.c.

#define VALIDATE_TX_SW_IF_INDEX (   mp)
Value:
do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__tx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_tx_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 148 of file snat.c.

#define vl_api_version (   n,
 
)    static u32 api_version=(v);

Definition at line 45 of file snat.c.

#define vl_endianfun

Definition at line 38 of file snat.c.

#define vl_print (   handle,
  ... 
)    vlib_cli_output (handle, __VA_ARGS__)

Definition at line 42 of file snat.c.

#define vl_typedefs

Definition at line 33 of file snat.c.

Function Documentation

static clib_error_t* add_address_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 418 of file snat.c.

+ Here is the call graph for this function:

u8* format_snat_key ( u8 s,
va_list *  args 
)

Definition at line 605 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_session ( u8 s,
va_list *  args 
)

Definition at line 624 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_snat_user ( u8 s,
va_list *  args 
)

Definition at line 638 of file snat.c.

+ Here is the call graph for this function:

static void increment_v4_address ( ip4_address_t a)
static

Definition at line 184 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void plugin_custom_dump_configure ( snat_main_t sm)
static

Definition at line 323 of file snat.c.

+ Here is the caller graph for this function:

static clib_error_t* show_snat_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 676 of file snat.c.

+ Here is the call graph for this function:

void snat_add_address ( snat_main_t sm,
ip4_address_t addr 
)

Definition at line 175 of file snat.c.

+ Here is the caller graph for this function:

int snat_alloc_outside_address_and_port ( snat_main_t sm,
snat_session_key_t k,
u32 address_indexp 
)

Definition at line 379 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_config ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 552 of file snat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_feature_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 466 of file snat.c.

+ Here is the call graph for this function:

void snat_free_outside_address_and_port ( snat_main_t sm,
snat_session_key_t k,
u32  address_index 
)

Definition at line 361 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* snat_init ( vlib_main_t vm)
static

Definition at line 332 of file snat.c.

+ Here is the call graph for this function:

static clib_error_t* snat_plugin_api_hookup ( vlib_main_t vm)
static

Definition at line 306 of file snat.c.

+ Here is the caller graph for this function:

static void vl_api_snat_add_address_range_t_handler ( vl_api_snat_add_address_range_t mp)
static

Definition at line 194 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vl_api_snat_add_address_range_t_print ( vl_api_snat_add_address_range_t mp,
void *  handle 
)
static

Definition at line 236 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vl_api_snat_interface_add_del_feature_t_handler ( vl_api_snat_interface_add_del_feature_t mp)
static

Definition at line 251 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vl_api_snat_interface_add_del_feature_t_print ( vl_api_snat_interface_add_del_feature_t mp,
void *  handle 
)
static

Definition at line 286 of file snat.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* vlib_plugin_register ( vlib_main_t vm,
vnet_plugin_handoff_t h,
int  from_early_init 
)

Definition at line 100 of file snat.c.

VNET_IP4_UNICAST_FEATURE_INIT ( ip4_snat_in2out  ,
static   
)
VNET_IP4_UNICAST_FEATURE_INIT ( ip4_snat_out2in  ,
static   
)

Variable Documentation

vlib_cli_command_t add_address_command
static
Initial value:
= {
.path = "snat add address",
.short_help = "snat add addresses <ip4-range-start> [- <ip4-range-end>]",
}
static clib_error_t * add_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: snat.c:418

(constructor) VLIB_CLI_COMMAND (add_address_command)

Definition at line 459 of file snat.c.

vlib_cli_command_t set_interface_snat_command
static
Initial value:
= {
.path = "set interface snat",
.short_help = "set interface snat in <intfc> out <intfc> [del]",
}
static clib_error_t * snat_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: snat.c:466

(constructor) VLIB_CLI_COMMAND (set_interface_snat_command)

Definition at line 545 of file snat.c.

vlib_cli_command_t show_snat_command
static
Initial value:
= {
.path = "show snat",
.short_help = "show snat",
.function = show_snat_command_fn,
}
static clib_error_t * show_snat_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: snat.c:676

(constructor) VLIB_CLI_COMMAND (show_snat_command)

Definition at line 712 of file snat.c.

snat_main_t snat_main

Definition at line 27 of file snat.c.