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