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