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