2 *------------------------------------------------------------------
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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/cop/cop.h>
27 #include <vnet/vnet_msg_enum.h>
29 #define vl_typedefs /* define message structures */
30 #include <vnet/vnet_all_api_h.h>
33 #define vl_endianfun /* define message structures */
34 #include <vnet/vnet_all_api_h.h>
37 /* instantiate all the print functions we know about */
38 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
40 #include <vnet/vnet_all_api_h.h>
43 #include <vlibapi/api_helper_macros.h>
45 #define foreach_vpe_api_msg \
46 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
47 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)
49 static void vl_api_cop_interface_enable_disable_t_handler
50 (vl_api_cop_interface_enable_disable_t * mp)
52 vl_api_cop_interface_enable_disable_reply_t *rmp;
54 u32 sw_if_index = ntohl (mp->sw_if_index);
57 VALIDATE_SW_IF_INDEX (mp);
59 enable_disable = (int) mp->enable_disable;
61 rv = cop_interface_enable_disable (sw_if_index, enable_disable);
63 BAD_SW_IF_INDEX_LABEL;
65 REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
68 static void vl_api_cop_whitelist_enable_disable_t_handler
69 (vl_api_cop_whitelist_enable_disable_t * mp)
71 vl_api_cop_whitelist_enable_disable_reply_t *rmp;
72 cop_whitelist_enable_disable_args_t _a, *a = &_a;
73 u32 sw_if_index = ntohl (mp->sw_if_index);
76 VALIDATE_SW_IF_INDEX (mp);
78 a->sw_if_index = sw_if_index;
81 a->default_cop = mp->default_cop;
82 a->fib_id = ntohl (mp->fib_id);
84 rv = cop_whitelist_enable_disable (a);
86 BAD_SW_IF_INDEX_LABEL;
88 REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
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()
98 #define vl_msg_name_crc_list
99 #include <vnet/vnet_all_api_h.h>
100 #undef vl_msg_name_crc_list
103 setup_message_id_table (api_main_t * am)
105 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
106 foreach_vl_msg_name_crc_cop;
110 static clib_error_t *
111 cop_api_hookup (vlib_main_t * vm)
113 api_main_t *am = &api_main;
116 vl_msg_api_set_handlers(VL_API_##N, #n, \
117 vl_api_##n##_t_handler, \
119 vl_api_##n##_t_endian, \
120 vl_api_##n##_t_print, \
121 sizeof(vl_api_##n##_t), 1);
126 * Set up the (msg_name, crc, message-id) table
128 setup_message_id_table (am);
133 VLIB_API_INIT_FUNCTION (cop_api_hookup);
136 * fd.io coding-style-patch-verification: ON
139 * eval: (c-set-style "gnu")