FD.io VPP  v21.01.1
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 {
55  adl_main_t *am = &adl_main;
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 {
85  adl_main_t *am = &adl_main;
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 
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  void register_vl_api_cop_interface_enable_disable_callback (void *);
113 
114  am->vlib_main = vm;
115 
116  /* Ask for a correctly-sized block of API message decode slots */
118 
119  /* Set up transitional API callbacks */
120  register_vl_api_cop_interface_enable_disable_callback
124 
125  return 0;
126 }
127 
129 
130 /*
131  * fd.io coding-style-patch-verification: ON
132  *
133  * Local Variables:
134  * eval: (c-set-style "gnu")
135  * End:
136  */
int vl_api_cop_whitelist_enable_disable_callback(adl_allowlist_enable_disable_args_t *a)
Definition: adl_api.c:77
vl_api_interface_index_t sw_if_index
Definition: adl.api:31
vlib_main_t * vm
Definition: in2out_ed.c:1580
Definition: adl.h:64
adl_main_t adl_main
Definition: adl.c:20
vl_api_interface_index_t sw_if_index
Definition: adl.api:52
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
int adl_allowlist_enable_disable(adl_allowlist_enable_disable_args_t *a)
Definition: adl.c:233
u16 msg_id_base
Definition: adl.h:67
int adl_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: adl.c:169
adl: enable/disable allow list filtration features on an interface Note: the supplied fib_id must mat...
Definition: adl.api:48
unsigned int u32
Definition: types.h:88
int vl_api_cop_interface_enable_disable_callback(u32 sw_if_index, int enable_disable)
Definition: adl_api.c:47
vlib_main_t * vlib_main
Definition: adl.h:70
void register_vl_api_cop_whitelist_enable_disable_callback(void *cb)
Definition: cop_api.c:115
#define REPLY_MACRO(t)
static void vl_api_adl_allowlist_enable_disable_t_handler(vl_api_adl_allowlist_enable_disable_t *mp)
Definition: adl_api.c:83
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:409
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_adl_interface_enable_disable_t_handler(vl_api_adl_interface_enable_disable_t *mp)
Definition: adl_api.c:53
adl: enable/disable filtration features on an interface
Definition: adl.api:27
static clib_error_t * adl_api_init(vlib_main_t *vm)
Definition: adl_api.c:108
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
#define VALIDATE_SW_IF_INDEX(mp)