diff options
Diffstat (limited to 'src/vnet/interface_cli.c')
-rw-r--r-- | src/vnet/interface_cli.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index 627af6f2b0d..74ac32522d7 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -2440,6 +2440,72 @@ VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = { /* *INDENT-ON* */ static clib_error_t * +set_pcap_filter_function (vlib_main_t *vm, unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + vnet_pcap_t *pp = &vnet_get_main ()->pcap; + unformat_input_t _line_input, *line_input = &_line_input; + vlib_is_packet_traced_fn_t *res = 0; + clib_error_t *error = 0; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != (uword) UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "%U", unformat_vlib_trace_filter_function, + &res)) + ; + else + { + error = clib_error_create ( + "expected valid trace filter function, got `%U'", + format_unformat_error, line_input); + goto done; + } + } + pp->current_filter_function = res; + +done: + unformat_free (line_input); + + return error; +} + +VLIB_CLI_COMMAND (set_pcap_filter_function_cli, static) = { + .path = "set pcap filter function", + .short_help = "set pcap filter function <func_name>", + .function = set_pcap_filter_function, +}; + +static clib_error_t * +show_pcap_filter_function (vlib_main_t *vm, unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + vnet_pcap_t *pp = &vnet_get_main ()->pcap; + vlib_trace_filter_main_t *tfm = &vlib_trace_filter_main; + vlib_is_packet_traced_fn_t *current_trace_filter_fn = + pp->current_filter_function; + vlib_trace_filter_function_registration_t *reg = + tfm->trace_filter_registration; + + while (reg) + { + vlib_cli_output (vm, "%sname:%s description: %s priority: %u", + reg->function == current_trace_filter_fn ? "(*) " : "", + reg->name, reg->description, reg->priority); + reg = reg->next; + } + return 0; +} + +VLIB_CLI_COMMAND (show_pcap_filter_function_cli, static) = { + .path = "show pcap filter function", + .short_help = "show pcap filter function", + .function = show_pcap_filter_function, +}; + +static clib_error_t * set_interface_name (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) { |