52 .path =
"packet-generator",
53 .short_help =
"Packet generator commands",
63 if (stream_index == ~0)
68 pg_stream_enable_disable (pg, s, is_enable);
114 u32 stream_index = ~0;
132 .path =
"packet-generator enable-stream",
133 .short_help =
"Enable packet generator streams",
141 .path =
"packet-generator disable-stream",
142 .short_help =
"Disable packet generator streams",
163 while (*junk_after_name && *junk_after_name !=
' ')
165 *junk_after_name = 0;
166 s =
format (s,
"edit-function %s, ", function_name);
177 int verbose = va_arg (*va,
int);
180 return format (s,
"%-16s%=12s%=16s%s",
181 "Name",
"Enabled",
"Count",
"Parameters");
183 s =
format (s,
"%-16v%=12s%=16Ld",
192 s =
format (s,
"size %d%c%d, ",
238 vlib_cli_output (vm,
"%U", format_pg_stream, s, verbose);
248 .path =
"show packet-generator ",
249 .short_help =
"show packet-generator [verbose]",
284 if (
unformat (input,
"limit %f", &x))
287 else if (
unformat (input,
"rate %f", &x))
333 int sub_input_given = 0;
337 char *pcap_file_name;
347 if (
unformat (input,
"name %v", &tmp))
354 else if (
unformat (input,
"node %U",
366 else if (
unformat (input,
"node %U",
373 else if (
unformat (input,
"interface %U",
378 else if (
unformat (input,
"pcap %s", &pcap_file_name))
381 else if (!sub_input_given
396 if (!sub_input_given && !pcap_file_name)
404 if (pcap_file_name != 0)
428 if (pcap_file_name != 0)
443 (
"failed to parse packet data from `%U'",
464 .path =
"packet-generator new",
466 .short_help =
"Create packet generator stream",
468 "Create packet generator stream\n" 472 "name STRING sets stream name\n" 473 "interface STRING interface for stream output \n" 474 "node NODE-NAME node for stream output\n" 475 "data STRING specifies packet data\n" 476 "pcap FILENAME read packet data from pcap file\n",
498 .path =
"packet-generator delete",
500 .short_help =
"Delete stream with given name",
510 u32 stream_index = ~0;
545 .path =
"packet-generator configure",
546 .short_help =
"Change packet generator stream parameters",
559 u8 *pcap_file_name = 0;
575 else if (
unformat (line_input,
"pcap %s", &pcap_file_name))
577 else if (
unformat (line_input,
"count %u", &count))
579 else if (
unformat (line_input,
"disable"))
603 if (!pcap_file_name && is_disable == 0)
628 .path =
"packet-generator capture",
629 .short_help =
"packet-generator capture <interface name> pcap <filename> [count <n>]",
648 if (
unformat (line_input,
"interface pg%u", &if_id))
669 .path =
"create packet-generator",
670 .short_help =
"create packet-generator interface <interface name>",
unformat_function_t unformat_vnet_hw_interface
static int pg_stream_is_enabled(pg_stream_t *s)
clib_error_t * pg_capture(pg_capture_args_t *a)
void pg_stream_add(pg_main_t *pg, pg_stream_t *s_init)
char * file_name
File name of pcap output.
static u8 * format_pg_edit_group(u8 *s, va_list *va)
u32 n_packets_to_capture
Number of packets to capture.
vnet_main_t * vnet_get_main(void)
pg_edit_group_t * edit_groups
static clib_error_t * pg_cli_init(vlib_main_t *vm)
PCAP utility definitions.
void(* edit_function)(struct pg_main_t *pg, struct pg_stream_t *s, struct pg_edit_group_t *g, u32 *buffers, u32 n_buffers)
uword * stream_index_by_name
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
unformat_function_t unformat_vnet_sw_interface
pg_edit_type_t packet_size_edit_type
void pg_stream_del(pg_main_t *pg, uword index)
PCAP main state data structure.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static uword unformat_pg_stream_parameter(unformat_input_t *input, va_list *args)
#define VLIB_INIT_FUNCTION(x)
uword unformat_pg_payload(unformat_input_t *input, va_list *args)
static clib_error_t * del_stream(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_error_return(e, args...)
#define clib_error_create(args...)
static clib_error_t * new_stream(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * enable_disable_stream(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void pg_stream_free(pg_stream_t *s)
u32 pg_interface_add_or_get(pg_main_t *pg, uword stream_index)
unformat_function_t unformat_hash_vec_string
clib_error_t * pcap_read(pcap_main_t *pm)
Read PCAP file.
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
static clib_error_t * create_pg_if_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u64 * replay_packet_timestamps
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * pg_pcap_read(pg_stream_t *s, char *file_name)
static uword pg_edit_group_n_bytes(pg_stream_t *s, u32 group_index)
void pg_stream_change(pg_main_t *pg, pg_stream_t *s)
unformat_function_t * unformat_edit
static u8 * format_pg_stream(u8 *s, va_list *va)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
u8 ** replay_packet_templates
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * validate_stream(pg_stream_t *s)
static clib_error_t * pg_capture_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void pg_enable_disable(u32 stream_index, int is_enable)
void pg_stream_enable_disable(pg_main_t *pg, pg_stream_t *s, int is_enable)
static clib_error_t * show_streams(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unsigned char function_name[]
u32 min_packet_bytes
Min/Max Packet bytes.
u64 * timestamps
Timestamps.
pcap_packet_type_t packet_type
Packet type.
u32 sw_if_index[VLIB_N_RX_TX]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unformat_function_t unformat_vlib_node
format_function_t format_clib_elf_symbol_with_address
f64 rate_packets_per_second
static u32 vlib_num_workers()
#define vec_foreach(var, vec)
Vector iterator.
u8 ** packets_read
Packets read from file.
vnet_device_class_t pg_dev_class
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * change_stream_parameters(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
pg_interface_t * interfaces
static uword pool_elts(void *v)
Number of active elements in a pool.