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