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