FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
adl_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * adl_api.c - adl api
4  *
5  * Copyright (c) 2016,2020 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vnet/plugin/plugin.h>
22 #include <adl/adl.h>
23 
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vpp/app/version.h>
27 
28 /* define message IDs */
29 #include <vnet/format_fns.h>
30 #include <adl/adl.api_enum.h>
31 #include <adl/adl.api_types.h>
32 
33 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
34 
35 #define REPLY_MSG_ID_BASE am->msg_id_base
37 
38 #define foreach_vpe_api_msg \
39 _(ADL_INTERFACE_ENABLE_DISABLE, adl_interface_enable_disable) \
40 _(ADL_LIST_ENABLE_DISABLE, adl_allowlist_enable_disable)
41 
42 /*
43  * Compatibility shim for the core engine cop_interface_enable_disable API,
44  * which will be deprecated in vpp 20.12.
45  */
47  (u32 sw_if_index, int enable_disable)
48 {
49  return adl_interface_enable_disable (sw_if_index, enable_disable);
50 }
51 
54 {
56  vl_api_adl_interface_enable_disable_reply_t *rmp;
57  int rv;
58  u32 sw_if_index = ntohl (mp->sw_if_index);
59  int enable_disable;
60 
62 
63  enable_disable = (int) mp->enable_disable;
64 
65  rv = adl_interface_enable_disable (sw_if_index, enable_disable);
66 
68 
69  REPLY_MACRO (VL_API_ADL_INTERFACE_ENABLE_DISABLE_REPLY);
70 }
71 
72 /*
73  * Compatibility shim for the core engine cop_whitelist_enable_disable API,
74  * which will be deprecated in vpp 20.12.
75  */
78 {
80 }
81 
84 {
86  vl_api_adl_allowlist_enable_disable_reply_t *rmp;
88  u32 sw_if_index = ntohl (mp->sw_if_index);
89  int rv;
90 
92 
93  a->sw_if_index = sw_if_index;
94  a->ip4 = mp->ip4;
95  a->ip6 = mp->ip6;
96  a->default_adl = mp->default_adl;
97  a->fib_id = ntohl (mp->fib_id);
98 
100 
102 
103  REPLY_MACRO (VL_API_ADL_ALLOWLIST_ENABLE_DISABLE_REPLY);
104 }
105 
106 #include <adl/adl.api.c>
107 static clib_error_t *
109 {
110  adl_main_t *am = &adl_main;
111  am->vlib_main = vm;
112 
113  /* Ask for a correctly-sized block of API message decode slots */
114  am->msg_id_base = setup_message_id_table ();
115 
116  return 0;
117 }
118 
120 
121 /*
122  * fd.io coding-style-patch-verification: ON
123  *
124  * Local Variables:
125  * eval: (c-set-style "gnu")
126  * End:
127  */
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
api.h
vl_api_adl_allowlist_enable_disable_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: adl.api:52
adl_api_init
static clib_error_t * adl_api_init(vlib_main_t *vm)
Definition: adl_api.c:108
vl_api_adl_allowlist_enable_disable_t::ip4
bool ip4
Definition: adl.api:54
vl_api_cop_interface_enable_disable_callback
int vl_api_cop_interface_enable_disable_callback(u32 sw_if_index, int enable_disable)
Definition: adl_api.c:47
vl_api_adl_allowlist_enable_disable_t::fib_id
u32 fib_id
Definition: adl.api:53
am
app_main_t * am
Definition: application.c:489
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
vl_api_cop_whitelist_enable_disable_callback
int vl_api_cop_whitelist_enable_disable_callback(adl_allowlist_enable_disable_args_t *a)
Definition: adl_api.c:77
adl_main_t
Definition: adl.h:64
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
vl_api_adl_interface_enable_disable_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: adl.api:31
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
adl_allowlist_enable_disable
int adl_allowlist_enable_disable(adl_allowlist_enable_disable_args_t *a)
Definition: adl.c:233
vl_api_adl_interface_enable_disable_t::enable_disable
bool enable_disable
Definition: adl.api:32
vl_api_adl_allowlist_enable_disable_t
adl: enable/disable allow list filtration features on an interface Note: the supplied fib_id must mat...
Definition: adl.api:48
adl_interface_enable_disable
int adl_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: adl.c:169
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
plugin.h
format_fns.h
vl_api_adl_allowlist_enable_disable_t_handler
static void vl_api_adl_allowlist_enable_disable_t_handler(vl_api_adl_allowlist_enable_disable_t *mp)
Definition: adl_api.c:83
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
api_helper_macros.h
adl_allowlist_enable_disable_args_t
Definition: adl.h:80
vl_api_adl_allowlist_enable_disable_t::default_adl
bool default_adl
Definition: adl.api:56
vlib_main_t
Definition: main.h:102
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:544
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
rv
int __clib_unused rv
Definition: application.c:491
vl_api_adl_allowlist_enable_disable_t::ip6
bool ip6
Definition: adl.api:55
vnet.h
vl_api_adl_interface_enable_disable_t
adl: enable/disable filtration features on an interface
Definition: adl.api:27
adl_main
adl_main_t adl_main
Definition: adl.c:20
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vl_api_adl_interface_enable_disable_t_handler
static void vl_api_adl_interface_enable_disable_t_handler(vl_api_adl_interface_enable_disable_t *mp)
Definition: adl_api.c:53
adl.h