]>
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, |
fea12efb | 148 | IMSG_ACL_CHECK, |
149 | IMSG_GET_LABEL_CHUNK, | |
e75f810c RW |
150 | IMSG_RELEASE_LABEL_CHUNK, |
151 | IMSG_INIT | |
152 | }; | |
153 | ||
154 | struct ldpd_init { | |
155 | char user[256]; | |
156 | char group[256]; | |
157 | char ctl_sock_path[MAXPATHLEN]; | |
158 | char zclient_serv_path[MAXPATHLEN]; | |
159 | u_short instance; | |
8429abe0 RW |
160 | }; |
161 | ||
162 | union ldpd_addr { | |
163 | struct in_addr v4; | |
164 | struct in6_addr v6; | |
165 | }; | |
166 | ||
167 | #define IN6_IS_SCOPE_EMBED(a) \ | |
168 | ((IN6_IS_ADDR_LINKLOCAL(a)) || \ | |
169 | (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \ | |
170 | (IN6_IS_ADDR_MC_INTFACELOCAL(a))) | |
171 | ||
172 | /* interface states */ | |
173 | #define IF_STA_DOWN 0x01 | |
174 | #define IF_STA_ACTIVE 0x02 | |
175 | ||
176 | /* targeted neighbor states */ | |
177 | #define TNBR_STA_DOWN 0x01 | |
178 | #define TNBR_STA_ACTIVE 0x02 | |
179 | ||
180 | /* interface types */ | |
181 | enum iface_type { | |
182 | IF_TYPE_POINTOPOINT, | |
183 | IF_TYPE_BROADCAST | |
184 | }; | |
185 | ||
186 | /* neighbor states */ | |
187 | #define NBR_STA_PRESENT 0x0001 | |
188 | #define NBR_STA_INITIAL 0x0002 | |
189 | #define NBR_STA_OPENREC 0x0004 | |
190 | #define NBR_STA_OPENSENT 0x0008 | |
191 | #define NBR_STA_OPER 0x0010 | |
192 | #define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \ | |
193 | NBR_STA_OPENSENT | NBR_STA_OPER) | |
194 | ||
195 | /* neighbor events */ | |
196 | enum nbr_event { | |
197 | NBR_EVT_NOTHING, | |
198 | NBR_EVT_MATCH_ADJ, | |
199 | NBR_EVT_CONNECT_UP, | |
200 | NBR_EVT_CLOSE_SESSION, | |
201 | NBR_EVT_INIT_RCVD, | |
202 | NBR_EVT_KEEPALIVE_RCVD, | |
203 | NBR_EVT_PDU_RCVD, | |
204 | NBR_EVT_PDU_SENT, | |
205 | NBR_EVT_INIT_SENT | |
206 | }; | |
207 | ||
208 | /* neighbor actions */ | |
209 | enum nbr_action { | |
210 | NBR_ACT_NOTHING, | |
211 | NBR_ACT_RST_KTIMEOUT, | |
212 | NBR_ACT_SESSION_EST, | |
213 | NBR_ACT_RST_KTIMER, | |
214 | NBR_ACT_CONNECT_SETUP, | |
215 | NBR_ACT_PASSIVE_INIT, | |
216 | NBR_ACT_KEEPALIVE_SEND, | |
217 | NBR_ACT_CLOSE_SESSION | |
218 | }; | |
219 | ||
057d48bd RW |
220 | /* forward declarations */ |
221 | RB_HEAD(global_adj_head, adj); | |
222 | RB_HEAD(nbr_adj_head, adj); | |
223 | RB_HEAD(ia_adj_head, adj); | |
8429abe0 RW |
224 | |
225 | struct map { | |
226 | uint8_t type; | |
227 | uint32_t msg_id; | |
228 | union { | |
229 | struct { | |
230 | uint16_t af; | |
231 | union ldpd_addr prefix; | |
232 | uint8_t prefixlen; | |
233 | } prefix; | |
234 | struct { | |
235 | uint16_t type; | |
236 | uint32_t pwid; | |
237 | uint32_t group_id; | |
238 | uint16_t ifmtu; | |
239 | } pwid; | |
d4afb819 RW |
240 | struct { |
241 | uint8_t type; | |
242 | union { | |
243 | uint16_t prefix_af; | |
aba50a83 | 244 | uint16_t pw_type; |
d4afb819 RW |
245 | } u; |
246 | } twcard; | |
8429abe0 RW |
247 | } fec; |
248 | struct { | |
249 | uint32_t status_code; | |
250 | uint32_t msg_id; | |
251 | uint16_t msg_type; | |
252 | } st; | |
253 | uint32_t label; | |
254 | uint32_t requestid; | |
255 | uint32_t pw_status; | |
256 | uint8_t flags; | |
257 | }; | |
258 | #define F_MAP_REQ_ID 0x01 /* optional request message id present */ | |
259 | #define F_MAP_STATUS 0x02 /* status */ | |
260 | #define F_MAP_PW_CWORD 0x04 /* pseudowire control word */ | |
261 | #define F_MAP_PW_ID 0x08 /* pseudowire connection id */ | |
262 | #define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */ | |
263 | #define F_MAP_PW_STATUS 0x20 /* pseudowire status */ | |
264 | ||
265 | struct notify_msg { | |
266 | uint32_t status_code; | |
267 | uint32_t msg_id; /* network byte order */ | |
268 | uint16_t msg_type; /* network byte order */ | |
269 | uint32_t pw_status; | |
270 | struct map fec; | |
8819fc38 RW |
271 | struct { |
272 | uint16_t type; | |
273 | uint16_t length; | |
274 | char *data; | |
275 | } rtlvs; | |
8429abe0 RW |
276 | uint8_t flags; |
277 | }; | |
278 | #define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */ | |
279 | #define F_NOTIF_FEC 0x02 /* fec tlv present */ | |
8819fc38 | 280 | #define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */ |
8429abe0 RW |
281 | |
282 | struct if_addr { | |
283 | LIST_ENTRY(if_addr) entry; | |
284 | int af; | |
285 | union ldpd_addr addr; | |
286 | uint8_t prefixlen; | |
287 | union ldpd_addr dstbrd; | |
288 | }; | |
289 | LIST_HEAD(if_addr_head, if_addr); | |
290 | ||
291 | struct iface_af { | |
292 | struct iface *iface; | |
293 | int af; | |
294 | int enabled; | |
295 | int state; | |
057d48bd | 296 | struct ia_adj_head adj_tree; |
8429abe0 | 297 | time_t uptime; |
eac6e3f0 | 298 | struct thread *hello_timer; |
8429abe0 RW |
299 | uint16_t hello_holdtime; |
300 | uint16_t hello_interval; | |
301 | }; | |
302 | ||
303 | struct iface { | |
7d3d7491 | 304 | RB_ENTRY(iface) entry; |
8429abe0 RW |
305 | char name[IF_NAMESIZE]; |
306 | unsigned int ifindex; | |
307 | struct if_addr_head addr_list; | |
308 | struct in6_addr linklocal; | |
309 | enum iface_type type; | |
988ded8d | 310 | int operative; |
8429abe0 RW |
311 | struct iface_af ipv4; |
312 | struct iface_af ipv6; | |
4af8997d | 313 | QOBJ_FIELDS |
8429abe0 | 314 | }; |
7d3d7491 RW |
315 | RB_HEAD(iface_head, iface); |
316 | RB_PROTOTYPE(iface_head, iface, entry, iface_compare); | |
4af8997d | 317 | DECLARE_QOBJ_TYPE(iface) |
8429abe0 RW |
318 | |
319 | /* source of targeted hellos */ | |
320 | struct tnbr { | |
7989cdba | 321 | RB_ENTRY(tnbr) entry; |
eac6e3f0 | 322 | struct thread *hello_timer; |
8429abe0 RW |
323 | struct adj *adj; |
324 | int af; | |
325 | union ldpd_addr addr; | |
326 | int state; | |
8429abe0 RW |
327 | uint16_t pw_count; |
328 | uint8_t flags; | |
4af8997d | 329 | QOBJ_FIELDS |
8429abe0 | 330 | }; |
7989cdba RW |
331 | RB_HEAD(tnbr_head, tnbr); |
332 | RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare); | |
4af8997d | 333 | DECLARE_QOBJ_TYPE(tnbr) |
8429abe0 RW |
334 | #define F_TNBR_CONFIGURED 0x01 |
335 | #define F_TNBR_DYNAMIC 0x02 | |
336 | ||
337 | enum auth_method { | |
338 | AUTH_NONE, | |
339 | AUTH_MD5SIG | |
340 | }; | |
341 | ||
342 | /* neighbor specific parameters */ | |
343 | struct nbr_params { | |
76c4abd1 | 344 | RB_ENTRY(nbr_params) entry; |
8429abe0 RW |
345 | struct in_addr lsr_id; |
346 | uint16_t keepalive; | |
347 | int gtsm_enabled; | |
348 | uint8_t gtsm_hops; | |
349 | struct { | |
350 | enum auth_method method; | |
351 | char md5key[TCP_MD5_KEY_LEN]; | |
352 | uint8_t md5key_len; | |
353 | } auth; | |
354 | uint8_t flags; | |
4af8997d | 355 | QOBJ_FIELDS |
8429abe0 | 356 | }; |
76c4abd1 RW |
357 | RB_HEAD(nbrp_head, nbr_params); |
358 | RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare); | |
4af8997d | 359 | DECLARE_QOBJ_TYPE(nbr_params) |
8429abe0 RW |
360 | #define F_NBRP_KEEPALIVE 0x01 |
361 | #define F_NBRP_GTSM 0x02 | |
362 | #define F_NBRP_GTSM_HOPS 0x04 | |
363 | ||
0f7b5df9 RW |
364 | struct ldp_stats { |
365 | uint32_t kalive_sent; | |
366 | uint32_t kalive_rcvd; | |
367 | uint32_t addr_sent; | |
368 | uint32_t addr_rcvd; | |
369 | uint32_t addrwdraw_sent; | |
370 | uint32_t addrwdraw_rcvd; | |
371 | uint32_t notif_sent; | |
372 | uint32_t notif_rcvd; | |
373 | uint32_t capability_sent; | |
374 | uint32_t capability_rcvd; | |
375 | uint32_t labelmap_sent; | |
376 | uint32_t labelmap_rcvd; | |
377 | uint32_t labelreq_sent; | |
378 | uint32_t labelreq_rcvd; | |
379 | uint32_t labelwdraw_sent; | |
380 | uint32_t labelwdraw_rcvd; | |
381 | uint32_t labelrel_sent; | |
382 | uint32_t labelrel_rcvd; | |
383 | uint32_t labelabreq_sent; | |
384 | uint32_t labelabreq_rcvd; | |
385 | }; | |
386 | ||
8429abe0 | 387 | struct l2vpn_if { |
029c1958 | 388 | RB_ENTRY(l2vpn_if) entry; |
8429abe0 RW |
389 | struct l2vpn *l2vpn; |
390 | char ifname[IF_NAMESIZE]; | |
391 | unsigned int ifindex; | |
988ded8d | 392 | int operative; |
26519d8c | 393 | uint8_t mac[ETHER_ADDR_LEN]; |
4af8997d | 394 | QOBJ_FIELDS |
8429abe0 | 395 | }; |
029c1958 RW |
396 | RB_HEAD(l2vpn_if_head, l2vpn_if); |
397 | RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare); | |
4af8997d | 398 | DECLARE_QOBJ_TYPE(l2vpn_if) |
8429abe0 RW |
399 | |
400 | struct l2vpn_pw { | |
20bacaeb | 401 | RB_ENTRY(l2vpn_pw) entry; |
8429abe0 RW |
402 | struct l2vpn *l2vpn; |
403 | struct in_addr lsr_id; | |
404 | int af; | |
405 | union ldpd_addr addr; | |
406 | uint32_t pwid; | |
407 | char ifname[IF_NAMESIZE]; | |
408 | unsigned int ifindex; | |
409 | uint32_t remote_group; | |
410 | uint16_t remote_mtu; | |
411 | uint32_t remote_status; | |
412 | uint8_t flags; | |
4af8997d | 413 | QOBJ_FIELDS |
8429abe0 | 414 | }; |
20bacaeb RW |
415 | RB_HEAD(l2vpn_pw_head, l2vpn_pw); |
416 | RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare); | |
4af8997d | 417 | DECLARE_QOBJ_TYPE(l2vpn_pw) |
8429abe0 RW |
418 | #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */ |
419 | #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */ | |
420 | #define F_PW_CWORD_CONF 0x04 /* control word configured */ | |
421 | #define F_PW_CWORD 0x08 /* control word negotiated */ | |
422 | #define F_PW_STATUS_UP 0x10 /* pseudowire is operational */ | |
eac6e3f0 | 423 | #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */ |
8429abe0 RW |
424 | |
425 | struct l2vpn { | |
90d7e7bd | 426 | RB_ENTRY(l2vpn) entry; |
8429abe0 RW |
427 | char name[L2VPN_NAME_LEN]; |
428 | int type; | |
429 | int pw_type; | |
430 | int mtu; | |
431 | char br_ifname[IF_NAMESIZE]; | |
432 | unsigned int br_ifindex; | |
029c1958 | 433 | struct l2vpn_if_head if_tree; |
20bacaeb RW |
434 | struct l2vpn_pw_head pw_tree; |
435 | struct l2vpn_pw_head pw_inactive_tree; | |
4af8997d | 436 | QOBJ_FIELDS |
8429abe0 | 437 | }; |
90d7e7bd RW |
438 | RB_HEAD(l2vpn_head, l2vpn); |
439 | RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare); | |
4af8997d | 440 | DECLARE_QOBJ_TYPE(l2vpn) |
8429abe0 RW |
441 | #define L2VPN_TYPE_VPWS 1 |
442 | #define L2VPN_TYPE_VPLS 2 | |
443 | ||
444 | /* ldp_conf */ | |
445 | enum ldpd_process { | |
446 | PROC_MAIN, | |
447 | PROC_LDP_ENGINE, | |
448 | PROC_LDE_ENGINE | |
449 | } ldpd_process; | |
450 | ||
0b4d8f1e RW |
451 | static const char * const log_procnames[] = { |
452 | "parent", | |
453 | "ldpe", | |
454 | "lde" | |
455 | }; | |
456 | ||
8429abe0 RW |
457 | enum socket_type { |
458 | LDP_SOCKET_DISC, | |
459 | LDP_SOCKET_EDISC, | |
460 | LDP_SOCKET_SESSION | |
461 | }; | |
462 | ||
463 | enum hello_type { | |
464 | HELLO_LINK, | |
465 | HELLO_TARGETED | |
466 | }; | |
467 | ||
468 | struct ldpd_af_conf { | |
469 | uint16_t keepalive; | |
eac6e3f0 RW |
470 | uint16_t lhello_holdtime; |
471 | uint16_t lhello_interval; | |
8429abe0 RW |
472 | uint16_t thello_holdtime; |
473 | uint16_t thello_interval; | |
474 | union ldpd_addr trans_addr; | |
45a8eba9 RW |
475 | char acl_thello_accept_from[ACL_NAMSIZ]; |
476 | char acl_label_allocate_for[ACL_NAMSIZ]; | |
477 | char acl_label_advertise_to[ACL_NAMSIZ]; | |
478 | char acl_label_advertise_for[ACL_NAMSIZ]; | |
479 | char acl_label_expnull_for[ACL_NAMSIZ]; | |
480 | char acl_label_accept_from[ACL_NAMSIZ]; | |
481 | char acl_label_accept_for[ACL_NAMSIZ]; | |
8429abe0 RW |
482 | int flags; |
483 | }; | |
484 | #define F_LDPD_AF_ENABLED 0x0001 | |
485 | #define F_LDPD_AF_THELLO_ACCEPT 0x0002 | |
486 | #define F_LDPD_AF_EXPNULL 0x0004 | |
487 | #define F_LDPD_AF_NO_GTSM 0x0008 | |
45a8eba9 | 488 | #define F_LDPD_AF_ALLOCHOSTONLY 0x0010 |
8429abe0 RW |
489 | |
490 | struct ldpd_conf { | |
491 | struct in_addr rtr_id; | |
492 | struct ldpd_af_conf ipv4; | |
493 | struct ldpd_af_conf ipv6; | |
7d3d7491 | 494 | struct iface_head iface_tree; |
7989cdba | 495 | struct tnbr_head tnbr_tree; |
76c4abd1 | 496 | struct nbrp_head nbrp_tree; |
90d7e7bd | 497 | struct l2vpn_head l2vpn_tree; |
eac6e3f0 RW |
498 | uint16_t lhello_holdtime; |
499 | uint16_t lhello_interval; | |
500 | uint16_t thello_holdtime; | |
501 | uint16_t thello_interval; | |
8429abe0 RW |
502 | uint16_t trans_pref; |
503 | int flags; | |
4af8997d | 504 | QOBJ_FIELDS |
8429abe0 | 505 | }; |
4af8997d | 506 | DECLARE_QOBJ_TYPE(ldpd_conf) |
8429abe0 RW |
507 | #define F_LDPD_NO_FIB_UPDATE 0x0001 |
508 | #define F_LDPD_DS_CISCO_INTEROP 0x0002 | |
eac6e3f0 | 509 | #define F_LDPD_ENABLED 0x0004 |
8429abe0 RW |
510 | |
511 | struct ldpd_af_global { | |
eac6e3f0 RW |
512 | struct thread *disc_ev; |
513 | struct thread *edisc_ev; | |
8429abe0 RW |
514 | int ldp_disc_socket; |
515 | int ldp_edisc_socket; | |
516 | int ldp_session_socket; | |
517 | }; | |
518 | ||
519 | struct ldpd_global { | |
520 | int cmd_opts; | |
dbce3582 | 521 | int sighup; |
eac6e3f0 | 522 | struct in_addr rtr_id; |
8429abe0 RW |
523 | struct ldpd_af_global ipv4; |
524 | struct ldpd_af_global ipv6; | |
525 | uint32_t conf_seqnum; | |
526 | int pfkeysock; | |
527 | struct if_addr_head addr_list; | |
057d48bd | 528 | struct global_adj_head adj_tree; |
8429abe0 RW |
529 | struct in_addr mcast_addr_v4; |
530 | struct in6_addr mcast_addr_v6; | |
531 | TAILQ_HEAD(, pending_conn) pending_conns; | |
532 | }; | |
533 | ||
534 | /* kroute */ | |
535 | struct kroute { | |
536 | int af; | |
537 | union ldpd_addr prefix; | |
538 | uint8_t prefixlen; | |
539 | union ldpd_addr nexthop; | |
540 | uint32_t local_label; | |
541 | uint32_t remote_label; | |
542 | unsigned short ifindex; | |
543 | uint8_t priority; | |
544 | uint16_t flags; | |
545 | }; | |
546 | ||
547 | struct kpw { | |
548 | unsigned short ifindex; | |
549 | int pw_type; | |
550 | int af; | |
551 | union ldpd_addr nexthop; | |
552 | uint32_t local_label; | |
553 | uint32_t remote_label; | |
554 | uint8_t flags; | |
555 | }; | |
556 | ||
557 | struct kaddr { | |
9cf67225 | 558 | char ifname[IF_NAMESIZE]; |
8429abe0 RW |
559 | unsigned short ifindex; |
560 | int af; | |
561 | union ldpd_addr addr; | |
562 | uint8_t prefixlen; | |
563 | union ldpd_addr dstbrd; | |
564 | }; | |
565 | ||
566 | struct kif { | |
567 | char ifname[IF_NAMESIZE]; | |
568 | unsigned short ifindex; | |
569 | int flags; | |
988ded8d | 570 | int operative; |
26519d8c | 571 | uint8_t mac[ETHER_ADDR_LEN]; |
8429abe0 | 572 | int mtu; |
8429abe0 RW |
573 | }; |
574 | ||
45a8eba9 RW |
575 | struct acl_check { |
576 | char acl[ACL_NAMSIZ]; | |
577 | int af; | |
578 | union ldpd_addr addr; | |
579 | uint8_t prefixlen; | |
580 | }; | |
581 | ||
8429abe0 RW |
582 | /* control data structures */ |
583 | struct ctl_iface { | |
584 | int af; | |
585 | char name[IF_NAMESIZE]; | |
586 | unsigned int ifindex; | |
587 | int state; | |
8429abe0 | 588 | enum iface_type type; |
8429abe0 RW |
589 | uint16_t hello_holdtime; |
590 | uint16_t hello_interval; | |
591 | time_t uptime; | |
592 | uint16_t adj_cnt; | |
593 | }; | |
594 | ||
eac6e3f0 RW |
595 | struct ctl_disc_if { |
596 | char name[IF_NAMESIZE]; | |
597 | int active_v4; | |
598 | int active_v6; | |
599 | int no_adj; | |
600 | }; | |
601 | ||
602 | struct ctl_disc_tnbr { | |
603 | int af; | |
604 | union ldpd_addr addr; | |
605 | int no_adj; | |
606 | }; | |
607 | ||
8429abe0 RW |
608 | struct ctl_adj { |
609 | int af; | |
610 | struct in_addr id; | |
611 | enum hello_type type; | |
612 | char ifname[IF_NAMESIZE]; | |
613 | union ldpd_addr src_addr; | |
614 | uint16_t holdtime; | |
0f7b5df9 | 615 | uint16_t holdtime_remaining; |
8429abe0 | 616 | union ldpd_addr trans_addr; |
0f7b5df9 | 617 | int ds_tlv; |
8429abe0 RW |
618 | }; |
619 | ||
620 | struct ctl_nbr { | |
621 | int af; | |
622 | struct in_addr id; | |
623 | union ldpd_addr laddr; | |
eac6e3f0 | 624 | in_port_t lport; |
8429abe0 | 625 | union ldpd_addr raddr; |
eac6e3f0 | 626 | in_port_t rport; |
0f7b5df9 | 627 | enum auth_method auth_method; |
eac6e3f0 | 628 | uint16_t holdtime; |
8429abe0 RW |
629 | time_t uptime; |
630 | int nbr_state; | |
0f7b5df9 | 631 | struct ldp_stats stats; |
99cfc17f | 632 | int flags; |
8429abe0 RW |
633 | }; |
634 | ||
635 | struct ctl_rt { | |
636 | int af; | |
637 | union ldpd_addr prefix; | |
638 | uint8_t prefixlen; | |
639 | struct in_addr nexthop; /* lsr-id */ | |
640 | uint32_t local_label; | |
641 | uint32_t remote_label; | |
642 | uint8_t flags; | |
643 | uint8_t in_use; | |
0f7b5df9 | 644 | int no_downstream; |
8429abe0 RW |
645 | }; |
646 | ||
647 | struct ctl_pw { | |
648 | uint16_t type; | |
eac6e3f0 | 649 | char l2vpn_name[L2VPN_NAME_LEN]; |
8429abe0 RW |
650 | char ifname[IF_NAMESIZE]; |
651 | uint32_t pwid; | |
652 | struct in_addr lsr_id; | |
653 | uint32_t local_label; | |
654 | uint32_t local_gid; | |
655 | uint16_t local_ifmtu; | |
eac6e3f0 | 656 | uint8_t local_cword; |
8429abe0 RW |
657 | uint32_t remote_label; |
658 | uint32_t remote_gid; | |
659 | uint16_t remote_ifmtu; | |
eac6e3f0 | 660 | uint8_t remote_cword; |
8429abe0 RW |
661 | uint32_t status; |
662 | }; | |
663 | ||
56b8a8d2 | 664 | extern struct ldpd_conf *ldpd_conf, *vty_conf; |
8429abe0 | 665 | extern struct ldpd_global global; |
e75f810c | 666 | extern struct ldpd_init init; |
8429abe0 RW |
667 | |
668 | /* parse.y */ | |
669 | struct ldpd_conf *parse_config(char *); | |
670 | int cmdline_symset(char *); | |
671 | ||
672 | /* kroute.c */ | |
8429abe0 RW |
673 | void kif_redistribute(const char *); |
674 | int kr_change(struct kroute *); | |
675 | int kr_delete(struct kroute *); | |
8429abe0 RW |
676 | int kmpw_set(struct kpw *); |
677 | int kmpw_unset(struct kpw *); | |
678 | ||
679 | /* util.c */ | |
680 | uint8_t mask2prefixlen(in_addr_t); | |
681 | uint8_t mask2prefixlen6(struct sockaddr_in6 *); | |
682 | in_addr_t prefixlen2mask(uint8_t); | |
683 | struct in6_addr *prefixlen2mask6(uint8_t); | |
684 | void ldp_applymask(int, union ldpd_addr *, | |
685 | const union ldpd_addr *, int); | |
686 | int ldp_addrcmp(int, const union ldpd_addr *, | |
687 | const union ldpd_addr *); | |
688 | int ldp_addrisset(int, const union ldpd_addr *); | |
689 | int ldp_prefixcmp(int, const union ldpd_addr *, | |
690 | const union ldpd_addr *, uint8_t); | |
691 | int bad_addr_v4(struct in_addr); | |
692 | int bad_addr_v6(struct in6_addr *); | |
693 | int bad_addr(int, union ldpd_addr *); | |
694 | void embedscope(struct sockaddr_in6 *); | |
695 | void recoverscope(struct sockaddr_in6 *); | |
696 | void addscope(struct sockaddr_in6 *, uint32_t); | |
697 | void clearscope(struct in6_addr *); | |
698 | struct sockaddr *addr2sa(int af, union ldpd_addr *, uint16_t); | |
eac6e3f0 RW |
699 | void sa2addr(struct sockaddr *, int *, union ldpd_addr *, |
700 | in_port_t *); | |
701 | socklen_t sockaddr_len(struct sockaddr *); | |
8429abe0 RW |
702 | |
703 | /* ldpd.c */ | |
eac6e3f0 | 704 | int ldp_write_handler(struct thread *); |
8429abe0 RW |
705 | void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t); |
706 | void main_imsg_compose_lde(int, pid_t, void *, uint16_t); | |
eac6e3f0 RW |
707 | int main_imsg_compose_both(enum imsg_type, void *, |
708 | uint16_t); | |
8429abe0 | 709 | void imsg_event_add(struct imsgev *); |
eac6e3f0 RW |
710 | int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, |
711 | pid_t, int, void *, uint16_t); | |
8429abe0 RW |
712 | void evbuf_enqueue(struct evbuf *, struct ibuf *); |
713 | void evbuf_event_add(struct evbuf *); | |
eac6e3f0 RW |
714 | void evbuf_init(struct evbuf *, int, |
715 | int (*)(struct thread *), void *); | |
8429abe0 | 716 | void evbuf_clear(struct evbuf *); |
45a8eba9 RW |
717 | int ldp_acl_request(struct imsgev *, char *, int, |
718 | union ldpd_addr *, uint8_t); | |
719 | void ldp_acl_reply(struct imsgev *, struct acl_check *); | |
8429abe0 RW |
720 | struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int); |
721 | struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int); | |
722 | int ldp_is_dual_stack(struct ldpd_conf *); | |
eac6e3f0 RW |
723 | in_addr_t ldp_rtr_id_get(struct ldpd_conf *); |
724 | int ldp_reload(struct ldpd_conf *); | |
eac6e3f0 | 725 | void ldp_clear_config(struct ldpd_conf *); |
8429abe0 RW |
726 | void merge_config(struct ldpd_conf *, struct ldpd_conf *); |
727 | struct ldpd_conf *config_new_empty(void); | |
728 | void config_clear(struct ldpd_conf *); | |
729 | ||
bbee85d2 RW |
730 | /* ldp_vty_conf.c */ |
731 | /* NOTE: the parameters' names should be preserved because of codegen */ | |
7d3d7491 | 732 | struct iface *iface_new_api(struct ldpd_conf *conf, |
bbee85d2 | 733 | const char *name); |
7d3d7491 RW |
734 | void iface_del_api(struct ldpd_conf *conf, |
735 | struct iface *iface); | |
7989cdba | 736 | struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af, |
bbee85d2 | 737 | union ldpd_addr *addr); |
7989cdba | 738 | void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr); |
76c4abd1 | 739 | struct nbr_params *nbrp_new_api(struct ldpd_conf *conf, |
bbee85d2 | 740 | struct in_addr lsr_id); |
76c4abd1 RW |
741 | void nbrp_del_api(struct ldpd_conf *conf, |
742 | struct nbr_params *nbrp); | |
90d7e7bd RW |
743 | struct l2vpn *l2vpn_new_api(struct ldpd_conf *conf, const char *name); |
744 | void l2vpn_del_api(struct ldpd_conf *conf, | |
745 | struct l2vpn *l2vpn); | |
bbee85d2 RW |
746 | struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf, |
747 | struct l2vpn *l2vpn, const char *ifname); | |
029c1958 RW |
748 | void l2vpn_if_del_api(struct l2vpn *l2vpn, |
749 | struct l2vpn_if *lif); | |
bbee85d2 RW |
750 | struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf, |
751 | struct l2vpn *l2vpn, const char *ifname); | |
20bacaeb RW |
752 | void l2vpn_pw_del_api(struct l2vpn *l2vpn, |
753 | struct l2vpn_pw *pw); | |
bbee85d2 | 754 | |
8429abe0 RW |
755 | /* socket.c */ |
756 | int ldp_create_socket(int, enum socket_type); | |
eac6e3f0 RW |
757 | void sock_set_nonblock(int); |
758 | void sock_set_cloexec(int); | |
8429abe0 RW |
759 | void sock_set_recvbuf(int); |
760 | int sock_set_reuse(int, int); | |
761 | int sock_set_bindany(int, int); | |
eac6e3f0 | 762 | int sock_set_md5sig(int, int, union ldpd_addr *, const char *); |
8429abe0 | 763 | int sock_set_ipv4_tos(int, int); |
eac6e3f0 RW |
764 | int sock_set_ipv4_pktinfo(int, int); |
765 | int sock_set_ipv4_recvdstaddr(int, int); | |
8429abe0 RW |
766 | int sock_set_ipv4_recvif(int, int); |
767 | int sock_set_ipv4_minttl(int, int); | |
768 | int sock_set_ipv4_ucast_ttl(int fd, int); | |
769 | int sock_set_ipv4_mcast_ttl(int, uint8_t); | |
770 | int sock_set_ipv4_mcast(struct iface *); | |
771 | int sock_set_ipv4_mcast_loop(int); | |
772 | int sock_set_ipv6_dscp(int, int); | |
773 | int sock_set_ipv6_pktinfo(int, int); | |
774 | int sock_set_ipv6_minhopcount(int, int); | |
775 | int sock_set_ipv6_ucast_hops(int, int); | |
776 | int sock_set_ipv6_mcast_hops(int, int); | |
777 | int sock_set_ipv6_mcast(struct iface *); | |
778 | int sock_set_ipv6_mcast_loop(int); | |
779 | ||
0b4d8f1e RW |
780 | /* logmsg.h */ |
781 | struct in6_addr; | |
782 | union ldpd_addr; | |
783 | struct hello_source; | |
784 | struct fec; | |
785 | ||
786 | const char *log_sockaddr(void *); | |
787 | const char *log_in6addr(const struct in6_addr *); | |
788 | const char *log_in6addr_scope(const struct in6_addr *, unsigned int); | |
789 | const char *log_addr(int, const union ldpd_addr *); | |
790 | char *log_label(uint32_t); | |
791 | const char *log_time(time_t); | |
792 | char *log_hello_src(const struct hello_source *); | |
793 | const char *log_map(const struct map *); | |
794 | const char *log_fec(const struct fec *); | |
795 | const char *af_name(int); | |
796 | const char *socket_name(int); | |
797 | const char *nbr_state_name(int); | |
798 | const char *if_state_name(int); | |
799 | const char *if_type_name(enum iface_type); | |
800 | const char *msg_name(uint16_t); | |
801 | const char *status_code_name(uint32_t); | |
802 | const char *pw_type_name(uint16_t); | |
803 | ||
eac6e3f0 RW |
804 | /* quagga */ |
805 | extern struct thread_master *master; | |
372b8bd3 | 806 | extern char ctl_sock_path[MAXPATHLEN]; |
eac6e3f0 RW |
807 | |
808 | /* ldp_zebra.c */ | |
64dffe25 RW |
809 | void ldp_zebra_init(struct thread_master *); |
810 | void ldp_zebra_destroy(void); | |
eac6e3f0 RW |
811 | |
812 | /* compatibility */ | |
813 | #ifndef __OpenBSD__ | |
814 | #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) | |
815 | #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 | |
816 | #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ | |
817 | (IN6_IS_ADDR_MULTICAST(a) && \ | |
818 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL)) | |
819 | #endif | |
8429abe0 RW |
820 | |
821 | #endif /* _LDPD_H_ */ |