Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
| 3 | * bfd_api.c - bfd 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 | */ |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 19 | /** |
| 20 | * @file |
| 21 | * @brief BFD binary API implementation |
| 22 | */ |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 23 | |
| 24 | #include <vnet/vnet.h> |
| 25 | #include <vlibmemory/api.h> |
| 26 | |
| 27 | #include <vnet/interface.h> |
| 28 | #include <vnet/api_errno.h> |
| 29 | #include <vnet/bfd/bfd_main.h> |
| 30 | #include <vnet/bfd/bfd_api.h> |
| 31 | |
| 32 | #include <vnet/vnet_msg_enum.h> |
| 33 | |
| 34 | #define vl_typedefs /* define message structures */ |
| 35 | #include <vnet/vnet_all_api_h.h> |
| 36 | #undef vl_typedefs |
| 37 | |
| 38 | #define vl_endianfun /* define message structures */ |
| 39 | #include <vnet/vnet_all_api_h.h> |
| 40 | #undef vl_endianfun |
| 41 | |
| 42 | /* instantiate all the print functions we know about */ |
| 43 | #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) |
| 44 | #define vl_printfun |
| 45 | #include <vnet/vnet_all_api_h.h> |
| 46 | #undef vl_printfun |
| 47 | |
| 48 | #include <vlibapi/api_helper_macros.h> |
| 49 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 50 | #define foreach_vpe_api_msg \ |
| 51 | _ (BFD_UDP_ADD, bfd_udp_add) \ |
Klement Sekera | a57a970 | 2017-02-02 06:58:07 +0100 | [diff] [blame] | 52 | _ (BFD_UDP_MOD, bfd_udp_mod) \ |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 53 | _ (BFD_UDP_DEL, bfd_udp_del) \ |
| 54 | _ (BFD_UDP_SESSION_DUMP, bfd_udp_session_dump) \ |
| 55 | _ (BFD_UDP_SESSION_SET_FLAGS, bfd_udp_session_set_flags) \ |
| 56 | _ (WANT_BFD_EVENTS, want_bfd_events) \ |
| 57 | _ (BFD_AUTH_SET_KEY, bfd_auth_set_key) \ |
| 58 | _ (BFD_AUTH_DEL_KEY, bfd_auth_del_key) \ |
| 59 | _ (BFD_AUTH_KEYS_DUMP, bfd_auth_keys_dump) \ |
| 60 | _ (BFD_UDP_AUTH_ACTIVATE, bfd_udp_auth_activate) \ |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 61 | _ (BFD_UDP_AUTH_DEACTIVATE, bfd_udp_auth_deactivate) \ |
| 62 | _ (BFD_UDP_SET_ECHO_SOURCE, bfd_udp_set_echo_source) \ |
| 63 | _ (BFD_UDP_DEL_ECHO_SOURCE, bfd_udp_del_echo_source) |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 64 | |
| 65 | pub_sub_handler (bfd_events, BFD_EVENTS); |
| 66 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 67 | #define BFD_UDP_API_PARAM_COMMON_CODE \ |
| 68 | ip46_address_t local_addr; \ |
| 69 | memset (&local_addr, 0, sizeof (local_addr)); \ |
| 70 | ip46_address_t peer_addr; \ |
| 71 | memset (&peer_addr, 0, sizeof (peer_addr)); \ |
| 72 | if (mp->is_ipv6) \ |
| 73 | { \ |
| 74 | clib_memcpy (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6)); \ |
| 75 | clib_memcpy (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6)); \ |
| 76 | } \ |
| 77 | else \ |
| 78 | { \ |
| 79 | clib_memcpy (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4)); \ |
| 80 | clib_memcpy (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4)); \ |
| 81 | } |
| 82 | |
| 83 | #define BFD_UDP_API_PARAM_FROM_MP(mp) \ |
| 84 | clib_net_to_host_u32 (mp->sw_if_index), &local_addr, &peer_addr |
| 85 | |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 86 | static void |
| 87 | vl_api_bfd_udp_add_t_handler (vl_api_bfd_udp_add_t * mp) |
| 88 | { |
| 89 | vl_api_bfd_udp_add_reply_t *rmp; |
| 90 | int rv; |
| 91 | |
| 92 | VALIDATE_SW_IF_INDEX (mp); |
| 93 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 94 | BFD_UDP_API_PARAM_COMMON_CODE; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 95 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 96 | rv = bfd_udp_add_session (BFD_UDP_API_PARAM_FROM_MP (mp), |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 97 | clib_net_to_host_u32 (mp->desired_min_tx), |
| 98 | clib_net_to_host_u32 (mp->required_min_rx), |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 99 | mp->detect_mult, mp->is_authenticated, |
| 100 | clib_net_to_host_u32 (mp->conf_key_id), |
| 101 | mp->bfd_key_id); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 102 | |
| 103 | BAD_SW_IF_INDEX_LABEL; |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 104 | REPLY_MACRO (VL_API_BFD_UDP_ADD_REPLY); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void |
Klement Sekera | a57a970 | 2017-02-02 06:58:07 +0100 | [diff] [blame] | 108 | vl_api_bfd_udp_mod_t_handler (vl_api_bfd_udp_mod_t * mp) |
| 109 | { |
| 110 | vl_api_bfd_udp_mod_reply_t *rmp; |
| 111 | int rv; |
| 112 | |
| 113 | VALIDATE_SW_IF_INDEX (mp); |
| 114 | |
| 115 | BFD_UDP_API_PARAM_COMMON_CODE; |
| 116 | |
| 117 | rv = bfd_udp_mod_session (BFD_UDP_API_PARAM_FROM_MP (mp), |
| 118 | clib_net_to_host_u32 (mp->desired_min_tx), |
| 119 | clib_net_to_host_u32 (mp->required_min_rx), |
| 120 | mp->detect_mult); |
| 121 | |
| 122 | BAD_SW_IF_INDEX_LABEL; |
| 123 | REPLY_MACRO (VL_API_BFD_UDP_MOD_REPLY); |
| 124 | } |
| 125 | |
| 126 | static void |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 127 | vl_api_bfd_udp_del_t_handler (vl_api_bfd_udp_del_t * mp) |
| 128 | { |
| 129 | vl_api_bfd_udp_del_reply_t *rmp; |
| 130 | int rv; |
| 131 | |
| 132 | VALIDATE_SW_IF_INDEX (mp); |
| 133 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 134 | BFD_UDP_API_PARAM_COMMON_CODE; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 135 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 136 | rv = bfd_udp_del_session (BFD_UDP_API_PARAM_FROM_MP (mp)); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 137 | |
| 138 | BAD_SW_IF_INDEX_LABEL; |
| 139 | REPLY_MACRO (VL_API_BFD_UDP_DEL_REPLY); |
| 140 | } |
| 141 | |
| 142 | void |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 143 | send_bfd_udp_session_details (vl_api_registration_t * reg, u32 context, |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 144 | bfd_session_t * bs) |
| 145 | { |
| 146 | if (bs->transport != BFD_TRANSPORT_UDP4 && |
| 147 | bs->transport != BFD_TRANSPORT_UDP6) |
| 148 | { |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | vl_api_bfd_udp_session_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); |
| 153 | memset (mp, 0, sizeof (*mp)); |
| 154 | mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_DETAILS); |
| 155 | mp->context = context; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 156 | mp->state = bs->local_state; |
| 157 | bfd_udp_session_t *bus = &bs->udp; |
| 158 | bfd_udp_key_t *key = &bus->key; |
| 159 | mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index); |
| 160 | mp->is_ipv6 = !(ip46_address_is_ip4 (&key->local_addr)); |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 161 | if ((!bs->auth.is_delayed && bs->auth.curr_key) || |
| 162 | (bs->auth.is_delayed && bs->auth.next_key)) |
| 163 | { |
| 164 | mp->is_authenticated = 1; |
| 165 | } |
| 166 | if (bs->auth.is_delayed && bs->auth.next_key) |
| 167 | { |
| 168 | mp->bfd_key_id = bs->auth.next_bfd_key_id; |
| 169 | mp->conf_key_id = clib_host_to_net_u32 (bs->auth.next_key->conf_key_id); |
| 170 | } |
| 171 | else if (!bs->auth.is_delayed && bs->auth.curr_key) |
| 172 | { |
| 173 | mp->bfd_key_id = bs->auth.curr_bfd_key_id; |
| 174 | mp->conf_key_id = clib_host_to_net_u32 (bs->auth.curr_key->conf_key_id); |
| 175 | } |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 176 | if (mp->is_ipv6) |
| 177 | { |
| 178 | clib_memcpy (mp->local_addr, &key->local_addr, |
| 179 | sizeof (key->local_addr)); |
| 180 | clib_memcpy (mp->peer_addr, &key->peer_addr, sizeof (key->peer_addr)); |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | clib_memcpy (mp->local_addr, key->local_addr.ip4.data, |
| 185 | sizeof (key->local_addr.ip4.data)); |
| 186 | clib_memcpy (mp->peer_addr, key->peer_addr.ip4.data, |
| 187 | sizeof (key->peer_addr.ip4.data)); |
| 188 | } |
| 189 | |
Klement Sekera | a57a970 | 2017-02-02 06:58:07 +0100 | [diff] [blame] | 190 | mp->required_min_rx = |
| 191 | clib_host_to_net_u32 (bs->config_required_min_rx_usec); |
| 192 | mp->desired_min_tx = clib_host_to_net_u32 (bs->config_desired_min_tx_usec); |
| 193 | mp->detect_mult = bs->local_detect_mult; |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 194 | vl_api_send_msg (reg, (u8 *) mp); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void |
| 198 | bfd_event (bfd_main_t * bm, bfd_session_t * bs) |
| 199 | { |
| 200 | vpe_api_main_t *vam = &vpe_api_main; |
| 201 | vpe_client_registration_t *reg; |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 202 | vl_api_registration_t *vl_reg; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 203 | /* *INDENT-OFF* */ |
| 204 | pool_foreach (reg, vam->bfd_events_registrations, ({ |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 205 | vl_reg = vl_api_client_index_to_registration (reg->client_index); |
| 206 | if (vl_reg) |
| 207 | { |
| 208 | switch (bs->transport) |
| 209 | { |
| 210 | case BFD_TRANSPORT_UDP4: |
| 211 | /* fallthrough */ |
| 212 | case BFD_TRANSPORT_UDP6: |
| 213 | send_bfd_udp_session_details (vl_reg, 0, bs); |
| 214 | } |
| 215 | } |
| 216 | })); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 217 | /* *INDENT-ON* */ |
| 218 | } |
| 219 | |
| 220 | static void |
| 221 | vl_api_bfd_udp_session_dump_t_handler (vl_api_bfd_udp_session_dump_t * mp) |
| 222 | { |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 223 | vl_api_registration_t *reg; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 224 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 225 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 226 | if (!reg) |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 227 | return; |
| 228 | |
| 229 | bfd_session_t *bs = NULL; |
| 230 | /* *INDENT-OFF* */ |
| 231 | pool_foreach (bs, bfd_main.sessions, ({ |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 232 | if (bs->transport == BFD_TRANSPORT_UDP4 || |
| 233 | bs->transport == BFD_TRANSPORT_UDP6) |
| 234 | send_bfd_udp_session_details (reg, mp->context, bs); |
| 235 | })); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 236 | /* *INDENT-ON* */ |
| 237 | } |
| 238 | |
| 239 | static void |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 240 | vl_api_bfd_udp_session_set_flags_t_handler (vl_api_bfd_udp_session_set_flags_t |
| 241 | * mp) |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 242 | { |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 243 | vl_api_bfd_udp_session_set_flags_reply_t *rmp; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 244 | int rv; |
| 245 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 246 | BFD_UDP_API_PARAM_COMMON_CODE; |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 247 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 248 | rv = bfd_udp_session_set_flags (BFD_UDP_API_PARAM_FROM_MP (mp), |
| 249 | mp->admin_up_down); |
| 250 | |
| 251 | REPLY_MACRO (VL_API_BFD_UDP_SESSION_SET_FLAGS_REPLY); |
| 252 | } |
| 253 | |
| 254 | static void |
| 255 | vl_api_bfd_auth_set_key_t_handler (vl_api_bfd_auth_set_key_t * mp) |
| 256 | { |
| 257 | vl_api_bfd_auth_set_key_reply_t *rmp; |
| 258 | int rv = bfd_auth_set_key (clib_net_to_host_u32 (mp->conf_key_id), |
| 259 | mp->auth_type, mp->key_len, mp->key); |
| 260 | |
| 261 | REPLY_MACRO (VL_API_BFD_AUTH_SET_KEY_REPLY); |
| 262 | } |
| 263 | |
| 264 | static void |
| 265 | vl_api_bfd_auth_del_key_t_handler (vl_api_bfd_auth_del_key_t * mp) |
| 266 | { |
| 267 | vl_api_bfd_auth_del_key_reply_t *rmp; |
| 268 | int rv = bfd_auth_del_key (clib_net_to_host_u32 (mp->conf_key_id)); |
| 269 | |
| 270 | REPLY_MACRO (VL_API_BFD_AUTH_DEL_KEY_REPLY); |
| 271 | } |
| 272 | |
| 273 | static void |
| 274 | vl_api_bfd_auth_keys_dump_t_handler (vl_api_bfd_auth_keys_dump_t * mp) |
| 275 | { |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 276 | vl_api_registration_t *reg; |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 277 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 278 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 279 | if (!reg) |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 280 | return; |
| 281 | |
| 282 | bfd_auth_key_t *key = NULL; |
| 283 | vl_api_bfd_auth_keys_details_t *rmp = NULL; |
| 284 | |
| 285 | /* *INDENT-OFF* */ |
| 286 | pool_foreach (key, bfd_main.auth_keys, ({ |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 287 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
| 288 | memset (rmp, 0, sizeof (*rmp)); |
| 289 | rmp->_vl_msg_id = ntohs (VL_API_BFD_AUTH_KEYS_DETAILS); |
| 290 | rmp->context = mp->context; |
| 291 | rmp->conf_key_id = clib_host_to_net_u32 (key->conf_key_id); |
| 292 | rmp->auth_type = key->auth_type; |
| 293 | rmp->use_count = clib_host_to_net_u32 (key->use_count); |
| 294 | vl_api_send_msg (reg, (u8 *)&rmp); |
| 295 | })); |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 296 | /* *INDENT-ON* */ |
| 297 | } |
| 298 | |
| 299 | static void |
| 300 | vl_api_bfd_udp_auth_activate_t_handler (vl_api_bfd_udp_auth_activate_t * mp) |
| 301 | { |
| 302 | vl_api_bfd_udp_auth_activate_reply_t *rmp; |
| 303 | int rv; |
| 304 | |
| 305 | VALIDATE_SW_IF_INDEX (mp); |
| 306 | |
| 307 | BFD_UDP_API_PARAM_COMMON_CODE; |
| 308 | |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 309 | rv = bfd_udp_auth_activate (BFD_UDP_API_PARAM_FROM_MP (mp), |
| 310 | clib_net_to_host_u32 (mp->conf_key_id), |
| 311 | mp->bfd_key_id, mp->is_delayed); |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 312 | |
| 313 | BAD_SW_IF_INDEX_LABEL; |
| 314 | REPLY_MACRO (VL_API_BFD_UDP_AUTH_ACTIVATE_REPLY); |
| 315 | } |
| 316 | |
| 317 | static void |
| 318 | vl_api_bfd_udp_auth_deactivate_t_handler (vl_api_bfd_udp_auth_deactivate_t * |
| 319 | mp) |
| 320 | { |
| 321 | vl_api_bfd_udp_auth_deactivate_reply_t *rmp; |
| 322 | int rv; |
| 323 | |
| 324 | VALIDATE_SW_IF_INDEX (mp); |
| 325 | |
| 326 | BFD_UDP_API_PARAM_COMMON_CODE; |
| 327 | |
| 328 | rv = |
| 329 | bfd_udp_auth_deactivate (BFD_UDP_API_PARAM_FROM_MP (mp), mp->is_delayed); |
| 330 | |
| 331 | BAD_SW_IF_INDEX_LABEL; |
| 332 | REPLY_MACRO (VL_API_BFD_UDP_AUTH_DEACTIVATE_REPLY); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 333 | } |
| 334 | |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 335 | static void |
| 336 | vl_api_bfd_udp_set_echo_source_t_handler (vl_api_bfd_udp_set_echo_source_t * |
| 337 | mp) |
| 338 | { |
| 339 | vl_api_bfd_udp_set_echo_source_reply_t *rmp; |
| 340 | int rv; |
| 341 | |
| 342 | VALIDATE_SW_IF_INDEX (mp); |
| 343 | |
| 344 | rv = bfd_udp_set_echo_source (clib_net_to_host_u32 (mp->sw_if_index)); |
| 345 | |
| 346 | BAD_SW_IF_INDEX_LABEL; |
| 347 | REPLY_MACRO (VL_API_BFD_UDP_SET_ECHO_SOURCE_REPLY); |
| 348 | } |
| 349 | |
| 350 | static void |
| 351 | vl_api_bfd_udp_del_echo_source_t_handler (vl_api_bfd_udp_del_echo_source_t * |
| 352 | mp) |
| 353 | { |
| 354 | vl_api_bfd_udp_del_echo_source_reply_t *rmp; |
| 355 | int rv; |
| 356 | |
| 357 | rv = bfd_udp_del_echo_source (); |
| 358 | |
| 359 | REPLY_MACRO (VL_API_BFD_UDP_DEL_ECHO_SOURCE_REPLY); |
| 360 | } |
| 361 | |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 362 | /* |
| 363 | * bfd_api_hookup |
| 364 | * Add vpe's API message handlers to the table. |
| 365 | * vlib has alread mapped shared memory and |
| 366 | * added the client registration handlers. |
| 367 | * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() |
| 368 | */ |
| 369 | #define vl_msg_name_crc_list |
| 370 | #include <vnet/vnet_all_api_h.h> |
| 371 | #undef vl_msg_name_crc_list |
| 372 | |
| 373 | static void |
| 374 | setup_message_id_table (api_main_t * am) |
| 375 | { |
Klement Sekera | 10db26f | 2017-01-11 08:16:53 +0100 | [diff] [blame] | 376 | #define _(id, n, crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 377 | foreach_vl_msg_name_crc_bfd; |
| 378 | #undef _ |
| 379 | } |
| 380 | |
| 381 | static clib_error_t * |
| 382 | bfd_api_hookup (vlib_main_t * vm) |
| 383 | { |
| 384 | api_main_t *am = &api_main; |
| 385 | |
Klement Sekera | 10db26f | 2017-01-11 08:16:53 +0100 | [diff] [blame] | 386 | #define _(N, n) \ |
| 387 | vl_msg_api_set_handlers (VL_API_##N, #n, vl_api_##n##_t_handler, \ |
| 388 | vl_noop_handler, vl_api_##n##_t_endian, \ |
| 389 | vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1); |
Pavel Kotucek | 20d1232 | 2016-12-21 09:13:17 +0100 | [diff] [blame] | 390 | foreach_vpe_api_msg; |
| 391 | #undef _ |
| 392 | |
| 393 | /* |
| 394 | * Set up the (msg_name, crc, message-id) table |
| 395 | */ |
| 396 | setup_message_id_table (am); |
| 397 | |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | VLIB_API_INIT_FUNCTION (bfd_api_hookup); |
| 402 | |
| 403 | /* |
| 404 | * fd.io coding-style-patch-verification: ON |
| 405 | * |
| 406 | * Local Variables: |
| 407 | * eval: (c-set-style "gnu") |
| 408 | * End: |
| 409 | */ |