]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldpd.h
Merge pull request #916 from donaldsharp/eigrp_various
[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 #include "vty.h"
33
34 #include "ldp.h"
35
36 #define CONF_FILE "/etc/ldpd.conf"
37 #define LDPD_USER "_ldpd"
38
39 #define LDPD_FD_ASYNC 3
40 #define LDPD_FD_SYNC 4
41
42 #define LDPD_OPT_VERBOSE 0x00000001
43 #define LDPD_OPT_VERBOSE2 0x00000002
44 #define LDPD_OPT_NOACTION 0x00000004
45
46 #define TCP_MD5_KEY_LEN 80
47 #define L2VPN_NAME_LEN 32
48
49 #define RT_BUF_SIZE 16384
50 #define MAX_RTSOCK_BUF 128 * 1024
51 #define LDP_BACKLOG 128
52
53 #define F_LDPD_INSERTED 0x0001
54 #define F_CONNECTED 0x0002
55 #define F_STATIC 0x0004
56 #define F_DYNAMIC 0x0008
57 #define F_REJECT 0x0010
58 #define F_BLACKHOLE 0x0020
59 #define F_REDISTRIBUTED 0x0040
60
61 struct evbuf {
62 struct msgbuf wbuf;
63 struct thread *ev;
64 int (*handler)(struct thread *);
65 void *arg;
66 };
67
68 struct imsgev {
69 struct imsgbuf ibuf;
70 int (*handler_write)(struct thread *);
71 struct thread *ev_write;
72 int (*handler_read)(struct thread *);
73 struct thread *ev_read;
74 };
75
76 enum imsg_type {
77 IMSG_NONE,
78 IMSG_CTL_RELOAD,
79 IMSG_CTL_SHOW_INTERFACE,
80 IMSG_CTL_SHOW_DISCOVERY,
81 IMSG_CTL_SHOW_DISCOVERY_DTL,
82 IMSG_CTL_SHOW_DISC_IFACE,
83 IMSG_CTL_SHOW_DISC_TNBR,
84 IMSG_CTL_SHOW_DISC_ADJ,
85 IMSG_CTL_SHOW_NBR,
86 IMSG_CTL_SHOW_NBR_DISC,
87 IMSG_CTL_SHOW_NBR_END,
88 IMSG_CTL_SHOW_LIB,
89 IMSG_CTL_SHOW_LIB_BEGIN,
90 IMSG_CTL_SHOW_LIB_SENT,
91 IMSG_CTL_SHOW_LIB_RCVD,
92 IMSG_CTL_SHOW_LIB_END,
93 IMSG_CTL_SHOW_L2VPN_PW,
94 IMSG_CTL_SHOW_L2VPN_BINDING,
95 IMSG_CTL_CLEAR_NBR,
96 IMSG_CTL_FIB_COUPLE,
97 IMSG_CTL_FIB_DECOUPLE,
98 IMSG_CTL_KROUTE,
99 IMSG_CTL_KROUTE_ADDR,
100 IMSG_CTL_IFINFO,
101 IMSG_CTL_END,
102 IMSG_CTL_LOG_VERBOSE,
103 IMSG_KLABEL_CHANGE,
104 IMSG_KLABEL_DELETE,
105 IMSG_KPWLABEL_CHANGE,
106 IMSG_KPWLABEL_DELETE,
107 IMSG_IFSTATUS,
108 IMSG_NEWADDR,
109 IMSG_DELADDR,
110 IMSG_RTRID_UPDATE,
111 IMSG_LABEL_MAPPING,
112 IMSG_LABEL_MAPPING_FULL,
113 IMSG_LABEL_REQUEST,
114 IMSG_LABEL_RELEASE,
115 IMSG_LABEL_WITHDRAW,
116 IMSG_LABEL_ABORT,
117 IMSG_REQUEST_ADD,
118 IMSG_REQUEST_ADD_END,
119 IMSG_MAPPING_ADD,
120 IMSG_MAPPING_ADD_END,
121 IMSG_RELEASE_ADD,
122 IMSG_RELEASE_ADD_END,
123 IMSG_WITHDRAW_ADD,
124 IMSG_WITHDRAW_ADD_END,
125 IMSG_ADDRESS_ADD,
126 IMSG_ADDRESS_DEL,
127 IMSG_NOTIFICATION,
128 IMSG_NOTIFICATION_SEND,
129 IMSG_NEIGHBOR_UP,
130 IMSG_NEIGHBOR_DOWN,
131 IMSG_NETWORK_ADD,
132 IMSG_NETWORK_UPDATE,
133 IMSG_SOCKET_IPC,
134 IMSG_SOCKET_NET,
135 IMSG_CLOSE_SOCKETS,
136 IMSG_REQUEST_SOCKETS,
137 IMSG_SETUP_SOCKETS,
138 IMSG_RECONF_CONF,
139 IMSG_RECONF_IFACE,
140 IMSG_RECONF_TNBR,
141 IMSG_RECONF_NBRP,
142 IMSG_RECONF_L2VPN,
143 IMSG_RECONF_L2VPN_IF,
144 IMSG_RECONF_L2VPN_PW,
145 IMSG_RECONF_L2VPN_IPW,
146 IMSG_RECONF_END,
147 IMSG_DEBUG_UPDATE,
148 IMSG_LOG,
149 IMSG_ACL_CHECK,
150 IMSG_INIT
151 };
152
153 struct ldpd_init {
154 char user[256];
155 char group[256];
156 char ctl_sock_path[MAXPATHLEN];
157 char zclient_serv_path[MAXPATHLEN];
158 u_short instance;
159 };
160
161 union ldpd_addr {
162 struct in_addr v4;
163 struct in6_addr v6;
164 };
165
166 #define IN6_IS_SCOPE_EMBED(a) \
167 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
168 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
169 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
170
171 /* interface states */
172 #define IF_STA_DOWN 0x01
173 #define IF_STA_ACTIVE 0x02
174
175 /* targeted neighbor states */
176 #define TNBR_STA_DOWN 0x01
177 #define TNBR_STA_ACTIVE 0x02
178
179 /* interface types */
180 enum iface_type {
181 IF_TYPE_POINTOPOINT,
182 IF_TYPE_BROADCAST
183 };
184
185 /* neighbor states */
186 #define NBR_STA_PRESENT 0x0001
187 #define NBR_STA_INITIAL 0x0002
188 #define NBR_STA_OPENREC 0x0004
189 #define NBR_STA_OPENSENT 0x0008
190 #define NBR_STA_OPER 0x0010
191 #define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \
192 NBR_STA_OPENSENT | NBR_STA_OPER)
193
194 /* neighbor events */
195 enum nbr_event {
196 NBR_EVT_NOTHING,
197 NBR_EVT_MATCH_ADJ,
198 NBR_EVT_CONNECT_UP,
199 NBR_EVT_CLOSE_SESSION,
200 NBR_EVT_INIT_RCVD,
201 NBR_EVT_KEEPALIVE_RCVD,
202 NBR_EVT_PDU_RCVD,
203 NBR_EVT_PDU_SENT,
204 NBR_EVT_INIT_SENT
205 };
206
207 /* neighbor actions */
208 enum nbr_action {
209 NBR_ACT_NOTHING,
210 NBR_ACT_RST_KTIMEOUT,
211 NBR_ACT_SESSION_EST,
212 NBR_ACT_RST_KTIMER,
213 NBR_ACT_CONNECT_SETUP,
214 NBR_ACT_PASSIVE_INIT,
215 NBR_ACT_KEEPALIVE_SEND,
216 NBR_ACT_CLOSE_SESSION
217 };
218
219 /* forward declarations */
220 RB_HEAD(global_adj_head, adj);
221 RB_HEAD(nbr_adj_head, adj);
222 RB_HEAD(ia_adj_head, adj);
223
224 struct map {
225 uint8_t type;
226 uint32_t msg_id;
227 union {
228 struct {
229 uint16_t af;
230 union ldpd_addr prefix;
231 uint8_t prefixlen;
232 } prefix;
233 struct {
234 uint16_t type;
235 uint32_t pwid;
236 uint32_t group_id;
237 uint16_t ifmtu;
238 } pwid;
239 struct {
240 uint8_t type;
241 union {
242 uint16_t prefix_af;
243 uint16_t pw_type;
244 } u;
245 } twcard;
246 } fec;
247 struct {
248 uint32_t status_code;
249 uint32_t msg_id;
250 uint16_t msg_type;
251 } st;
252 uint32_t label;
253 uint32_t requestid;
254 uint32_t pw_status;
255 uint8_t flags;
256 };
257 #define F_MAP_REQ_ID 0x01 /* optional request message id present */
258 #define F_MAP_STATUS 0x02 /* status */
259 #define F_MAP_PW_CWORD 0x04 /* pseudowire control word */
260 #define F_MAP_PW_ID 0x08 /* pseudowire connection id */
261 #define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */
262 #define F_MAP_PW_STATUS 0x20 /* pseudowire status */
263
264 struct notify_msg {
265 uint32_t status_code;
266 uint32_t msg_id; /* network byte order */
267 uint16_t msg_type; /* network byte order */
268 uint32_t pw_status;
269 struct map fec;
270 struct {
271 uint16_t type;
272 uint16_t length;
273 char *data;
274 } rtlvs;
275 uint8_t flags;
276 };
277 #define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */
278 #define F_NOTIF_FEC 0x02 /* fec tlv present */
279 #define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */
280
281 struct if_addr {
282 LIST_ENTRY(if_addr) entry;
283 int af;
284 union ldpd_addr addr;
285 uint8_t prefixlen;
286 union ldpd_addr dstbrd;
287 };
288 LIST_HEAD(if_addr_head, if_addr);
289
290 struct iface_af {
291 struct iface *iface;
292 int af;
293 int enabled;
294 int state;
295 struct ia_adj_head adj_tree;
296 time_t uptime;
297 struct thread *hello_timer;
298 uint16_t hello_holdtime;
299 uint16_t hello_interval;
300 };
301
302 struct iface {
303 RB_ENTRY(iface) entry;
304 char name[IF_NAMESIZE];
305 unsigned int ifindex;
306 struct if_addr_head addr_list;
307 struct in6_addr linklocal;
308 enum iface_type type;
309 int operative;
310 struct iface_af ipv4;
311 struct iface_af ipv6;
312 QOBJ_FIELDS
313 };
314 RB_HEAD(iface_head, iface);
315 RB_PROTOTYPE(iface_head, iface, entry, iface_compare);
316 DECLARE_QOBJ_TYPE(iface)
317
318 /* source of targeted hellos */
319 struct tnbr {
320 RB_ENTRY(tnbr) entry;
321 struct thread *hello_timer;
322 struct adj *adj;
323 int af;
324 union ldpd_addr addr;
325 int state;
326 uint16_t pw_count;
327 uint8_t flags;
328 QOBJ_FIELDS
329 };
330 RB_HEAD(tnbr_head, tnbr);
331 RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare);
332 DECLARE_QOBJ_TYPE(tnbr)
333 #define F_TNBR_CONFIGURED 0x01
334 #define F_TNBR_DYNAMIC 0x02
335
336 enum auth_method {
337 AUTH_NONE,
338 AUTH_MD5SIG
339 };
340
341 /* neighbor specific parameters */
342 struct nbr_params {
343 RB_ENTRY(nbr_params) entry;
344 struct in_addr lsr_id;
345 uint16_t keepalive;
346 int gtsm_enabled;
347 uint8_t gtsm_hops;
348 struct {
349 enum auth_method method;
350 char md5key[TCP_MD5_KEY_LEN];
351 uint8_t md5key_len;
352 } auth;
353 uint8_t flags;
354 QOBJ_FIELDS
355 };
356 RB_HEAD(nbrp_head, nbr_params);
357 RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare);
358 DECLARE_QOBJ_TYPE(nbr_params)
359 #define F_NBRP_KEEPALIVE 0x01
360 #define F_NBRP_GTSM 0x02
361 #define F_NBRP_GTSM_HOPS 0x04
362
363 struct ldp_stats {
364 uint32_t kalive_sent;
365 uint32_t kalive_rcvd;
366 uint32_t addr_sent;
367 uint32_t addr_rcvd;
368 uint32_t addrwdraw_sent;
369 uint32_t addrwdraw_rcvd;
370 uint32_t notif_sent;
371 uint32_t notif_rcvd;
372 uint32_t capability_sent;
373 uint32_t capability_rcvd;
374 uint32_t labelmap_sent;
375 uint32_t labelmap_rcvd;
376 uint32_t labelreq_sent;
377 uint32_t labelreq_rcvd;
378 uint32_t labelwdraw_sent;
379 uint32_t labelwdraw_rcvd;
380 uint32_t labelrel_sent;
381 uint32_t labelrel_rcvd;
382 uint32_t labelabreq_sent;
383 uint32_t labelabreq_rcvd;
384 };
385
386 struct l2vpn_if {
387 RB_ENTRY(l2vpn_if) entry;
388 struct l2vpn *l2vpn;
389 char ifname[IF_NAMESIZE];
390 unsigned int ifindex;
391 int operative;
392 uint8_t mac[ETH_ALEN];
393 QOBJ_FIELDS
394 };
395 RB_HEAD(l2vpn_if_head, l2vpn_if);
396 RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare);
397 DECLARE_QOBJ_TYPE(l2vpn_if)
398
399 struct l2vpn_pw {
400 RB_ENTRY(l2vpn_pw) entry;
401 struct l2vpn *l2vpn;
402 struct in_addr lsr_id;
403 int af;
404 union ldpd_addr addr;
405 uint32_t pwid;
406 char ifname[IF_NAMESIZE];
407 unsigned int ifindex;
408 uint32_t remote_group;
409 uint16_t remote_mtu;
410 uint32_t remote_status;
411 uint8_t flags;
412 QOBJ_FIELDS
413 };
414 RB_HEAD(l2vpn_pw_head, l2vpn_pw);
415 RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare);
416 DECLARE_QOBJ_TYPE(l2vpn_pw)
417 #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */
418 #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */
419 #define F_PW_CWORD_CONF 0x04 /* control word configured */
420 #define F_PW_CWORD 0x08 /* control word negotiated */
421 #define F_PW_STATUS_UP 0x10 /* pseudowire is operational */
422 #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */
423
424 struct l2vpn {
425 RB_ENTRY(l2vpn) entry;
426 char name[L2VPN_NAME_LEN];
427 int type;
428 int pw_type;
429 int mtu;
430 char br_ifname[IF_NAMESIZE];
431 unsigned int br_ifindex;
432 struct l2vpn_if_head if_tree;
433 struct l2vpn_pw_head pw_tree;
434 struct l2vpn_pw_head pw_inactive_tree;
435 QOBJ_FIELDS
436 };
437 RB_HEAD(l2vpn_head, l2vpn);
438 RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare);
439 DECLARE_QOBJ_TYPE(l2vpn)
440 #define L2VPN_TYPE_VPWS 1
441 #define L2VPN_TYPE_VPLS 2
442
443 /* ldp_conf */
444 enum ldpd_process {
445 PROC_MAIN,
446 PROC_LDP_ENGINE,
447 PROC_LDE_ENGINE
448 } ldpd_process;
449
450 static const char * const log_procnames[] = {
451 "parent",
452 "ldpe",
453 "lde"
454 };
455
456 enum socket_type {
457 LDP_SOCKET_DISC,
458 LDP_SOCKET_EDISC,
459 LDP_SOCKET_SESSION
460 };
461
462 enum hello_type {
463 HELLO_LINK,
464 HELLO_TARGETED
465 };
466
467 struct ldpd_af_conf {
468 uint16_t keepalive;
469 uint16_t lhello_holdtime;
470 uint16_t lhello_interval;
471 uint16_t thello_holdtime;
472 uint16_t thello_interval;
473 union ldpd_addr trans_addr;
474 char acl_thello_accept_from[ACL_NAMSIZ];
475 char acl_label_allocate_for[ACL_NAMSIZ];
476 char acl_label_advertise_to[ACL_NAMSIZ];
477 char acl_label_advertise_for[ACL_NAMSIZ];
478 char acl_label_expnull_for[ACL_NAMSIZ];
479 char acl_label_accept_from[ACL_NAMSIZ];
480 char acl_label_accept_for[ACL_NAMSIZ];
481 int flags;
482 };
483 #define F_LDPD_AF_ENABLED 0x0001
484 #define F_LDPD_AF_THELLO_ACCEPT 0x0002
485 #define F_LDPD_AF_EXPNULL 0x0004
486 #define F_LDPD_AF_NO_GTSM 0x0008
487 #define F_LDPD_AF_ALLOCHOSTONLY 0x0010
488
489 struct ldpd_conf {
490 struct in_addr rtr_id;
491 struct ldpd_af_conf ipv4;
492 struct ldpd_af_conf ipv6;
493 struct iface_head iface_tree;
494 struct tnbr_head tnbr_tree;
495 struct nbrp_head nbrp_tree;
496 struct l2vpn_head l2vpn_tree;
497 uint16_t lhello_holdtime;
498 uint16_t lhello_interval;
499 uint16_t thello_holdtime;
500 uint16_t thello_interval;
501 uint16_t trans_pref;
502 int flags;
503 QOBJ_FIELDS
504 };
505 DECLARE_QOBJ_TYPE(ldpd_conf)
506 #define F_LDPD_NO_FIB_UPDATE 0x0001
507 #define F_LDPD_DS_CISCO_INTEROP 0x0002
508 #define F_LDPD_ENABLED 0x0004
509
510 struct ldpd_af_global {
511 struct thread *disc_ev;
512 struct thread *edisc_ev;
513 int ldp_disc_socket;
514 int ldp_edisc_socket;
515 int ldp_session_socket;
516 };
517
518 struct ldpd_global {
519 int cmd_opts;
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[ETH_ALEN];
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_config_apply(struct vty *, 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_ */