blob: a4adbadf86124c38c693e003214a29426eecc705 [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 Sekera0e3c0de2016-09-29 14:43:44 +020027/* *INDENT-OFF* */
Klement Sekerab16bfe32017-02-28 11:56:48 +010028/** identifier of BFD session based on UDP transport only */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020029typedef CLIB_PACKED (struct {
Klement Sekerab16bfe32017-02-28 11:56:48 +010030 /** interface to which the session is tied */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020031 u32 sw_if_index;
Klement Sekerab16bfe32017-02-28 11:56:48 +010032 /** local address */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020033 ip46_address_t local_addr;
Klement Sekerab16bfe32017-02-28 11:56:48 +010034 /** peer address */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020035 ip46_address_t peer_addr;
Klement Sekera0e3c0de2016-09-29 14:43:44 +020036}) bfd_udp_key_t;
37/* *INDENT-ON* */
38
Klement Sekerab16bfe32017-02-28 11:56:48 +010039/** UDP transport specific data embedded in bfd_session's union */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020040typedef struct
41{
Klement Sekerab16bfe32017-02-28 11:56:48 +010042 /** key identifying this session */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020043 bfd_udp_key_t key;
Klement Sekerab16bfe32017-02-28 11:56:48 +010044 /** adjacency index returned from adj lock call */
Klement Sekera0e3c0de2016-09-29 14:43:44 +020045 adj_index_t adj_index;
46} bfd_udp_session_t;
47
Klement Sekerab16bfe32017-02-28 11:56:48 +010048/** bfd udp echo packet trace capture */
Klement Sekeraaeeac3b2017-02-14 07:11:52 +010049typedef struct
50{
51 u32 len;
52 u8 data[400];
53} bfd_udp_echo_input_trace_t;
54
Klement Sekera2bce0332017-02-09 06:03:46 +010055struct bfd_session_s;
56
Klement Sekerab16bfe32017-02-28 11:56:48 +010057/**
58 * @brief add the necessary transport layer by prepending it to existing data
59 *
Klement Sekerae50e8562017-04-04 16:19:48 +020060 *
Klement Sekerab16bfe32017-02-28 11:56:48 +010061 * @param is_echo 1 if this is echo packet, 0 if control frame
62 *
63 * @return 1 on success, 0 on failure
64 */
Klement Sekerae50e8562017-04-04 16:19:48 +020065int bfd_add_udp4_transport (vlib_main_t * vm, u32 bi,
Klement Sekera239790f2017-02-16 10:53:53 +010066 const struct bfd_session_s *bs, int is_echo);
Klement Sekerab16bfe32017-02-28 11:56:48 +010067
68/**
69 * @brief add the necessary transport layer by prepending it to existing data
70 *
71 * @param is_echo 1 if this is echo packet, 0 if control frame
72 *
73 * @return 1 on success, 0 on failure
74 */
Klement Sekerae50e8562017-04-04 16:19:48 +020075int bfd_add_udp6_transport (vlib_main_t * vm, u32 bi,
Klement Sekera239790f2017-02-16 10:53:53 +010076 const struct bfd_session_s *bs, int is_echo);
77
78/**
Klement Sekerae50e8562017-04-04 16:19:48 +020079 * @brief transport packet over udpv4
80 *
81 * @param is_echo 1 if this is echo packet, 0 if control frame
82 *
83 * @return 1 on success, 0 on failure
84 */
85int bfd_transport_udp4 (vlib_main_t * vm, u32 bi,
86 const struct bfd_session_s *bs);
87
88/**
89 * @brief transport packet over udpv6
90 *
91 * @param is_echo 1 if this is echo packet, 0 if control frame
92 *
93 * @return 1 on success, 0 on failure
94 */
95int bfd_transport_udp6 (vlib_main_t * vm, u32 bi,
96 const struct bfd_session_s *bs);
97
98/**
Klement Sekera239790f2017-02-16 10:53:53 +010099 * @brief check if the bfd udp layer is echo-capable at this time
100 *
101 * @return 1 if available, 0 otherwise
102 */
103int bfd_udp_is_echo_available (bfd_transport_e transport);
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200104
Klement Sekerab16bfe32017-02-28 11:56:48 +0100105/**
106 * @brief get echo source information - used by CLI
107 */
108void bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index,
109 int *have_usable_ip4, ip4_address_t * ip4,
110 int *have_usable_ip6, ip6_address_t * ip6);
Klement Sekera73884482017-02-23 09:26:30 +0100111
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200112#endif /* __included_bfd_udp_h__ */
113
114/*
115 * fd.io coding-style-patch-verification: ON
116 *
117 * Local Variables:
118 * eval: (c-set-style "gnu")
119 * End:
120 */