Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1 | /* * Copyright (c) 2011-2016 Cisco and/or its affiliates. |
| 2 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | * you may not use this file except in compliance with the License. |
| 4 | * You may obtain a copy of the License at: |
| 5 | * |
| 6 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * |
| 8 | * Unless required by applicable law or agreed to in writing, software |
| 9 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | * See the License for the specific language governing permissions and |
| 12 | * limitations under the License. |
| 13 | */ |
| 14 | /** |
| 15 | * @file |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 16 | * @brief BFD UDP transport layer declarations |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #ifndef __included_bfd_udp_h__ |
| 20 | #define __included_bfd_udp_h__ |
| 21 | |
| 22 | #include <vppinfra/clib.h> |
| 23 | #include <vnet/adj/adj_types.h> |
| 24 | #include <vnet/ip/ip6_packet.h> |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 25 | #include <vnet/bfd/bfd_api.h> |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 26 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 27 | /* *INDENT-OFF* */ |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 28 | /** identifier of BFD session based on UDP transport only */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 29 | typedef CLIB_PACKED (struct { |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 30 | union { |
| 31 | /** interface to which the session is tied - single-hop */ |
| 32 | u32 sw_if_index; |
| 33 | /** the FIB index the peer is in - multi-hop*/ |
| 34 | u32 fib_index; |
| 35 | }; |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 36 | /** local address */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 37 | ip46_address_t local_addr; |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 38 | /** peer address */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 39 | ip46_address_t peer_addr; |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 40 | }) bfd_udp_key_t; |
| 41 | /* *INDENT-ON* */ |
| 42 | |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 43 | /** UDP transport specific data embedded in bfd_session's union */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 44 | typedef struct |
| 45 | { |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 46 | /** key identifying this session */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 47 | bfd_udp_key_t key; |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 48 | /** adjacency index returned from adj lock call */ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 49 | adj_index_t adj_index; |
| 50 | } bfd_udp_session_t; |
| 51 | |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 52 | /** bfd udp echo packet trace capture */ |
Klement Sekera | aeeac3b | 2017-02-14 07:11:52 +0100 | [diff] [blame] | 53 | typedef struct |
| 54 | { |
| 55 | u32 len; |
| 56 | u8 data[400]; |
| 57 | } bfd_udp_echo_input_trace_t; |
| 58 | |
Klement Sekera | 2bce033 | 2017-02-09 06:03:46 +0100 | [diff] [blame] | 59 | struct bfd_session_s; |
| 60 | |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 61 | /** |
| 62 | * @brief add the necessary transport layer by prepending it to existing data |
| 63 | * |
Klement Sekera | e50e856 | 2017-04-04 16:19:48 +0200 | [diff] [blame] | 64 | * |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 65 | * @param is_echo 1 if this is echo packet, 0 if control frame |
| 66 | * |
| 67 | * @return 1 on success, 0 on failure |
| 68 | */ |
Klement Sekera | e50e856 | 2017-04-04 16:19:48 +0200 | [diff] [blame] | 69 | int bfd_add_udp4_transport (vlib_main_t * vm, u32 bi, |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 70 | const struct bfd_session_s *bs, int is_echo); |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * @brief add the necessary transport layer by prepending it to existing data |
| 74 | * |
| 75 | * @param is_echo 1 if this is echo packet, 0 if control frame |
| 76 | * |
| 77 | * @return 1 on success, 0 on failure |
| 78 | */ |
Klement Sekera | e50e856 | 2017-04-04 16:19:48 +0200 | [diff] [blame] | 79 | int bfd_add_udp6_transport (vlib_main_t * vm, u32 bi, |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 80 | const struct bfd_session_s *bs, int is_echo); |
| 81 | |
| 82 | /** |
Klement Sekera | e50e856 | 2017-04-04 16:19:48 +0200 | [diff] [blame] | 83 | * @brief transport packet over udpv4 |
| 84 | * |
| 85 | * @param is_echo 1 if this is echo packet, 0 if control frame |
| 86 | * |
| 87 | * @return 1 on success, 0 on failure |
| 88 | */ |
| 89 | int bfd_transport_udp4 (vlib_main_t * vm, u32 bi, |
| 90 | const struct bfd_session_s *bs); |
| 91 | |
| 92 | /** |
| 93 | * @brief transport packet over udpv6 |
| 94 | * |
| 95 | * @param is_echo 1 if this is echo packet, 0 if control frame |
| 96 | * |
| 97 | * @return 1 on success, 0 on failure |
| 98 | */ |
| 99 | int bfd_transport_udp6 (vlib_main_t * vm, u32 bi, |
| 100 | const struct bfd_session_s *bs); |
| 101 | |
| 102 | /** |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 103 | * @brief check if the bfd udp layer is echo-capable at this time |
| 104 | * |
| 105 | * @return 1 if available, 0 otherwise |
| 106 | */ |
| 107 | int bfd_udp_is_echo_available (bfd_transport_e transport); |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 108 | |
Klement Sekera | b16bfe3 | 2017-02-28 11:56:48 +0100 | [diff] [blame] | 109 | /** |
| 110 | * @brief get echo source information - used by CLI |
| 111 | */ |
| 112 | void bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index, |
| 113 | int *have_usable_ip4, ip4_address_t * ip4, |
| 114 | int *have_usable_ip6, ip6_address_t * ip6); |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 115 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 116 | #endif /* __included_bfd_udp_h__ */ |
| 117 | |
| 118 | /* |
| 119 | * fd.io coding-style-patch-verification: ON |
| 120 | * |
| 121 | * Local Variables: |
| 122 | * eval: (c-set-style "gnu") |
| 123 | * End: |
| 124 | */ |