Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1 | #include <vnet/bfd/bfd_protocol.h> |
| 2 | |
| 3 | u8 bfd_pkt_get_version (const bfd_pkt_t *pkt) |
| 4 | { |
| 5 | return pkt->head.vers_diag >> 5; |
| 6 | } |
| 7 | |
| 8 | void bfd_pkt_set_version (bfd_pkt_t *pkt, int version) |
| 9 | { |
| 10 | pkt->head.vers_diag = |
| 11 | (version << 5) | (pkt->head.vers_diag & ((1 << 5) - 1)); |
| 12 | } |
| 13 | |
| 14 | u8 bfd_pkt_get_diag_code (const bfd_pkt_t *pkt) |
| 15 | { |
| 16 | return pkt->head.vers_diag & ((1 << 5) - 1); |
| 17 | } |
| 18 | |
| 19 | void bfd_pkt_set_diag_code (bfd_pkt_t *pkt, int value) |
| 20 | { |
| 21 | pkt->head.vers_diag = |
| 22 | (pkt->head.vers_diag & ~((1 << 5) - 1)) | (value & ((1 << 5) - 1)); |
| 23 | } |
| 24 | |
| 25 | u8 bfd_pkt_get_state (const bfd_pkt_t *pkt) |
| 26 | { |
| 27 | return pkt->head.sta_flags >> 6; |
| 28 | } |
| 29 | |
| 30 | void bfd_pkt_set_state (bfd_pkt_t *pkt, int value) |
| 31 | { |
| 32 | pkt->head.sta_flags = (value << 6) | (pkt->head.sta_flags & ((1 << 6) - 1)); |
| 33 | } |
| 34 | |
| 35 | u8 bfd_pkt_get_poll (const bfd_pkt_t *pkt) |
| 36 | { |
| 37 | return (pkt->head.sta_flags >> 5) & 1; |
| 38 | } |
| 39 | |
| 40 | void bfd_pkt_set_final (bfd_pkt_t *pkt) { pkt->head.sta_flags |= 1 << 5; } |
| 41 | |
| 42 | u8 bfd_pkt_get_final (const bfd_pkt_t *pkt) |
| 43 | { |
| 44 | return (pkt->head.sta_flags >> 4) & 1; |
| 45 | } |
| 46 | |
| 47 | void bfd_pkt_set_poll (bfd_pkt_t *pkt); |
| 48 | u8 bfd_pkt_get_control_plane_independent (const bfd_pkt_t *pkt) |
| 49 | { |
| 50 | return (pkt->head.sta_flags >> 3) & 1; |
| 51 | } |
| 52 | |
| 53 | void bfd_pkt_set_control_plane_independent (bfd_pkt_t *pkt); |
| 54 | |
| 55 | u8 bfd_pkt_get_auth_present (const bfd_pkt_t *pkt) |
| 56 | { |
| 57 | return (pkt->head.sta_flags >> 2) & 1; |
| 58 | } |
| 59 | |
| 60 | void bfd_pkt_set_auth_present (bfd_pkt_t *pkt); |
| 61 | |
| 62 | u8 bfd_pkt_get_demand (const bfd_pkt_t *pkt) |
| 63 | { |
| 64 | return (pkt->head.sta_flags >> 1) & 1; |
| 65 | } |
| 66 | |
| 67 | void bfd_pkt_set_demand (bfd_pkt_t *pkt) { pkt->head.sta_flags |= 1 << 1; } |
| 68 | |
| 69 | u8 bfd_pkt_get_multipoint (const bfd_pkt_t *pkt) |
| 70 | { |
| 71 | return pkt->head.sta_flags & 1; |
| 72 | } |
| 73 | |
| 74 | void bfd_pkt_set_multipoint (bfd_pkt_t *pkt); |