2 *------------------------------------------------------------------
3 * Copyright (c) 2023 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
19 #include <sys/ioctl.h>
22 #include <vlib/vlib.h>
23 #include <bpf_trace_filter/bpf_trace_filter.h>
26 set_bpf_trace_filter_command_fn (vlib_main_t *vm, unformat_input_t *input,
27 vlib_cli_command_t *cmd)
29 unformat_input_t _line_input, *line_input = &_line_input;
33 clib_error_t *err = 0;
35 /* Get a line of input. */
36 if (!unformat_user (input, unformat_line_input, line_input))
39 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
41 if (unformat (line_input, "del"))
43 else if (unformat (line_input, "no-optimize"))
45 else if (unformat (line_input, "%s", &bpf_expr))
49 err = clib_error_return (0, "unknown input `%U'",
50 format_unformat_error, input);
54 unformat_free (line_input);
59 err = bpf_trace_filter_set_unset ((char *) bpf_expr, is_del, optimize);
64 VLIB_CLI_COMMAND (set_bpf_trace_filter, static) = {
65 .path = "set bpf trace filter",
66 .short_help = "set bpf trace filter [del] [no-optimize] {<pcap string>}",
67 .function = set_bpf_trace_filter_command_fn,
71 show_bpf_trace_filter_command_fn (vlib_main_t *vm, unformat_input_t *input,
72 vlib_cli_command_t *cmd)
74 bpf_trace_filter_main_t *btm = &bpf_trace_filter_main;
76 if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
78 return (clib_error_return (0, "unknown input '%U'",
79 format_unformat_error, input));
82 vlib_cli_output (vm, "%U", format_bpf_trace_filter, btm);
87 VLIB_CLI_COMMAND (show_bpf_trace_filter, static) = {
88 .path = "show bpf trace filter",
89 .short_help = "show bpf trace filter",
90 .function = show_bpf_trace_filter_command_fn,
94 * fd.io coding-style-patch-verification: ON
97 * eval: (c-set-style "gnu")