]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: ISC |
8429abe0 RW |
2 | /* $OpenBSD$ */ |
3 | ||
4 | /* | |
5 | * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> | |
6 | * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> | |
7 | * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> | |
8429abe0 RW |
8 | */ |
9 | ||
10 | /* LDP protocol definitions */ | |
11 | ||
12 | #ifndef _LDP_H_ | |
13 | #define _LDP_H_ | |
14 | ||
8429abe0 RW |
15 | /* misc */ |
16 | #define LDP_VERSION 1 | |
17 | #define LDP_PORT 646 | |
18 | #define LDP_MAX_LEN 4096 | |
19 | ||
20 | /* All Routers on this Subnet group multicast addresses */ | |
21 | #define AllRouters_v4 "224.0.0.2" | |
22 | #define AllRouters_v6 "ff02::2" | |
23 | ||
24 | #define LINK_DFLT_HOLDTIME 15 | |
25 | #define TARGETED_DFLT_HOLDTIME 45 | |
26 | #define MIN_HOLDTIME 3 | |
27 | #define MAX_HOLDTIME 0xffff | |
28 | #define INFINITE_HOLDTIME 0xffff | |
29 | ||
30 | #define DEFAULT_KEEPALIVE 180 | |
31 | #define MIN_KEEPALIVE 3 | |
32 | #define MAX_KEEPALIVE 0xffff | |
33 | #define KEEPALIVE_PER_PERIOD 3 | |
34 | #define INIT_FSM_TIMEOUT 15 | |
35 | ||
36 | #define DEFAULT_HELLO_INTERVAL 5 | |
37 | #define MIN_HELLO_INTERVAL 1 | |
38 | #define MAX_HELLO_INTERVAL 0xffff | |
39 | ||
40 | #define INIT_DELAY_TMR 15 | |
41 | #define MAX_DELAY_TMR 120 | |
42 | ||
e1894ff7 KS |
43 | #define DFLT_WAIT_FOR_SYNC 10 |
44 | ||
8429abe0 RW |
45 | #define MIN_PWID_ID 1 |
46 | #define MAX_PWID_ID 0xffffffff | |
47 | ||
48 | #define DEFAULT_L2VPN_MTU 1500 | |
49 | #define MIN_L2VPN_MTU 512 | |
50 | #define MAX_L2VPN_MTU 0xffff | |
51 | ||
52 | /* LDP message types */ | |
53 | #define MSG_TYPE_NOTIFICATION 0x0001 | |
54 | #define MSG_TYPE_HELLO 0x0100 | |
55 | #define MSG_TYPE_INIT 0x0200 | |
56 | #define MSG_TYPE_KEEPALIVE 0x0201 | |
8819fc38 | 57 | #define MSG_TYPE_CAPABILITY 0x0202 /* RFC 5561 */ |
8429abe0 RW |
58 | #define MSG_TYPE_ADDR 0x0300 |
59 | #define MSG_TYPE_ADDRWITHDRAW 0x0301 | |
60 | #define MSG_TYPE_LABELMAPPING 0x0400 | |
61 | #define MSG_TYPE_LABELREQUEST 0x0401 | |
62 | #define MSG_TYPE_LABELWITHDRAW 0x0402 | |
63 | #define MSG_TYPE_LABELRELEASE 0x0403 | |
64 | #define MSG_TYPE_LABELABORTREQ 0x0404 | |
65 | ||
66 | /* LDP TLV types */ | |
67 | #define TLV_TYPE_FEC 0x0100 | |
68 | #define TLV_TYPE_ADDRLIST 0x0101 | |
69 | #define TLV_TYPE_HOPCOUNT 0x0103 | |
70 | #define TLV_TYPE_PATHVECTOR 0x0104 | |
71 | #define TLV_TYPE_GENERICLABEL 0x0200 | |
72 | #define TLV_TYPE_ATMLABEL 0x0201 | |
73 | #define TLV_TYPE_FRLABEL 0x0202 | |
74 | #define TLV_TYPE_STATUS 0x0300 | |
75 | #define TLV_TYPE_EXTSTATUS 0x0301 | |
76 | #define TLV_TYPE_RETURNEDPDU 0x0302 | |
77 | #define TLV_TYPE_RETURNEDMSG 0x0303 | |
78 | #define TLV_TYPE_COMMONHELLO 0x0400 | |
79 | #define TLV_TYPE_IPV4TRANSADDR 0x0401 | |
80 | #define TLV_TYPE_CONFIG 0x0402 | |
81 | #define TLV_TYPE_IPV6TRANSADDR 0x0403 | |
82 | #define TLV_TYPE_COMMONSESSION 0x0500 | |
83 | #define TLV_TYPE_ATMSESSIONPAR 0x0501 | |
84 | #define TLV_TYPE_FRSESSION 0x0502 | |
85 | #define TLV_TYPE_LABELREQUEST 0x0600 | |
86 | /* RFC 4447 */ | |
26519d8c | 87 | #define TLV_TYPE_MAC_LIST 0x8404 |
357db527 | 88 | #define TLV_TYPE_PW_STATUS 0x896A |
8429abe0 RW |
89 | #define TLV_TYPE_PW_IF_PARAM 0x096B |
90 | #define TLV_TYPE_PW_GROUP_ID 0x096C | |
8819fc38 RW |
91 | /* RFC 5561 */ |
92 | #define TLV_TYPE_RETURNED_TLVS 0x8304 | |
93 | #define TLV_TYPE_DYNAMIC_CAP 0x8506 | |
d4afb819 RW |
94 | /* RFC 5918 */ |
95 | #define TLV_TYPE_TWCARD_CAP 0x850B | |
257799cd RW |
96 | /* RFC 5919 */ |
97 | #define TLV_TYPE_UNOTIF_CAP 0x8603 | |
8429abe0 RW |
98 | /* RFC 7552 */ |
99 | #define TLV_TYPE_DUALSTACK 0x8701 | |
100 | ||
101 | /* LDP header */ | |
102 | struct ldp_hdr { | |
103 | uint16_t version; | |
104 | uint16_t length; | |
105 | uint32_t lsr_id; | |
106 | uint16_t lspace_id; | |
eac6e3f0 | 107 | } __attribute__ ((packed)); |
8429abe0 RW |
108 | |
109 | #define LDP_HDR_SIZE 10 /* actual size of the LDP header */ | |
110 | #define LDP_HDR_PDU_LEN 6 /* minimum "PDU Length" */ | |
111 | #define LDP_HDR_DEAD_LEN 4 | |
112 | ||
113 | /* TLV record */ | |
114 | struct tlv { | |
115 | uint16_t type; | |
116 | uint16_t length; | |
117 | }; | |
118 | #define TLV_HDR_SIZE 4 | |
119 | ||
120 | struct ldp_msg { | |
121 | uint16_t type; | |
122 | uint16_t length; | |
123 | uint32_t id; | |
124 | /* Mandatory Parameters */ | |
125 | /* Optional Parameters */ | |
eac6e3f0 | 126 | } __attribute__ ((packed)); |
8429abe0 RW |
127 | |
128 | #define LDP_MSG_SIZE 8 /* minimum size of LDP message */ | |
129 | #define LDP_MSG_LEN 4 /* minimum "Message Length" */ | |
130 | #define LDP_MSG_DEAD_LEN 4 | |
131 | ||
132 | #define UNKNOWN_FLAG 0x8000 | |
133 | #define FORWARD_FLAG 0xc000 | |
134 | ||
135 | struct hello_prms_tlv { | |
136 | uint16_t type; | |
137 | uint16_t length; | |
138 | uint16_t holdtime; | |
139 | uint16_t flags; | |
140 | }; | |
141 | #define F_HELLO_TARGETED 0x8000 | |
142 | #define F_HELLO_REQ_TARG 0x4000 | |
143 | #define F_HELLO_GTSM 0x2000 | |
144 | ||
145 | struct hello_prms_opt4_tlv { | |
146 | uint16_t type; | |
147 | uint16_t length; | |
148 | uint32_t value; | |
149 | }; | |
150 | ||
151 | struct hello_prms_opt16_tlv { | |
152 | uint16_t type; | |
153 | uint16_t length; | |
154 | uint8_t value[16]; | |
155 | }; | |
156 | ||
157 | #define DUAL_STACK_LDPOV4 4 | |
158 | #define DUAL_STACK_LDPOV6 6 | |
159 | ||
160 | #define F_HELLO_TLV_RCVD_ADDR 0x01 | |
161 | #define F_HELLO_TLV_RCVD_CONF 0x02 | |
162 | #define F_HELLO_TLV_RCVD_DS 0x04 | |
163 | ||
164 | #define S_SUCCESS 0x00000000 | |
165 | #define S_BAD_LDP_ID 0x80000001 | |
166 | #define S_BAD_PROTO_VER 0x80000002 | |
167 | #define S_BAD_PDU_LEN 0x80000003 | |
168 | #define S_UNKNOWN_MSG 0x00000004 | |
169 | #define S_BAD_MSG_LEN 0x80000005 | |
170 | #define S_UNKNOWN_TLV 0x00000006 | |
171 | #define S_BAD_TLV_LEN 0x80000007 | |
172 | #define S_BAD_TLV_VAL 0x80000008 | |
173 | #define S_HOLDTIME_EXP 0x80000009 | |
174 | #define S_SHUTDOWN 0x8000000A | |
175 | #define S_LOOP_DETECTED 0x0000000B | |
176 | #define S_UNKNOWN_FEC 0x0000000C | |
177 | #define S_NO_ROUTE 0x0000000D | |
178 | #define S_NO_LABEL_RES 0x0000000E | |
179 | #define S_AVAILABLE 0x0000000F | |
180 | #define S_NO_HELLO 0x80000010 | |
181 | #define S_PARM_ADV_MODE 0x80000011 | |
182 | #define S_MAX_PDU_LEN 0x80000012 | |
183 | #define S_PARM_L_RANGE 0x80000013 | |
184 | #define S_KEEPALIVE_TMR 0x80000014 | |
185 | #define S_LAB_REQ_ABRT 0x00000015 | |
186 | #define S_MISS_MSG 0x00000016 | |
187 | #define S_UNSUP_ADDR 0x00000017 | |
188 | #define S_KEEPALIVE_BAD 0x80000018 | |
189 | #define S_INTERN_ERR 0x80000019 | |
190 | /* RFC 4447 */ | |
191 | #define S_ILLEGAL_CBIT 0x00000024 | |
192 | #define S_WRONG_CBIT 0x00000025 | |
193 | #define S_INCPT_BITRATE 0x00000026 | |
194 | #define S_CEP_MISCONF 0x00000027 | |
195 | #define S_PW_STATUS 0x00000028 | |
196 | #define S_UNASSIGN_TAI 0x00000029 | |
197 | #define S_MISCONF_ERR 0x0000002A | |
198 | #define S_WITHDRAW_MTHD 0x0000002B | |
8819fc38 RW |
199 | /* RFC 5561 */ |
200 | #define S_UNSSUPORTDCAP 0x0000002E | |
257799cd RW |
201 | /* RFC 5919 */ |
202 | #define S_ENDOFLIB 0x0000002F | |
8429abe0 RW |
203 | /* RFC 7552 */ |
204 | #define S_TRANS_MISMTCH 0x80000032 | |
205 | #define S_DS_NONCMPLNCE 0x80000033 | |
206 | ||
207 | struct sess_prms_tlv { | |
208 | uint16_t type; | |
209 | uint16_t length; | |
210 | uint16_t proto_version; | |
211 | uint16_t keepalive_time; | |
212 | uint8_t reserved; | |
213 | uint8_t pvlim; | |
214 | uint16_t max_pdu_len; | |
215 | uint32_t lsr_id; | |
216 | uint16_t lspace_id; | |
eac6e3f0 | 217 | } __attribute__ ((packed)); |
8429abe0 RW |
218 | |
219 | #define SESS_PRMS_SIZE 18 | |
220 | #define SESS_PRMS_LEN 14 | |
221 | ||
222 | struct status_tlv { | |
223 | uint16_t type; | |
224 | uint16_t length; | |
225 | uint32_t status_code; | |
226 | uint32_t msg_id; | |
227 | uint16_t msg_type; | |
eac6e3f0 | 228 | } __attribute__ ((packed)); |
8429abe0 RW |
229 | |
230 | #define STATUS_SIZE 14 | |
231 | #define STATUS_TLV_LEN 10 | |
232 | #define STATUS_FATAL 0x80000000 | |
233 | ||
8819fc38 RW |
234 | struct capability_tlv { |
235 | uint16_t type; | |
236 | uint16_t length; | |
237 | uint8_t reserved; | |
238 | }; | |
239 | #define STATE_BIT 0x80 | |
240 | ||
241 | #define F_CAP_TLV_RCVD_DYNAMIC 0x01 | |
d4afb819 | 242 | #define F_CAP_TLV_RCVD_TWCARD 0x02 |
257799cd | 243 | #define F_CAP_TLV_RCVD_UNOTIF 0x04 |
8819fc38 RW |
244 | |
245 | #define CAP_TLV_DYNAMIC_SIZE 5 | |
246 | #define CAP_TLV_DYNAMIC_LEN 1 | |
247 | ||
d4afb819 RW |
248 | #define CAP_TLV_TWCARD_SIZE 5 |
249 | #define CAP_TLV_TWCARD_LEN 1 | |
250 | ||
257799cd RW |
251 | #define CAP_TLV_UNOTIF_SIZE 5 |
252 | #define CAP_TLV_UNOTIF_LEN 1 | |
253 | ||
8429abe0 RW |
254 | #define AF_IPV4 0x1 |
255 | #define AF_IPV6 0x2 | |
256 | ||
257 | struct address_list_tlv { | |
258 | uint16_t type; | |
259 | uint16_t length; | |
260 | uint16_t family; | |
261 | /* address entries */ | |
eac6e3f0 | 262 | } __attribute__ ((packed)); |
8429abe0 RW |
263 | |
264 | #define ADDR_LIST_SIZE 6 | |
265 | ||
266 | #define FEC_ELM_WCARD_LEN 1 | |
267 | #define FEC_ELM_PREFIX_MIN_LEN 4 | |
268 | #define FEC_PWID_ELM_MIN_LEN 8 | |
05aac414 | 269 | #define FEC_PWID_SIZE 4 |
d4afb819 | 270 | #define FEC_ELM_TWCARD_MIN_LEN 3 |
8429abe0 RW |
271 | |
272 | #define MAP_TYPE_WILDCARD 0x01 | |
273 | #define MAP_TYPE_PREFIX 0x02 | |
d4afb819 | 274 | #define MAP_TYPE_TYPED_WCARD 0x05 |
8429abe0 RW |
275 | #define MAP_TYPE_PWID 0x80 |
276 | #define MAP_TYPE_GENPWID 0x81 | |
277 | ||
278 | #define CONTROL_WORD_FLAG 0x8000 | |
8429abe0 RW |
279 | #define DEFAULT_PW_TYPE PW_TYPE_ETHERNET |
280 | ||
aba50a83 RW |
281 | #define PW_TWCARD_RESERVED_BIT 0x8000 |
282 | ||
8429abe0 RW |
283 | /* RFC 4447 Sub-TLV record */ |
284 | struct subtlv { | |
285 | uint8_t type; | |
286 | uint8_t length; | |
287 | }; | |
288 | #define SUBTLV_HDR_SIZE 2 | |
289 | ||
290 | #define SUBTLV_IFMTU 0x01 | |
291 | #define SUBTLV_VLANID 0x06 | |
292 | ||
293 | #define FEC_SUBTLV_IFMTU_SIZE 4 | |
294 | #define FEC_SUBTLV_VLANID_SIZE 4 | |
295 | ||
296 | struct label_tlv { | |
297 | uint16_t type; | |
298 | uint16_t length; | |
299 | uint32_t label; | |
300 | }; | |
301 | #define LABEL_TLV_SIZE 8 | |
302 | #define LABEL_TLV_LEN 4 | |
303 | ||
304 | struct reqid_tlv { | |
305 | uint16_t type; | |
306 | uint16_t length; | |
307 | uint32_t reqid; | |
308 | }; | |
309 | #define REQID_TLV_SIZE 8 | |
310 | #define REQID_TLV_LEN 4 | |
311 | ||
312 | struct pw_status_tlv { | |
313 | uint16_t type; | |
314 | uint16_t length; | |
315 | uint32_t value; | |
316 | }; | |
317 | #define PW_STATUS_TLV_SIZE 8 | |
318 | #define PW_STATUS_TLV_LEN 4 | |
319 | ||
8429abe0 RW |
320 | #define NO_LABEL UINT32_MAX |
321 | ||
322 | #endif /* !_LDP_H_ */ |