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