]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldpd.h
Merge pull request #675 from opensourcerouting/ldpd-cherry-picks
[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_GET_LABEL_CHUNK,
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;
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
220 /* forward declarations */
221 RB_HEAD(global_adj_head, adj);
222 RB_HEAD(nbr_adj_head, adj);
223 RB_HEAD(ia_adj_head, adj);
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;
240 struct {
241 uint8_t type;
242 union {
243 uint16_t prefix_af;
244 uint16_t pw_type;
245 } u;
246 } twcard;
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;
271 struct {
272 uint16_t type;
273 uint16_t length;
274 char *data;
275 } rtlvs;
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 */
280 #define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */
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;
296 struct ia_adj_head adj_tree;
297 time_t uptime;
298 struct thread *hello_timer;
299 uint16_t hello_holdtime;
300 uint16_t hello_interval;
301 };
302
303 struct iface {
304 RB_ENTRY(iface) entry;
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;
310 int operative;
311 struct iface_af ipv4;
312 struct iface_af ipv6;
313 QOBJ_FIELDS
314 };
315 RB_HEAD(iface_head, iface);
316 RB_PROTOTYPE(iface_head, iface, entry, iface_compare);
317 DECLARE_QOBJ_TYPE(iface)
318
319 /* source of targeted hellos */
320 struct tnbr {
321 RB_ENTRY(tnbr) entry;
322 struct thread *hello_timer;
323 struct adj *adj;
324 int af;
325 union ldpd_addr addr;
326 int state;
327 uint16_t pw_count;
328 uint8_t flags;
329 QOBJ_FIELDS
330 };
331 RB_HEAD(tnbr_head, tnbr);
332 RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare);
333 DECLARE_QOBJ_TYPE(tnbr)
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 {
344 RB_ENTRY(nbr_params) entry;
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;
355 QOBJ_FIELDS
356 };
357 RB_HEAD(nbrp_head, nbr_params);
358 RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare);
359 DECLARE_QOBJ_TYPE(nbr_params)
360 #define F_NBRP_KEEPALIVE 0x01
361 #define F_NBRP_GTSM 0x02
362 #define F_NBRP_GTSM_HOPS 0x04
363
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
387 struct l2vpn_if {
388 RB_ENTRY(l2vpn_if) entry;
389 struct l2vpn *l2vpn;
390 char ifname[IF_NAMESIZE];
391 unsigned int ifindex;
392 int operative;
393 uint8_t mac[ETHER_ADDR_LEN];
394 QOBJ_FIELDS
395 };
396 RB_HEAD(l2vpn_if_head, l2vpn_if);
397 RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare);
398 DECLARE_QOBJ_TYPE(l2vpn_if)
399
400 struct l2vpn_pw {
401 RB_ENTRY(l2vpn_pw) entry;
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;
413 QOBJ_FIELDS
414 };
415 RB_HEAD(l2vpn_pw_head, l2vpn_pw);
416 RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare);
417 DECLARE_QOBJ_TYPE(l2vpn_pw)
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 */
423 #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */
424
425 struct l2vpn {
426 RB_ENTRY(l2vpn) entry;
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;
433 struct l2vpn_if_head if_tree;
434 struct l2vpn_pw_head pw_tree;
435 struct l2vpn_pw_head pw_inactive_tree;
436 QOBJ_FIELDS
437 };
438 RB_HEAD(l2vpn_head, l2vpn);
439 RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare);
440 DECLARE_QOBJ_TYPE(l2vpn)
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
451 static const char * const log_procnames[] = {
452 "parent",
453 "ldpe",
454 "lde"
455 };
456
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;
470 uint16_t lhello_holdtime;
471 uint16_t lhello_interval;
472 uint16_t thello_holdtime;
473 uint16_t thello_interval;
474 union ldpd_addr trans_addr;
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];
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
488 #define F_LDPD_AF_ALLOCHOSTONLY 0x0010
489
490 struct ldpd_conf {
491 struct in_addr rtr_id;
492 struct ldpd_af_conf ipv4;
493 struct ldpd_af_conf ipv6;
494 struct iface_head iface_tree;
495 struct tnbr_head tnbr_tree;
496 struct nbrp_head nbrp_tree;
497 struct l2vpn_head l2vpn_tree;
498 uint16_t lhello_holdtime;
499 uint16_t lhello_interval;
500 uint16_t thello_holdtime;
501 uint16_t thello_interval;
502 uint16_t trans_pref;
503 int flags;
504 QOBJ_FIELDS
505 };
506 DECLARE_QOBJ_TYPE(ldpd_conf)
507 #define F_LDPD_NO_FIB_UPDATE 0x0001
508 #define F_LDPD_DS_CISCO_INTEROP 0x0002
509 #define F_LDPD_ENABLED 0x0004
510
511 struct ldpd_af_global {
512 struct thread *disc_ev;
513 struct thread *edisc_ev;
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;
521 int sighup;
522 struct in_addr rtr_id;
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;
528 struct global_adj_head adj_tree;
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 {
558 char ifname[IF_NAMESIZE];
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;
570 int operative;
571 uint8_t mac[ETHER_ADDR_LEN];
572 int mtu;
573 };
574
575 struct acl_check {
576 char acl[ACL_NAMSIZ];
577 int af;
578 union ldpd_addr addr;
579 uint8_t prefixlen;
580 };
581
582 /* control data structures */
583 struct ctl_iface {
584 int af;
585 char name[IF_NAMESIZE];
586 unsigned int ifindex;
587 int state;
588 enum iface_type type;
589 uint16_t hello_holdtime;
590 uint16_t hello_interval;
591 time_t uptime;
592 uint16_t adj_cnt;
593 };
594
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
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;
615 uint16_t holdtime_remaining;
616 union ldpd_addr trans_addr;
617 int ds_tlv;
618 };
619
620 struct ctl_nbr {
621 int af;
622 struct in_addr id;
623 union ldpd_addr laddr;
624 in_port_t lport;
625 union ldpd_addr raddr;
626 in_port_t rport;
627 enum auth_method auth_method;
628 uint16_t holdtime;
629 time_t uptime;
630 int nbr_state;
631 struct ldp_stats stats;
632 int flags;
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;
644 int no_downstream;
645 };
646
647 struct ctl_pw {
648 uint16_t type;
649 char l2vpn_name[L2VPN_NAME_LEN];
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;
656 uint8_t local_cword;
657 uint32_t remote_label;
658 uint32_t remote_gid;
659 uint16_t remote_ifmtu;
660 uint8_t remote_cword;
661 uint32_t status;
662 };
663
664 extern struct ldpd_conf *ldpd_conf, *vty_conf;
665 extern struct ldpd_global global;
666 extern struct ldpd_init init;
667
668 /* parse.y */
669 struct ldpd_conf *parse_config(char *);
670 int cmdline_symset(char *);
671
672 /* kroute.c */
673 void kif_redistribute(const char *);
674 int kr_change(struct kroute *);
675 int kr_delete(struct kroute *);
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);
699 void sa2addr(struct sockaddr *, int *, union ldpd_addr *,
700 in_port_t *);
701 socklen_t sockaddr_len(struct sockaddr *);
702
703 /* ldpd.c */
704 int ldp_write_handler(struct thread *);
705 void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t);
706 void main_imsg_compose_lde(int, pid_t, void *, uint16_t);
707 int main_imsg_compose_both(enum imsg_type, void *,
708 uint16_t);
709 void imsg_event_add(struct imsgev *);
710 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
711 pid_t, int, void *, uint16_t);
712 void evbuf_enqueue(struct evbuf *, struct ibuf *);
713 void evbuf_event_add(struct evbuf *);
714 void evbuf_init(struct evbuf *, int,
715 int (*)(struct thread *), void *);
716 void evbuf_clear(struct evbuf *);
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 *);
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 *);
723 in_addr_t ldp_rtr_id_get(struct ldpd_conf *);
724 int ldp_reload(struct ldpd_conf *);
725 void ldp_clear_config(struct ldpd_conf *);
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
730 /* ldp_vty_conf.c */
731 /* NOTE: the parameters' names should be preserved because of codegen */
732 struct iface *iface_new_api(struct ldpd_conf *conf,
733 const char *name);
734 void iface_del_api(struct ldpd_conf *conf,
735 struct iface *iface);
736 struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af,
737 union ldpd_addr *addr);
738 void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr);
739 struct nbr_params *nbrp_new_api(struct ldpd_conf *conf,
740 struct in_addr lsr_id);
741 void nbrp_del_api(struct ldpd_conf *conf,
742 struct nbr_params *nbrp);
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);
746 struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf,
747 struct l2vpn *l2vpn, const char *ifname);
748 void l2vpn_if_del_api(struct l2vpn *l2vpn,
749 struct l2vpn_if *lif);
750 struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf,
751 struct l2vpn *l2vpn, const char *ifname);
752 void l2vpn_pw_del_api(struct l2vpn *l2vpn,
753 struct l2vpn_pw *pw);
754
755 /* socket.c */
756 int ldp_create_socket(int, enum socket_type);
757 void sock_set_nonblock(int);
758 void sock_set_cloexec(int);
759 void sock_set_recvbuf(int);
760 int sock_set_reuse(int, int);
761 int sock_set_bindany(int, int);
762 int sock_set_md5sig(int, int, union ldpd_addr *, const char *);
763 int sock_set_ipv4_tos(int, int);
764 int sock_set_ipv4_pktinfo(int, int);
765 int sock_set_ipv4_recvdstaddr(int, int);
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
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
804 /* quagga */
805 extern struct thread_master *master;
806 extern char ctl_sock_path[MAXPATHLEN];
807
808 /* ldp_zebra.c */
809 void ldp_zebra_init(struct thread_master *);
810 void ldp_zebra_destroy(void);
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
820
821 #endif /* _LDPD_H_ */