]>
Commit | Line | Data |
---|---|---|
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 Esben Norby <norby@openbsd.org> | |
7 | * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> | |
8 | * | |
9 | * Permission to use, copy, modify, and distribute this software for any | |
10 | * purpose with or without fee is hereby granted, provided that the above | |
11 | * copyright notice and this permission notice appear in all copies. | |
12 | * | |
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
20 | */ | |
21 | ||
22 | #ifndef _LDPD_H_ | |
23 | #define _LDPD_H_ | |
24 | ||
eac6e3f0 RW |
25 | #include "openbsd-queue.h" |
26 | #include "openbsd-tree.h" | |
27 | #include "imsg.h" | |
28 | #include "thread.h" | |
4af8997d | 29 | #include "qobj.h" |
26519d8c | 30 | #include "prefix.h" |
45a8eba9 | 31 | #include "filter.h" |
8429abe0 RW |
32 | |
33 | #include "ldp.h" | |
34 | ||
35 | #define CONF_FILE "/etc/ldpd.conf" | |
8429abe0 RW |
36 | #define LDPD_USER "_ldpd" |
37 | ||
28e8294c RW |
38 | #define LDPD_FD_ASYNC 3 |
39 | #define LDPD_FD_SYNC 4 | |
40 | ||
8429abe0 RW |
41 | #define LDPD_OPT_VERBOSE 0x00000001 |
42 | #define LDPD_OPT_VERBOSE2 0x00000002 | |
43 | #define LDPD_OPT_NOACTION 0x00000004 | |
44 | ||
45 | #define TCP_MD5_KEY_LEN 80 | |
46 | #define L2VPN_NAME_LEN 32 | |
47 | ||
48 | #define RT_BUF_SIZE 16384 | |
49 | #define MAX_RTSOCK_BUF 128 * 1024 | |
50 | #define LDP_BACKLOG 128 | |
51 | ||
52 | #define F_LDPD_INSERTED 0x0001 | |
53 | #define F_CONNECTED 0x0002 | |
54 | #define F_STATIC 0x0004 | |
55 | #define F_DYNAMIC 0x0008 | |
56 | #define F_REJECT 0x0010 | |
57 | #define F_BLACKHOLE 0x0020 | |
58 | #define F_REDISTRIBUTED 0x0040 | |
59 | ||
60 | struct evbuf { | |
eac6e3f0 RW |
61 | struct msgbuf wbuf; |
62 | struct thread *ev; | |
63 | int (*handler)(struct thread *); | |
64 | void *arg; | |
8429abe0 RW |
65 | }; |
66 | ||
67 | struct imsgev { | |
68 | struct imsgbuf ibuf; | |
eac6e3f0 RW |
69 | int (*handler_write)(struct thread *); |
70 | struct thread *ev_write; | |
71 | int (*handler_read)(struct thread *); | |
72 | struct thread *ev_read; | |
8429abe0 RW |
73 | }; |
74 | ||
75 | enum imsg_type { | |
76 | IMSG_NONE, | |
77 | IMSG_CTL_RELOAD, | |
78 | IMSG_CTL_SHOW_INTERFACE, | |
79 | IMSG_CTL_SHOW_DISCOVERY, | |
bc0eb287 | 80 | IMSG_CTL_SHOW_DISCOVERY_DTL, |
eac6e3f0 RW |
81 | IMSG_CTL_SHOW_DISC_IFACE, |
82 | IMSG_CTL_SHOW_DISC_TNBR, | |
83 | IMSG_CTL_SHOW_DISC_ADJ, | |
8429abe0 | 84 | IMSG_CTL_SHOW_NBR, |
eac6e3f0 RW |
85 | IMSG_CTL_SHOW_NBR_DISC, |
86 | IMSG_CTL_SHOW_NBR_END, | |
8429abe0 | 87 | IMSG_CTL_SHOW_LIB, |
0f7b5df9 RW |
88 | IMSG_CTL_SHOW_LIB_BEGIN, |
89 | IMSG_CTL_SHOW_LIB_SENT, | |
90 | IMSG_CTL_SHOW_LIB_RCVD, | |
91 | IMSG_CTL_SHOW_LIB_END, | |
8429abe0 RW |
92 | IMSG_CTL_SHOW_L2VPN_PW, |
93 | IMSG_CTL_SHOW_L2VPN_BINDING, | |
94 | IMSG_CTL_CLEAR_NBR, | |
95 | IMSG_CTL_FIB_COUPLE, | |
96 | IMSG_CTL_FIB_DECOUPLE, | |
97 | IMSG_CTL_KROUTE, | |
98 | IMSG_CTL_KROUTE_ADDR, | |
99 | IMSG_CTL_IFINFO, | |
100 | IMSG_CTL_END, | |
101 | IMSG_CTL_LOG_VERBOSE, | |
102 | IMSG_KLABEL_CHANGE, | |
103 | IMSG_KLABEL_DELETE, | |
104 | IMSG_KPWLABEL_CHANGE, | |
105 | IMSG_KPWLABEL_DELETE, | |
106 | IMSG_IFSTATUS, | |
107 | IMSG_NEWADDR, | |
108 | IMSG_DELADDR, | |
eac6e3f0 | 109 | IMSG_RTRID_UPDATE, |
8429abe0 RW |
110 | IMSG_LABEL_MAPPING, |
111 | IMSG_LABEL_MAPPING_FULL, | |
112 | IMSG_LABEL_REQUEST, | |
113 | IMSG_LABEL_RELEASE, | |
114 | IMSG_LABEL_WITHDRAW, | |
115 | IMSG_LABEL_ABORT, | |
116 | IMSG_REQUEST_ADD, | |
117 | IMSG_REQUEST_ADD_END, | |
118 | IMSG_MAPPING_ADD, | |
119 | IMSG_MAPPING_ADD_END, | |
120 | IMSG_RELEASE_ADD, | |
121 | IMSG_RELEASE_ADD_END, | |
122 | IMSG_WITHDRAW_ADD, | |
123 | IMSG_WITHDRAW_ADD_END, | |
124 | IMSG_ADDRESS_ADD, | |
125 | IMSG_ADDRESS_DEL, | |
126 | IMSG_NOTIFICATION, | |
127 | IMSG_NOTIFICATION_SEND, | |
128 | IMSG_NEIGHBOR_UP, | |
129 | IMSG_NEIGHBOR_DOWN, | |
130 | IMSG_NETWORK_ADD, | |
8cb1fc45 | 131 | IMSG_NETWORK_UPDATE, |
8429abe0 RW |
132 | IMSG_SOCKET_IPC, |
133 | IMSG_SOCKET_NET, | |
134 | IMSG_CLOSE_SOCKETS, | |
135 | IMSG_REQUEST_SOCKETS, | |
136 | IMSG_SETUP_SOCKETS, | |
137 | IMSG_RECONF_CONF, | |
138 | IMSG_RECONF_IFACE, | |
139 | IMSG_RECONF_TNBR, | |
140 | IMSG_RECONF_NBRP, | |
141 | IMSG_RECONF_L2VPN, | |
142 | IMSG_RECONF_L2VPN_IF, | |
143 | IMSG_RECONF_L2VPN_PW, | |
eac6e3f0 RW |
144 | IMSG_RECONF_L2VPN_IPW, |
145 | IMSG_RECONF_END, | |
146 | IMSG_DEBUG_UPDATE, | |
45a8eba9 | 147 | IMSG_LOG, |
01d1458f | 148 | IMSG_ACL_CHECK |
8429abe0 RW |
149 | }; |
150 | ||
151 | union ldpd_addr { | |
152 | struct in_addr v4; | |
153 | struct in6_addr v6; | |
154 | }; | |
155 | ||
156 | #define IN6_IS_SCOPE_EMBED(a) \ | |
157 | ((IN6_IS_ADDR_LINKLOCAL(a)) || \ | |
158 | (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \ | |
159 | (IN6_IS_ADDR_MC_INTFACELOCAL(a))) | |
160 | ||
161 | /* interface states */ | |
162 | #define IF_STA_DOWN 0x01 | |
163 | #define IF_STA_ACTIVE 0x02 | |
164 | ||
165 | /* targeted neighbor states */ | |
166 | #define TNBR_STA_DOWN 0x01 | |
167 | #define TNBR_STA_ACTIVE 0x02 | |
168 | ||
169 | /* interface types */ | |
170 | enum iface_type { | |
171 | IF_TYPE_POINTOPOINT, | |
172 | IF_TYPE_BROADCAST | |
173 | }; | |
174 | ||
175 | /* neighbor states */ | |
176 | #define NBR_STA_PRESENT 0x0001 | |
177 | #define NBR_STA_INITIAL 0x0002 | |
178 | #define NBR_STA_OPENREC 0x0004 | |
179 | #define NBR_STA_OPENSENT 0x0008 | |
180 | #define NBR_STA_OPER 0x0010 | |
181 | #define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \ | |
182 | NBR_STA_OPENSENT | NBR_STA_OPER) | |
183 | ||
184 | /* neighbor events */ | |
185 | enum nbr_event { | |
186 | NBR_EVT_NOTHING, | |
187 | NBR_EVT_MATCH_ADJ, | |
188 | NBR_EVT_CONNECT_UP, | |
189 | NBR_EVT_CLOSE_SESSION, | |
190 | NBR_EVT_INIT_RCVD, | |
191 | NBR_EVT_KEEPALIVE_RCVD, | |
192 | NBR_EVT_PDU_RCVD, | |
193 | NBR_EVT_PDU_SENT, | |
194 | NBR_EVT_INIT_SENT | |
195 | }; | |
196 | ||
197 | /* neighbor actions */ | |
198 | enum nbr_action { | |
199 | NBR_ACT_NOTHING, | |
200 | NBR_ACT_RST_KTIMEOUT, | |
201 | NBR_ACT_SESSION_EST, | |
202 | NBR_ACT_RST_KTIMER, | |
203 | NBR_ACT_CONNECT_SETUP, | |
204 | NBR_ACT_PASSIVE_INIT, | |
205 | NBR_ACT_KEEPALIVE_SEND, | |
206 | NBR_ACT_CLOSE_SESSION | |
207 | }; | |
208 | ||
057d48bd RW |
209 | /* forward declarations */ |
210 | RB_HEAD(global_adj_head, adj); | |
211 | RB_HEAD(nbr_adj_head, adj); | |
212 | RB_HEAD(ia_adj_head, adj); | |
8429abe0 RW |
213 | |
214 | struct map { | |
215 | uint8_t type; | |
216 | uint32_t msg_id; | |
217 | union { | |
218 | struct { | |
219 | uint16_t af; | |
220 | union ldpd_addr prefix; | |
221 | uint8_t prefixlen; | |
222 | } prefix; | |
223 | struct { | |
224 | uint16_t type; | |
225 | uint32_t pwid; | |
226 | uint32_t group_id; | |
227 | uint16_t ifmtu; | |
228 | } pwid; | |
d4afb819 RW |
229 | struct { |
230 | uint8_t type; | |
231 | union { | |
232 | uint16_t prefix_af; | |
aba50a83 | 233 | uint16_t pw_type; |
d4afb819 RW |
234 | } u; |
235 | } twcard; | |
8429abe0 RW |
236 | } fec; |
237 | struct { | |
238 | uint32_t status_code; | |
239 | uint32_t msg_id; | |
240 | uint16_t msg_type; | |
241 | } st; | |
242 | uint32_t label; | |
243 | uint32_t requestid; | |
244 | uint32_t pw_status; | |
245 | uint8_t flags; | |
246 | }; | |
247 | #define F_MAP_REQ_ID 0x01 /* optional request message id present */ | |
248 | #define F_MAP_STATUS 0x02 /* status */ | |
249 | #define F_MAP_PW_CWORD 0x04 /* pseudowire control word */ | |
250 | #define F_MAP_PW_ID 0x08 /* pseudowire connection id */ | |
251 | #define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */ | |
252 | #define F_MAP_PW_STATUS 0x20 /* pseudowire status */ | |
253 | ||
254 | struct notify_msg { | |
255 | uint32_t status_code; | |
256 | uint32_t msg_id; /* network byte order */ | |
257 | uint16_t msg_type; /* network byte order */ | |
258 | uint32_t pw_status; | |
259 | struct map fec; | |
8819fc38 RW |
260 | struct { |
261 | uint16_t type; | |
262 | uint16_t length; | |
263 | char *data; | |
264 | } rtlvs; | |
8429abe0 RW |
265 | uint8_t flags; |
266 | }; | |
267 | #define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */ | |
268 | #define F_NOTIF_FEC 0x02 /* fec tlv present */ | |
8819fc38 | 269 | #define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */ |
8429abe0 RW |
270 | |
271 | struct if_addr { | |
272 | LIST_ENTRY(if_addr) entry; | |
273 | int af; | |
274 | union ldpd_addr addr; | |
275 | uint8_t prefixlen; | |
276 | union ldpd_addr dstbrd; | |
277 | }; | |
278 | LIST_HEAD(if_addr_head, if_addr); | |
279 | ||
280 | struct iface_af { | |
281 | struct iface *iface; | |
282 | int af; | |
283 | int enabled; | |
284 | int state; | |
057d48bd | 285 | struct ia_adj_head adj_tree; |
8429abe0 | 286 | time_t uptime; |
eac6e3f0 | 287 | struct thread *hello_timer; |
8429abe0 RW |
288 | uint16_t hello_holdtime; |
289 | uint16_t hello_interval; | |
290 | }; | |
291 | ||
292 | struct iface { | |
7d3d7491 | 293 | RB_ENTRY(iface) entry; |
8429abe0 RW |
294 | char name[IF_NAMESIZE]; |
295 | unsigned int ifindex; | |
296 | struct if_addr_head addr_list; | |
297 | struct in6_addr linklocal; | |
298 | enum iface_type type; | |
8429abe0 | 299 | uint16_t flags; |
8429abe0 RW |
300 | struct iface_af ipv4; |
301 | struct iface_af ipv6; | |
4af8997d | 302 | QOBJ_FIELDS |
8429abe0 | 303 | }; |
7d3d7491 RW |
304 | RB_HEAD(iface_head, iface); |
305 | RB_PROTOTYPE(iface_head, iface, entry, iface_compare); | |
4af8997d | 306 | DECLARE_QOBJ_TYPE(iface) |
8429abe0 RW |
307 | |
308 | /* source of targeted hellos */ | |
309 | struct tnbr { | |
7989cdba | 310 | RB_ENTRY(tnbr) entry; |
eac6e3f0 | 311 | struct thread *hello_timer; |
8429abe0 RW |
312 | struct adj *adj; |
313 | int af; | |
314 | union ldpd_addr addr; | |
315 | int state; | |
8429abe0 RW |
316 | uint16_t pw_count; |
317 | uint8_t flags; | |
4af8997d | 318 | QOBJ_FIELDS |
8429abe0 | 319 | }; |
7989cdba RW |
320 | RB_HEAD(tnbr_head, tnbr); |
321 | RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare); | |
4af8997d | 322 | DECLARE_QOBJ_TYPE(tnbr) |
8429abe0 RW |
323 | #define F_TNBR_CONFIGURED 0x01 |
324 | #define F_TNBR_DYNAMIC 0x02 | |
325 | ||
326 | enum auth_method { | |
327 | AUTH_NONE, | |
328 | AUTH_MD5SIG | |
329 | }; | |
330 | ||
331 | /* neighbor specific parameters */ | |
332 | struct nbr_params { | |
76c4abd1 | 333 | RB_ENTRY(nbr_params) entry; |
8429abe0 RW |
334 | struct in_addr lsr_id; |
335 | uint16_t keepalive; | |
336 | int gtsm_enabled; | |
337 | uint8_t gtsm_hops; | |
338 | struct { | |
339 | enum auth_method method; | |
340 | char md5key[TCP_MD5_KEY_LEN]; | |
341 | uint8_t md5key_len; | |
342 | } auth; | |
343 | uint8_t flags; | |
4af8997d | 344 | QOBJ_FIELDS |
8429abe0 | 345 | }; |
76c4abd1 RW |
346 | RB_HEAD(nbrp_head, nbr_params); |
347 | RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare); | |
4af8997d | 348 | DECLARE_QOBJ_TYPE(nbr_params) |
8429abe0 RW |
349 | #define F_NBRP_KEEPALIVE 0x01 |
350 | #define F_NBRP_GTSM 0x02 | |
351 | #define F_NBRP_GTSM_HOPS 0x04 | |
352 | ||
0f7b5df9 RW |
353 | struct ldp_stats { |
354 | uint32_t kalive_sent; | |
355 | uint32_t kalive_rcvd; | |
356 | uint32_t addr_sent; | |
357 | uint32_t addr_rcvd; | |
358 | uint32_t addrwdraw_sent; | |
359 | uint32_t addrwdraw_rcvd; | |
360 | uint32_t notif_sent; | |
361 | uint32_t notif_rcvd; | |
362 | uint32_t capability_sent; | |
363 | uint32_t capability_rcvd; | |
364 | uint32_t labelmap_sent; | |
365 | uint32_t labelmap_rcvd; | |
366 | uint32_t labelreq_sent; | |
367 | uint32_t labelreq_rcvd; | |
368 | uint32_t labelwdraw_sent; | |
369 | uint32_t labelwdraw_rcvd; | |
370 | uint32_t labelrel_sent; | |
371 | uint32_t labelrel_rcvd; | |
372 | uint32_t labelabreq_sent; | |
373 | uint32_t labelabreq_rcvd; | |
374 | }; | |
375 | ||
8429abe0 | 376 | struct l2vpn_if { |
029c1958 | 377 | RB_ENTRY(l2vpn_if) entry; |
8429abe0 RW |
378 | struct l2vpn *l2vpn; |
379 | char ifname[IF_NAMESIZE]; | |
380 | unsigned int ifindex; | |
381 | uint16_t flags; | |
26519d8c | 382 | uint8_t mac[ETHER_ADDR_LEN]; |
4af8997d | 383 | QOBJ_FIELDS |
8429abe0 | 384 | }; |
029c1958 RW |
385 | RB_HEAD(l2vpn_if_head, l2vpn_if); |
386 | RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare); | |
4af8997d | 387 | DECLARE_QOBJ_TYPE(l2vpn_if) |
8429abe0 RW |
388 | |
389 | struct l2vpn_pw { | |
20bacaeb | 390 | RB_ENTRY(l2vpn_pw) entry; |
8429abe0 RW |
391 | struct l2vpn *l2vpn; |
392 | struct in_addr lsr_id; | |
393 | int af; | |
394 | union ldpd_addr addr; | |
395 | uint32_t pwid; | |
396 | char ifname[IF_NAMESIZE]; | |
397 | unsigned int ifindex; | |
398 | uint32_t remote_group; | |
399 | uint16_t remote_mtu; | |
400 | uint32_t remote_status; | |
401 | uint8_t flags; | |
4af8997d | 402 | QOBJ_FIELDS |
8429abe0 | 403 | }; |
20bacaeb RW |
404 | RB_HEAD(l2vpn_pw_head, l2vpn_pw); |
405 | RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare); | |
4af8997d | 406 | DECLARE_QOBJ_TYPE(l2vpn_pw) |
8429abe0 RW |
407 | #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */ |
408 | #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */ | |
409 | #define F_PW_CWORD_CONF 0x04 /* control word configured */ | |
410 | #define F_PW_CWORD 0x08 /* control word negotiated */ | |
411 | #define F_PW_STATUS_UP 0x10 /* pseudowire is operational */ | |
eac6e3f0 | 412 | #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */ |
8429abe0 RW |
413 | |
414 | struct l2vpn { | |
90d7e7bd | 415 | RB_ENTRY(l2vpn) entry; |
8429abe0 RW |
416 | char name[L2VPN_NAME_LEN]; |
417 | int type; | |
418 | int pw_type; | |
419 | int mtu; | |
420 | char br_ifname[IF_NAMESIZE]; | |
421 | unsigned int br_ifindex; | |
029c1958 | 422 | struct l2vpn_if_head if_tree; |
20bacaeb RW |
423 | struct l2vpn_pw_head pw_tree; |
424 | struct l2vpn_pw_head pw_inactive_tree; | |
4af8997d | 425 | QOBJ_FIELDS |
8429abe0 | 426 | }; |
90d7e7bd RW |
427 | RB_HEAD(l2vpn_head, l2vpn); |
428 | RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare); | |
4af8997d | 429 | DECLARE_QOBJ_TYPE(l2vpn) |
8429abe0 RW |
430 | #define L2VPN_TYPE_VPWS 1 |
431 | #define L2VPN_TYPE_VPLS 2 | |
432 | ||
433 | /* ldp_conf */ | |
434 | enum ldpd_process { | |
435 | PROC_MAIN, | |
436 | PROC_LDP_ENGINE, | |
437 | PROC_LDE_ENGINE | |
438 | } ldpd_process; | |
439 | ||
fa68f9da RW |
440 | static const char * const log_procnames[] = { |
441 | "parent", | |
442 | "ldpe", | |
443 | "lde" | |
444 | }; | |
445 | ||
8429abe0 RW |
446 | enum socket_type { |
447 | LDP_SOCKET_DISC, | |
448 | LDP_SOCKET_EDISC, | |
449 | LDP_SOCKET_SESSION | |
450 | }; | |
451 | ||
452 | enum hello_type { | |
453 | HELLO_LINK, | |
454 | HELLO_TARGETED | |
455 | }; | |
456 | ||
457 | struct ldpd_af_conf { | |
458 | uint16_t keepalive; | |
eac6e3f0 RW |
459 | uint16_t lhello_holdtime; |
460 | uint16_t lhello_interval; | |
8429abe0 RW |
461 | uint16_t thello_holdtime; |
462 | uint16_t thello_interval; | |
463 | union ldpd_addr trans_addr; | |
45a8eba9 RW |
464 | char acl_thello_accept_from[ACL_NAMSIZ]; |
465 | char acl_label_allocate_for[ACL_NAMSIZ]; | |
466 | char acl_label_advertise_to[ACL_NAMSIZ]; | |
467 | char acl_label_advertise_for[ACL_NAMSIZ]; | |
468 | char acl_label_expnull_for[ACL_NAMSIZ]; | |
469 | char acl_label_accept_from[ACL_NAMSIZ]; | |
470 | char acl_label_accept_for[ACL_NAMSIZ]; | |
8429abe0 RW |
471 | int flags; |
472 | }; | |
473 | #define F_LDPD_AF_ENABLED 0x0001 | |
474 | #define F_LDPD_AF_THELLO_ACCEPT 0x0002 | |
475 | #define F_LDPD_AF_EXPNULL 0x0004 | |
476 | #define F_LDPD_AF_NO_GTSM 0x0008 | |
45a8eba9 | 477 | #define F_LDPD_AF_ALLOCHOSTONLY 0x0010 |
8429abe0 RW |
478 | |
479 | struct ldpd_conf { | |
480 | struct in_addr rtr_id; | |
481 | struct ldpd_af_conf ipv4; | |
482 | struct ldpd_af_conf ipv6; | |
7d3d7491 | 483 | struct iface_head iface_tree; |
7989cdba | 484 | struct tnbr_head tnbr_tree; |
76c4abd1 | 485 | struct nbrp_head nbrp_tree; |
90d7e7bd | 486 | struct l2vpn_head l2vpn_tree; |
eac6e3f0 RW |
487 | uint16_t lhello_holdtime; |
488 | uint16_t lhello_interval; | |
489 | uint16_t thello_holdtime; | |
490 | uint16_t thello_interval; | |
8429abe0 RW |
491 | uint16_t trans_pref; |
492 | int flags; | |
4af8997d | 493 | QOBJ_FIELDS |
8429abe0 | 494 | }; |
4af8997d | 495 | DECLARE_QOBJ_TYPE(ldpd_conf) |
8429abe0 RW |
496 | #define F_LDPD_NO_FIB_UPDATE 0x0001 |
497 | #define F_LDPD_DS_CISCO_INTEROP 0x0002 | |
eac6e3f0 | 498 | #define F_LDPD_ENABLED 0x0004 |
8429abe0 RW |
499 | |
500 | struct ldpd_af_global { | |
eac6e3f0 RW |
501 | struct thread *disc_ev; |
502 | struct thread *edisc_ev; | |
8429abe0 RW |
503 | int ldp_disc_socket; |
504 | int ldp_edisc_socket; | |
505 | int ldp_session_socket; | |
506 | }; | |
507 | ||
508 | struct ldpd_global { | |
509 | int cmd_opts; | |
dbce3582 | 510 | int sighup; |
8429abe0 | 511 | time_t uptime; |
eac6e3f0 | 512 | struct in_addr rtr_id; |
8429abe0 RW |
513 | struct ldpd_af_global ipv4; |
514 | struct ldpd_af_global ipv6; | |
515 | uint32_t conf_seqnum; | |
516 | int pfkeysock; | |
517 | struct if_addr_head addr_list; | |
057d48bd | 518 | struct global_adj_head adj_tree; |
8429abe0 RW |
519 | struct in_addr mcast_addr_v4; |
520 | struct in6_addr mcast_addr_v6; | |
521 | TAILQ_HEAD(, pending_conn) pending_conns; | |
522 | }; | |
523 | ||
524 | /* kroute */ | |
525 | struct kroute { | |
526 | int af; | |
527 | union ldpd_addr prefix; | |
528 | uint8_t prefixlen; | |
529 | union ldpd_addr nexthop; | |
530 | uint32_t local_label; | |
531 | uint32_t remote_label; | |
532 | unsigned short ifindex; | |
533 | uint8_t priority; | |
534 | uint16_t flags; | |
535 | }; | |
536 | ||
537 | struct kpw { | |
538 | unsigned short ifindex; | |
539 | int pw_type; | |
540 | int af; | |
541 | union ldpd_addr nexthop; | |
542 | uint32_t local_label; | |
543 | uint32_t remote_label; | |
544 | uint8_t flags; | |
545 | }; | |
546 | ||
547 | struct kaddr { | |
548 | unsigned short ifindex; | |
549 | int af; | |
550 | union ldpd_addr addr; | |
551 | uint8_t prefixlen; | |
552 | union ldpd_addr dstbrd; | |
553 | }; | |
554 | ||
555 | struct kif { | |
556 | char ifname[IF_NAMESIZE]; | |
557 | unsigned short ifindex; | |
558 | int flags; | |
26519d8c | 559 | uint8_t mac[ETHER_ADDR_LEN]; |
8429abe0 | 560 | int mtu; |
8429abe0 RW |
561 | }; |
562 | ||
45a8eba9 RW |
563 | struct acl_check { |
564 | char acl[ACL_NAMSIZ]; | |
565 | int af; | |
566 | union ldpd_addr addr; | |
567 | uint8_t prefixlen; | |
568 | }; | |
569 | ||
8429abe0 RW |
570 | /* control data structures */ |
571 | struct ctl_iface { | |
572 | int af; | |
573 | char name[IF_NAMESIZE]; | |
574 | unsigned int ifindex; | |
575 | int state; | |
576 | uint16_t flags; | |
8429abe0 | 577 | enum iface_type type; |
8429abe0 RW |
578 | uint16_t hello_holdtime; |
579 | uint16_t hello_interval; | |
580 | time_t uptime; | |
581 | uint16_t adj_cnt; | |
582 | }; | |
583 | ||
eac6e3f0 RW |
584 | struct ctl_disc_if { |
585 | char name[IF_NAMESIZE]; | |
586 | int active_v4; | |
587 | int active_v6; | |
588 | int no_adj; | |
589 | }; | |
590 | ||
591 | struct ctl_disc_tnbr { | |
592 | int af; | |
593 | union ldpd_addr addr; | |
594 | int no_adj; | |
595 | }; | |
596 | ||
8429abe0 RW |
597 | struct ctl_adj { |
598 | int af; | |
599 | struct in_addr id; | |
600 | enum hello_type type; | |
601 | char ifname[IF_NAMESIZE]; | |
602 | union ldpd_addr src_addr; | |
603 | uint16_t holdtime; | |
0f7b5df9 | 604 | uint16_t holdtime_remaining; |
8429abe0 | 605 | union ldpd_addr trans_addr; |
0f7b5df9 | 606 | int ds_tlv; |
8429abe0 RW |
607 | }; |
608 | ||
609 | struct ctl_nbr { | |
610 | int af; | |
611 | struct in_addr id; | |
612 | union ldpd_addr laddr; | |
eac6e3f0 | 613 | in_port_t lport; |
8429abe0 | 614 | union ldpd_addr raddr; |
eac6e3f0 | 615 | in_port_t rport; |
0f7b5df9 | 616 | enum auth_method auth_method; |
eac6e3f0 | 617 | uint16_t holdtime; |
8429abe0 RW |
618 | time_t uptime; |
619 | int nbr_state; | |
0f7b5df9 | 620 | struct ldp_stats stats; |
99cfc17f | 621 | int flags; |
8429abe0 RW |
622 | }; |
623 | ||
624 | struct ctl_rt { | |
625 | int af; | |
626 | union ldpd_addr prefix; | |
627 | uint8_t prefixlen; | |
628 | struct in_addr nexthop; /* lsr-id */ | |
629 | uint32_t local_label; | |
630 | uint32_t remote_label; | |
631 | uint8_t flags; | |
632 | uint8_t in_use; | |
0f7b5df9 | 633 | int no_downstream; |
8429abe0 RW |
634 | }; |
635 | ||
636 | struct ctl_pw { | |
637 | uint16_t type; | |
eac6e3f0 | 638 | char l2vpn_name[L2VPN_NAME_LEN]; |
8429abe0 RW |
639 | char ifname[IF_NAMESIZE]; |
640 | uint32_t pwid; | |
641 | struct in_addr lsr_id; | |
642 | uint32_t local_label; | |
643 | uint32_t local_gid; | |
644 | uint16_t local_ifmtu; | |
eac6e3f0 | 645 | uint8_t local_cword; |
8429abe0 RW |
646 | uint32_t remote_label; |
647 | uint32_t remote_gid; | |
648 | uint16_t remote_ifmtu; | |
eac6e3f0 | 649 | uint8_t remote_cword; |
8429abe0 RW |
650 | uint32_t status; |
651 | }; | |
652 | ||
56b8a8d2 | 653 | extern struct ldpd_conf *ldpd_conf, *vty_conf; |
8429abe0 RW |
654 | extern struct ldpd_global global; |
655 | ||
656 | /* parse.y */ | |
657 | struct ldpd_conf *parse_config(char *); | |
658 | int cmdline_symset(char *); | |
659 | ||
660 | /* kroute.c */ | |
8429abe0 RW |
661 | void kif_redistribute(const char *); |
662 | int kr_change(struct kroute *); | |
663 | int kr_delete(struct kroute *); | |
8429abe0 RW |
664 | int kmpw_set(struct kpw *); |
665 | int kmpw_unset(struct kpw *); | |
666 | ||
667 | /* util.c */ | |
668 | uint8_t mask2prefixlen(in_addr_t); | |
669 | uint8_t mask2prefixlen6(struct sockaddr_in6 *); | |
670 | in_addr_t prefixlen2mask(uint8_t); | |
671 | struct in6_addr *prefixlen2mask6(uint8_t); | |
672 | void ldp_applymask(int, union ldpd_addr *, | |
673 | const union ldpd_addr *, int); | |
674 | int ldp_addrcmp(int, const union ldpd_addr *, | |
675 | const union ldpd_addr *); | |
676 | int ldp_addrisset(int, const union ldpd_addr *); | |
677 | int ldp_prefixcmp(int, const union ldpd_addr *, | |
678 | const union ldpd_addr *, uint8_t); | |
679 | int bad_addr_v4(struct in_addr); | |
680 | int bad_addr_v6(struct in6_addr *); | |
681 | int bad_addr(int, union ldpd_addr *); | |
682 | void embedscope(struct sockaddr_in6 *); | |
683 | void recoverscope(struct sockaddr_in6 *); | |
684 | void addscope(struct sockaddr_in6 *, uint32_t); | |
685 | void clearscope(struct in6_addr *); | |
686 | struct sockaddr *addr2sa(int af, union ldpd_addr *, uint16_t); | |
eac6e3f0 RW |
687 | void sa2addr(struct sockaddr *, int *, union ldpd_addr *, |
688 | in_port_t *); | |
689 | socklen_t sockaddr_len(struct sockaddr *); | |
8429abe0 RW |
690 | |
691 | /* ldpd.c */ | |
eac6e3f0 | 692 | int ldp_write_handler(struct thread *); |
8429abe0 RW |
693 | void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t); |
694 | void main_imsg_compose_lde(int, pid_t, void *, uint16_t); | |
eac6e3f0 RW |
695 | int main_imsg_compose_both(enum imsg_type, void *, |
696 | uint16_t); | |
8429abe0 | 697 | void imsg_event_add(struct imsgev *); |
eac6e3f0 RW |
698 | int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, |
699 | pid_t, int, void *, uint16_t); | |
8429abe0 RW |
700 | void evbuf_enqueue(struct evbuf *, struct ibuf *); |
701 | void evbuf_event_add(struct evbuf *); | |
eac6e3f0 RW |
702 | void evbuf_init(struct evbuf *, int, |
703 | int (*)(struct thread *), void *); | |
8429abe0 | 704 | void evbuf_clear(struct evbuf *); |
45a8eba9 RW |
705 | int ldp_acl_request(struct imsgev *, char *, int, |
706 | union ldpd_addr *, uint8_t); | |
707 | void ldp_acl_reply(struct imsgev *, struct acl_check *); | |
8429abe0 RW |
708 | struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int); |
709 | struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int); | |
710 | int ldp_is_dual_stack(struct ldpd_conf *); | |
eac6e3f0 RW |
711 | in_addr_t ldp_rtr_id_get(struct ldpd_conf *); |
712 | int ldp_reload(struct ldpd_conf *); | |
eac6e3f0 | 713 | void ldp_clear_config(struct ldpd_conf *); |
8429abe0 RW |
714 | void merge_config(struct ldpd_conf *, struct ldpd_conf *); |
715 | struct ldpd_conf *config_new_empty(void); | |
716 | void config_clear(struct ldpd_conf *); | |
717 | ||
bbee85d2 RW |
718 | /* ldp_vty_conf.c */ |
719 | /* NOTE: the parameters' names should be preserved because of codegen */ | |
7d3d7491 | 720 | struct iface *iface_new_api(struct ldpd_conf *conf, |
bbee85d2 | 721 | const char *name); |
7d3d7491 RW |
722 | void iface_del_api(struct ldpd_conf *conf, |
723 | struct iface *iface); | |
7989cdba | 724 | struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af, |
bbee85d2 | 725 | union ldpd_addr *addr); |
7989cdba | 726 | void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr); |
76c4abd1 | 727 | struct nbr_params *nbrp_new_api(struct ldpd_conf *conf, |
bbee85d2 | 728 | struct in_addr lsr_id); |
76c4abd1 RW |
729 | void nbrp_del_api(struct ldpd_conf *conf, |
730 | struct nbr_params *nbrp); | |
90d7e7bd RW |
731 | struct l2vpn *l2vpn_new_api(struct ldpd_conf *conf, const char *name); |
732 | void l2vpn_del_api(struct ldpd_conf *conf, | |
733 | struct l2vpn *l2vpn); | |
bbee85d2 RW |
734 | struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf, |
735 | struct l2vpn *l2vpn, const char *ifname); | |
029c1958 RW |
736 | void l2vpn_if_del_api(struct l2vpn *l2vpn, |
737 | struct l2vpn_if *lif); | |
bbee85d2 RW |
738 | struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf, |
739 | struct l2vpn *l2vpn, const char *ifname); | |
20bacaeb RW |
740 | void l2vpn_pw_del_api(struct l2vpn *l2vpn, |
741 | struct l2vpn_pw *pw); | |
bbee85d2 | 742 | |
8429abe0 RW |
743 | /* socket.c */ |
744 | int ldp_create_socket(int, enum socket_type); | |
eac6e3f0 RW |
745 | void sock_set_nonblock(int); |
746 | void sock_set_cloexec(int); | |
8429abe0 RW |
747 | void sock_set_recvbuf(int); |
748 | int sock_set_reuse(int, int); | |
749 | int sock_set_bindany(int, int); | |
eac6e3f0 | 750 | int sock_set_md5sig(int, int, union ldpd_addr *, const char *); |
8429abe0 | 751 | int sock_set_ipv4_tos(int, int); |
eac6e3f0 RW |
752 | int sock_set_ipv4_pktinfo(int, int); |
753 | int sock_set_ipv4_recvdstaddr(int, int); | |
8429abe0 RW |
754 | int sock_set_ipv4_recvif(int, int); |
755 | int sock_set_ipv4_minttl(int, int); | |
756 | int sock_set_ipv4_ucast_ttl(int fd, int); | |
757 | int sock_set_ipv4_mcast_ttl(int, uint8_t); | |
758 | int sock_set_ipv4_mcast(struct iface *); | |
759 | int sock_set_ipv4_mcast_loop(int); | |
760 | int sock_set_ipv6_dscp(int, int); | |
761 | int sock_set_ipv6_pktinfo(int, int); | |
762 | int sock_set_ipv6_minhopcount(int, int); | |
763 | int sock_set_ipv6_ucast_hops(int, int); | |
764 | int sock_set_ipv6_mcast_hops(int, int); | |
765 | int sock_set_ipv6_mcast(struct iface *); | |
766 | int sock_set_ipv6_mcast_loop(int); | |
767 | ||
fa68f9da RW |
768 | /* logmsg.h */ |
769 | struct in6_addr; | |
770 | union ldpd_addr; | |
771 | struct hello_source; | |
772 | struct fec; | |
773 | ||
774 | const char *log_sockaddr(void *); | |
775 | const char *log_in6addr(const struct in6_addr *); | |
776 | const char *log_in6addr_scope(const struct in6_addr *, unsigned int); | |
777 | const char *log_addr(int, const union ldpd_addr *); | |
778 | char *log_label(uint32_t); | |
779 | const char *log_time(time_t); | |
780 | char *log_hello_src(const struct hello_source *); | |
781 | const char *log_map(const struct map *); | |
782 | const char *log_fec(const struct fec *); | |
783 | const char *af_name(int); | |
784 | const char *socket_name(int); | |
785 | const char *nbr_state_name(int); | |
786 | const char *if_state_name(int); | |
787 | const char *if_type_name(enum iface_type); | |
788 | const char *msg_name(uint16_t); | |
789 | const char *status_code_name(uint32_t); | |
790 | const char *pw_type_name(uint16_t); | |
791 | ||
eac6e3f0 RW |
792 | /* quagga */ |
793 | extern struct thread_master *master; | |
372b8bd3 | 794 | extern char ctl_sock_path[MAXPATHLEN]; |
eac6e3f0 RW |
795 | |
796 | /* ldp_zebra.c */ | |
64dffe25 RW |
797 | void ldp_zebra_init(struct thread_master *); |
798 | void ldp_zebra_destroy(void); | |
eac6e3f0 RW |
799 | |
800 | /* compatibility */ | |
801 | #ifndef __OpenBSD__ | |
802 | #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) | |
803 | #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 | |
804 | #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ | |
805 | (IN6_IS_ADDR_MULTICAST(a) && \ | |
806 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL)) | |
807 | #endif | |
8429abe0 RW |
808 | |
809 | #endif /* _LDPD_H_ */ |