2 * Copyright (c) 2011-2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_bfd_protocol_h__
16 #define __included_bfd_protocol_h__
19 * @brief BFD protocol declarations
22 #include <vppinfra/types.h>
23 #include <vppinfra/clib.h>
26 typedef CLIB_PACKED (struct {
28 An optional Authentication Section MAY be present:
31 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
32 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 | Auth Type | Auth Len | Authentication Data... |
34 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 typedef CLIB_PACKED (struct {
45 The Mandatory Section of a BFD Control packet has the following
49 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
52 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 | Your Discriminator |
56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 | Desired Min TX Interval |
58 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 | Required Min RX Interval |
60 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 | Required Min Echo RX Interval |
62 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 typedef CLIB_PACKED (struct {
83 }) bfd_pkt_with_auth_t;
86 u8 bfd_pkt_get_version (const bfd_pkt_t * pkt);
87 void bfd_pkt_set_version (bfd_pkt_t * pkt, int version);
88 u8 bfd_pkt_get_diag_code (const bfd_pkt_t * pkt);
89 void bfd_pkt_set_diag_code (bfd_pkt_t * pkt, int value);
90 u8 bfd_pkt_get_state (const bfd_pkt_t * pkt);
91 void bfd_pkt_set_state (bfd_pkt_t * pkt, int value);
92 u8 bfd_pkt_get_poll (const bfd_pkt_t * pkt);
93 void bfd_pkt_set_final (bfd_pkt_t * pkt);
94 u8 bfd_pkt_get_final (const bfd_pkt_t * pkt);
95 void bfd_pkt_set_poll (bfd_pkt_t * pkt);
96 u8 bfd_pkt_get_control_plane_independent (const bfd_pkt_t * pkt);
97 void bfd_pkt_set_control_plane_independent (bfd_pkt_t * pkt);
98 u8 bfd_pkt_get_auth_present (const bfd_pkt_t * pkt);
99 void bfd_pkt_set_auth_present (bfd_pkt_t * pkt);
100 u8 bfd_pkt_get_demand (const bfd_pkt_t * pkt);
101 void bfd_pkt_set_demand (bfd_pkt_t * pkt);
102 u8 bfd_pkt_get_multipoint (const bfd_pkt_t * pkt);
103 void bfd_pkt_set_multipoint (bfd_pkt_t * pkt);
105 /* BFD diagnostic codes */
106 #define foreach_bfd_diag_code(F) \
107 F (0, no_diag, "No Diagnostic") \
108 F (1, det_time_exp, "Control Detection Time Expired") \
109 F (2, echo_failed, "Echo Function Failed") \
110 F (3, neighbor_sig_down, "Neighbor Signaled Session Down") \
111 F (4, fwd_plain_reset, "Forwarding Plane Reset") \
112 F (5, path_down, "Path Down") \
113 F (6, concat_path_down, "Concatenated Path Down") \
114 F (7, admin_down, "Administratively Down") \
115 F (8, reverse_concat_path_down, "Reverse Concatenated Path Down")
117 #define BFD_DIAG_CODE_NAME(t) BFD_DIAG_CODE_##t
121 #define F(n, t, s) BFD_DIAG_CODE_NAME (t) = n,
122 foreach_bfd_diag_code (F)
126 const char *bfd_diag_code_string (bfd_diag_code_e diag);
128 /* BFD state values */
129 #define foreach_bfd_state(F) \
130 F (0, admin_down, "AdminDown") \
131 F (1, down, "Down") \
132 F (2, init, "Init") \
135 #define BFD_STATE_NAME(t) BFD_STATE_##t
139 #define F(n, t, s) BFD_STATE_NAME (t) = n,
140 foreach_bfd_state (F)
144 const char *bfd_state_string (bfd_state_e state);
146 #endif /* __included_bfd_protocol_h__ */
149 * fd.io coding-style-patch-verification: ON
152 * eval: (c-set-style "gnu")