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