]>
Commit | Line | Data |
---|---|---|
e9e2c950 RZ |
1 | /********************************************************************* |
2 | * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF") | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the Free | |
6 | * Software Foundation; either version 2 of the License, or (at your option) | |
7 | * any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; see the file COPYING; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | * | |
18 | * bfdctl.h: all BFDd control socket protocol definitions. | |
19 | * | |
20 | * Authors | |
21 | * ------- | |
22 | * Rafael Zalamena <rzalamena@opensourcerouting.org> | |
23 | */ | |
24 | ||
25 | #ifndef _BFDCTRL_H_ | |
26 | #define _BFDCTRL_H_ | |
27 | ||
28 | #include <netinet/in.h> | |
29 | ||
30 | #include <stdbool.h> | |
31 | #include <stdint.h> | |
32 | ||
33 | /* | |
34 | * Auxiliary definitions | |
35 | */ | |
36 | struct sockaddr_any { | |
37 | union { | |
38 | struct sockaddr_in sa_sin; | |
39 | struct sockaddr_in6 sa_sin6; | |
40 | }; | |
41 | }; | |
42 | ||
43 | #ifndef MAXNAMELEN | |
44 | #define MAXNAMELEN 32 | |
45 | #endif | |
46 | ||
47 | #define BPC_DEF_DETECTMULTIPLIER 3 | |
48 | #define BPC_DEF_RECEIVEINTERVAL 300 /* milliseconds */ | |
49 | #define BPC_DEF_TRANSMITINTERVAL 300 /* milliseconds */ | |
4df3e31c IR |
50 | #define BPC_DEF_ECHORECEIVEINTERVAL 50 /* milliseconds */ |
51 | #define BPC_DEF_ECHOTRANSMITINTERVAL 50 /* milliseconds */ | |
e9e2c950 RZ |
52 | |
53 | /* Peer status */ | |
54 | enum bfd_peer_status { | |
55 | BPS_SHUTDOWN = 0, /* == PTM_BFD_ADM_DOWN, "adm-down" */ | |
56 | BPS_DOWN = 1, /* == PTM_BFD_DOWN, "down" */ | |
57 | BPS_INIT = 2, /* == PTM_BFD_INIT, "init" */ | |
58 | BPS_UP = 3, /* == PTM_BFD_UP, "up" */ | |
59 | }; | |
60 | ||
61 | struct bfd_peer_cfg { | |
62 | bool bpc_mhop; | |
63 | bool bpc_ipv4; | |
64 | struct sockaddr_any bpc_peer; | |
65 | struct sockaddr_any bpc_local; | |
66 | ||
67 | bool bpc_has_label; | |
68 | char bpc_label[MAXNAMELEN]; | |
69 | ||
e9e2c950 RZ |
70 | bool bpc_has_localif; |
71 | char bpc_localif[MAXNAMELEN + 1]; | |
72 | ||
73 | bool bpc_has_vrfname; | |
74 | char bpc_vrfname[MAXNAMELEN + 1]; | |
75 | ||
76 | bool bpc_has_detectmultiplier; | |
77 | uint8_t bpc_detectmultiplier; | |
78 | ||
79 | bool bpc_has_recvinterval; | |
80 | uint64_t bpc_recvinterval; | |
81 | ||
82 | bool bpc_has_txinterval; | |
83 | uint64_t bpc_txinterval; | |
84 | ||
4df3e31c IR |
85 | bool bpc_has_echorecvinterval; |
86 | uint64_t bpc_echorecvinterval; | |
87 | ||
88 | bool bpc_has_echotxinterval; | |
89 | uint64_t bpc_echotxinterval; | |
e9e2c950 | 90 | |
262e1d25 RZ |
91 | bool bpc_has_minimum_ttl; |
92 | uint8_t bpc_minimum_ttl; | |
93 | ||
e9e2c950 RZ |
94 | bool bpc_echo; |
95 | bool bpc_createonly; | |
96 | bool bpc_shutdown; | |
97 | ||
9beff0bd | 98 | bool bpc_cbit; |
1a2e2fff | 99 | bool bpc_passive; |
9beff0bd | 100 | |
18322efd RZ |
101 | bool bpc_has_profile; |
102 | char bpc_profile[64]; | |
103 | ||
e9e2c950 RZ |
104 | /* Status information */ |
105 | enum bfd_peer_status bpc_bps; | |
106 | uint32_t bpc_id; | |
107 | uint32_t bpc_remoteid; | |
108 | uint8_t bpc_diag; | |
109 | uint8_t bpc_remotediag; | |
110 | uint8_t bpc_remote_detectmultiplier; | |
111 | uint64_t bpc_remote_recvinterval; | |
112 | uint64_t bpc_remote_txinterval; | |
113 | uint64_t bpc_remote_echointerval; | |
114 | uint64_t bpc_lastevent; | |
115 | }; | |
116 | ||
117 | ||
118 | /* | |
119 | * Protocol definitions | |
120 | */ | |
121 | enum bc_msg_version { | |
122 | BMV_VERSION_1 = 1, | |
123 | }; | |
124 | ||
125 | enum bc_msg_type { | |
126 | BMT_RESPONSE = 1, | |
127 | BMT_REQUEST_ADD = 2, | |
128 | BMT_REQUEST_DEL = 3, | |
129 | BMT_NOTIFY = 4, | |
130 | BMT_NOTIFY_ADD = 5, | |
131 | BMT_NOTIFY_DEL = 6, | |
132 | }; | |
133 | ||
134 | /* Notify flags to use with bcm_notify. */ | |
135 | #define BCM_NOTIFY_ALL ((uint64_t)-1) | |
136 | #define BCM_NOTIFY_PEER_STATE (1ULL << 0) | |
137 | #define BCM_NOTIFY_CONFIG (1ULL << 1) | |
138 | #define BCM_NOTIFY_NONE 0 | |
139 | ||
140 | /* Response 'status' definitions. */ | |
141 | #define BCM_RESPONSE_OK "ok" | |
142 | #define BCM_RESPONSE_ERROR "error" | |
143 | ||
144 | /* Notify operation. */ | |
145 | #define BCM_NOTIFY_PEER_STATUS "status" | |
146 | #define BCM_NOTIFY_CONFIG_ADD "add" | |
147 | #define BCM_NOTIFY_CONFIG_DELETE "delete" | |
148 | #define BCM_NOTIFY_CONFIG_UPDATE "update" | |
149 | ||
150 | /* Notification special ID. */ | |
151 | #define BCM_NOTIFY_ID 0 | |
152 | ||
153 | struct bfd_control_msg { | |
154 | /* Total length without the header. */ | |
155 | uint32_t bcm_length; | |
156 | /* | |
157 | * Message request/response id. | |
158 | * All requests will have a correspondent response with the | |
159 | * same id. | |
160 | */ | |
161 | uint16_t bcm_id; | |
162 | /* Message type. */ | |
163 | uint8_t bcm_type; | |
164 | /* Message version. */ | |
165 | uint8_t bcm_ver; | |
166 | /* Message payload. */ | |
167 | uint8_t bcm_data[0]; | |
168 | }; | |
169 | ||
170 | #endif |