FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
cop_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * cop_api.c - cop api
4  *
5  * Copyright (c) 2016 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 <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/cop/cop.h>
26 
27 #include <vnet/vnet_msg_enum.h>
28 
29 #define vl_typedefs /* define message structures */
30 #include <vnet/vnet_all_api_h.h>
31 #undef vl_typedefs
32 
33 #define vl_endianfun /* define message structures */
34 #include <vnet/vnet_all_api_h.h>
35 #undef vl_endianfun
36 
37 /* instantiate all the print functions we know about */
38 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
39 #define vl_printfun
40 #include <vnet/vnet_all_api_h.h>
41 #undef vl_printfun
42 
44 
45 #define foreach_vpe_api_msg \
46 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
47 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)
48 
51 {
52  vl_api_cop_interface_enable_disable_reply_t *rmp;
53  int rv;
54  u32 sw_if_index = ntohl (mp->sw_if_index);
55  int enable_disable;
56 
58 
59  enable_disable = (int) mp->enable_disable;
60 
61  rv = cop_interface_enable_disable (sw_if_index, enable_disable);
62 
64 
65  REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
66 }
67 
70 {
71  vl_api_cop_whitelist_enable_disable_reply_t *rmp;
73  u32 sw_if_index = ntohl (mp->sw_if_index);
74  int rv;
75 
77 
78  a->sw_if_index = sw_if_index;
79  a->ip4 = mp->ip4;
80  a->ip6 = mp->ip6;
81  a->default_cop = mp->default_cop;
82  a->fib_id = ntohl (mp->fib_id);
83 
85 
87 
88  REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
89 }
90 
91 /*
92  * cop_api_hookup
93  * Add vpe's API message handlers to the table.
94  * vlib has alread mapped shared memory and
95  * added the client registration handlers.
96  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
97  */
98 #define vl_msg_name_crc_list
99 #include <vnet/vnet_all_api_h.h>
100 #undef vl_msg_name_crc_list
101 
102 static void
104 {
105 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
106  foreach_vl_msg_name_crc_cop;
107 #undef _
108 }
109 
110 static clib_error_t *
112 {
113  api_main_t *am = &api_main;
114 
115 #define _(N,n) \
116  vl_msg_api_set_handlers(VL_API_##N, #n, \
117  vl_api_##n##_t_handler, \
118  vl_noop_handler, \
119  vl_api_##n##_t_endian, \
120  vl_api_##n##_t_print, \
121  sizeof(vl_api_##n##_t), 1);
123 #undef _
124 
125  /*
126  * Set up the (msg_name, crc, message-id) table
127  */
129 
130  return 0;
131 }
132 
134 
135 /*
136  * fd.io coding-style-patch-verification: ON
137  *
138  * Local Variables:
139  * eval: (c-set-style "gnu")
140  * End:
141  */
VLIB_API_INIT_FUNCTION(cop_api_hookup)
cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must matc...
Definition: cop.api:45
static void vl_api_cop_whitelist_enable_disable_t_handler(vl_api_cop_whitelist_enable_disable_t *mp)
Definition: cop_api.c:69
a
Definition: bitmap.h:516
static clib_error_t * cop_api_hookup(vlib_main_t *vm)
Definition: cop_api.c:111
#define REPLY_MACRO(t)
int cop_whitelist_enable_disable(cop_whitelist_enable_disable_args_t *a)
Definition: cop.c:229
static void setup_message_id_table(api_main_t *am)
Definition: cop_api.c:103
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:198
#define BAD_SW_IF_INDEX_LABEL
api_main_t api_main
Definition: api_shared.c:35
vlib_main_t * vm
Definition: buffer.c:283
cop: enable/disable junk filtration features on an interface
Definition: cop.api:25
static void vl_api_cop_interface_enable_disable_t_handler(vl_api_cop_interface_enable_disable_t *mp)
Definition: cop_api.c:50
int cop_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: cop.c:151
#define foreach_vpe_api_msg
Definition: cop_api.c:45
unsigned int u32
Definition: types.h:88
#define VALIDATE_SW_IF_INDEX(mp)