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.
17 * @brief BFD protocol implementation
19 #include <vnet/bfd/bfd_protocol.h>
22 bfd_pkt_get_version (const bfd_pkt_t * pkt)
24 return pkt->head.vers_diag >> 5;
28 bfd_pkt_set_version (bfd_pkt_t * pkt, int version)
31 (version << 5) | (pkt->head.vers_diag & ((1 << 5) - 1));
35 bfd_pkt_get_diag_code (const bfd_pkt_t * pkt)
37 return pkt->head.vers_diag & ((1 << 5) - 1);
41 bfd_pkt_set_diag_code (bfd_pkt_t * pkt, int value)
44 (pkt->head.vers_diag & ~((1 << 5) - 1)) | (value & ((1 << 5) - 1));
48 bfd_pkt_get_state (const bfd_pkt_t * pkt)
50 return pkt->head.sta_flags >> 6;
54 bfd_pkt_set_state (bfd_pkt_t * pkt, int value)
56 pkt->head.sta_flags = (value << 6) | (pkt->head.sta_flags & ((1 << 6) - 1));
60 bfd_pkt_get_poll (const bfd_pkt_t * pkt)
62 return (pkt->head.sta_flags >> 5) & 1;
66 bfd_pkt_set_poll (bfd_pkt_t * pkt)
68 pkt->head.sta_flags |= 1 << 5;
72 bfd_pkt_get_final (const bfd_pkt_t * pkt)
74 return (pkt->head.sta_flags >> 4) & 1;
78 bfd_pkt_set_final (bfd_pkt_t * pkt)
80 pkt->head.sta_flags |= 1 << 4;
84 bfd_pkt_get_control_plane_independent (const bfd_pkt_t * pkt)
86 return (pkt->head.sta_flags >> 3) & 1;
91 bfd_pkt_set_control_plane_independent (bfd_pkt_t * pkt)
93 pkt->head.sta_flags |= 1 << 3;
98 bfd_pkt_get_auth_present (const bfd_pkt_t * pkt)
100 return (pkt->head.sta_flags >> 2) & 1;
104 bfd_pkt_set_auth_present (bfd_pkt_t * pkt)
106 pkt->head.sta_flags |= 1 << 2;
110 bfd_pkt_get_demand (const bfd_pkt_t * pkt)
112 return (pkt->head.sta_flags >> 1) & 1;
117 bfd_pkt_set_demand (bfd_pkt_t * pkt)
119 pkt->head.sta_flags |= 1 << 1;
124 bfd_pkt_get_multipoint (const bfd_pkt_t * pkt)
126 return (pkt->head.sta_flags >> 0) & 1;
131 bfd_pkt_set_multipoint (bfd_pkt_t * pkt)
133 pkt->head.sta_flags |= 1 << 0;
138 bfd_max_key_len_for_auth_type (bfd_auth_type_e auth_type)
140 #define F(t, l, n, s) \
141 if (auth_type == t) \
145 foreach_bfd_auth_type (F);
151 bfd_auth_type_str (bfd_auth_type_e auth_type)
153 #define F(t, l, n, s) \
154 if (auth_type == t) \
158 foreach_bfd_auth_type (F);
164 bfd_diag_code_string (bfd_diag_code_e diag)
167 case BFD_DIAG_CODE_NAME (t): \
171 foreach_bfd_diag_code (F)}
177 bfd_state_string (bfd_state_e state)
180 case BFD_STATE_NAME (t): \
184 foreach_bfd_state (F)}
190 * fd.io coding-style-patch-verification: ON
193 * eval: (c-set-style "gnu")