blob: 8f4bfee2bd72d9febe2844f93f0b376a71281842 [file] [log] [blame]
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001/* * 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 Sekerab16bfe32017-02-28 11:56:48 +010016 * @brief BFD UDP transport layer declarations
Klement Sekera0e3c0de2016-09-29 14:43:44 +020017 */
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 Sekera239790f2017-02-16 10:53:53 +010025#include <vnet/bfd/bfd_api.h>
Klement Sekera0e3c0de2016-09-29 14:43:44 +020026
Klement Sekerab16bfe32017-02-28 11:56:48 +010027/** identifier of BFD session based on UDP transport only */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020028typedef CLIB_PACKED (struct {
Neale Ranns88fc83e2017-04-05 08:11:14 -070029 union {
30 /** interface to which the session is tied - single-hop */
31 u32 sw_if_index;
32 /** the FIB index the peer is in - multi-hop*/
33 u32 fib_index;
34 };
Klement Sekerab16bfe32017-02-28 11:56:48 +010035 /** local address */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020036 ip46_address_t local_addr;
Klement Sekerab16bfe32017-02-28 11:56:48 +010037 /** peer address */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020038 ip46_address_t peer_addr;
Klement Sekera0e3c0de2016-09-29 14:43:44 +020039}) bfd_udp_key_t;
Klement Sekera0e3c0de2016-09-29 14:43:44 +020040
Klement Sekerab16bfe32017-02-28 11:56:48 +010041/** UDP transport specific data embedded in bfd_session's union */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020042typedef struct
43{
Klement Sekerab16bfe32017-02-28 11:56:48 +010044 /** key identifying this session */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020045 bfd_udp_key_t key;
Klement Sekerab16bfe32017-02-28 11:56:48 +010046 /** adjacency index returned from adj lock call */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020047 adj_index_t adj_index;
48} bfd_udp_session_t;
49
Klement Sekerab16bfe32017-02-28 11:56:48 +010050/** bfd udp echo packet trace capture */
Klement Sekeraaeeac3b2017-02-14 07:11:52 +010051typedef struct
52{
53 u32 len;
54 u8 data[400];
55} bfd_udp_echo_input_trace_t;
56
Klement Sekera2bce0332017-02-09 06:03:46 +010057struct bfd_session_s;
58
Klement Sekerab16bfe32017-02-28 11:56:48 +010059/**
60 * @brief add the necessary transport layer by prepending it to existing data
61 *
Klement Sekerae50e8562017-04-04 16:19:48 +020062 *
Klement Sekerab16bfe32017-02-28 11:56:48 +010063 * @param is_echo 1 if this is echo packet, 0 if control frame
64 *
65 * @return 1 on success, 0 on failure
66 */
Klement Sekerae50e8562017-04-04 16:19:48 +020067int bfd_add_udp4_transport (vlib_main_t * vm, u32 bi,
Klement Sekera239790f2017-02-16 10:53:53 +010068 const struct bfd_session_s *bs, int is_echo);
Klement Sekerab16bfe32017-02-28 11:56:48 +010069
70/**
71 * @brief add the necessary transport layer by prepending it to existing data
72 *
73 * @param is_echo 1 if this is echo packet, 0 if control frame
74 *
75 * @return 1 on success, 0 on failure
76 */
Klement Sekerae50e8562017-04-04 16:19:48 +020077int bfd_add_udp6_transport (vlib_main_t * vm, u32 bi,
Klement Sekera239790f2017-02-16 10:53:53 +010078 const struct bfd_session_s *bs, int is_echo);
79
80/**
Klement Sekerae50e8562017-04-04 16:19:48 +020081 * @brief transport packet over udpv4
82 *
Klement Sekerae50e8562017-04-04 16:19:48 +020083 * @return 1 on success, 0 on failure
84 */
Klement Sekera617d4292022-09-20 15:10:10 +020085int bfd_transport_udp4 (vlib_main_t *vm, vlib_node_runtime_t *rt, u32 bi,
Klement Sekeracdaf0d82022-02-14 20:20:22 +000086 const struct bfd_session_s *bs, int is_echo);
Klement Sekerae50e8562017-04-04 16:19:48 +020087
88/**
89 * @brief transport packet over udpv6
90 *
Klement Sekerae50e8562017-04-04 16:19:48 +020091 * @return 1 on success, 0 on failure
92 */
Klement Sekera617d4292022-09-20 15:10:10 +020093int bfd_transport_udp6 (vlib_main_t *vm, vlib_node_runtime_t *rt, u32 bi,
Klement Sekeracdaf0d82022-02-14 20:20:22 +000094 const struct bfd_session_s *bs, int is_echo);
Klement Sekerae50e8562017-04-04 16:19:48 +020095
96/**
Klement Sekera239790f2017-02-16 10:53:53 +010097 * @brief check if the bfd udp layer is echo-capable at this time
98 *
99 * @return 1 if available, 0 otherwise
100 */
101int bfd_udp_is_echo_available (bfd_transport_e transport);
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200102
Klement Sekerab16bfe32017-02-28 11:56:48 +0100103/**
104 * @brief get echo source information - used by CLI
105 */
106void bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index,
107 int *have_usable_ip4, ip4_address_t * ip4,
108 int *have_usable_ip6, ip6_address_t * ip6);
Klement Sekera73884482017-02-23 09:26:30 +0100109
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200110#endif /* __included_bfd_udp_h__ */
111
112/*
113 * fd.io coding-style-patch-verification: ON
114 *
115 * Local Variables:
116 * eval: (c-set-style "gnu")
117 * End:
118 */