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>
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.
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.
26 #include "openbsd-tree.h"
37 #include "lib/ldp_sync.h"
39 #define CONF_FILE "/etc/ldpd.conf"
40 #define LDPD_USER "_ldpd"
42 #define LDPD_FD_ASYNC 3
43 #define LDPD_FD_SYNC 4
45 #define LDPD_OPT_VERBOSE 0x00000001
46 #define LDPD_OPT_VERBOSE2 0x00000002
47 #define LDPD_OPT_NOACTION 0x00000004
49 #define TCP_MD5_KEY_LEN 80
51 #define RT_BUF_SIZE 16384
52 #define MAX_RTSOCK_BUF 128 * 1024
53 #define LDP_BACKLOG 128
55 #define F_LDPD_INSERTED 0x0001
56 #define F_CONNECTED 0x0002
57 #define F_STATIC 0x0004
58 #define F_DYNAMIC 0x0008
59 #define F_REJECT 0x0010
60 #define F_BLACKHOLE 0x0020
61 #define F_REDISTRIBUTED 0x0040
66 int (*handler
)(struct thread
*);
72 int (*handler_write
)(struct thread
*);
73 struct thread
*ev_write
;
74 int (*handler_read
)(struct thread
*);
75 struct thread
*ev_read
;
81 IMSG_CTL_SHOW_INTERFACE
,
82 IMSG_CTL_SHOW_DISCOVERY
,
83 IMSG_CTL_SHOW_DISCOVERY_DTL
,
84 IMSG_CTL_SHOW_DISC_IFACE
,
85 IMSG_CTL_SHOW_DISC_TNBR
,
86 IMSG_CTL_SHOW_DISC_ADJ
,
88 IMSG_CTL_SHOW_NBR_DISC
,
89 IMSG_CTL_SHOW_NBR_END
,
91 IMSG_CTL_SHOW_LIB_BEGIN
,
92 IMSG_CTL_SHOW_LIB_SENT
,
93 IMSG_CTL_SHOW_LIB_RCVD
,
94 IMSG_CTL_SHOW_LIB_END
,
95 IMSG_CTL_SHOW_L2VPN_PW
,
96 IMSG_CTL_SHOW_L2VPN_BINDING
,
97 IMSG_CTL_SHOW_LDP_SYNC
,
100 IMSG_CTL_FIB_DECOUPLE
,
102 IMSG_CTL_KROUTE_ADDR
,
105 IMSG_CTL_LOG_VERBOSE
,
117 IMSG_LABEL_MAPPING_FULL
,
123 IMSG_REQUEST_ADD_END
,
125 IMSG_MAPPING_ADD_END
,
127 IMSG_RELEASE_ADD_END
,
129 IMSG_WITHDRAW_ADD_END
,
133 IMSG_NOTIFICATION_SEND
,
141 IMSG_REQUEST_SOCKETS
,
148 IMSG_RECONF_L2VPN_IF
,
149 IMSG_RECONF_L2VPN_PW
,
150 IMSG_RECONF_L2VPN_IPW
,
159 IMSG_LDP_SYNC_IF_STATE_REQUEST
,
160 IMSG_LDP_SYNC_IF_STATE_UPDATE
,
170 char ctl_sock_path
[MAXPATHLEN
];
171 char zclient_serv_path
[MAXPATHLEN
];
172 unsigned short instance
;
176 char name
[ACL_NAMSIZ
];
184 #define IN6_IS_SCOPE_EMBED(a) \
185 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
186 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
187 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
189 /* interface states */
190 #define IF_STA_DOWN 0x01
191 #define IF_STA_ACTIVE 0x02
193 /* targeted neighbor states */
194 #define TNBR_STA_DOWN 0x01
195 #define TNBR_STA_ACTIVE 0x02
197 /* interface types */
203 /* neighbor states */
204 #define NBR_STA_PRESENT 0x0001
205 #define NBR_STA_INITIAL 0x0002
206 #define NBR_STA_OPENREC 0x0004
207 #define NBR_STA_OPENSENT 0x0008
208 #define NBR_STA_OPER 0x0010
209 #define NBR_STA_SESSION (NBR_STA_INITIAL | NBR_STA_OPENREC | \
210 NBR_STA_OPENSENT | NBR_STA_OPER)
212 /* neighbor events */
217 NBR_EVT_CLOSE_SESSION
,
219 NBR_EVT_KEEPALIVE_RCVD
,
225 /* neighbor actions */
228 NBR_ACT_RST_KTIMEOUT
,
231 NBR_ACT_CONNECT_SETUP
,
232 NBR_ACT_PASSIVE_INIT
,
233 NBR_ACT_KEEPALIVE_SEND
,
234 NBR_ACT_CLOSE_SESSION
237 /* LDP IGP Sync states */
238 #define LDP_SYNC_STA_UNKNOWN 0x0000
239 #define LDP_SYNC_STA_NOT_ACH 0x0001
240 #define LDP_SYNC_STA_ACH 0x0002
242 /* LDP IGP Sync events */
243 enum ldp_sync_event
{
244 LDP_SYNC_EVT_NOTHING
,
245 LDP_SYNC_EVT_LDP_SYNC_START
,
246 LDP_SYNC_EVT_LDP_SYNC_COMPLETE
,
247 LDP_SYNC_EVT_CONFIG_LDP_OFF
,
248 LDP_SYNC_EVT_ADJ_DEL
,
249 LDP_SYNC_EVT_ADJ_NEW
,
250 LDP_SYNC_EVT_SESSION_CLOSE
,
251 LDP_SYNC_EVT_CONFIG_LDP_ON
,
252 LDP_SYNC_EVT_IFACE_SHUTDOWN
255 /* LDP IGP Sync actions */
256 enum ldp_sync_action
{
257 LDP_SYNC_ACT_NOTHING
,
258 LDP_SYNC_ACT_IFACE_START_SYNC
,
259 LDP_SYNC_ACT_LDP_START_SYNC
,
260 LDP_SYNC_ACT_LDP_COMPLETE_SYNC
,
261 LDP_SYNC_ACT_CONFIG_LDP_OFF
,
262 LDP_SYNC_ACT_IFACE_SHUTDOWN
265 /* forward declarations */
266 RB_HEAD(global_adj_head
, adj
);
267 RB_HEAD(nbr_adj_head
, adj
);
268 RB_HEAD(ia_adj_head
, adj
);
276 union ldpd_addr prefix
;
294 uint32_t status_code
;
303 #define F_MAP_REQ_ID 0x01 /* optional request message id present */
304 #define F_MAP_STATUS 0x02 /* status */
305 #define F_MAP_PW_CWORD 0x04 /* pseudowire control word */
306 #define F_MAP_PW_ID 0x08 /* pseudowire connection id */
307 #define F_MAP_PW_IFMTU 0x10 /* pseudowire interface parameter */
308 #define F_MAP_PW_STATUS 0x20 /* pseudowire status */
311 uint32_t status_code
;
312 uint32_t msg_id
; /* network byte order */
313 uint16_t msg_type
; /* network byte order */
323 #define F_NOTIF_PW_STATUS 0x01 /* pseudowire status tlv present */
324 #define F_NOTIF_FEC 0x02 /* fec tlv present */
325 #define F_NOTIF_RETURNED_TLVS 0x04 /* returned tlvs present */
328 LIST_ENTRY(if_addr
) entry
;
330 union ldpd_addr addr
;
332 union ldpd_addr dstbrd
;
334 LIST_HEAD(if_addr_head
, if_addr
);
341 struct ia_adj_head adj_tree
;
343 struct thread
*hello_timer
;
344 uint16_t hello_holdtime
;
345 uint16_t hello_interval
;
348 struct iface_ldp_sync
{
350 struct thread
*wait_for_sync_timer
;
354 RB_ENTRY(iface
) entry
;
355 char name
[IF_NAMESIZE
];
357 struct if_addr_head addr_list
;
358 struct in6_addr linklocal
;
359 enum iface_type type
;
361 struct iface_af ipv4
;
362 struct iface_af ipv6
;
363 struct iface_ldp_sync ldp_sync
;
366 RB_HEAD(iface_head
, iface
);
367 RB_PROTOTYPE(iface_head
, iface
, entry
, iface_compare
);
368 DECLARE_QOBJ_TYPE(iface
);
370 /* source of targeted hellos */
372 RB_ENTRY(tnbr
) entry
;
373 struct thread
*hello_timer
;
376 union ldpd_addr addr
;
383 RB_HEAD(tnbr_head
, tnbr
);
384 RB_PROTOTYPE(tnbr_head
, tnbr
, entry
, tnbr_compare
);
385 DECLARE_QOBJ_TYPE(tnbr
);
386 #define F_TNBR_CONFIGURED 0x01
387 #define F_TNBR_DYNAMIC 0x02
394 /* neighbor specific parameters */
396 RB_ENTRY(nbr_params
) entry
;
397 struct in_addr lsr_id
;
402 enum auth_method method
;
403 char md5key
[TCP_MD5_KEY_LEN
];
409 RB_HEAD(nbrp_head
, nbr_params
);
410 RB_PROTOTYPE(nbrp_head
, nbr_params
, entry
, nbr_params_compare
);
411 DECLARE_QOBJ_TYPE(nbr_params
);
412 #define F_NBRP_KEEPALIVE 0x01
413 #define F_NBRP_GTSM 0x02
414 #define F_NBRP_GTSM_HOPS 0x04
417 uint32_t kalive_sent
;
418 uint32_t kalive_rcvd
;
421 uint32_t addrwdraw_sent
;
422 uint32_t addrwdraw_rcvd
;
425 uint32_t capability_sent
;
426 uint32_t capability_rcvd
;
427 uint32_t labelmap_sent
;
428 uint32_t labelmap_rcvd
;
429 uint32_t labelreq_sent
;
430 uint32_t labelreq_rcvd
;
431 uint32_t labelwdraw_sent
;
432 uint32_t labelwdraw_rcvd
;
433 uint32_t labelrel_sent
;
434 uint32_t labelrel_rcvd
;
435 uint32_t labelabreq_sent
;
436 uint32_t labelabreq_rcvd
;
437 uint32_t unknown_tlv
;
438 uint32_t unknown_msg
;
442 struct ldp_entity_stats
{
443 uint32_t session_attempts
;
444 uint32_t session_rejects_hello
;
445 uint32_t session_rejects_ad
;
446 uint32_t session_rejects_max_pdu
;
447 uint32_t session_rejects_lr
;
449 uint32_t bad_pdu_len
;
450 uint32_t bad_msg_len
;
451 uint32_t bad_tlv_len
;
452 uint32_t malformed_tlv
;
453 uint32_t keepalive_timer_exp
;
454 uint32_t shutdown_rcv_notify
;
455 uint32_t shutdown_send_notify
;
459 RB_ENTRY(l2vpn_if
) entry
;
461 char ifname
[IF_NAMESIZE
];
464 uint8_t mac
[ETH_ALEN
];
467 RB_HEAD(l2vpn_if_head
, l2vpn_if
);
468 RB_PROTOTYPE(l2vpn_if_head
, l2vpn_if
, entry
, l2vpn_if_compare
);
469 DECLARE_QOBJ_TYPE(l2vpn_if
);
472 RB_ENTRY(l2vpn_pw
) entry
;
474 struct in_addr lsr_id
;
476 union ldpd_addr addr
;
478 char ifname
[IF_NAMESIZE
];
481 uint32_t remote_group
;
483 uint32_t local_status
;
484 uint32_t remote_status
;
489 RB_HEAD(l2vpn_pw_head
, l2vpn_pw
);
490 RB_PROTOTYPE(l2vpn_pw_head
, l2vpn_pw
, entry
, l2vpn_pw_compare
);
491 DECLARE_QOBJ_TYPE(l2vpn_pw
);
492 #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */
493 #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */
494 #define F_PW_CWORD_CONF 0x04 /* control word configured */
495 #define F_PW_CWORD 0x08 /* control word negotiated */
496 #define F_PW_STATIC_NBR_ADDR 0x10 /* static neighbor address configured */
498 #define F_PW_NO_ERR 0x00 /* no error reported */
499 #define F_PW_LOCAL_NOT_FWD 0x01 /* locally can't forward over PW */
500 #define F_PW_REMOTE_NOT_FWD 0x02 /* remote end of PW reported fwd error*/
501 #define F_PW_NO_REMOTE_LABEL 0x03 /* have not recvd label from peer */
502 #define F_PW_MTU_MISMATCH 0x04 /* mtu mismatch between peers */
505 RB_ENTRY(l2vpn
) entry
;
506 char name
[L2VPN_NAME_LEN
];
510 char br_ifname
[IF_NAMESIZE
];
511 ifindex_t br_ifindex
;
512 struct l2vpn_if_head if_tree
;
513 struct l2vpn_pw_head pw_tree
;
514 struct l2vpn_pw_head pw_inactive_tree
;
517 RB_HEAD(l2vpn_head
, l2vpn
);
518 RB_PROTOTYPE(l2vpn_head
, l2vpn
, entry
, l2vpn_compare
);
519 DECLARE_QOBJ_TYPE(l2vpn
);
520 #define L2VPN_TYPE_VPWS 1
521 #define L2VPN_TYPE_VPLS 2
524 extern enum ldpd_process
{
530 static const char * const log_procnames
[] = {
547 struct ldpd_af_conf
{
549 uint16_t lhello_holdtime
;
550 uint16_t lhello_interval
;
551 uint16_t thello_holdtime
;
552 uint16_t thello_interval
;
553 union ldpd_addr trans_addr
;
554 char acl_thello_accept_from
[ACL_NAMSIZ
];
555 char acl_label_allocate_for
[ACL_NAMSIZ
];
556 char acl_label_advertise_to
[ACL_NAMSIZ
];
557 char acl_label_advertise_for
[ACL_NAMSIZ
];
558 char acl_label_expnull_for
[ACL_NAMSIZ
];
559 char acl_label_accept_from
[ACL_NAMSIZ
];
560 char acl_label_accept_for
[ACL_NAMSIZ
];
563 #define F_LDPD_AF_ENABLED 0x0001
564 #define F_LDPD_AF_THELLO_ACCEPT 0x0002
565 #define F_LDPD_AF_EXPNULL 0x0004
566 #define F_LDPD_AF_NO_GTSM 0x0008
567 #define F_LDPD_AF_ALLOCHOSTONLY 0x0010
570 struct in_addr rtr_id
;
571 struct ldpd_af_conf ipv4
;
572 struct ldpd_af_conf ipv6
;
573 struct iface_head iface_tree
;
574 struct tnbr_head tnbr_tree
;
575 struct nbrp_head nbrp_tree
;
576 struct l2vpn_head l2vpn_tree
;
577 uint16_t lhello_holdtime
;
578 uint16_t lhello_interval
;
579 uint16_t thello_holdtime
;
580 uint16_t thello_interval
;
582 uint16_t wait_for_sync_interval
;
584 time_t config_change_time
;
585 struct ldp_entity_stats stats
;
588 DECLARE_QOBJ_TYPE(ldpd_conf
);
589 #define F_LDPD_NO_FIB_UPDATE 0x0001
590 #define F_LDPD_DS_CISCO_INTEROP 0x0002
591 #define F_LDPD_ENABLED 0x0004
592 #define F_LDPD_ORDERED_CONTROL 0x0008
593 #define F_LDPD_ALLOW_BROKEN_LSP 0x0010
595 struct ldpd_af_global
{
596 struct thread
*disc_ev
;
597 struct thread
*edisc_ev
;
599 int ldp_edisc_socket
;
600 int ldp_session_socket
;
605 struct in_addr rtr_id
;
606 struct ldpd_af_global ipv4
;
607 struct ldpd_af_global ipv6
;
608 uint32_t conf_seqnum
;
610 struct if_addr_head addr_list
;
611 struct global_adj_head adj_tree
;
612 struct in_addr mcast_addr_v4
;
613 struct in6_addr mcast_addr_v6
;
614 TAILQ_HEAD(, pending_conn
) pending_conns
;
620 union ldpd_addr prefix
;
622 union ldpd_addr nexthop
;
623 uint32_t local_label
;
624 uint32_t remote_label
;
627 uint8_t route_instance
;
632 char ifname
[IF_NAMESIZE
];
635 union ldpd_addr addr
;
637 union ldpd_addr dstbrd
;
641 char ifname
[IF_NAMESIZE
];
645 uint8_t mac
[ETH_ALEN
];
650 char acl
[ACL_NAMSIZ
];
652 union ldpd_addr addr
;
656 /* control data structures */
659 char name
[IF_NAMESIZE
];
662 enum iface_type type
;
663 uint16_t hello_holdtime
;
664 uint16_t hello_interval
;
670 char name
[IF_NAMESIZE
];
676 struct ctl_disc_tnbr
{
678 union ldpd_addr addr
;
685 enum hello_type type
;
686 char ifname
[IF_NAMESIZE
];
687 union ldpd_addr src_addr
;
689 uint16_t holdtime_remaining
;
690 union ldpd_addr trans_addr
;
697 union ldpd_addr laddr
;
699 union ldpd_addr raddr
;
701 enum auth_method auth_method
;
705 struct ldp_stats stats
;
707 uint16_t max_pdu_len
;
708 uint16_t hold_time_remaining
;
713 union ldpd_addr prefix
;
715 struct in_addr nexthop
; /* lsr-id */
716 uint32_t local_label
;
717 uint32_t remote_label
;
725 char l2vpn_name
[L2VPN_NAME_LEN
];
726 char ifname
[IF_NAMESIZE
];
728 struct in_addr lsr_id
;
729 uint32_t local_label
;
731 uint16_t local_ifmtu
;
733 uint32_t remote_label
;
735 uint16_t remote_ifmtu
;
736 uint8_t remote_cword
;
741 struct ctl_ldp_sync
{
742 char name
[IF_NAMESIZE
];
747 uint16_t wait_time_remaining
;
748 struct in_addr peer_ldp_id
;
751 extern struct ldpd_conf
*ldpd_conf
, *vty_conf
;
752 extern struct ldpd_global global
;
753 extern struct ldpd_init init
;
756 struct ldpd_conf
*parse_config(char *);
757 int cmdline_symset(char *);
760 void pw2zpw(struct l2vpn_pw
*, struct zapi_pw
*);
761 void kif_redistribute(const char *);
762 int kr_change(struct kroute
*);
763 int kr_delete(struct kroute
*);
764 int kmpw_add(struct zapi_pw
*);
765 int kmpw_del(struct zapi_pw
*);
766 int kmpw_set(struct zapi_pw
*);
767 int kmpw_unset(struct zapi_pw
*);
770 uint8_t mask2prefixlen(in_addr_t
);
771 uint8_t mask2prefixlen6(struct sockaddr_in6
*);
772 in_addr_t
prefixlen2mask(uint8_t);
773 struct in6_addr
*prefixlen2mask6(uint8_t);
774 void ldp_applymask(int, union ldpd_addr
*,
775 const union ldpd_addr
*, int);
776 int ldp_addrcmp(int, const union ldpd_addr
*,
777 const union ldpd_addr
*);
778 int ldp_addrisset(int, const union ldpd_addr
*);
779 int ldp_prefixcmp(int, const union ldpd_addr
*,
780 const union ldpd_addr
*, uint8_t);
781 int bad_addr_v4(struct in_addr
);
782 int bad_addr_v6(struct in6_addr
*);
783 int bad_addr(int, union ldpd_addr
*);
784 void embedscope(struct sockaddr_in6
*);
785 void recoverscope(struct sockaddr_in6
*);
786 void addscope(struct sockaddr_in6
*, uint32_t);
787 void clearscope(struct in6_addr
*);
788 void addr2sa(int af
, const union ldpd_addr
*, uint16_t,
789 union sockunion
*su
);
790 void sa2addr(struct sockaddr
*, int *, union ldpd_addr
*,
792 socklen_t
sockaddr_len(struct sockaddr
*);
795 int ldp_write_handler(struct thread
*);
796 void main_imsg_compose_ldpe(int, pid_t
, void *, uint16_t);
797 void main_imsg_compose_lde(int, pid_t
, void *, uint16_t);
798 int main_imsg_compose_both(enum imsg_type
, void *,
800 void imsg_event_add(struct imsgev
*);
801 int imsg_compose_event(struct imsgev
*, uint16_t, uint32_t,
802 pid_t
, int, void *, uint16_t);
803 void evbuf_enqueue(struct evbuf
*, struct ibuf
*);
804 void evbuf_event_add(struct evbuf
*);
805 void evbuf_init(struct evbuf
*, int,
806 int (*)(struct thread
*), void *);
807 void evbuf_clear(struct evbuf
*);
808 int ldp_acl_request(struct imsgev
*, char *, int,
809 union ldpd_addr
*, uint8_t);
810 void ldp_acl_reply(struct imsgev
*, struct acl_check
*);
811 struct ldpd_af_conf
*ldp_af_conf_get(struct ldpd_conf
*, int);
812 struct ldpd_af_global
*ldp_af_global_get(struct ldpd_global
*, int);
813 int ldp_is_dual_stack(struct ldpd_conf
*);
814 in_addr_t
ldp_rtr_id_get(struct ldpd_conf
*);
815 int ldp_config_apply(struct vty
*, struct ldpd_conf
*);
816 void ldp_clear_config(struct ldpd_conf
*);
817 void merge_config(struct ldpd_conf
*, struct ldpd_conf
*);
818 struct ldpd_conf
*config_new_empty(void);
819 void config_clear(struct ldpd_conf
*);
822 /* NOTE: the parameters' names should be preserved because of codegen */
823 struct iface
*iface_new_api(struct ldpd_conf
*conf
,
825 void iface_del_api(struct ldpd_conf
*conf
,
826 struct iface
*iface
);
827 struct tnbr
*tnbr_new_api(struct ldpd_conf
*conf
, int af
,
828 union ldpd_addr
*addr
);
829 void tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
);
830 struct nbr_params
*nbrp_new_api(struct ldpd_conf
*conf
,
831 struct in_addr lsr_id
);
832 void nbrp_del_api(struct ldpd_conf
*conf
,
833 struct nbr_params
*nbrp
);
834 struct l2vpn
*l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
);
835 void l2vpn_del_api(struct ldpd_conf
*conf
,
836 struct l2vpn
*l2vpn
);
837 struct l2vpn_if
*l2vpn_if_new_api(struct ldpd_conf
*conf
,
838 struct l2vpn
*l2vpn
, const char *ifname
);
839 void l2vpn_if_del_api(struct l2vpn
*l2vpn
,
840 struct l2vpn_if
*lif
);
841 struct l2vpn_pw
*l2vpn_pw_new_api(struct ldpd_conf
*conf
,
842 struct l2vpn
*l2vpn
, const char *ifname
);
843 void l2vpn_pw_del_api(struct l2vpn
*l2vpn
,
844 struct l2vpn_pw
*pw
);
847 int ldp_create_socket(int, enum socket_type
);
848 void sock_set_nonblock(int);
849 void sock_set_cloexec(int);
850 void sock_set_recvbuf(int);
851 int sock_set_reuse(int, int);
852 int sock_set_bindany(int, int);
853 int sock_set_md5sig(int, int, union ldpd_addr
*, const char *);
854 int sock_set_ipv4_tos(int, int);
855 int sock_set_ipv4_pktinfo(int, int);
856 int sock_set_ipv4_recvdstaddr(int fd
, ifindex_t ifindex
);
857 int sock_set_ipv4_recvif(int, int);
858 int sock_set_ipv4_minttl(int, int);
859 int sock_set_ipv4_ucast_ttl(int fd
, int);
860 int sock_set_ipv4_mcast_ttl(int, uint8_t);
861 int sock_set_ipv4_mcast(struct iface
*);
862 int sock_set_ipv4_mcast_loop(int);
863 int sock_set_ipv6_dscp(int, int);
864 int sock_set_ipv6_pktinfo(int, int);
865 int sock_set_ipv6_minhopcount(int, int);
866 int sock_set_ipv6_ucast_hops(int, int);
867 int sock_set_ipv6_mcast_hops(int, int);
868 int sock_set_ipv6_mcast(struct iface
*);
869 int sock_set_ipv6_mcast_loop(int);
877 const char *log_sockaddr(void *);
878 const char *log_in6addr(const struct in6_addr
*);
879 const char *log_in6addr_scope(const struct in6_addr
*addr
,
881 const char *log_addr(int, const union ldpd_addr
*);
882 char *log_label(uint32_t);
883 const char *log_time(time_t);
884 char *log_hello_src(const struct hello_source
*);
885 const char *log_map(const struct map
*);
886 const char *log_fec(const struct fec
*);
887 const char *af_name(int);
888 const char *socket_name(int);
889 const char *nbr_state_name(int);
890 const char *if_state_name(int);
891 const char *if_type_name(enum iface_type
);
892 const char *msg_name(uint16_t);
893 const char *status_code_name(uint32_t);
894 const char *pw_type_name(uint16_t);
895 const char *pw_error_code(uint8_t);
898 extern struct thread_master
*master
;
899 extern char ctl_sock_path
[MAXPATHLEN
];
902 void ldp_zebra_init(struct thread_master
*);
903 void ldp_zebra_destroy(void);
904 int ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state
*);
905 int ldp_zebra_send_rlfa_labels(struct zapi_rlfa_response
*
908 void ldp_zebra_regdereg_zebra_info(bool want_register
);
912 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
913 #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
914 #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
915 (IN6_IS_ADDR_MULTICAST(a) && \
916 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL))
919 DECLARE_HOOK(ldp_register_mib
, (struct thread_master
* tm
), (tm
));
921 extern void ldp_agentx_enabled(void);
923 #endif /* _LDPD_H_ */