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