]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/ldpd.h
zebra: fix detection of interface renames
[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 147 IMSG_LOG,
fea12efb 148 IMSG_ACL_CHECK,
149 IMSG_GET_LABEL_CHUNK,
150 IMSG_RELEASE_LABEL_CHUNK
8429abe0
RW
151};
152
153union ldpd_addr {
154 struct in_addr v4;
155 struct in6_addr v6;
156};
157
158#define IN6_IS_SCOPE_EMBED(a) \
159 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
160 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
161 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
162
163/* interface states */
164#define IF_STA_DOWN 0x01
165#define IF_STA_ACTIVE 0x02
166
167/* targeted neighbor states */
168#define TNBR_STA_DOWN 0x01
169#define TNBR_STA_ACTIVE 0x02
170
171/* interface types */
172enum iface_type {
173 IF_TYPE_POINTOPOINT,
174 IF_TYPE_BROADCAST
175};
176
177/* neighbor states */
178#define NBR_STA_PRESENT 0x0001
179#define NBR_STA_INITIAL 0x0002
180#define NBR_STA_OPENREC 0x0004
181#define NBR_STA_OPENSENT 0x0008
182#define NBR_STA_OPER 0x0010
183#define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \
184 NBR_STA_OPENSENT | NBR_STA_OPER)
185
186/* neighbor events */
187enum nbr_event {
188 NBR_EVT_NOTHING,
189 NBR_EVT_MATCH_ADJ,
190 NBR_EVT_CONNECT_UP,
191 NBR_EVT_CLOSE_SESSION,
192 NBR_EVT_INIT_RCVD,
193 NBR_EVT_KEEPALIVE_RCVD,
194 NBR_EVT_PDU_RCVD,
195 NBR_EVT_PDU_SENT,
196 NBR_EVT_INIT_SENT
197};
198
199/* neighbor actions */
200enum nbr_action {
201 NBR_ACT_NOTHING,
202 NBR_ACT_RST_KTIMEOUT,
203 NBR_ACT_SESSION_EST,
204 NBR_ACT_RST_KTIMER,
205 NBR_ACT_CONNECT_SETUP,
206 NBR_ACT_PASSIVE_INIT,
207 NBR_ACT_KEEPALIVE_SEND,
208 NBR_ACT_CLOSE_SESSION
209};
210
057d48bd
RW
211/* forward declarations */
212RB_HEAD(global_adj_head, adj);
213RB_HEAD(nbr_adj_head, adj);
214RB_HEAD(ia_adj_head, adj);
8429abe0
RW
215
216struct map {
217 uint8_t type;
218 uint32_t msg_id;
219 union {
220 struct {
221 uint16_t af;
222 union ldpd_addr prefix;
223 uint8_t prefixlen;
224 } prefix;
225 struct {
226 uint16_t type;
227 uint32_t pwid;
228 uint32_t group_id;
229 uint16_t ifmtu;
230 } pwid;
d4afb819
RW
231 struct {
232 uint8_t type;
233 union {
234 uint16_t prefix_af;
aba50a83 235 uint16_t pw_type;
d4afb819
RW
236 } u;
237 } twcard;
8429abe0
RW
238 } fec;
239 struct {
240 uint32_t status_code;
241 uint32_t msg_id;
242 uint16_t msg_type;
243 } st;
244 uint32_t label;
245 uint32_t requestid;
246 uint32_t pw_status;
247 uint8_t flags;
248};
249#define F_MAP_REQ_ID 0x01 /* optional request message id present */
250#define F_MAP_STATUS 0x02 /* status */
251#define F_MAP_PW_CWORD 0x04 /* pseudowire control word */
252#define F_MAP_PW_ID 0x08 /* pseudowire connection id */
253#define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */
254#define F_MAP_PW_STATUS 0x20 /* pseudowire status */
255
256struct notify_msg {
257 uint32_t status_code;
258 uint32_t msg_id; /* network byte order */
259 uint16_t msg_type; /* network byte order */
260 uint32_t pw_status;
261 struct map fec;
8819fc38
RW
262 struct {
263 uint16_t type;
264 uint16_t length;
265 char *data;
266 } rtlvs;
8429abe0
RW
267 uint8_t flags;
268};
269#define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */
270#define F_NOTIF_FEC 0x02 /* fec tlv present */
8819fc38 271#define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */
8429abe0
RW
272
273struct if_addr {
274 LIST_ENTRY(if_addr) entry;
275 int af;
276 union ldpd_addr addr;
277 uint8_t prefixlen;
278 union ldpd_addr dstbrd;
279};
280LIST_HEAD(if_addr_head, if_addr);
281
282struct iface_af {
283 struct iface *iface;
284 int af;
285 int enabled;
286 int state;
057d48bd 287 struct ia_adj_head adj_tree;
8429abe0 288 time_t uptime;
eac6e3f0 289 struct thread *hello_timer;
8429abe0
RW
290 uint16_t hello_holdtime;
291 uint16_t hello_interval;
292};
293
294struct iface {
7d3d7491 295 RB_ENTRY(iface) entry;
8429abe0
RW
296 char name[IF_NAMESIZE];
297 unsigned int ifindex;
298 struct if_addr_head addr_list;
299 struct in6_addr linklocal;
300 enum iface_type type;
8429abe0 301 uint16_t flags;
8429abe0
RW
302 struct iface_af ipv4;
303 struct iface_af ipv6;
4af8997d 304 QOBJ_FIELDS
8429abe0 305};
7d3d7491
RW
306RB_HEAD(iface_head, iface);
307RB_PROTOTYPE(iface_head, iface, entry, iface_compare);
4af8997d 308DECLARE_QOBJ_TYPE(iface)
8429abe0
RW
309
310/* source of targeted hellos */
311struct tnbr {
7989cdba 312 RB_ENTRY(tnbr) entry;
eac6e3f0 313 struct thread *hello_timer;
8429abe0
RW
314 struct adj *adj;
315 int af;
316 union ldpd_addr addr;
317 int state;
8429abe0
RW
318 uint16_t pw_count;
319 uint8_t flags;
4af8997d 320 QOBJ_FIELDS
8429abe0 321};
7989cdba
RW
322RB_HEAD(tnbr_head, tnbr);
323RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare);
4af8997d 324DECLARE_QOBJ_TYPE(tnbr)
8429abe0
RW
325#define F_TNBR_CONFIGURED 0x01
326#define F_TNBR_DYNAMIC 0x02
327
328enum auth_method {
329 AUTH_NONE,
330 AUTH_MD5SIG
331};
332
333/* neighbor specific parameters */
334struct nbr_params {
76c4abd1 335 RB_ENTRY(nbr_params) entry;
8429abe0
RW
336 struct in_addr lsr_id;
337 uint16_t keepalive;
338 int gtsm_enabled;
339 uint8_t gtsm_hops;
340 struct {
341 enum auth_method method;
342 char md5key[TCP_MD5_KEY_LEN];
343 uint8_t md5key_len;
344 } auth;
345 uint8_t flags;
4af8997d 346 QOBJ_FIELDS
8429abe0 347};
76c4abd1
RW
348RB_HEAD(nbrp_head, nbr_params);
349RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare);
4af8997d 350DECLARE_QOBJ_TYPE(nbr_params)
8429abe0
RW
351#define F_NBRP_KEEPALIVE 0x01
352#define F_NBRP_GTSM 0x02
353#define F_NBRP_GTSM_HOPS 0x04
354
0f7b5df9
RW
355struct ldp_stats {
356 uint32_t kalive_sent;
357 uint32_t kalive_rcvd;
358 uint32_t addr_sent;
359 uint32_t addr_rcvd;
360 uint32_t addrwdraw_sent;
361 uint32_t addrwdraw_rcvd;
362 uint32_t notif_sent;
363 uint32_t notif_rcvd;
364 uint32_t capability_sent;
365 uint32_t capability_rcvd;
366 uint32_t labelmap_sent;
367 uint32_t labelmap_rcvd;
368 uint32_t labelreq_sent;
369 uint32_t labelreq_rcvd;
370 uint32_t labelwdraw_sent;
371 uint32_t labelwdraw_rcvd;
372 uint32_t labelrel_sent;
373 uint32_t labelrel_rcvd;
374 uint32_t labelabreq_sent;
375 uint32_t labelabreq_rcvd;
376};
377
8429abe0 378struct l2vpn_if {
029c1958 379 RB_ENTRY(l2vpn_if) entry;
8429abe0
RW
380 struct l2vpn *l2vpn;
381 char ifname[IF_NAMESIZE];
382 unsigned int ifindex;
383 uint16_t flags;
26519d8c 384 uint8_t mac[ETHER_ADDR_LEN];
4af8997d 385 QOBJ_FIELDS
8429abe0 386};
029c1958
RW
387RB_HEAD(l2vpn_if_head, l2vpn_if);
388RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare);
4af8997d 389DECLARE_QOBJ_TYPE(l2vpn_if)
8429abe0
RW
390
391struct l2vpn_pw {
20bacaeb 392 RB_ENTRY(l2vpn_pw) entry;
8429abe0
RW
393 struct l2vpn *l2vpn;
394 struct in_addr lsr_id;
395 int af;
396 union ldpd_addr addr;
397 uint32_t pwid;
398 char ifname[IF_NAMESIZE];
399 unsigned int ifindex;
400 uint32_t remote_group;
401 uint16_t remote_mtu;
402 uint32_t remote_status;
403 uint8_t flags;
4af8997d 404 QOBJ_FIELDS
8429abe0 405};
20bacaeb
RW
406RB_HEAD(l2vpn_pw_head, l2vpn_pw);
407RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare);
4af8997d 408DECLARE_QOBJ_TYPE(l2vpn_pw)
8429abe0
RW
409#define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */
410#define F_PW_STATUSTLV 0x02 /* status tlv negotiated */
411#define F_PW_CWORD_CONF 0x04 /* control word configured */
412#define F_PW_CWORD 0x08 /* control word negotiated */
413#define F_PW_STATUS_UP 0x10 /* pseudowire is operational */
eac6e3f0 414#define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */
8429abe0
RW
415
416struct l2vpn {
90d7e7bd 417 RB_ENTRY(l2vpn) entry;
8429abe0
RW
418 char name[L2VPN_NAME_LEN];
419 int type;
420 int pw_type;
421 int mtu;
422 char br_ifname[IF_NAMESIZE];
423 unsigned int br_ifindex;
029c1958 424 struct l2vpn_if_head if_tree;
20bacaeb
RW
425 struct l2vpn_pw_head pw_tree;
426 struct l2vpn_pw_head pw_inactive_tree;
4af8997d 427 QOBJ_FIELDS
8429abe0 428};
90d7e7bd
RW
429RB_HEAD(l2vpn_head, l2vpn);
430RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare);
4af8997d 431DECLARE_QOBJ_TYPE(l2vpn)
8429abe0
RW
432#define L2VPN_TYPE_VPWS 1
433#define L2VPN_TYPE_VPLS 2
434
435/* ldp_conf */
436enum ldpd_process {
437 PROC_MAIN,
438 PROC_LDP_ENGINE,
439 PROC_LDE_ENGINE
440} ldpd_process;
441
442enum socket_type {
443 LDP_SOCKET_DISC,
444 LDP_SOCKET_EDISC,
445 LDP_SOCKET_SESSION
446};
447
448enum hello_type {
449 HELLO_LINK,
450 HELLO_TARGETED
451};
452
453struct ldpd_af_conf {
454 uint16_t keepalive;
eac6e3f0
RW
455 uint16_t lhello_holdtime;
456 uint16_t lhello_interval;
8429abe0
RW
457 uint16_t thello_holdtime;
458 uint16_t thello_interval;
459 union ldpd_addr trans_addr;
45a8eba9
RW
460 char acl_thello_accept_from[ACL_NAMSIZ];
461 char acl_label_allocate_for[ACL_NAMSIZ];
462 char acl_label_advertise_to[ACL_NAMSIZ];
463 char acl_label_advertise_for[ACL_NAMSIZ];
464 char acl_label_expnull_for[ACL_NAMSIZ];
465 char acl_label_accept_from[ACL_NAMSIZ];
466 char acl_label_accept_for[ACL_NAMSIZ];
8429abe0
RW
467 int flags;
468};
469#define F_LDPD_AF_ENABLED 0x0001
470#define F_LDPD_AF_THELLO_ACCEPT 0x0002
471#define F_LDPD_AF_EXPNULL 0x0004
472#define F_LDPD_AF_NO_GTSM 0x0008
45a8eba9 473#define F_LDPD_AF_ALLOCHOSTONLY 0x0010
8429abe0
RW
474
475struct ldpd_conf {
476 struct in_addr rtr_id;
477 struct ldpd_af_conf ipv4;
478 struct ldpd_af_conf ipv6;
7d3d7491 479 struct iface_head iface_tree;
7989cdba 480 struct tnbr_head tnbr_tree;
76c4abd1 481 struct nbrp_head nbrp_tree;
90d7e7bd 482 struct l2vpn_head l2vpn_tree;
eac6e3f0
RW
483 uint16_t lhello_holdtime;
484 uint16_t lhello_interval;
485 uint16_t thello_holdtime;
486 uint16_t thello_interval;
8429abe0
RW
487 uint16_t trans_pref;
488 int flags;
4af8997d 489 QOBJ_FIELDS
8429abe0 490};
4af8997d 491DECLARE_QOBJ_TYPE(ldpd_conf)
8429abe0
RW
492#define F_LDPD_NO_FIB_UPDATE 0x0001
493#define F_LDPD_DS_CISCO_INTEROP 0x0002
eac6e3f0 494#define F_LDPD_ENABLED 0x0004
8429abe0
RW
495
496struct ldpd_af_global {
eac6e3f0
RW
497 struct thread *disc_ev;
498 struct thread *edisc_ev;
8429abe0
RW
499 int ldp_disc_socket;
500 int ldp_edisc_socket;
501 int ldp_session_socket;
502};
503
504struct ldpd_global {
505 int cmd_opts;
dbce3582 506 int sighup;
8429abe0 507 time_t uptime;
eac6e3f0 508 struct in_addr rtr_id;
8429abe0
RW
509 struct ldpd_af_global ipv4;
510 struct ldpd_af_global ipv6;
511 uint32_t conf_seqnum;
512 int pfkeysock;
513 struct if_addr_head addr_list;
057d48bd 514 struct global_adj_head adj_tree;
8429abe0
RW
515 struct in_addr mcast_addr_v4;
516 struct in6_addr mcast_addr_v6;
517 TAILQ_HEAD(, pending_conn) pending_conns;
518};
519
520/* kroute */
521struct kroute {
522 int af;
523 union ldpd_addr prefix;
524 uint8_t prefixlen;
525 union ldpd_addr nexthop;
526 uint32_t local_label;
527 uint32_t remote_label;
528 unsigned short ifindex;
529 uint8_t priority;
530 uint16_t flags;
531};
532
533struct kpw {
534 unsigned short ifindex;
535 int pw_type;
536 int af;
537 union ldpd_addr nexthop;
538 uint32_t local_label;
539 uint32_t remote_label;
540 uint8_t flags;
541};
542
543struct kaddr {
544 unsigned short ifindex;
545 int af;
546 union ldpd_addr addr;
547 uint8_t prefixlen;
548 union ldpd_addr dstbrd;
549};
550
551struct kif {
552 char ifname[IF_NAMESIZE];
553 unsigned short ifindex;
554 int flags;
26519d8c 555 uint8_t mac[ETHER_ADDR_LEN];
8429abe0 556 int mtu;
8429abe0
RW
557};
558
45a8eba9
RW
559struct acl_check {
560 char acl[ACL_NAMSIZ];
561 int af;
562 union ldpd_addr addr;
563 uint8_t prefixlen;
564};
565
8429abe0
RW
566/* control data structures */
567struct ctl_iface {
568 int af;
569 char name[IF_NAMESIZE];
570 unsigned int ifindex;
571 int state;
572 uint16_t flags;
8429abe0 573 enum iface_type type;
8429abe0
RW
574 uint16_t hello_holdtime;
575 uint16_t hello_interval;
576 time_t uptime;
577 uint16_t adj_cnt;
578};
579
eac6e3f0
RW
580struct ctl_disc_if {
581 char name[IF_NAMESIZE];
582 int active_v4;
583 int active_v6;
584 int no_adj;
585};
586
587struct ctl_disc_tnbr {
588 int af;
589 union ldpd_addr addr;
590 int no_adj;
591};
592
8429abe0
RW
593struct ctl_adj {
594 int af;
595 struct in_addr id;
596 enum hello_type type;
597 char ifname[IF_NAMESIZE];
598 union ldpd_addr src_addr;
599 uint16_t holdtime;
0f7b5df9 600 uint16_t holdtime_remaining;
8429abe0 601 union ldpd_addr trans_addr;
0f7b5df9 602 int ds_tlv;
8429abe0
RW
603};
604
605struct ctl_nbr {
606 int af;
607 struct in_addr id;
608 union ldpd_addr laddr;
eac6e3f0 609 in_port_t lport;
8429abe0 610 union ldpd_addr raddr;
eac6e3f0 611 in_port_t rport;
0f7b5df9 612 enum auth_method auth_method;
eac6e3f0 613 uint16_t holdtime;
8429abe0
RW
614 time_t uptime;
615 int nbr_state;
0f7b5df9 616 struct ldp_stats stats;
99cfc17f 617 int flags;
8429abe0
RW
618};
619
620struct ctl_rt {
621 int af;
622 union ldpd_addr prefix;
623 uint8_t prefixlen;
624 struct in_addr nexthop; /* lsr-id */
625 uint32_t local_label;
626 uint32_t remote_label;
627 uint8_t flags;
628 uint8_t in_use;
0f7b5df9 629 int no_downstream;
8429abe0
RW
630};
631
632struct ctl_pw {
633 uint16_t type;
eac6e3f0 634 char l2vpn_name[L2VPN_NAME_LEN];
8429abe0
RW
635 char ifname[IF_NAMESIZE];
636 uint32_t pwid;
637 struct in_addr lsr_id;
638 uint32_t local_label;
639 uint32_t local_gid;
640 uint16_t local_ifmtu;
eac6e3f0 641 uint8_t local_cword;
8429abe0
RW
642 uint32_t remote_label;
643 uint32_t remote_gid;
644 uint16_t remote_ifmtu;
eac6e3f0 645 uint8_t remote_cword;
8429abe0
RW
646 uint32_t status;
647};
648
56b8a8d2 649extern struct ldpd_conf *ldpd_conf, *vty_conf;
8429abe0
RW
650extern struct ldpd_global global;
651
652/* parse.y */
653struct ldpd_conf *parse_config(char *);
654int cmdline_symset(char *);
655
656/* kroute.c */
8429abe0
RW
657void kif_redistribute(const char *);
658int kr_change(struct kroute *);
659int kr_delete(struct kroute *);
8429abe0
RW
660int kmpw_set(struct kpw *);
661int kmpw_unset(struct kpw *);
662
663/* util.c */
664uint8_t mask2prefixlen(in_addr_t);
665uint8_t mask2prefixlen6(struct sockaddr_in6 *);
666in_addr_t prefixlen2mask(uint8_t);
667struct in6_addr *prefixlen2mask6(uint8_t);
668void ldp_applymask(int, union ldpd_addr *,
669 const union ldpd_addr *, int);
670int ldp_addrcmp(int, const union ldpd_addr *,
671 const union ldpd_addr *);
672int ldp_addrisset(int, const union ldpd_addr *);
673int ldp_prefixcmp(int, const union ldpd_addr *,
674 const union ldpd_addr *, uint8_t);
675int bad_addr_v4(struct in_addr);
676int bad_addr_v6(struct in6_addr *);
677int bad_addr(int, union ldpd_addr *);
678void embedscope(struct sockaddr_in6 *);
679void recoverscope(struct sockaddr_in6 *);
680void addscope(struct sockaddr_in6 *, uint32_t);
681void clearscope(struct in6_addr *);
682struct sockaddr *addr2sa(int af, union ldpd_addr *, uint16_t);
eac6e3f0
RW
683void sa2addr(struct sockaddr *, int *, union ldpd_addr *,
684 in_port_t *);
685socklen_t sockaddr_len(struct sockaddr *);
8429abe0
RW
686
687/* ldpd.c */
eac6e3f0 688int ldp_write_handler(struct thread *);
8429abe0
RW
689void main_imsg_compose_ldpe(int, pid_t, void *, uint16_t);
690void main_imsg_compose_lde(int, pid_t, void *, uint16_t);
eac6e3f0
RW
691int main_imsg_compose_both(enum imsg_type, void *,
692 uint16_t);
8429abe0 693void imsg_event_add(struct imsgev *);
eac6e3f0
RW
694int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
695 pid_t, int, void *, uint16_t);
8429abe0
RW
696void evbuf_enqueue(struct evbuf *, struct ibuf *);
697void evbuf_event_add(struct evbuf *);
eac6e3f0
RW
698void evbuf_init(struct evbuf *, int,
699 int (*)(struct thread *), void *);
8429abe0 700void evbuf_clear(struct evbuf *);
45a8eba9
RW
701int ldp_acl_request(struct imsgev *, char *, int,
702 union ldpd_addr *, uint8_t);
703void ldp_acl_reply(struct imsgev *, struct acl_check *);
8429abe0
RW
704struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int);
705struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int);
706int ldp_is_dual_stack(struct ldpd_conf *);
eac6e3f0
RW
707in_addr_t ldp_rtr_id_get(struct ldpd_conf *);
708int ldp_reload(struct ldpd_conf *);
eac6e3f0 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_ */