]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2fb975da TT |
2 | /* NHRP daemon internal structures and function prototypes |
3 | * Copyright (c) 2014-2015 Timo Teräs | |
2fb975da TT |
4 | */ |
5 | ||
6 | #ifndef NHRPD_H | |
7 | #define NHRPD_H | |
8 | ||
2fb975da TT |
9 | #include "zbuf.h" |
10 | #include "zclient.h" | |
11 | #include "debug.h" | |
819dc8bb | 12 | #include "memory.h" |
fe9e7b71 | 13 | #include "resolver.h" |
819dc8bb | 14 | |
bf8d3d6a | 15 | DECLARE_MGROUP(NHRPD); |
2fb975da TT |
16 | |
17 | #define NHRPD_DEFAULT_HOLDTIME 7200 | |
18 | ||
442deed8 | 19 | #define NHRP_VTY_PORT 2610 |
2fb975da TT |
20 | #define NHRP_DEFAULT_CONFIG "nhrpd.conf" |
21 | ||
cd9d0537 | 22 | extern struct event_loop *master; |
2fb975da | 23 | |
996c9314 LB |
24 | enum { NHRP_OK = 0, |
25 | NHRP_ERR_FAIL, | |
26 | NHRP_ERR_NO_MEMORY, | |
27 | NHRP_ERR_UNSUPPORTED_INTERFACE, | |
28 | NHRP_ERR_NHRP_NOT_ENABLED, | |
29 | NHRP_ERR_ENTRY_EXISTS, | |
30 | NHRP_ERR_ENTRY_NOT_FOUND, | |
31 | NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH, | |
32 | __NHRP_ERR_MAX }; | |
6c8ca260 | 33 | #define NHRP_ERR_MAX (__NHRP_ERR_MAX - 1) |
2fb975da TT |
34 | |
35 | struct notifier_block; | |
36 | ||
37 | typedef void (*notifier_fn_t)(struct notifier_block *, unsigned long); | |
38 | ||
865bf787 DL |
39 | PREDECL_DLIST(notifier_list); |
40 | ||
2fb975da | 41 | struct notifier_block { |
865bf787 | 42 | struct notifier_list_item notifier_entry; |
2fb975da TT |
43 | notifier_fn_t action; |
44 | }; | |
45 | ||
865bf787 DL |
46 | DECLARE_DLIST(notifier_list, struct notifier_block, notifier_entry); |
47 | ||
2fb975da | 48 | struct notifier_list { |
865bf787 | 49 | struct notifier_list_head head; |
2fb975da TT |
50 | }; |
51 | ||
996c9314 LB |
52 | #define NOTIFIER_LIST_INITIALIZER(l) \ |
53 | { \ | |
865bf787 | 54 | .head = INIT_DLIST((l)->head) \ |
996c9314 | 55 | } |
2fb975da TT |
56 | |
57 | static inline void notifier_init(struct notifier_list *l) | |
58 | { | |
865bf787 | 59 | notifier_list_init(&l->head); |
2fb975da TT |
60 | } |
61 | ||
996c9314 LB |
62 | static inline void notifier_add(struct notifier_block *n, |
63 | struct notifier_list *l, notifier_fn_t action) | |
2fb975da TT |
64 | { |
65 | n->action = action; | |
865bf787 | 66 | notifier_list_add_tail(&l->head, n); |
2fb975da TT |
67 | } |
68 | ||
865bf787 DL |
69 | static inline void notifier_del(struct notifier_block *n, |
70 | struct notifier_list *l) | |
2fb975da | 71 | { |
865bf787 | 72 | notifier_list_del(&l->head, n); |
2fb975da TT |
73 | } |
74 | ||
75 | static inline void notifier_call(struct notifier_list *l, int cmd) | |
76 | { | |
865bf787 DL |
77 | struct notifier_block *n; |
78 | ||
79 | frr_each_safe (notifier_list, &l->head, n) | |
123ea351 | 80 | n->action(n, cmd); |
2fb975da TT |
81 | } |
82 | ||
83 | static inline int notifier_active(struct notifier_list *l) | |
84 | { | |
865bf787 | 85 | return notifier_list_count(&l->head) > 0; |
2fb975da TT |
86 | } |
87 | ||
7f48cfa5 PG |
88 | extern struct hash *nhrp_gre_list; |
89 | ||
2fb975da TT |
90 | void nhrp_zebra_init(void); |
91 | void nhrp_zebra_terminate(void); | |
f468a45a | 92 | void nhrp_send_zebra_configure_arp(struct interface *ifp, int family); |
05657ec2 PG |
93 | void nhrp_send_zebra_nbr(union sockunion *in, |
94 | union sockunion *out, | |
95 | struct interface *ifp); | |
7f48cfa5 PG |
96 | |
97 | void nhrp_send_zebra_gre_source_set(struct interface *ifp, | |
98 | unsigned int link_idx, | |
99 | vrf_id_t link_vrf_id); | |
100 | ||
101 | extern int nhrp_send_zebra_gre_request(struct interface *ifp); | |
102 | extern struct nhrp_gre_info *nhrp_gre_info_alloc(struct nhrp_gre_info *p); | |
103 | ||
2fb975da TT |
104 | struct zbuf; |
105 | struct nhrp_vc; | |
106 | struct nhrp_cache; | |
107 | struct nhrp_nhs; | |
108 | struct nhrp_interface; | |
109 | ||
110 | #define MAX_ID_LENGTH 64 | |
111 | #define MAX_CERT_LENGTH 2048 | |
112 | ||
113 | enum nhrp_notify_type { | |
114 | NOTIFY_INTERFACE_UP, | |
115 | NOTIFY_INTERFACE_DOWN, | |
116 | NOTIFY_INTERFACE_CHANGED, | |
117 | NOTIFY_INTERFACE_ADDRESS_CHANGED, | |
118 | NOTIFY_INTERFACE_NBMA_CHANGED, | |
119 | NOTIFY_INTERFACE_MTU_CHANGED, | |
58ef1668 | 120 | NOTIFY_INTERFACE_IPSEC_CHANGED, |
2fb975da TT |
121 | |
122 | NOTIFY_VC_IPSEC_CHANGED, | |
123 | NOTIFY_VC_IPSEC_UPDATE_NBMA, | |
124 | ||
125 | NOTIFY_PEER_UP, | |
126 | NOTIFY_PEER_DOWN, | |
127 | NOTIFY_PEER_IFCONFIG_CHANGED, | |
128 | NOTIFY_PEER_MTU_CHANGED, | |
129 | NOTIFY_PEER_NBMA_CHANGING, | |
130 | ||
131 | NOTIFY_CACHE_UP, | |
132 | NOTIFY_CACHE_DOWN, | |
133 | NOTIFY_CACHE_DELETE, | |
134 | NOTIFY_CACHE_USED, | |
135 | NOTIFY_CACHE_BINDING_CHANGE, | |
136 | }; | |
137 | ||
138 | struct nhrp_vc { | |
139 | struct notifier_list notifier_list; | |
6cfd90f3 | 140 | uint32_t ipsec; |
4cbaf956 | 141 | uint32_t ike_uniqueid; |
2fb975da TT |
142 | uint8_t updating; |
143 | uint8_t abort_migration; | |
144 | ||
145 | struct nhrp_vc_peer { | |
146 | union sockunion nbma; | |
147 | char id[MAX_ID_LENGTH]; | |
148 | uint16_t certlen; | |
149 | uint8_t cert[MAX_CERT_LENGTH]; | |
150 | } local, remote; | |
151 | }; | |
152 | ||
153 | enum nhrp_route_type { | |
154 | NHRP_ROUTE_BLACKHOLE, | |
155 | NHRP_ROUTE_LOCAL, | |
156 | NHRP_ROUTE_NBMA_NEXTHOP, | |
157 | NHRP_ROUTE_OFF_NBMA, | |
158 | }; | |
159 | ||
160 | struct nhrp_peer { | |
161 | unsigned int ref; | |
162 | unsigned online : 1; | |
163 | unsigned requested : 1; | |
164 | unsigned fallback_requested : 1; | |
165 | unsigned prio : 1; | |
166 | struct notifier_list notifier_list; | |
167 | struct interface *ifp; | |
168 | struct nhrp_vc *vc; | |
e6685141 | 169 | struct event *t_fallback; |
2fb975da | 170 | struct notifier_block vc_notifier, ifp_notifier; |
e6685141 | 171 | struct event *t_timer; |
2fb975da TT |
172 | }; |
173 | ||
174 | struct nhrp_packet_parser { | |
175 | struct interface *ifp; | |
176 | struct nhrp_afi_data *if_ad; | |
177 | struct nhrp_peer *peer; | |
178 | struct zbuf *pkt; | |
179 | struct zbuf payload; | |
180 | struct zbuf extensions; | |
181 | struct nhrp_packet_header *hdr; | |
182 | enum nhrp_route_type route_type; | |
183 | struct prefix route_prefix; | |
184 | union sockunion src_nbma, src_proto, dst_proto; | |
185 | }; | |
186 | ||
187 | struct nhrp_reqid_pool { | |
188 | struct hash *reqid_hash; | |
189 | uint32_t next_request_id; | |
190 | }; | |
191 | ||
192 | struct nhrp_reqid { | |
193 | uint32_t request_id; | |
194 | void (*cb)(struct nhrp_reqid *, void *); | |
195 | }; | |
196 | ||
197 | extern struct nhrp_reqid_pool nhrp_packet_reqid; | |
198 | extern struct nhrp_reqid_pool nhrp_event_reqid; | |
199 | ||
200 | enum nhrp_cache_type { | |
201 | NHRP_CACHE_INVALID = 0, | |
202 | NHRP_CACHE_INCOMPLETE, | |
203 | NHRP_CACHE_NEGATIVE, | |
204 | NHRP_CACHE_CACHED, | |
205 | NHRP_CACHE_DYNAMIC, | |
206 | NHRP_CACHE_NHS, | |
207 | NHRP_CACHE_STATIC, | |
208 | NHRP_CACHE_LOCAL, | |
209 | NHRP_CACHE_NUM_TYPES | |
210 | }; | |
211 | ||
996c9314 | 212 | extern const char *const nhrp_cache_type_str[]; |
2fb975da TT |
213 | extern unsigned long nhrp_cache_counts[NHRP_CACHE_NUM_TYPES]; |
214 | ||
fef2ed13 PG |
215 | struct nhrp_cache_config { |
216 | struct interface *ifp; | |
217 | union sockunion remote_addr; | |
218 | enum nhrp_cache_type type; | |
219 | union sockunion nbma; | |
220 | }; | |
221 | ||
2fb975da TT |
222 | struct nhrp_cache { |
223 | struct interface *ifp; | |
224 | union sockunion remote_addr; | |
225 | ||
226 | unsigned map : 1; | |
227 | unsigned used : 1; | |
228 | unsigned route_installed : 1; | |
229 | unsigned nhrp_route_installed : 1; | |
230 | ||
231 | struct notifier_block peer_notifier; | |
232 | struct notifier_block newpeer_notifier; | |
233 | struct notifier_list notifier_list; | |
234 | struct nhrp_reqid eventid; | |
e6685141 DS |
235 | struct event *t_timeout; |
236 | struct event *t_auth; | |
2fb975da TT |
237 | |
238 | struct { | |
239 | enum nhrp_cache_type type; | |
240 | union sockunion remote_nbma_natoa; | |
85365e51 | 241 | union sockunion remote_nbma_claimed; |
2fb975da TT |
242 | struct nhrp_peer *peer; |
243 | time_t expires; | |
244 | uint32_t mtu; | |
bb58f442 | 245 | int holding_time; |
2fb975da TT |
246 | } cur, new; |
247 | }; | |
248 | ||
249 | struct nhrp_shortcut { | |
250 | struct prefix *p; | |
251 | union sockunion addr; | |
252 | ||
253 | struct nhrp_reqid reqid; | |
e6685141 | 254 | struct event *t_timer; |
2fb975da TT |
255 | |
256 | enum nhrp_cache_type type; | |
257 | unsigned int holding_time; | |
258 | unsigned route_installed : 1; | |
259 | unsigned expiring : 1; | |
260 | ||
261 | struct nhrp_cache *cache; | |
262 | struct notifier_block cache_notifier; | |
263 | }; | |
264 | ||
2ab2a761 | 265 | PREDECL_DLIST(nhrp_nhslist); |
db4db2bb | 266 | PREDECL_DLIST(nhrp_mcastlist); |
811de44f | 267 | PREDECL_DLIST(nhrp_reglist); |
2ab2a761 | 268 | |
2fb975da TT |
269 | struct nhrp_nhs { |
270 | struct interface *ifp; | |
2ab2a761 | 271 | struct nhrp_nhslist_item nhslist_entry; |
2fb975da TT |
272 | |
273 | unsigned hub : 1; | |
274 | afi_t afi; | |
275 | union sockunion proto_addr; | |
996c9314 | 276 | const char *nbma_fqdn; /* IP-address or FQDN */ |
2fb975da | 277 | |
e6685141 | 278 | struct event *t_resolve; |
2fb975da | 279 | struct resolver_query dns_resolve; |
811de44f | 280 | struct nhrp_reglist_head reglist_head; |
2fb975da TT |
281 | }; |
282 | ||
2ab2a761 DL |
283 | DECLARE_DLIST(nhrp_nhslist, struct nhrp_nhs, nhslist_entry); |
284 | ||
fa31fcf2 AL |
285 | struct nhrp_multicast { |
286 | struct interface *ifp; | |
db4db2bb | 287 | struct nhrp_mcastlist_item mcastlist_entry; |
fa31fcf2 AL |
288 | afi_t afi; |
289 | union sockunion nbma_addr; /* IP-address */ | |
290 | }; | |
291 | ||
db4db2bb DL |
292 | DECLARE_DLIST(nhrp_mcastlist, struct nhrp_multicast, mcastlist_entry); |
293 | ||
0ca036b4 | 294 | struct nhrp_registration { |
811de44f | 295 | struct nhrp_reglist_item reglist_entry; |
e6685141 | 296 | struct event *t_register; |
0ca036b4 TT |
297 | struct nhrp_nhs *nhs; |
298 | struct nhrp_reqid reqid; | |
299 | unsigned int timeout; | |
300 | unsigned mark : 1; | |
301 | union sockunion proto_addr; | |
302 | struct nhrp_peer *peer; | |
303 | struct notifier_block peer_notifier; | |
304 | }; | |
305 | ||
811de44f DL |
306 | DECLARE_DLIST(nhrp_reglist, struct nhrp_registration, reglist_entry); |
307 | ||
2fb975da TT |
308 | #define NHRP_IFF_SHORTCUT 0x0001 |
309 | #define NHRP_IFF_REDIRECT 0x0002 | |
310 | #define NHRP_IFF_REG_NO_UNIQUE 0x0100 | |
311 | ||
312 | struct nhrp_interface { | |
313 | struct interface *ifp; | |
314 | ||
315 | unsigned enabled : 1; | |
316 | ||
317 | char *ipsec_profile, *ipsec_fallback_profile, *source; | |
318 | union sockunion nbma; | |
319 | union sockunion nat_nbma; | |
7f48cfa5 PG |
320 | unsigned int link_idx; |
321 | unsigned int link_vrf_id; | |
322 | uint32_t i_grekey; | |
323 | uint32_t o_grekey; | |
2fb975da TT |
324 | |
325 | struct hash *peer_hash; | |
fef2ed13 | 326 | struct hash *cache_config_hash; |
2fb975da TT |
327 | struct hash *cache_hash; |
328 | ||
329 | struct notifier_list notifier_list; | |
330 | ||
331 | struct interface *nbmaifp; | |
332 | struct notifier_block nbmanifp_notifier; | |
333 | ||
334 | struct nhrp_afi_data { | |
335 | unsigned flags; | |
336 | unsigned short configured : 1; | |
337 | union sockunion addr; | |
338 | uint32_t network_id; | |
339 | short configured_mtu; | |
340 | unsigned short mtu; | |
341 | unsigned int holdtime; | |
2ab2a761 | 342 | struct nhrp_nhslist_head nhslist_head; |
db4db2bb | 343 | struct nhrp_mcastlist_head mcastlist_head; |
2fb975da TT |
344 | } afi[AFI_MAX]; |
345 | }; | |
346 | ||
7f48cfa5 PG |
347 | struct nhrp_gre_info { |
348 | ifindex_t ifindex; | |
349 | struct in_addr vtep_ip; /* IFLA_GRE_LOCAL */ | |
350 | struct in_addr vtep_ip_remote; /* IFLA_GRE_REMOTE */ | |
351 | uint32_t ikey; | |
352 | uint32_t okey; | |
353 | ifindex_t ifindex_link; /* Interface index of interface | |
354 | * linked with GRE | |
355 | */ | |
356 | vrf_id_t vrfid_link; | |
357 | }; | |
358 | ||
26efbc7b DS |
359 | extern struct zebra_privs_t nhrpd_privs; |
360 | ||
2fb975da TT |
361 | int sock_open_unix(const char *path); |
362 | ||
363 | void nhrp_interface_init(void); | |
364 | void nhrp_interface_update(struct interface *ifp); | |
365 | void nhrp_interface_update_mtu(struct interface *ifp, afi_t afi); | |
7f48cfa5 PG |
366 | void nhrp_interface_update_nbma(struct interface *ifp, |
367 | struct nhrp_gre_info *gre_info); | |
2fb975da | 368 | |
121f9dee QY |
369 | int nhrp_interface_add(ZAPI_CALLBACK_ARGS); |
370 | int nhrp_interface_delete(ZAPI_CALLBACK_ARGS); | |
371 | int nhrp_interface_up(ZAPI_CALLBACK_ARGS); | |
372 | int nhrp_interface_down(ZAPI_CALLBACK_ARGS); | |
373 | int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS); | |
374 | int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS); | |
a243d1db DL |
375 | int nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS); |
376 | int nhrp_gre_update(ZAPI_CALLBACK_ARGS); | |
996c9314 LB |
377 | |
378 | void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, | |
379 | notifier_fn_t fn); | |
2fb975da | 380 | void nhrp_interface_notify_del(struct interface *ifp, struct notifier_block *n); |
996c9314 LB |
381 | void nhrp_interface_set_protection(struct interface *ifp, const char *profile, |
382 | const char *fallback_profile); | |
2fb975da | 383 | void nhrp_interface_set_source(struct interface *ifp, const char *ifname); |
138c5a74 DS |
384 | extern int nhrp_ifp_create(struct interface *ifp); |
385 | extern int nhrp_ifp_up(struct interface *ifp); | |
386 | extern int nhrp_ifp_down(struct interface *ifp); | |
387 | extern int nhrp_ifp_destroy(struct interface *ifp); | |
2fb975da | 388 | |
996c9314 LB |
389 | int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, |
390 | const char *nbma_fqdn); | |
391 | int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, | |
392 | const char *nbma_fqdn); | |
2ab2a761 | 393 | int nhrp_nhs_free(struct nhrp_interface *nifp, afi_t afi, struct nhrp_nhs *nhs); |
2fb975da | 394 | void nhrp_nhs_terminate(void); |
996c9314 LB |
395 | void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, |
396 | void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, | |
397 | void *), | |
398 | void *ctx); | |
ee72f0a0 | 399 | void nhrp_nhs_interface_del(struct interface *ifp); |
2fb975da | 400 | |
0f8595a9 RD |
401 | int nhrp_multicast_add(struct interface *ifp, afi_t afi, |
402 | union sockunion *nbma_addr); | |
403 | int nhrp_multicast_del(struct interface *ifp, afi_t afi, | |
404 | union sockunion *nbma_addr); | |
fa31fcf2 AL |
405 | void nhrp_multicast_interface_del(struct interface *ifp); |
406 | void nhrp_multicast_foreach(struct interface *ifp, afi_t afi, | |
0f8595a9 RD |
407 | void (*cb)(struct nhrp_multicast *, void *), |
408 | void *ctx); | |
9084e209 | 409 | void netlink_mcast_set_nflog_group(int nlgroup); |
fa31fcf2 | 410 | |
2fb975da | 411 | void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp); |
996c9314 LB |
412 | void nhrp_route_announce(int add, enum nhrp_cache_type type, |
413 | const struct prefix *p, struct interface *ifp, | |
414 | const union sockunion *nexthop, uint32_t mtu); | |
121f9dee | 415 | int nhrp_route_read(ZAPI_CALLBACK_ARGS); |
996c9314 LB |
416 | int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, |
417 | union sockunion *via, struct interface **ifp); | |
418 | enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, | |
419 | union sockunion *addr, struct prefix *p, | |
420 | struct nhrp_peer **peer); | |
2fb975da TT |
421 | |
422 | void nhrp_config_init(void); | |
423 | ||
424 | void nhrp_shortcut_init(void); | |
425 | void nhrp_shortcut_terminate(void); | |
426 | void nhrp_shortcut_initiate(union sockunion *addr); | |
996c9314 LB |
427 | void nhrp_shortcut_foreach(afi_t afi, |
428 | void (*cb)(struct nhrp_shortcut *, void *), | |
429 | void *ctx); | |
2fb975da TT |
430 | void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force); |
431 | void nhrp_shortcut_prefix_change(const struct prefix *p, int deleted); | |
432 | ||
ee72f0a0 | 433 | void nhrp_cache_interface_del(struct interface *ifp); |
fef2ed13 PG |
434 | void nhrp_cache_config_free(struct nhrp_cache_config *c); |
435 | struct nhrp_cache_config *nhrp_cache_config_get(struct interface *ifp, | |
436 | union sockunion *remote_addr, | |
437 | int create); | |
996c9314 LB |
438 | struct nhrp_cache *nhrp_cache_get(struct interface *ifp, |
439 | union sockunion *remote_addr, int create); | |
440 | void nhrp_cache_foreach(struct interface *ifp, | |
441 | void (*cb)(struct nhrp_cache *, void *), void *ctx); | |
fef2ed13 PG |
442 | void nhrp_cache_config_foreach(struct interface *ifp, |
443 | void (*cb)(struct nhrp_cache_config *, void *), void *ctx); | |
2fb975da | 444 | void nhrp_cache_set_used(struct nhrp_cache *, int); |
996c9314 LB |
445 | int nhrp_cache_update_binding(struct nhrp_cache *, enum nhrp_cache_type type, |
446 | int holding_time, struct nhrp_peer *p, | |
85365e51 AL |
447 | uint32_t mtu, union sockunion *nbma_natoa, |
448 | union sockunion *claimed_nbma); | |
996c9314 LB |
449 | void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *, |
450 | notifier_fn_t); | |
2fb975da TT |
451 | void nhrp_cache_notify_del(struct nhrp_cache *c, struct notifier_block *); |
452 | ||
453 | void nhrp_vc_init(void); | |
454 | void nhrp_vc_terminate(void); | |
996c9314 LB |
455 | struct nhrp_vc *nhrp_vc_get(const union sockunion *src, |
456 | const union sockunion *dst, int create); | |
2fb975da | 457 | int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc); |
996c9314 LB |
458 | void nhrp_vc_notify_add(struct nhrp_vc *, struct notifier_block *, |
459 | notifier_fn_t); | |
2fb975da TT |
460 | void nhrp_vc_notify_del(struct nhrp_vc *, struct notifier_block *); |
461 | void nhrp_vc_foreach(void (*cb)(struct nhrp_vc *, void *), void *ctx); | |
462 | void nhrp_vc_reset(void); | |
463 | ||
464 | void vici_init(void); | |
465 | void vici_terminate(void); | |
083bbfae GG |
466 | void vici_terminate_vc_by_profile_name(char *profile_name); |
467 | void vici_terminate_vc_by_ike_id(unsigned int ike_id); | |
996c9314 LB |
468 | void vici_request_vc(const char *profile, union sockunion *src, |
469 | union sockunion *dst, int prio); | |
2fb975da TT |
470 | |
471 | extern const char *nhrp_event_socket_path; | |
472 | ||
473 | void evmgr_init(void); | |
474 | void evmgr_terminate(void); | |
475 | void evmgr_set_socket(const char *socket); | |
996c9314 LB |
476 | void evmgr_notify(const char *name, struct nhrp_cache *c, |
477 | void (*cb)(struct nhrp_reqid *, void *)); | |
2fb975da | 478 | |
996c9314 LB |
479 | struct nhrp_packet_header *nhrp_packet_push(struct zbuf *zb, uint8_t type, |
480 | const union sockunion *src_nbma, | |
481 | const union sockunion *src_proto, | |
482 | const union sockunion *dst_proto); | |
2fb975da TT |
483 | void nhrp_packet_complete(struct zbuf *zb, struct nhrp_packet_header *hdr); |
484 | uint16_t nhrp_packet_calculate_checksum(const uint8_t *pdu, uint16_t len); | |
485 | ||
996c9314 LB |
486 | struct nhrp_packet_header *nhrp_packet_pull(struct zbuf *zb, |
487 | union sockunion *src_nbma, | |
488 | union sockunion *src_proto, | |
489 | union sockunion *dst_proto); | |
490 | ||
491 | struct nhrp_cie_header *nhrp_cie_push(struct zbuf *zb, uint8_t code, | |
492 | const union sockunion *nbma, | |
493 | const union sockunion *proto); | |
494 | struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb, | |
495 | struct nhrp_packet_header *hdr, | |
496 | union sockunion *nbma, | |
497 | union sockunion *proto); | |
498 | ||
499 | struct nhrp_extension_header * | |
500 | nhrp_ext_push(struct zbuf *zb, struct nhrp_packet_header *hdr, uint16_t type); | |
2fb975da | 501 | void nhrp_ext_complete(struct zbuf *zb, struct nhrp_extension_header *ext); |
996c9314 LB |
502 | struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb, |
503 | struct zbuf *payload); | |
504 | void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, | |
505 | struct interface *); | |
506 | int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, | |
507 | struct interface *ifp, struct nhrp_extension_header *ext, | |
508 | struct zbuf *extpayload); | |
509 | ||
510 | uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *, struct nhrp_reqid *r, | |
511 | void (*cb)(struct nhrp_reqid *, void *)); | |
2fb975da TT |
512 | void nhrp_reqid_free(struct nhrp_reqid_pool *, struct nhrp_reqid *r); |
513 | struct nhrp_reqid *nhrp_reqid_lookup(struct nhrp_reqid_pool *, uint32_t reqid); | |
514 | ||
515 | int nhrp_packet_init(void); | |
516 | ||
ee72f0a0 | 517 | void nhrp_peer_interface_del(struct interface *ifp); |
996c9314 LB |
518 | struct nhrp_peer *nhrp_peer_get(struct interface *ifp, |
519 | const union sockunion *remote_nbma); | |
2fb975da TT |
520 | struct nhrp_peer *nhrp_peer_ref(struct nhrp_peer *p); |
521 | void nhrp_peer_unref(struct nhrp_peer *p); | |
522 | int nhrp_peer_check(struct nhrp_peer *p, int establish); | |
996c9314 LB |
523 | void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *, |
524 | notifier_fn_t); | |
2fb975da TT |
525 | void nhrp_peer_notify_del(struct nhrp_peer *p, struct notifier_block *); |
526 | void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb); | |
527 | void nhrp_peer_send(struct nhrp_peer *p, struct zbuf *zb); | |
528 | void nhrp_peer_send_indication(struct interface *ifp, uint16_t, struct zbuf *); | |
529 | ||
bb58f442 GG |
530 | int nhrp_nhs_match_ip(union sockunion *in_ip, struct nhrp_interface *nifp); |
531 | ||
2fb975da | 532 | #endif |