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