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