]> git.proxmox.com Git - mirror_frr.git/blob - ldpd/ldpd.h
Merge pull request #6243 from pguibert6WIND/flowspec_some_regression_seen
[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 uint8_t reason;
426 QOBJ_FIELDS
427 };
428 RB_HEAD(l2vpn_pw_head, l2vpn_pw);
429 RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare);
430 DECLARE_QOBJ_TYPE(l2vpn_pw)
431 #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */
432 #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */
433 #define F_PW_CWORD_CONF 0x04 /* control word configured */
434 #define F_PW_CWORD 0x08 /* control word negotiated */
435 #define F_PW_STATIC_NBR_ADDR 0x10 /* static neighbor address configured */
436
437 #define F_PW_NO_ERR 0x00 /* no error reported */
438 #define F_PW_LOCAL_NOT_FWD 0x01 /* locally can't forward over PW */
439 #define F_PW_REMOTE_NOT_FWD 0x02 /* remote end of PW reported fwd error*/
440 #define F_PW_NO_REMOTE_LABEL 0x03 /* have not recvd label from peer */
441 #define F_PW_MTU_MISMATCH 0x04 /* mtu mismatch between peers */
442
443 struct l2vpn {
444 RB_ENTRY(l2vpn) entry;
445 char name[L2VPN_NAME_LEN];
446 int type;
447 int pw_type;
448 int mtu;
449 char br_ifname[IF_NAMESIZE];
450 ifindex_t br_ifindex;
451 struct l2vpn_if_head if_tree;
452 struct l2vpn_pw_head pw_tree;
453 struct l2vpn_pw_head pw_inactive_tree;
454 QOBJ_FIELDS
455 };
456 RB_HEAD(l2vpn_head, l2vpn);
457 RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare);
458 DECLARE_QOBJ_TYPE(l2vpn)
459 #define L2VPN_TYPE_VPWS 1
460 #define L2VPN_TYPE_VPLS 2
461
462 /* ldp_conf */
463 extern enum ldpd_process {
464 PROC_MAIN,
465 PROC_LDP_ENGINE,
466 PROC_LDE_ENGINE
467 } ldpd_process;
468
469 static const char * const log_procnames[] = {
470 "parent",
471 "ldpe",
472 "lde"
473 };
474
475 enum socket_type {
476 LDP_SOCKET_DISC,
477 LDP_SOCKET_EDISC,
478 LDP_SOCKET_SESSION
479 };
480
481 enum hello_type {
482 HELLO_LINK,
483 HELLO_TARGETED
484 };
485
486 struct ldpd_af_conf {
487 uint16_t keepalive;
488 uint16_t lhello_holdtime;
489 uint16_t lhello_interval;
490 uint16_t thello_holdtime;
491 uint16_t thello_interval;
492 union ldpd_addr trans_addr;
493 char acl_thello_accept_from[ACL_NAMSIZ];
494 char acl_label_allocate_for[ACL_NAMSIZ];
495 char acl_label_advertise_to[ACL_NAMSIZ];
496 char acl_label_advertise_for[ACL_NAMSIZ];
497 char acl_label_expnull_for[ACL_NAMSIZ];
498 char acl_label_accept_from[ACL_NAMSIZ];
499 char acl_label_accept_for[ACL_NAMSIZ];
500 int flags;
501 };
502 #define F_LDPD_AF_ENABLED 0x0001
503 #define F_LDPD_AF_THELLO_ACCEPT 0x0002
504 #define F_LDPD_AF_EXPNULL 0x0004
505 #define F_LDPD_AF_NO_GTSM 0x0008
506 #define F_LDPD_AF_ALLOCHOSTONLY 0x0010
507
508 struct ldpd_conf {
509 struct in_addr rtr_id;
510 struct ldpd_af_conf ipv4;
511 struct ldpd_af_conf ipv6;
512 struct iface_head iface_tree;
513 struct tnbr_head tnbr_tree;
514 struct nbrp_head nbrp_tree;
515 struct l2vpn_head l2vpn_tree;
516 uint16_t lhello_holdtime;
517 uint16_t lhello_interval;
518 uint16_t thello_holdtime;
519 uint16_t thello_interval;
520 uint16_t trans_pref;
521 int flags;
522 QOBJ_FIELDS
523 };
524 DECLARE_QOBJ_TYPE(ldpd_conf)
525 #define F_LDPD_NO_FIB_UPDATE 0x0001
526 #define F_LDPD_DS_CISCO_INTEROP 0x0002
527 #define F_LDPD_ENABLED 0x0004
528 #define F_LDPD_ORDERED_CONTROL 0x0008
529
530
531 struct ldpd_af_global {
532 struct thread *disc_ev;
533 struct thread *edisc_ev;
534 int ldp_disc_socket;
535 int ldp_edisc_socket;
536 int ldp_session_socket;
537 };
538
539 struct ldpd_global {
540 int cmd_opts;
541 struct in_addr rtr_id;
542 struct ldpd_af_global ipv4;
543 struct ldpd_af_global ipv6;
544 uint32_t conf_seqnum;
545 int pfkeysock;
546 struct if_addr_head addr_list;
547 struct global_adj_head adj_tree;
548 struct in_addr mcast_addr_v4;
549 struct in6_addr mcast_addr_v6;
550 TAILQ_HEAD(, pending_conn) pending_conns;
551 };
552
553 /* kroute */
554 struct kroute {
555 int af;
556 union ldpd_addr prefix;
557 uint8_t prefixlen;
558 union ldpd_addr nexthop;
559 uint32_t local_label;
560 uint32_t remote_label;
561 ifindex_t ifindex;
562 uint8_t route_type;
563 uint8_t route_instance;
564 uint16_t flags;
565 };
566
567 struct kaddr {
568 char ifname[IF_NAMESIZE];
569 ifindex_t ifindex;
570 int af;
571 union ldpd_addr addr;
572 uint8_t prefixlen;
573 union ldpd_addr dstbrd;
574 };
575
576 struct kif {
577 char ifname[IF_NAMESIZE];
578 ifindex_t ifindex;
579 int flags;
580 int operative;
581 uint8_t mac[ETH_ALEN];
582 int mtu;
583 };
584
585 struct acl_check {
586 char acl[ACL_NAMSIZ];
587 int af;
588 union ldpd_addr addr;
589 uint8_t prefixlen;
590 };
591
592 /* control data structures */
593 struct ctl_iface {
594 int af;
595 char name[IF_NAMESIZE];
596 ifindex_t ifindex;
597 int state;
598 enum iface_type type;
599 uint16_t hello_holdtime;
600 uint16_t hello_interval;
601 time_t uptime;
602 uint16_t adj_cnt;
603 };
604
605 struct ctl_disc_if {
606 char name[IF_NAMESIZE];
607 int active_v4;
608 int active_v6;
609 int no_adj;
610 };
611
612 struct ctl_disc_tnbr {
613 int af;
614 union ldpd_addr addr;
615 int no_adj;
616 };
617
618 struct ctl_adj {
619 int af;
620 struct in_addr id;
621 enum hello_type type;
622 char ifname[IF_NAMESIZE];
623 union ldpd_addr src_addr;
624 uint16_t holdtime;
625 uint16_t holdtime_remaining;
626 union ldpd_addr trans_addr;
627 int ds_tlv;
628 };
629
630 struct ctl_nbr {
631 int af;
632 struct in_addr id;
633 union ldpd_addr laddr;
634 in_port_t lport;
635 union ldpd_addr raddr;
636 in_port_t rport;
637 enum auth_method auth_method;
638 uint16_t holdtime;
639 time_t uptime;
640 int nbr_state;
641 struct ldp_stats stats;
642 int flags;
643 };
644
645 struct ctl_rt {
646 int af;
647 union ldpd_addr prefix;
648 uint8_t prefixlen;
649 struct in_addr nexthop; /* lsr-id */
650 uint32_t local_label;
651 uint32_t remote_label;
652 uint8_t flags;
653 uint8_t in_use;
654 int no_downstream;
655 };
656
657 struct ctl_pw {
658 uint16_t type;
659 char l2vpn_name[L2VPN_NAME_LEN];
660 char ifname[IF_NAMESIZE];
661 uint32_t pwid;
662 struct in_addr lsr_id;
663 uint32_t local_label;
664 uint32_t local_gid;
665 uint16_t local_ifmtu;
666 uint8_t local_cword;
667 uint32_t remote_label;
668 uint32_t remote_gid;
669 uint16_t remote_ifmtu;
670 uint8_t remote_cword;
671 uint32_t status;
672 uint8_t reason;
673 };
674
675 extern struct ldpd_conf *ldpd_conf, *vty_conf;
676 extern struct ldpd_global global;
677 extern struct ldpd_init init;
678
679 /* parse.y */
680 struct ldpd_conf *parse_config(char *);
681 int cmdline_symset(char *);
682
683 /* kroute.c */
684 void pw2zpw(struct l2vpn_pw *, struct zapi_pw *);
685 void kif_redistribute(const char *);
686 int kr_change(struct kroute *);
687 int kr_delete(struct kroute *);
688 int kmpw_add(struct zapi_pw *);
689 int kmpw_del(struct zapi_pw *);
690 int kmpw_set(struct zapi_pw *);
691 int kmpw_unset(struct zapi_pw *);
692
693 /* util.c */
694 uint8_t mask2prefixlen(in_addr_t);
695 uint8_t mask2prefixlen6(struct sockaddr_in6 *);
696 in_addr_t prefixlen2mask(uint8_t);
697 struct in6_addr *prefixlen2mask6(uint8_t);
698 void ldp_applymask(int, union ldpd_addr *,
699 const union ldpd_addr *, int);
700 int ldp_addrcmp(int, const union ldpd_addr *,
701 const union ldpd_addr *);
702 int ldp_addrisset(int, const union ldpd_addr *);
703 int ldp_prefixcmp(int, const union ldpd_addr *,
704 const union ldpd_addr *, uint8_t);
705 int bad_addr_v4(struct in_addr);
706 int bad_addr_v6(struct in6_addr *);
707 int bad_addr(int, union ldpd_addr *);
708 void embedscope(struct sockaddr_in6 *);
709 void recoverscope(struct sockaddr_in6 *);
710 void addscope(struct sockaddr_in6 *, uint32_t);
711 void clearscope(struct in6_addr *);
712 void addr2sa(int af, const union ldpd_addr *, uint16_t,
713 union sockunion *su);
714 void sa2addr(struct sockaddr *, int *, union ldpd_addr *,
715 in_port_t *);
716 socklen_t sockaddr_len(struct sockaddr *);
717
718 /* ldpd.c */
719 int ldp_write_handler(struct thread *);
720 void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t);
721 void main_imsg_compose_lde(int, pid_t, void *, uint16_t);
722 int main_imsg_compose_both(enum imsg_type, void *,
723 uint16_t);
724 void imsg_event_add(struct imsgev *);
725 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
726 pid_t, int, void *, uint16_t);
727 void evbuf_enqueue(struct evbuf *, struct ibuf *);
728 void evbuf_event_add(struct evbuf *);
729 void evbuf_init(struct evbuf *, int,
730 int (*)(struct thread *), void *);
731 void evbuf_clear(struct evbuf *);
732 int ldp_acl_request(struct imsgev *, char *, int,
733 union ldpd_addr *, uint8_t);
734 void ldp_acl_reply(struct imsgev *, struct acl_check *);
735 struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int);
736 struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int);
737 int ldp_is_dual_stack(struct ldpd_conf *);
738 in_addr_t ldp_rtr_id_get(struct ldpd_conf *);
739 int ldp_config_apply(struct vty *, struct ldpd_conf *);
740 void ldp_clear_config(struct ldpd_conf *);
741 void merge_config(struct ldpd_conf *, struct ldpd_conf *);
742 struct ldpd_conf *config_new_empty(void);
743 void config_clear(struct ldpd_conf *);
744
745 /* ldp_vty_conf.c */
746 /* NOTE: the parameters' names should be preserved because of codegen */
747 struct iface *iface_new_api(struct ldpd_conf *conf,
748 const char *name);
749 void iface_del_api(struct ldpd_conf *conf,
750 struct iface *iface);
751 struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af,
752 union ldpd_addr *addr);
753 void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr);
754 struct nbr_params *nbrp_new_api(struct ldpd_conf *conf,
755 struct in_addr lsr_id);
756 void nbrp_del_api(struct ldpd_conf *conf,
757 struct nbr_params *nbrp);
758 struct l2vpn *l2vpn_new_api(struct ldpd_conf *conf, const char *name);
759 void l2vpn_del_api(struct ldpd_conf *conf,
760 struct l2vpn *l2vpn);
761 struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf,
762 struct l2vpn *l2vpn, const char *ifname);
763 void l2vpn_if_del_api(struct l2vpn *l2vpn,
764 struct l2vpn_if *lif);
765 struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf,
766 struct l2vpn *l2vpn, const char *ifname);
767 void l2vpn_pw_del_api(struct l2vpn *l2vpn,
768 struct l2vpn_pw *pw);
769
770 /* socket.c */
771 int ldp_create_socket(int, enum socket_type);
772 void sock_set_nonblock(int);
773 void sock_set_cloexec(int);
774 void sock_set_recvbuf(int);
775 int sock_set_reuse(int, int);
776 int sock_set_bindany(int, int);
777 int sock_set_md5sig(int, int, union ldpd_addr *, const char *);
778 int sock_set_ipv4_tos(int, int);
779 int sock_set_ipv4_pktinfo(int, int);
780 int sock_set_ipv4_recvdstaddr(int fd, ifindex_t ifindex);
781 int sock_set_ipv4_recvif(int, int);
782 int sock_set_ipv4_minttl(int, int);
783 int sock_set_ipv4_ucast_ttl(int fd, int);
784 int sock_set_ipv4_mcast_ttl(int, uint8_t);
785 int sock_set_ipv4_mcast(struct iface *);
786 int sock_set_ipv4_mcast_loop(int);
787 int sock_set_ipv6_dscp(int, int);
788 int sock_set_ipv6_pktinfo(int, int);
789 int sock_set_ipv6_minhopcount(int, int);
790 int sock_set_ipv6_ucast_hops(int, int);
791 int sock_set_ipv6_mcast_hops(int, int);
792 int sock_set_ipv6_mcast(struct iface *);
793 int sock_set_ipv6_mcast_loop(int);
794
795 /* logmsg.h */
796 struct in6_addr;
797 union ldpd_addr;
798 struct hello_source;
799 struct fec;
800
801 const char *log_sockaddr(void *);
802 const char *log_in6addr(const struct in6_addr *);
803 const char *log_in6addr_scope(const struct in6_addr *addr,
804 ifindex_t ifidx);
805 const char *log_addr(int, const union ldpd_addr *);
806 char *log_label(uint32_t);
807 const char *log_time(time_t);
808 char *log_hello_src(const struct hello_source *);
809 const char *log_map(const struct map *);
810 const char *log_fec(const struct fec *);
811 const char *af_name(int);
812 const char *socket_name(int);
813 const char *nbr_state_name(int);
814 const char *if_state_name(int);
815 const char *if_type_name(enum iface_type);
816 const char *msg_name(uint16_t);
817 const char *status_code_name(uint32_t);
818 const char *pw_type_name(uint16_t);
819 const char *pw_error_code(uint8_t);
820
821 /* quagga */
822 extern struct thread_master *master;
823 extern char ctl_sock_path[MAXPATHLEN];
824
825 /* ldp_zebra.c */
826 void ldp_zebra_init(struct thread_master *);
827 void ldp_zebra_destroy(void);
828
829 /* compatibility */
830 #ifndef __OpenBSD__
831 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
832 #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
833 #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
834 (IN6_IS_ADDR_MULTICAST(a) && \
835 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL))
836 #endif
837
838 #endif /* _LDPD_H_ */