48 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 56 #define vl_api_version(n,v) static u32 api_version=(v); 63 .arc_name =
"ip4-output",
64 .node_name =
"flowperpkt",
76 #define REPLY_MACRO(t) \ 78 unix_shared_memory_queue_t * q = \ 79 vl_api_client_index_to_input_queue (mp->client_index); \ 83 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 84 rmp->_vl_msg_id = ntohs((t)+fm->msg_id_base); \ 85 rmp->context = mp->context; \ 86 rmp->retval = ntohl(rv); \ 88 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 94 vl_print (handle, (char *)s); \ 98 #define VALIDATE_SW_IF_INDEX(mp) \ 99 do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ 100 vnet_main_t *__vnm = vnet_get_main(); \ 101 if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ 103 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ 104 goto bad_sw_if_index; \ 108 #define BAD_SW_IF_INDEX_LABEL \ 181 udp->
dst_port = clib_host_to_net_u16 (collector_port);
182 udp->
length = clib_host_to_net_u16 (
vec_len (rewrite) -
sizeof (*ip));
199 destinationIPv4Address, 4);
228 ip->
length = clib_host_to_net_u16 ((
u8 *) f - (
u8 *) ip);
270 memset (a, 0,
sizeof (*a));
281 clib_warning (
"vnet_flow_report_add_del returned %d", rv);
310 REPLY_MACRO (VL_API_FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY);
324 s =
format (0,
"SCRIPT: flowperpkt_tx_interface_add_del ");
325 s =
format (s,
"sw_if_index %d is_add %d is_ipv6 %d ",
332 #define foreach_flowperpkt_plugin_api_msg \ 333 _(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del) 366 u32 sw_if_index = ~0;
382 if (sw_if_index == ~0)
391 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
393 (0,
"Invalid interface, only works on physical ports");
396 case VNET_API_ERROR_UNIMPLEMENTED:
423 .path =
"flowperpkt feature add-del",
425 "flowperpkt feature add-del <interface-name> [disable]",
440 vl_msg_api_set_handlers((VL_API_##N + fm->msg_id_base), \ 442 vl_api_##n##_t_handler, \ 444 vl_api_##n##_t_endian, \ 445 vl_api_##n##_t_print, \ 446 sizeof(vl_api_##n##_t), 1); 453 #define vl_msg_name_crc_list 455 #undef vl_msg_name_crc_list 460 #define _(id,n,crc) \ 461 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + fm->msg_id_base); 462 foreach_vl_msg_name_crc_flowperpkt;
481 name =
format (0,
"flowperpkt_%08x%c", api_version, 0);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
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)
clib_error_t * vlib_plugin_register(vlib_main_t *vm, vnet_plugin_handoff_t *h, int from_early_init)
plugin-api required function
u64 nanosecond_time_0
Time reference pair.
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_main_t * vlib_main
convenience vlib_main_t pointer
unformat_function_t unformat_vnet_sw_interface
u16 msg_id_base
API message ID base.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void vl_api_flowperpkt_tx_interface_add_del_t_handler(vl_api_flowperpkt_tx_interface_add_del_t *mp)
API message handler.
static clib_error_t * flowperpkt_plugin_api_hookup(vlib_main_t *vm)
Set up the API message handling tables.
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.
flow_report_stream_t * streams
flow-per-packet plugin header file
VNET_FEATURE_INIT(flow_perpacket, static)
#define VLIB_INIT_FUNCTION(x)
int report_created
Has the report been created?
Enable / disable per-packet IPFIX recording on an interface.
vnet_flow_rewrite_callback_t * rewrite_callback
#define BAD_SW_IF_INDEX_LABEL
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.
#define clib_warning(format, args...)
vlib_buffer_t ** buffers_per_worker
ipfix buffers under construction, per-worker thread
flow_report_main_t flow_report_main
vnet_main_t * vnet_main
convenience vnet_main_t pointer
static u32 version_length(u16 length)
vlib_thread_main_t vlib_thread_main
#define foreach_flowperpkt_plugin_api_msg
#define vec_free(V)
Free vector's memory (no header).
static u32 ipfix_id_count(u16 id, u16 count)
static u64 unix_time_now_nsec(void)
#define VLIB_CLI_COMMAND(x,...)
#define VALIDATE_SW_IF_INDEX(mp)
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
flowperpkt_main_t flowperpkt_main
u16 * next_record_offset_per_worker
next record offset, per worker thread
#define VNET_FEATURES(...)
static u32 ipfix_set_id_length(u16 set_id, u16 length)
void flowperpkt_flush_callback(void)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * flowperpkt_init(vlib_main_t *vm)
Set up the API message handling tables.
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.
vnet_flow_data_callback_t * flow_data_callback
static void setup_message_id_table(flowperpkt_main_t *fm, api_main_t *am)
u16 vl_msg_api_get_msg_ids(char *name, int n)
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
Reply to enable/disable per-packet IPFIX recording messages.
static u16 ip4_header_checksum(ip4_header_t *i)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a)
vlib_frame_t ** frames_per_worker
frames containing ipfix buffers, per-worker thread