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