]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/ldpe.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ldpd / ldpe.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: ISC
8429abe0
RW
2/* $OpenBSD$ */
3
4/*
5 * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
6 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
7 * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
8429abe0
RW
8 */
9
10#ifndef _LDPE_H_
11#define _LDPE_H_
12
cd85bc2e 13#include "queue.h"
eac6e3f0
RW
14#include "openbsd-tree.h"
15#ifdef __OpenBSD__
8429abe0 16#include <net/pfkeyv2.h>
eac6e3f0 17#endif
8429abe0
RW
18
19#include "ldpd.h"
e1894ff7 20#include "lib/ldp_sync.h"
8429abe0 21
057d48bd
RW
22/* forward declarations */
23TAILQ_HEAD(mapping_head, mapping_entry);
24
8429abe0
RW
25struct hello_source {
26 enum hello_type type;
27 struct {
28 struct iface_af *ia;
29 union ldpd_addr src_addr;
30 } link;
31 struct tnbr *target;
32};
33
34struct adj {
057d48bd 35 RB_ENTRY(adj) global_entry, nbr_entry, ia_entry;
8429abe0
RW
36 struct in_addr lsr_id;
37 struct nbr *nbr;
38 int ds_tlv;
39 struct hello_source source;
eac6e3f0 40 struct thread *inactivity_timer;
8429abe0
RW
41 uint16_t holdtime;
42 union ldpd_addr trans_addr;
43};
057d48bd
RW
44RB_PROTOTYPE(global_adj_head, adj, global_entry, adj_compare)
45RB_PROTOTYPE(nbr_adj_head, adj, nbr_entry, adj_compare)
46RB_PROTOTYPE(ia_adj_head, adj, ia_entry, adj_compare)
8429abe0
RW
47
48struct tcp_conn {
49 struct nbr *nbr;
50 int fd;
51 struct ibuf_read *rbuf;
52 struct evbuf wbuf;
eac6e3f0
RW
53 struct thread *rev;
54 in_port_t lport;
55 in_port_t rport;
8429abe0
RW
56};
57
58struct nbr {
59 RB_ENTRY(nbr) id_tree, addr_tree, pid_tree;
60 struct tcp_conn *tcp;
057d48bd 61 struct nbr_adj_head adj_tree; /* adjacencies */
eac6e3f0
RW
62 struct thread *ev_connect;
63 struct thread *keepalive_timer;
64 struct thread *keepalive_timeout;
65 struct thread *init_timeout;
66 struct thread *initdelay_timer;
8429abe0
RW
67
68 struct mapping_head mapping_list;
69 struct mapping_head withdraw_list;
70 struct mapping_head request_list;
71 struct mapping_head release_list;
72 struct mapping_head abortreq_list;
73
74 uint32_t peerid; /* unique ID in DB */
75 int af;
76 int ds_tlv;
77 int v4_enabled; /* announce/process v4 msgs */
78 int v6_enabled; /* announce/process v6 msgs */
79 struct in_addr id; /* lsr id */
80 union ldpd_addr laddr; /* local address */
81 union ldpd_addr raddr; /* remote address */
6cd8093d 82 ifindex_t raddr_scope; /* remote address scope (v6) */
8429abe0
RW
83 time_t uptime;
84 int fd;
85 int state;
86 uint32_t conf_seqnum;
87 int idtimer_cnt;
88 uint16_t keepalive;
89 uint16_t max_pdu_len;
0f7b5df9 90 struct ldp_stats stats;
8429abe0
RW
91
92 struct {
93 uint8_t established;
94 uint32_t spi_in;
95 uint32_t spi_out;
96 enum auth_method method;
97 char md5key[TCP_MD5_KEY_LEN];
98 } auth;
99 int flags;
100};
101#define F_NBR_GTSM_NEGOTIATED 0x01
8819fc38 102#define F_NBR_CAP_DYNAMIC 0x02
d4afb819 103#define F_NBR_CAP_TWCARD 0x04
257799cd 104#define F_NBR_CAP_UNOTIF 0x08
8429abe0
RW
105
106RB_HEAD(nbr_id_head, nbr);
107RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare)
108RB_HEAD(nbr_addr_head, nbr);
109RB_PROTOTYPE(nbr_addr_head, nbr, addr_tree, nbr_addr_compare)
110RB_HEAD(nbr_pid_head, nbr);
111RB_PROTOTYPE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare)
112
113struct pending_conn {
114 TAILQ_ENTRY(pending_conn) entry;
115 int fd;
116 int af;
117 union ldpd_addr addr;
eac6e3f0 118 struct thread *ev_timeout;
8429abe0
RW
119};
120#define PENDING_CONN_TIMEOUT 5
121
122struct mapping_entry {
123 TAILQ_ENTRY(mapping_entry) entry;
124 struct map map;
125};
126
127struct ldpd_sysdep {
128 uint8_t no_pfkey;
129 uint8_t no_md5sig;
130};
131
132extern struct ldpd_conf *leconf;
133extern struct ldpd_sysdep sysdep;
134extern struct nbr_id_head nbrs_by_id;
135extern struct nbr_addr_head nbrs_by_addr;
136extern struct nbr_pid_head nbrs_by_pid;
137
138/* accept.c */
139void accept_init(void);
cc9f21da 140int accept_add(int, void (*)(struct thread *), void *);
8429abe0
RW
141void accept_del(int);
142void accept_pause(void);
143void accept_unpause(void);
144
145/* hello.c */
146int send_hello(enum hello_type, struct iface_af *, struct tnbr *);
147void recv_hello(struct in_addr, struct ldp_msg *, int, union ldpd_addr *,
148 struct iface *, int, char *, uint16_t);
149
150/* init.c */
151void send_init(struct nbr *);
152int recv_init(struct nbr *, char *, uint16_t);
8819fc38
RW
153void send_capability(struct nbr *, uint16_t, int);
154int recv_capability(struct nbr *, char *, uint16_t);
8429abe0
RW
155
156/* keepalive.c */
157void send_keepalive(struct nbr *);
158int recv_keepalive(struct nbr *, char *, uint16_t);
159
160/* notification.c */
161void send_notification_full(struct tcp_conn *, struct notify_msg *);
adbdf465 162void send_notification(struct tcp_conn *, uint32_t, uint32_t, uint16_t);
8819fc38
RW
163void send_notification_rtlvs(struct nbr *, uint32_t, uint32_t, uint16_t,
164 uint16_t, uint16_t, char *);
8429abe0
RW
165int recv_notification(struct nbr *, char *, uint16_t);
166int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint16_t);
167
168/* address.c */
169void send_address_single(struct nbr *, struct if_addr *, int);
170void send_address_all(struct nbr *, int);
26519d8c 171void send_mac_withdrawal(struct nbr *, struct map *, uint8_t *);
8429abe0
RW
172int recv_address(struct nbr *, char *, uint16_t);
173
174/* labelmapping.c */
175#define PREFIX_SIZE(x) (((x) + 7) / 8)
176void send_labelmessage(struct nbr *, uint16_t, struct mapping_head *);
177int recv_labelmessage(struct nbr *, char *, uint16_t, uint16_t);
178int gen_pw_status_tlv(struct ibuf *, uint32_t);
257799cd 179uint16_t len_fec_tlv(struct map *);
8429abe0
RW
180int gen_fec_tlv(struct ibuf *, struct map *);
181int tlv_decode_fec_elm(struct nbr *, struct ldp_msg *, char *,
182 uint16_t, struct map *);
183
184/* ldpe.c */
274f5abf
RW
185void ldpe(void);
186void ldpe_init(struct ldpd_init *);
8429abe0
RW
187int ldpe_imsg_compose_parent(int, pid_t, void *,
188 uint16_t);
f2232fdf 189void ldpe_imsg_compose_parent_sync(int, pid_t, void *, uint16_t);
8429abe0
RW
190int ldpe_imsg_compose_lde(int, uint32_t, pid_t, void *,
191 uint16_t);
45a8eba9 192int ldpe_acl_check(char *, int, union ldpd_addr *, uint8_t);
8429abe0
RW
193void ldpe_reset_nbrs(int);
194void ldpe_reset_ds_nbrs(void);
195void ldpe_remove_dynamic_tnbrs(int);
196void ldpe_stop_init_backoff(int);
197struct ctl_conn;
6cd8093d 198void ldpe_iface_ctl(struct ctl_conn *c, ifindex_t ifidx);
8429abe0 199void ldpe_adj_ctl(struct ctl_conn *);
bc0eb287 200void ldpe_adj_detail_ctl(struct ctl_conn *);
8429abe0 201void ldpe_nbr_ctl(struct ctl_conn *);
e1894ff7 202void ldpe_ldp_sync_ctl(struct ctl_conn *);
8429abe0
RW
203void mapping_list_add(struct mapping_head *, struct map *);
204void mapping_list_clr(struct mapping_head *);
f9a4d683 205void ldpe_set_config_change_time(void);
8429abe0
RW
206
207/* interface.c */
52b530fc 208struct iface *if_new(const char *);
1d75a89d
RW
209void ldpe_if_init(struct iface *);
210void ldpe_if_exit(struct iface *);
6cd8093d 211struct iface *if_lookup(struct ldpd_conf *c, ifindex_t ifidx);
eac6e3f0
RW
212struct iface *if_lookup_name(struct ldpd_conf *, const char *);
213void if_update_info(struct iface *, struct kif *);
8429abe0
RW
214struct iface_af *iface_af_get(struct iface *, int);
215void if_addr_add(struct kaddr *);
216void if_addr_del(struct kaddr *);
61cd1100 217void ldp_if_update(struct iface *, int);
8429abe0 218void if_update_all(int);
eac6e3f0
RW
219uint16_t if_get_hello_holdtime(struct iface_af *);
220uint16_t if_get_hello_interval(struct iface_af *);
e1894ff7 221uint16_t if_get_wait_for_sync_interval(void);
8429abe0
RW
222struct ctl_iface *if_to_ctl(struct iface_af *);
223in_addr_t if_get_ipv4_addr(struct iface *);
e1894ff7
KS
224int ldp_sync_fsm_adj_event(struct adj *, enum ldp_sync_event);
225int ldp_sync_fsm_nbr_event(struct nbr *, enum ldp_sync_event);
226int ldp_sync_fsm_state_req(struct ldp_igp_sync_if_state_req *);
227int ldp_sync_fsm(struct iface *, enum ldp_sync_event);
228void ldp_sync_fsm_reset_all(void);
229const char *ldp_sync_state_name(int);
230const char *ldp_sync_event_name(int);
231struct ctl_ldp_sync *ldp_sync_to_ctl(struct iface *);
8429abe0
RW
232
233/* adjacency.c */
234struct adj *adj_new(struct in_addr, struct hello_source *,
235 union ldpd_addr *);
236void adj_del(struct adj *, uint32_t);
f2725627 237struct adj *adj_find(struct in_addr, struct hello_source *);
522faa1f 238int adj_get_af(const struct adj *adj);
8429abe0
RW
239void adj_start_itimer(struct adj *);
240void adj_stop_itimer(struct adj *);
eac6e3f0 241struct tnbr *tnbr_new(int, union ldpd_addr *);
8429abe0 242struct tnbr *tnbr_find(struct ldpd_conf *, int, union ldpd_addr *);
7989cdba 243struct tnbr *tnbr_check(struct ldpd_conf *, struct tnbr *);
8429abe0
RW
244void tnbr_update(struct tnbr *);
245void tnbr_update_all(int);
eac6e3f0
RW
246uint16_t tnbr_get_hello_holdtime(struct tnbr *);
247uint16_t tnbr_get_hello_interval(struct tnbr *);
8429abe0
RW
248struct ctl_adj *adj_to_ctl(struct adj *);
249
250/* neighbor.c */
251int nbr_fsm(struct nbr *, enum nbr_event);
252struct nbr *nbr_new(struct in_addr, int, int, union ldpd_addr *,
253 uint32_t);
254void nbr_del(struct nbr *);
255struct nbr *nbr_find_ldpid(uint32_t);
f9a4d683
KS
256struct nbr *nbr_get_first_ldpid(void);
257struct nbr *nbr_get_next_ldpid(uint32_t);
8429abe0
RW
258struct nbr *nbr_find_addr(int, union ldpd_addr *);
259struct nbr *nbr_find_peerid(uint32_t);
260int nbr_adj_count(struct nbr *, int);
261int nbr_session_active_role(struct nbr *);
262void nbr_stop_ktimer(struct nbr *);
263void nbr_stop_ktimeout(struct nbr *);
264void nbr_stop_itimeout(struct nbr *);
265void nbr_start_idtimer(struct nbr *);
266void nbr_stop_idtimer(struct nbr *);
267int nbr_pending_idtimer(struct nbr *);
268int nbr_pending_connect(struct nbr *);
269int nbr_establish_connection(struct nbr *);
270int nbr_gtsm_enabled(struct nbr *, struct nbr_params *);
271int nbr_gtsm_setup(int, int, struct nbr_params *);
272int nbr_gtsm_check(int, struct nbr *, struct nbr_params *);
273struct nbr_params *nbr_params_new(struct in_addr);
274struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr);
275uint16_t nbr_get_keepalive(int, struct in_addr);
276struct ctl_nbr *nbr_to_ctl(struct nbr *);
277void nbr_clear_ctl(struct ctl_nbr *);
278
279/* packet.c */
280int gen_ldp_hdr(struct ibuf *, uint16_t);
281int gen_msg_hdr(struct ibuf *, uint16_t, uint16_t);
282int send_packet(int, int, union ldpd_addr *,
283 struct iface_af *, void *, size_t);
cc9f21da
DS
284void disc_recv_packet(struct thread *thread);
285void session_accept(struct thread *thread);
8429abe0
RW
286void session_accept_nbr(struct nbr *, int);
287void session_shutdown(struct nbr *, uint32_t, uint32_t,
288 uint32_t);
289void session_close(struct nbr *);
290struct tcp_conn *tcp_new(int, struct nbr *);
291void pending_conn_del(struct pending_conn *);
292struct pending_conn *pending_conn_find(int, union ldpd_addr *);
293
56b7d725 294extern char *pkt_ptr; /* packet buffer */
8429abe0
RW
295
296/* pfkey.c */
eac6e3f0 297#ifdef __OpenBSD__
8429abe0
RW
298int pfkey_read(int, struct sadb_msg *);
299int pfkey_establish(struct nbr *, struct nbr_params *);
300int pfkey_remove(struct nbr *);
301int pfkey_init(void);
eac6e3f0 302#endif
8429abe0
RW
303
304/* l2vpn.c */
305void ldpe_l2vpn_init(struct l2vpn *);
306void ldpe_l2vpn_exit(struct l2vpn *);
307void ldpe_l2vpn_pw_init(struct l2vpn_pw *);
308void ldpe_l2vpn_pw_exit(struct l2vpn_pw *);
309
8451921b
DL
310DECLARE_HOOK(ldp_nbr_state_change, (struct nbr * nbr, int old_state),
311 (nbr, old_state));
f9a4d683 312
8429abe0 313#endif /* _LDPE_H_ */