Line data Source code
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 : 34 : #define REPLY_MSG_ID_BASE am->msg_id_base 35 : #include <vlibapi/api_helper_macros.h> 36 : 37 : #define foreach_vpe_api_msg \ 38 : _(ADL_INTERFACE_ENABLE_DISABLE, adl_interface_enable_disable) \ 39 : _(ADL_LIST_ENABLE_DISABLE, adl_allowlist_enable_disable) 40 : 41 : /* 42 : * Compatibility shim for the core engine cop_interface_enable_disable API, 43 : * which will be deprecated in vpp 20.12. 44 : */ 45 0 : int vl_api_cop_interface_enable_disable_callback 46 : (u32 sw_if_index, int enable_disable) 47 : { 48 0 : return adl_interface_enable_disable (sw_if_index, enable_disable); 49 : } 50 : 51 1 : static void vl_api_adl_interface_enable_disable_t_handler 52 : (vl_api_adl_interface_enable_disable_t * mp) 53 : { 54 1 : adl_main_t *am = &adl_main; 55 : vl_api_adl_interface_enable_disable_reply_t *rmp; 56 : int rv; 57 1 : u32 sw_if_index = ntohl (mp->sw_if_index); 58 : int enable_disable; 59 : 60 1 : VALIDATE_SW_IF_INDEX (mp); 61 : 62 1 : enable_disable = (int) mp->enable_disable; 63 : 64 1 : rv = adl_interface_enable_disable (sw_if_index, enable_disable); 65 : 66 1 : BAD_SW_IF_INDEX_LABEL; 67 : 68 1 : REPLY_MACRO (VL_API_ADL_INTERFACE_ENABLE_DISABLE_REPLY); 69 : } 70 : 71 : /* 72 : * Compatibility shim for the core engine cop_whitelist_enable_disable API, 73 : * which will be deprecated in vpp 20.12. 74 : */ 75 0 : int vl_api_cop_whitelist_enable_disable_callback 76 : (adl_allowlist_enable_disable_args_t * a) 77 : { 78 0 : return adl_allowlist_enable_disable (a); 79 : } 80 : 81 1 : static void vl_api_adl_allowlist_enable_disable_t_handler 82 : (vl_api_adl_allowlist_enable_disable_t * mp) 83 : { 84 1 : adl_main_t *am = &adl_main; 85 : vl_api_adl_allowlist_enable_disable_reply_t *rmp; 86 1 : adl_allowlist_enable_disable_args_t _a, *a = &_a; 87 1 : u32 sw_if_index = ntohl (mp->sw_if_index); 88 : int rv; 89 : 90 1 : VALIDATE_SW_IF_INDEX (mp); 91 : 92 1 : a->sw_if_index = sw_if_index; 93 1 : a->ip4 = mp->ip4; 94 1 : a->ip6 = mp->ip6; 95 1 : a->default_adl = mp->default_adl; 96 1 : a->fib_id = ntohl (mp->fib_id); 97 : 98 1 : rv = adl_allowlist_enable_disable (a); 99 : 100 1 : BAD_SW_IF_INDEX_LABEL; 101 : 102 1 : REPLY_MACRO (VL_API_ADL_ALLOWLIST_ENABLE_DISABLE_REPLY); 103 : } 104 : 105 : #include <adl/adl.api.c> 106 : static clib_error_t * 107 559 : adl_api_init (vlib_main_t * vm) 108 : { 109 559 : adl_main_t *am = &adl_main; 110 559 : am->vlib_main = vm; 111 : 112 : /* Ask for a correctly-sized block of API message decode slots */ 113 559 : am->msg_id_base = setup_message_id_table (); 114 : 115 559 : return 0; 116 : } 117 : 118 1119 : VLIB_INIT_FUNCTION (adl_api_init); 119 : 120 : /* 121 : * fd.io coding-style-patch-verification: ON 122 : * 123 : * Local Variables: 124 : * eval: (c-set-style "gnu") 125 : * End: 126 : */