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