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