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 *------------------------------------------------------------------
18 #include <vlib/vlib.h>
19 #include <bpf_trace_filter/bpf_trace_filter.h>
20 #include <vlibapi/api.h>
21 #include <vlibmemory/api.h>
23 /* define message IDs */
24 #include <bpf_trace_filter/bpf_trace_filter.api_enum.h>
25 #include <bpf_trace_filter/bpf_trace_filter.api_types.h>
27 #define REPLY_MSG_ID_BASE (bm->msg_id_base)
28 #include <vlibapi/api_helper_macros.h>
31 vl_api_bpf_trace_filter_set_t_handler (vl_api_bpf_trace_filter_set_t *mp)
33 bpf_trace_filter_main_t *bm = &bpf_trace_filter_main;
34 vl_api_bpf_trace_filter_set_reply_t *rmp;
35 clib_error_t *err = 0;
37 u8 is_del = !mp->is_add;
40 bpf_expr = vl_api_from_api_to_new_c_string (&mp->filter);
41 err = bpf_trace_filter_set_unset (bpf_expr, is_del, 0);
46 clib_error_report (err);
50 REPLY_MACRO (VL_API_BPF_TRACE_FILTER_SET_REPLY);
54 vl_api_bpf_trace_filter_set_v2_t_handler (vl_api_bpf_trace_filter_set_v2_t *mp)
56 bpf_trace_filter_main_t *bm = &bpf_trace_filter_main;
57 vl_api_bpf_trace_filter_set_v2_reply_t *rmp;
58 clib_error_t *err = 0;
60 u8 is_del = !mp->is_add;
61 u8 optimize = !!mp->optimize;
64 bpf_expr = vl_api_from_api_to_new_c_string (&mp->filter);
65 err = bpf_trace_filter_set_unset (bpf_expr, is_del, optimize);
70 clib_error_report (err);
74 REPLY_MACRO (VL_API_BPF_TRACE_FILTER_SET_V2_REPLY);
77 #include <bpf_trace_filter/bpf_trace_filter.api.c>
80 bpf_trace_filter_plugin_api_hookup (vlib_main_t *vm)
82 bpf_trace_filter_main_t *bm = &bpf_trace_filter_main;
84 /* ask for a correctly-sized block of API message decode slots */
85 bm->msg_id_base = setup_message_id_table ();
89 VLIB_API_INIT_FUNCTION (bpf_trace_filter_plugin_api_hookup);
92 * fd.io coding-style-patch-verification: ON
95 * eval: (c-set-style "gnu")