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 #include <vnet/bfd/bfd_protocol.h>
18 bfd_pkt_get_version (const bfd_pkt_t * pkt)
20 return pkt->head.vers_diag >> 5;
24 bfd_pkt_set_version (bfd_pkt_t * pkt, int version)
27 (version << 5) | (pkt->head.vers_diag & ((1 << 5) - 1));
31 bfd_pkt_get_diag_code (const bfd_pkt_t * pkt)
33 return pkt->head.vers_diag & ((1 << 5) - 1);
37 bfd_pkt_set_diag_code (bfd_pkt_t * pkt, int value)
40 (pkt->head.vers_diag & ~((1 << 5) - 1)) | (value & ((1 << 5) - 1));
44 bfd_pkt_get_state (const bfd_pkt_t * pkt)
46 return pkt->head.sta_flags >> 6;
50 bfd_pkt_set_state (bfd_pkt_t * pkt, int value)
52 pkt->head.sta_flags = (value << 6) | (pkt->head.sta_flags & ((1 << 6) - 1));
56 bfd_pkt_get_poll (const bfd_pkt_t * pkt)
58 return (pkt->head.sta_flags >> 5) & 1;
62 bfd_pkt_set_poll (bfd_pkt_t * pkt)
64 pkt->head.sta_flags |= 1 << 5;
68 bfd_pkt_get_final (const bfd_pkt_t * pkt)
70 return (pkt->head.sta_flags >> 4) & 1;
74 bfd_pkt_set_final (bfd_pkt_t * pkt)
76 pkt->head.sta_flags |= 1 << 4;
80 bfd_pkt_get_control_plane_independent (const bfd_pkt_t * pkt)
82 return (pkt->head.sta_flags >> 3) & 1;
87 bfd_pkt_set_control_plane_independent (bfd_pkt_t * pkt)
89 pkt->head.sta_flags |= 1 << 3;
94 bfd_pkt_get_auth_present (const bfd_pkt_t * pkt)
96 return (pkt->head.sta_flags >> 2) & 1;
100 bfd_pkt_set_auth_present (bfd_pkt_t * pkt)
102 pkt->head.sta_flags |= 1 << 2;
106 bfd_pkt_get_demand (const bfd_pkt_t * pkt)
108 return (pkt->head.sta_flags >> 1) & 1;
113 bfd_pkt_set_demand (bfd_pkt_t * pkt)
115 pkt->head.sta_flags |= 1 << 1;
120 bfd_pkt_get_multipoint (const bfd_pkt_t * pkt)
122 return (pkt->head.sta_flags >> 0) & 1;
127 bfd_pkt_set_multipoint (bfd_pkt_t * pkt)
129 pkt->head.sta_flags |= 1 << 0;
134 bfd_max_len_for_auth_type (bfd_auth_type_e auth_type)
136 #define F(t, l, n, s) \
137 if (auth_type == t) \
141 foreach_bfd_auth_type (F);
147 bfd_auth_type_str (bfd_auth_type_e auth_type)
149 #define F(t, l, n, s) \
150 if (auth_type == t) \
154 foreach_bfd_auth_type (F);
160 bfd_diag_code_string (bfd_diag_code_e diag)
163 case BFD_DIAG_CODE_NAME (t): \
167 foreach_bfd_diag_code (F)}
173 bfd_state_string (bfd_state_e state)
176 case BFD_STATE_NAME (t): \
180 foreach_bfd_state (F)}
186 * fd.io coding-style-patch-verification: ON
189 * eval: (c-set-style "gnu")