]>
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" | |
8429abe0 RW |
29 | |
30 | #include "ldp.h" | |
31 | ||
32 | #define CONF_FILE "/etc/ldpd.conf" | |
8429abe0 RW |
33 | #define LDPD_USER "_ldpd" |
34 | ||
35 | #define LDPD_OPT_VERBOSE 0x00000001 | |
36 | #define LDPD_OPT_VERBOSE2 0x00000002 | |
37 | #define LDPD_OPT_NOACTION 0x00000004 | |
38 | ||
39 | #define TCP_MD5_KEY_LEN 80 | |
40 | #define L2VPN_NAME_LEN 32 | |
41 | ||
42 | #define RT_BUF_SIZE 16384 | |
43 | #define MAX_RTSOCK_BUF 128 * 1024 | |
44 | #define LDP_BACKLOG 128 | |
45 | ||
46 | #define F_LDPD_INSERTED 0x0001 | |
47 | #define F_CONNECTED 0x0002 | |
48 | #define F_STATIC 0x0004 | |
49 | #define F_DYNAMIC 0x0008 | |
50 | #define F_REJECT 0x0010 | |
51 | #define F_BLACKHOLE 0x0020 | |
52 | #define F_REDISTRIBUTED 0x0040 | |
53 | ||
54 | struct evbuf { | |
eac6e3f0 RW |
55 | struct msgbuf wbuf; |
56 | struct thread *ev; | |
57 | int (*handler)(struct thread *); | |
58 | void *arg; | |
8429abe0 RW |
59 | }; |
60 | ||
61 | struct imsgev { | |
62 | struct imsgbuf ibuf; | |
eac6e3f0 RW |
63 | int (*handler_write)(struct thread *); |
64 | struct thread *ev_write; | |
65 | int (*handler_read)(struct thread *); | |
66 | struct thread *ev_read; | |
8429abe0 RW |
67 | }; |
68 | ||
69 | enum imsg_type { | |
70 | IMSG_NONE, | |
71 | IMSG_CTL_RELOAD, | |
72 | IMSG_CTL_SHOW_INTERFACE, | |
73 | IMSG_CTL_SHOW_DISCOVERY, | |
eac6e3f0 RW |
74 | IMSG_CTL_SHOW_DISC_IFACE, |
75 | IMSG_CTL_SHOW_DISC_TNBR, | |
76 | IMSG_CTL_SHOW_DISC_ADJ, | |
8429abe0 | 77 | IMSG_CTL_SHOW_NBR, |
eac6e3f0 RW |
78 | IMSG_CTL_SHOW_NBR_DISC, |
79 | IMSG_CTL_SHOW_NBR_END, | |
8429abe0 RW |
80 | IMSG_CTL_SHOW_LIB, |
81 | IMSG_CTL_SHOW_L2VPN_PW, | |
82 | IMSG_CTL_SHOW_L2VPN_BINDING, | |
83 | IMSG_CTL_CLEAR_NBR, | |
84 | IMSG_CTL_FIB_COUPLE, | |
85 | IMSG_CTL_FIB_DECOUPLE, | |
86 | IMSG_CTL_KROUTE, | |
87 | IMSG_CTL_KROUTE_ADDR, | |
88 | IMSG_CTL_IFINFO, | |
89 | IMSG_CTL_END, | |
90 | IMSG_CTL_LOG_VERBOSE, | |
91 | IMSG_KLABEL_CHANGE, | |
92 | IMSG_KLABEL_DELETE, | |
93 | IMSG_KPWLABEL_CHANGE, | |
94 | IMSG_KPWLABEL_DELETE, | |
95 | IMSG_IFSTATUS, | |
96 | IMSG_NEWADDR, | |
97 | IMSG_DELADDR, | |
eac6e3f0 | 98 | IMSG_RTRID_UPDATE, |
8429abe0 RW |
99 | IMSG_LABEL_MAPPING, |
100 | IMSG_LABEL_MAPPING_FULL, | |
101 | IMSG_LABEL_REQUEST, | |
102 | IMSG_LABEL_RELEASE, | |
103 | IMSG_LABEL_WITHDRAW, | |
104 | IMSG_LABEL_ABORT, | |
105 | IMSG_REQUEST_ADD, | |
106 | IMSG_REQUEST_ADD_END, | |
107 | IMSG_MAPPING_ADD, | |
108 | IMSG_MAPPING_ADD_END, | |
109 | IMSG_RELEASE_ADD, | |
110 | IMSG_RELEASE_ADD_END, | |
111 | IMSG_WITHDRAW_ADD, | |
112 | IMSG_WITHDRAW_ADD_END, | |
113 | IMSG_ADDRESS_ADD, | |
114 | IMSG_ADDRESS_DEL, | |
115 | IMSG_NOTIFICATION, | |
116 | IMSG_NOTIFICATION_SEND, | |
117 | IMSG_NEIGHBOR_UP, | |
118 | IMSG_NEIGHBOR_DOWN, | |
119 | IMSG_NETWORK_ADD, | |
120 | IMSG_NETWORK_DEL, | |
121 | IMSG_SOCKET_IPC, | |
122 | IMSG_SOCKET_NET, | |
123 | IMSG_CLOSE_SOCKETS, | |
124 | IMSG_REQUEST_SOCKETS, | |
125 | IMSG_SETUP_SOCKETS, | |
126 | IMSG_RECONF_CONF, | |
127 | IMSG_RECONF_IFACE, | |
128 | IMSG_RECONF_TNBR, | |
129 | IMSG_RECONF_NBRP, | |
130 | IMSG_RECONF_L2VPN, | |
131 | IMSG_RECONF_L2VPN_IF, | |
132 | IMSG_RECONF_L2VPN_PW, | |
eac6e3f0 RW |
133 | IMSG_RECONF_L2VPN_IPW, |
134 | IMSG_RECONF_END, | |
135 | IMSG_DEBUG_UPDATE, | |
136 | IMSG_LOG | |
8429abe0 RW |
137 | }; |
138 | ||
139 | union ldpd_addr { | |
140 | struct in_addr v4; | |
141 | struct in6_addr v6; | |
142 | }; | |
143 | ||
144 | #define IN6_IS_SCOPE_EMBED(a) \ | |
145 | ((IN6_IS_ADDR_LINKLOCAL(a)) || \ | |
146 | (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \ | |
147 | (IN6_IS_ADDR_MC_INTFACELOCAL(a))) | |
148 | ||
149 | /* interface states */ | |
150 | #define IF_STA_DOWN 0x01 | |
151 | #define IF_STA_ACTIVE 0x02 | |
152 | ||
153 | /* targeted neighbor states */ | |
154 | #define TNBR_STA_DOWN 0x01 | |
155 | #define TNBR_STA_ACTIVE 0x02 | |
156 | ||
157 | /* interface types */ | |
158 | enum iface_type { | |
159 | IF_TYPE_POINTOPOINT, | |
160 | IF_TYPE_BROADCAST | |
161 | }; | |
162 | ||
163 | /* neighbor states */ | |
164 | #define NBR_STA_PRESENT 0x0001 | |
165 | #define NBR_STA_INITIAL 0x0002 | |
166 | #define NBR_STA_OPENREC 0x0004 | |
167 | #define NBR_STA_OPENSENT 0x0008 | |
168 | #define NBR_STA_OPER 0x0010 | |
169 | #define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \ | |
170 | NBR_STA_OPENSENT | NBR_STA_OPER) | |
171 | ||
172 | /* neighbor events */ | |
173 | enum nbr_event { | |
174 | NBR_EVT_NOTHING, | |
175 | NBR_EVT_MATCH_ADJ, | |
176 | NBR_EVT_CONNECT_UP, | |
177 | NBR_EVT_CLOSE_SESSION, | |
178 | NBR_EVT_INIT_RCVD, | |
179 | NBR_EVT_KEEPALIVE_RCVD, | |
180 | NBR_EVT_PDU_RCVD, | |
181 | NBR_EVT_PDU_SENT, | |
182 | NBR_EVT_INIT_SENT | |
183 | }; | |
184 | ||
185 | /* neighbor actions */ | |
186 | enum nbr_action { | |
187 | NBR_ACT_NOTHING, | |
188 | NBR_ACT_RST_KTIMEOUT, | |
189 | NBR_ACT_SESSION_EST, | |
190 | NBR_ACT_RST_KTIMER, | |
191 | NBR_ACT_CONNECT_SETUP, | |
192 | NBR_ACT_PASSIVE_INIT, | |
193 | NBR_ACT_KEEPALIVE_SEND, | |
194 | NBR_ACT_CLOSE_SESSION | |
195 | }; | |
196 | ||
197 | TAILQ_HEAD(mapping_head, mapping_entry); | |
198 | ||
199 | struct map { | |
200 | uint8_t type; | |
201 | uint32_t msg_id; | |
202 | union { | |
203 | struct { | |
204 | uint16_t af; | |
205 | union ldpd_addr prefix; | |
206 | uint8_t prefixlen; | |
207 | } prefix; | |
208 | struct { | |
209 | uint16_t type; | |
210 | uint32_t pwid; | |
211 | uint32_t group_id; | |
212 | uint16_t ifmtu; | |
213 | } pwid; | |
214 | } fec; | |
215 | struct { | |
216 | uint32_t status_code; | |
217 | uint32_t msg_id; | |
218 | uint16_t msg_type; | |
219 | } st; | |
220 | uint32_t label; | |
221 | uint32_t requestid; | |
222 | uint32_t pw_status; | |
223 | uint8_t flags; | |
224 | }; | |
225 | #define F_MAP_REQ_ID 0x01 /* optional request message id present */ | |
226 | #define F_MAP_STATUS 0x02 /* status */ | |
227 | #define F_MAP_PW_CWORD 0x04 /* pseudowire control word */ | |
228 | #define F_MAP_PW_ID 0x08 /* pseudowire connection id */ | |
229 | #define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */ | |
230 | #define F_MAP_PW_STATUS 0x20 /* pseudowire status */ | |
231 | ||
232 | struct notify_msg { | |
233 | uint32_t status_code; | |
234 | uint32_t msg_id; /* network byte order */ | |
235 | uint16_t msg_type; /* network byte order */ | |
236 | uint32_t pw_status; | |
237 | struct map fec; | |
238 | uint8_t flags; | |
239 | }; | |
240 | #define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */ | |
241 | #define F_NOTIF_FEC 0x02 /* fec tlv present */ | |
242 | ||
243 | struct if_addr { | |
244 | LIST_ENTRY(if_addr) entry; | |
245 | int af; | |
246 | union ldpd_addr addr; | |
247 | uint8_t prefixlen; | |
248 | union ldpd_addr dstbrd; | |
249 | }; | |
250 | LIST_HEAD(if_addr_head, if_addr); | |
251 | ||
252 | struct iface_af { | |
253 | struct iface *iface; | |
254 | int af; | |
255 | int enabled; | |
256 | int state; | |
257 | LIST_HEAD(, adj) adj_list; | |
258 | time_t uptime; | |
eac6e3f0 | 259 | struct thread *hello_timer; |
8429abe0 RW |
260 | uint16_t hello_holdtime; |
261 | uint16_t hello_interval; | |
262 | }; | |
263 | ||
264 | struct iface { | |
265 | LIST_ENTRY(iface) entry; | |
266 | char name[IF_NAMESIZE]; | |
267 | unsigned int ifindex; | |
268 | struct if_addr_head addr_list; | |
269 | struct in6_addr linklocal; | |
270 | enum iface_type type; | |
8429abe0 | 271 | uint16_t flags; |
8429abe0 RW |
272 | struct iface_af ipv4; |
273 | struct iface_af ipv6; | |
274 | }; | |
275 | ||
276 | /* source of targeted hellos */ | |
277 | struct tnbr { | |
278 | LIST_ENTRY(tnbr) entry; | |
eac6e3f0 | 279 | struct thread *hello_timer; |
8429abe0 RW |
280 | struct adj *adj; |
281 | int af; | |
282 | union ldpd_addr addr; | |
283 | int state; | |
8429abe0 RW |
284 | uint16_t pw_count; |
285 | uint8_t flags; | |
286 | }; | |
287 | #define F_TNBR_CONFIGURED 0x01 | |
288 | #define F_TNBR_DYNAMIC 0x02 | |
289 | ||
290 | enum auth_method { | |
291 | AUTH_NONE, | |
292 | AUTH_MD5SIG | |
293 | }; | |
294 | ||
295 | /* neighbor specific parameters */ | |
296 | struct nbr_params { | |
297 | LIST_ENTRY(nbr_params) entry; | |
298 | struct in_addr lsr_id; | |
299 | uint16_t keepalive; | |
300 | int gtsm_enabled; | |
301 | uint8_t gtsm_hops; | |
302 | struct { | |
303 | enum auth_method method; | |
304 | char md5key[TCP_MD5_KEY_LEN]; | |
305 | uint8_t md5key_len; | |
306 | } auth; | |
307 | uint8_t flags; | |
308 | }; | |
309 | #define F_NBRP_KEEPALIVE 0x01 | |
310 | #define F_NBRP_GTSM 0x02 | |
311 | #define F_NBRP_GTSM_HOPS 0x04 | |
312 | ||
313 | struct l2vpn_if { | |
314 | LIST_ENTRY(l2vpn_if) entry; | |
315 | struct l2vpn *l2vpn; | |
316 | char ifname[IF_NAMESIZE]; | |
317 | unsigned int ifindex; | |
318 | uint16_t flags; | |
8429abe0 RW |
319 | }; |
320 | ||
321 | struct l2vpn_pw { | |
322 | LIST_ENTRY(l2vpn_pw) entry; | |
323 | struct l2vpn *l2vpn; | |
324 | struct in_addr lsr_id; | |
325 | int af; | |
326 | union ldpd_addr addr; | |
327 | uint32_t pwid; | |
328 | char ifname[IF_NAMESIZE]; | |
329 | unsigned int ifindex; | |
330 | uint32_t remote_group; | |
331 | uint16_t remote_mtu; | |
332 | uint32_t remote_status; | |
333 | uint8_t flags; | |
334 | }; | |
335 | #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */ | |
336 | #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */ | |
337 | #define F_PW_CWORD_CONF 0x04 /* control word configured */ | |
338 | #define F_PW_CWORD 0x08 /* control word negotiated */ | |
339 | #define F_PW_STATUS_UP 0x10 /* pseudowire is operational */ | |
eac6e3f0 | 340 | #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */ |
8429abe0 RW |
341 | |
342 | struct l2vpn { | |
343 | LIST_ENTRY(l2vpn) entry; | |
344 | char name[L2VPN_NAME_LEN]; | |
345 | int type; | |
346 | int pw_type; | |
347 | int mtu; | |
348 | char br_ifname[IF_NAMESIZE]; | |
349 | unsigned int br_ifindex; | |
350 | LIST_HEAD(, l2vpn_if) if_list; | |
351 | LIST_HEAD(, l2vpn_pw) pw_list; | |
eac6e3f0 | 352 | LIST_HEAD(, l2vpn_pw) pw_inactive_list; |
8429abe0 RW |
353 | }; |
354 | #define L2VPN_TYPE_VPWS 1 | |
355 | #define L2VPN_TYPE_VPLS 2 | |
356 | ||
357 | /* ldp_conf */ | |
358 | enum ldpd_process { | |
359 | PROC_MAIN, | |
360 | PROC_LDP_ENGINE, | |
361 | PROC_LDE_ENGINE | |
362 | } ldpd_process; | |
363 | ||
364 | enum socket_type { | |
365 | LDP_SOCKET_DISC, | |
366 | LDP_SOCKET_EDISC, | |
367 | LDP_SOCKET_SESSION | |
368 | }; | |
369 | ||
370 | enum hello_type { | |
371 | HELLO_LINK, | |
372 | HELLO_TARGETED | |
373 | }; | |
374 | ||
375 | struct ldpd_af_conf { | |
376 | uint16_t keepalive; | |
eac6e3f0 RW |
377 | uint16_t lhello_holdtime; |
378 | uint16_t lhello_interval; | |
8429abe0 RW |
379 | uint16_t thello_holdtime; |
380 | uint16_t thello_interval; | |
381 | union ldpd_addr trans_addr; | |
382 | int flags; | |
383 | }; | |
384 | #define F_LDPD_AF_ENABLED 0x0001 | |
385 | #define F_LDPD_AF_THELLO_ACCEPT 0x0002 | |
386 | #define F_LDPD_AF_EXPNULL 0x0004 | |
387 | #define F_LDPD_AF_NO_GTSM 0x0008 | |
388 | ||
389 | struct ldpd_conf { | |
390 | struct in_addr rtr_id; | |
391 | struct ldpd_af_conf ipv4; | |
392 | struct ldpd_af_conf ipv6; | |
393 | LIST_HEAD(, iface) iface_list; | |
394 | LIST_HEAD(, tnbr) tnbr_list; | |
395 | LIST_HEAD(, nbr_params) nbrp_list; | |
396 | LIST_HEAD(, l2vpn) l2vpn_list; | |
eac6e3f0 RW |
397 | uint16_t lhello_holdtime; |
398 | uint16_t lhello_interval; | |
399 | uint16_t thello_holdtime; | |
400 | uint16_t thello_interval; | |
8429abe0 RW |
401 | uint16_t trans_pref; |
402 | int flags; | |
403 | }; | |
404 | #define F_LDPD_NO_FIB_UPDATE 0x0001 | |
405 | #define F_LDPD_DS_CISCO_INTEROP 0x0002 | |
eac6e3f0 | 406 | #define F_LDPD_ENABLED 0x0004 |
8429abe0 RW |
407 | |
408 | struct ldpd_af_global { | |
eac6e3f0 RW |
409 | struct thread *disc_ev; |
410 | struct thread *edisc_ev; | |
8429abe0 RW |
411 | int ldp_disc_socket; |
412 | int ldp_edisc_socket; | |
413 | int ldp_session_socket; | |
414 | }; | |
415 | ||
416 | struct ldpd_global { | |
417 | int cmd_opts; | |
418 | time_t uptime; | |
eac6e3f0 | 419 | struct in_addr rtr_id; |
8429abe0 RW |
420 | struct ldpd_af_global ipv4; |
421 | struct ldpd_af_global ipv6; | |
422 | uint32_t conf_seqnum; | |
423 | int pfkeysock; | |
424 | struct if_addr_head addr_list; | |
425 | LIST_HEAD(, adj) adj_list; | |
426 | struct in_addr mcast_addr_v4; | |
427 | struct in6_addr mcast_addr_v6; | |
428 | TAILQ_HEAD(, pending_conn) pending_conns; | |
429 | }; | |
430 | ||
431 | /* kroute */ | |
432 | struct kroute { | |
433 | int af; | |
434 | union ldpd_addr prefix; | |
435 | uint8_t prefixlen; | |
436 | union ldpd_addr nexthop; | |
437 | uint32_t local_label; | |
438 | uint32_t remote_label; | |
439 | unsigned short ifindex; | |
440 | uint8_t priority; | |
441 | uint16_t flags; | |
442 | }; | |
443 | ||
444 | struct kpw { | |
445 | unsigned short ifindex; | |
446 | int pw_type; | |
447 | int af; | |
448 | union ldpd_addr nexthop; | |
449 | uint32_t local_label; | |
450 | uint32_t remote_label; | |
451 | uint8_t flags; | |
452 | }; | |
453 | ||
454 | struct kaddr { | |
455 | unsigned short ifindex; | |
456 | int af; | |
457 | union ldpd_addr addr; | |
458 | uint8_t prefixlen; | |
459 | union ldpd_addr dstbrd; | |
460 | }; | |
461 | ||
462 | struct kif { | |
463 | char ifname[IF_NAMESIZE]; | |
464 | unsigned short ifindex; | |
465 | int flags; | |
8429abe0 | 466 | int mtu; |
8429abe0 RW |
467 | }; |
468 | ||
469 | /* control data structures */ | |
470 | struct ctl_iface { | |
471 | int af; | |
472 | char name[IF_NAMESIZE]; | |
473 | unsigned int ifindex; | |
474 | int state; | |
475 | uint16_t flags; | |
8429abe0 | 476 | enum iface_type type; |
8429abe0 RW |
477 | uint16_t hello_holdtime; |
478 | uint16_t hello_interval; | |
479 | time_t uptime; | |
480 | uint16_t adj_cnt; | |
481 | }; | |
482 | ||
eac6e3f0 RW |
483 | struct ctl_disc_if { |
484 | char name[IF_NAMESIZE]; | |
485 | int active_v4; | |
486 | int active_v6; | |
487 | int no_adj; | |
488 | }; | |
489 | ||
490 | struct ctl_disc_tnbr { | |
491 | int af; | |
492 | union ldpd_addr addr; | |
493 | int no_adj; | |
494 | }; | |
495 | ||
8429abe0 RW |
496 | struct ctl_adj { |
497 | int af; | |
498 | struct in_addr id; | |
499 | enum hello_type type; | |
500 | char ifname[IF_NAMESIZE]; | |
501 | union ldpd_addr src_addr; | |
502 | uint16_t holdtime; | |
503 | union ldpd_addr trans_addr; | |
504 | }; | |
505 | ||
506 | struct ctl_nbr { | |
507 | int af; | |
508 | struct in_addr id; | |
509 | union ldpd_addr laddr; | |
eac6e3f0 | 510 | in_port_t lport; |
8429abe0 | 511 | union ldpd_addr raddr; |
eac6e3f0 RW |
512 | in_port_t rport; |
513 | uint16_t holdtime; | |
8429abe0 RW |
514 | time_t uptime; |
515 | int nbr_state; | |
516 | }; | |
517 | ||
518 | struct ctl_rt { | |
519 | int af; | |
520 | union ldpd_addr prefix; | |
521 | uint8_t prefixlen; | |
522 | struct in_addr nexthop; /* lsr-id */ | |
523 | uint32_t local_label; | |
524 | uint32_t remote_label; | |
525 | uint8_t flags; | |
526 | uint8_t in_use; | |
eac6e3f0 | 527 | int first; |
8429abe0 RW |
528 | }; |
529 | ||
530 | struct ctl_pw { | |
531 | uint16_t type; | |
eac6e3f0 | 532 | char l2vpn_name[L2VPN_NAME_LEN]; |
8429abe0 RW |
533 | char ifname[IF_NAMESIZE]; |
534 | uint32_t pwid; | |
535 | struct in_addr lsr_id; | |
536 | uint32_t local_label; | |
537 | uint32_t local_gid; | |
538 | uint16_t local_ifmtu; | |
eac6e3f0 | 539 | uint8_t local_cword; |
8429abe0 RW |
540 | uint32_t remote_label; |
541 | uint32_t remote_gid; | |
542 | uint16_t remote_ifmtu; | |
eac6e3f0 | 543 | uint8_t remote_cword; |
8429abe0 RW |
544 | uint32_t status; |
545 | }; | |
546 | ||
547 | extern struct ldpd_conf *ldpd_conf; | |
548 | extern struct ldpd_global global; | |
549 | ||
550 | /* parse.y */ | |
551 | struct ldpd_conf *parse_config(char *); | |
552 | int cmdline_symset(char *); | |
553 | ||
554 | /* kroute.c */ | |
8429abe0 RW |
555 | void kif_redistribute(const char *); |
556 | int kr_change(struct kroute *); | |
557 | int kr_delete(struct kroute *); | |
8429abe0 RW |
558 | int kmpw_set(struct kpw *); |
559 | int kmpw_unset(struct kpw *); | |
560 | ||
561 | /* util.c */ | |
562 | uint8_t mask2prefixlen(in_addr_t); | |
563 | uint8_t mask2prefixlen6(struct sockaddr_in6 *); | |
564 | in_addr_t prefixlen2mask(uint8_t); | |
565 | struct in6_addr *prefixlen2mask6(uint8_t); | |
566 | void ldp_applymask(int, union ldpd_addr *, | |
567 | const union ldpd_addr *, int); | |
568 | int ldp_addrcmp(int, const union ldpd_addr *, | |
569 | const union ldpd_addr *); | |
570 | int ldp_addrisset(int, const union ldpd_addr *); | |
571 | int ldp_prefixcmp(int, const union ldpd_addr *, | |
572 | const union ldpd_addr *, uint8_t); | |
573 | int bad_addr_v4(struct in_addr); | |
574 | int bad_addr_v6(struct in6_addr *); | |
575 | int bad_addr(int, union ldpd_addr *); | |
576 | void embedscope(struct sockaddr_in6 *); | |
577 | void recoverscope(struct sockaddr_in6 *); | |
578 | void addscope(struct sockaddr_in6 *, uint32_t); | |
579 | void clearscope(struct in6_addr *); | |
580 | struct sockaddr *addr2sa(int af, union ldpd_addr *, uint16_t); | |
eac6e3f0 RW |
581 | void sa2addr(struct sockaddr *, int *, union ldpd_addr *, |
582 | in_port_t *); | |
583 | socklen_t sockaddr_len(struct sockaddr *); | |
8429abe0 RW |
584 | |
585 | /* ldpd.c */ | |
eac6e3f0 | 586 | int ldp_write_handler(struct thread *); |
8429abe0 RW |
587 | void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t); |
588 | void main_imsg_compose_lde(int, pid_t, void *, uint16_t); | |
eac6e3f0 RW |
589 | int main_imsg_compose_both(enum imsg_type, void *, |
590 | uint16_t); | |
8429abe0 | 591 | void imsg_event_add(struct imsgev *); |
eac6e3f0 RW |
592 | int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, |
593 | pid_t, int, void *, uint16_t); | |
8429abe0 RW |
594 | void evbuf_enqueue(struct evbuf *, struct ibuf *); |
595 | void evbuf_event_add(struct evbuf *); | |
eac6e3f0 RW |
596 | void evbuf_init(struct evbuf *, int, |
597 | int (*)(struct thread *), void *); | |
8429abe0 RW |
598 | void evbuf_clear(struct evbuf *); |
599 | struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int); | |
600 | struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int); | |
601 | int ldp_is_dual_stack(struct ldpd_conf *); | |
eac6e3f0 RW |
602 | in_addr_t ldp_rtr_id_get(struct ldpd_conf *); |
603 | int ldp_reload(struct ldpd_conf *); | |
604 | struct ldpd_conf *ldp_dup_config(struct ldpd_conf *); | |
605 | void ldp_clear_config(struct ldpd_conf *); | |
8429abe0 RW |
606 | void merge_config(struct ldpd_conf *, struct ldpd_conf *); |
607 | struct ldpd_conf *config_new_empty(void); | |
608 | void config_clear(struct ldpd_conf *); | |
609 | ||
610 | /* socket.c */ | |
611 | int ldp_create_socket(int, enum socket_type); | |
eac6e3f0 RW |
612 | void sock_set_nonblock(int); |
613 | void sock_set_cloexec(int); | |
8429abe0 RW |
614 | void sock_set_recvbuf(int); |
615 | int sock_set_reuse(int, int); | |
616 | int sock_set_bindany(int, int); | |
eac6e3f0 | 617 | int sock_set_md5sig(int, int, union ldpd_addr *, const char *); |
8429abe0 | 618 | int sock_set_ipv4_tos(int, int); |
eac6e3f0 RW |
619 | int sock_set_ipv4_pktinfo(int, int); |
620 | int sock_set_ipv4_recvdstaddr(int, int); | |
8429abe0 RW |
621 | int sock_set_ipv4_recvif(int, int); |
622 | int sock_set_ipv4_minttl(int, int); | |
623 | int sock_set_ipv4_ucast_ttl(int fd, int); | |
624 | int sock_set_ipv4_mcast_ttl(int, uint8_t); | |
625 | int sock_set_ipv4_mcast(struct iface *); | |
626 | int sock_set_ipv4_mcast_loop(int); | |
627 | int sock_set_ipv6_dscp(int, int); | |
628 | int sock_set_ipv6_pktinfo(int, int); | |
629 | int sock_set_ipv6_minhopcount(int, int); | |
630 | int sock_set_ipv6_ucast_hops(int, int); | |
631 | int sock_set_ipv6_mcast_hops(int, int); | |
632 | int sock_set_ipv6_mcast(struct iface *); | |
633 | int sock_set_ipv6_mcast_loop(int); | |
634 | ||
eac6e3f0 RW |
635 | /* quagga */ |
636 | extern struct thread_master *master; | |
637 | ||
638 | /* ldp_zebra.c */ | |
639 | void ldp_zebra_init(struct thread_master *); | |
640 | ||
641 | /* compatibility */ | |
642 | #ifndef __OpenBSD__ | |
643 | #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) | |
644 | #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 | |
645 | #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ | |
646 | (IN6_IS_ADDR_MULTICAST(a) && \ | |
647 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL)) | |
648 | #endif | |
8429abe0 RW |
649 | |
650 | #endif /* _LDPD_H_ */ |