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>
27 set_bpf_trace_filter_command_fn (vlib_main_t *vm, unformat_input_t *input,
28 vlib_cli_command_t *cmd)
30 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, "%s", &bpf_expr))
46 return clib_error_return (0, "unknown input `%U'",
47 format_unformat_error, input);
50 err = bpf_trace_filter_set_unset ((char *) bpf_expr, is_del);
51 unformat_free (line_input);
56 VLIB_CLI_COMMAND (set_bpf_trace_filter, static) = {
57 .path = "set bpf trace filter",
58 .short_help = "set bpf trace filter {<pcap string>}",
59 .function = set_bpf_trace_filter_command_fn,
63 * fd.io coding-style-patch-verification: ON
66 * eval: (c-set-style "gnu")