FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
flowperpkt.c File Reference

Per-packet IPFIX flow record generator plugin. More...

+ Include dependency graph for flowperpkt.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_printfun
 
#define vl_api_version(n, v)   static u32 api_version=(v);
 
#define REPLY_MACRO(t)
 
#define FINISH
 
#define VALIDATE_SW_IF_INDEX(mp)
 
#define BAD_SW_IF_INDEX_LABEL
 
#define foreach_flowperpkt_plugin_api_msg   _(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del)
 
#define vl_msg_name_crc_list
 

Functions

 VNET_FEATURE_INIT (flow_perpacket, static)
 
u8flowperpkt_template_rewrite (flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
 Create an IPFIX template packet rewrite string. More...
 
vlib_frame_tflowperpkt_data_callback (flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
 Flush accumulated data. More...
 
static int flowperpkt_tx_interface_add_del_feature (flowperpkt_main_t *fm, u32 sw_if_index, int is_add)
 configure / deconfigure the IPFIX flow-per-packet More...
 
void vl_api_flowperpkt_tx_interface_add_del_t_handler (vl_api_flowperpkt_tx_interface_add_del_t *mp)
 API message handler. More...
 
static void * vl_api_flowperpkt_tx_interface_add_del_t_print (vl_api_flowperpkt_tx_interface_add_del_t *mp, void *handle)
 API message custom-dump function. More...
 
clib_error_tvlib_plugin_register (vlib_main_t *vm, vnet_plugin_handoff_t *h, int from_early_init)
 plugin-api required function More...
 
static clib_error_tflowperpkt_tx_interface_add_del_feature_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tflowperpkt_plugin_api_hookup (vlib_main_t *vm)
 Set up the API message handling tables. More...
 
static void setup_message_id_table (flowperpkt_main_t *fm, api_main_t *am)
 
static clib_error_tflowperpkt_init (vlib_main_t *vm)
 Set up the API message handling tables. More...
 

Variables

flowperpkt_main_t flowperpkt_main
 
static vlib_cli_command_t flowperpkt_enable_disable_command
 (constructor) VLIB_CLI_COMMAND (flowperpkt_enable_disable_command) More...
 

Detailed Description

Per-packet IPFIX flow record generator plugin.

This file implements vpp plugin registration mechanics, debug CLI, and binary API handling.

Definition in file flowperpkt.c.

Macro Definition Documentation

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

Definition at line 108 of file flowperpkt.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 vl_print(handle,...)
Definition: flowperpkt.c:48
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:300

Definition at line 92 of file flowperpkt.c.

#define foreach_flowperpkt_plugin_api_msg   _(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del)

Definition at line 332 of file flowperpkt.c.

#define REPLY_MACRO (   t)
Value:
do { \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = ntohs((t)+fm->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 76 of file flowperpkt.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:46
#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 98 of file flowperpkt.c.

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

Definition at line 56 of file flowperpkt.c.

#define vl_endianfun

Definition at line 43 of file flowperpkt.c.

#define vl_msg_name_crc_list

Definition at line 453 of file flowperpkt.c.

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

Definition at line 48 of file flowperpkt.c.

#define vl_printfun

Definition at line 49 of file flowperpkt.c.

#define vl_typedefs

Definition at line 38 of file flowperpkt.c.

Function Documentation

vlib_frame_t* flowperpkt_data_callback ( flow_report_main_t frm,
flow_report_t fr,
vlib_frame_t f,
u32 to_next,
u32  node_index 
)

Flush accumulated data.

Parameters
frmflow_report_main_t *
frflow_report_t *
fvlib_frame_t *

Notes: This function must simply return the incoming frame, or no template packets will be sent.

Definition at line 245 of file flowperpkt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* flowperpkt_init ( vlib_main_t vm)
static

Set up the API message handling tables.

Parameters
vmvlib_main_t * vlib main data structure pointer
Returns
0 to indicate all is well, or a clib_error_t

Definition at line 472 of file flowperpkt.c.

+ Here is the call graph for this function:

static clib_error_t* flowperpkt_plugin_api_hookup ( vlib_main_t vm)
static

Set up the API message handling tables.

Parameters
vmvlib_main_t * vlib main data structure pointer
Returns
0 to indicate all is well

Definition at line 436 of file flowperpkt.c.

+ Here is the caller graph for this function:

u8* flowperpkt_template_rewrite ( flow_report_main_t frm,
flow_report_t fr,
ip4_address_t collector_address,
ip4_address_t src_address,
u16  collector_port 
)

Create an IPFIX template packet rewrite string.

Parameters
frmflow_report_main_t *
frflow_report_t *
collector_addressip4_address_t * the IPFIX collector address
src_addressip4_address_t * the source address we should use
collector_portu16 the collector port we should use, host byte order
Returns
u8 * vector containing the indicated IPFIX template packet

Definition at line 124 of file flowperpkt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int flowperpkt_tx_interface_add_del_feature ( flowperpkt_main_t fm,
u32  sw_if_index,
int  is_add 
)
static

configure / deconfigure the IPFIX flow-per-packet

Parameters
fmflowperpkt_main_t * fm
sw_if_indexu32 the desired interface
is_addint 1 to enable the feature, 0 to disable it
Returns
0 if successful, non-zero otherwise

Definition at line 262 of file flowperpkt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 361 of file flowperpkt.c.

+ Here is the call graph for this function:

static void setup_message_id_table ( flowperpkt_main_t fm,
api_main_t am 
)
static

Definition at line 458 of file flowperpkt.c.

+ Here is the caller graph for this function:

void vl_api_flowperpkt_tx_interface_add_del_t_handler ( vl_api_flowperpkt_tx_interface_add_del_t mp)

API message handler.

Parameters
mpvl_api_flowperpkt_tx_interface_add_del_t * mp the api message

Definition at line 297 of file flowperpkt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vl_api_flowperpkt_tx_interface_add_del_t_print ( vl_api_flowperpkt_tx_interface_add_del_t mp,
void *  handle 
)
static

API message custom-dump function.

Parameters
mpvl_api_flowperpkt_tx_interface_add_del_t * mp the api message
handlevoid * print function handle
Returns
u8 * output string

Definition at line 320 of file flowperpkt.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 
)

plugin-api required function

Parameters
vmvlib_main_t * vlib main data structure pointer
hvlib_plugin_handoff_t * handoff structure
from_early_initint notused

Notes: This routine exists to convince the vlib plugin framework that we haven't accidentally copied a random .dll into the plugin directory.

Also collects global variable pointers passed from the vpp engine

Definition at line 348 of file flowperpkt.c.

VNET_FEATURE_INIT ( flow_perpacket  ,
static   
)

Variable Documentation

vlib_cli_command_t flowperpkt_enable_disable_command
static
Initial value:
= {
.path = "flowperpkt feature add-del",
.short_help =
"flowperpkt feature add-del <interface-name> [disable]",
}
static clib_error_t * flowperpkt_tx_interface_add_del_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: flowperpkt.c:361

(constructor) VLIB_CLI_COMMAND (flowperpkt_enable_disable_command)

Definition at line 422 of file flowperpkt.c.

flowperpkt_main_t flowperpkt_main

Definition at line 53 of file flowperpkt.c.