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