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