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