1 /*
2 * Copyright (c) 2000-2024 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
30 * All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. Neither the name of the project nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 */
56
57 #ifndef _NETINET6_ND6_H_
58 #define _NETINET6_ND6_H_
59 #include <sys/appleapiopts.h>
60 #include <net/net_kev.h>
61
62 /* see net/route.h, or net/if_inarp.h */
63 #ifndef RTF_ANNOUNCE
64 #define RTF_ANNOUNCE RTF_PROTO2
65 #endif
66
67 #include <sys/queue.h>
68
69 #ifdef BSD_KERNEL_PRIVATE
70 #include <net/flowadv.h>
71 #include <kern/locks.h>
72 #include <sys/tree.h>
73 #include <sys/eventhandler.h>
74 #include <netinet6/nd6_var.h>
75 #include <sys/sdt.h>
76
77 struct llinfo_nd6 {
78 /*
79 * The following are protected by rnh_lock
80 */
81 struct llinfo_nd6 *ln_next;
82 struct llinfo_nd6 *ln_prev;
83 struct rtentry *ln_rt;
84 /*
85 * The following are protected by rt_lock
86 */
87 struct ifnet *ln_exclifp; /* excluded interface (prefix proxy) */
88 struct mbuf *ln_hold; /* last packet until resolved/timeout */
89 uint32_t ln_asked; /* # of queries already sent for this addr */
90 short ln_state; /* reachability state */
91 short ln_router; /* 2^0: ND6 router bit */
92 u_int32_t ln_flags; /* flags; see below */
93 u_int64_t ln_expire; /* lifetime for NDP state transition */
94 u_int64_t ln_lastused; /* last used timestamp */
95 struct if_llreach *ln_llreach; /* link-layer reachability record */
96 };
97
98 /* Values for ln_flags */
99 #define ND6_LNF_TIMER_SKIP 0x1 /* modified by nd6_timer() */
100 #define ND6_LNF_IN_USE 0x2 /* currently in llinfo_nd6 list */
101 #endif /* BSD_KERNEL_PRIVATE */
102
103 #define ND6_LLINFO_PURGE -3
104 #define ND6_LLINFO_NOSTATE -2
105 /*
106 * We don't need the WAITDELETE state any more, but we keep the definition
107 * in a comment line instead of removing it. This is necessary to avoid
108 * unintentionally reusing the value for another purpose, which might
109 * affect backward compatibility with old applications.
110 * (20000711 [email protected])
111 */
112 /* #define ND6_LLINFO_WAITDELETE -1 */
113 #define ND6_LLINFO_INCOMPLETE 0
114 #define ND6_LLINFO_REACHABLE 1
115 #define ND6_LLINFO_STALE 2
116 #define ND6_LLINFO_DELAY 3
117 #define ND6_LLINFO_PROBE 4
118
119 #ifdef BSD_KERNEL_PRIVATE
120
121 #define ND6_CACHE_STATE_TRANSITION(ln, nstate) do {\
122 DTRACE_IP2(nd6_state_transition, struct llinfo_nd6 *, (ln), int, (nstate));\
123 if (nd6_debug >= 3) {\
124 struct rtentry *ln_rt = (ln) != NULL ? (ln)->ln_rt : NULL; \
125 nd6log3(info,\
126 "[%s:%d]: NDP cache entry changed from %s -> %s for address %s.\n",\
127 __func__,\
128 __LINE__,\
129 ndcache_state2str((ln)->ln_state),\
130 ndcache_state2str((nstate)),\
131 ln_rt != NULL ? ip6_sprintf(&SIN6(rt_key(ln_rt))->sin6_addr) : "N/A");\
132 }\
133 if ((ln) != NULL) {\
134 if ((ln)->ln_rt != NULL && (ln)->ln_rt->rt_ifp != NULL &&\
135 ((ln)->ln_rt->rt_ifp->if_eflags & IFEF_IPV6_ND6ALT) &&\
136 ((ln)->ln_state == ND6_LLINFO_REACHABLE)) {\
137 VERIFY((nstate) != ND6_LLINFO_STALE &&\
138 (nstate) != ND6_LLINFO_DELAY &&\
139 (nstate) != ND6_LLINFO_PROBE);\
140 }\
141 (ln)->ln_state = (nstate);\
142 }\
143 } while(0)
144
145 #define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
146 #define ND6_LLINFO_PERMANENT(n) \
147 (((n)->ln_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE))
148
149 #define ND6_EUI64_GBIT 0x01
150 #define ND6_EUI64_UBIT 0x02
151
152 #define ND6_EUI64_TO_IFID(in6) \
153 do {(in6)->s6_addr[8] ^= ND6_EUI64_UBIT; } while (0)
154
155 #define ND6_EUI64_GROUP(in6) ((in6)->s6_addr[8] & ND6_EUI64_GBIT)
156 #define ND6_EUI64_INDIVIDUAL(in6) (!ND6_EUI64_GROUP(in6))
157 #define ND6_EUI64_LOCAL(in6) ((in6)->s6_addr[8] & ND6_EUI64_UBIT)
158 #define ND6_EUI64_UNIVERSAL(in6) (!ND6_EUI64_LOCAL(in6))
159 #define ND6_IFID_LOCAL(in6) (!ND6_EUI64_LOCAL(in6))
160 #define ND6_IFID_UNIVERSAL(in6) (!ND6_EUI64_UNIVERSAL(in6))
161 #endif /* BSD_KERNEL_PRIVATE */
162
163 #if !defined(BSD_KERNEL_PRIVATE)
164 struct nd_ifinfo {
165 #else
166 /* For binary compatibility, this structure must not change */
167 /* NOTE: nd_ifinfo is defined in nd6_var.h */
168 struct nd_ifinfo_compat {
169 #endif /* !BSD_KERNEL_PRIVATE */
170 u_int32_t linkmtu; /* LinkMTU */
171 u_int32_t maxmtu; /* Upper bound of LinkMTU */
172 u_int32_t basereachable; /* BaseReachableTime */
173 u_int32_t reachable; /* Reachable Time */
174 u_int32_t retrans; /* Retrans Timer */
175 u_int32_t flags; /* Flags */
176 int recalctm; /* BaseReacable re-calculation timer */
177 u_int8_t chlim; /* CurHopLimit */
178 u_int8_t receivedra;
179 /* the following 3 members are for privacy extension for addrconf */
180 u_int8_t randomseed0[8]; /* upper 64 bits of SHA256 digest */
181 u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
182 u_int8_t randomid[8]; /* current random ID */
183 };
184
185 #define ND6_IFF_PERFORMNUD 0x1
186 #if defined(PRIVATE)
187
188 /*
189 * APPLE: not used. Interface specific router advertisements are handled with a
190 * specific ifnet flag: IFEF_ACCEPT_RTADVD
191 */
192 #define ND6_IFF_ACCEPT_RTADV 0x2
193
194 /* APPLE: NOT USED not related to ND. */
195 #define ND6_IFF_PREFER_SOURCE 0x4
196
197 /* IPv6 operation is disabled due to * DAD failure. (XXX: not ND-specific) */
198 #define ND6_IFF_IFDISABLED 0x8
199
200 #define ND6_IFF_DONT_SET_IFROUTE 0x10 /* NOT USED */
201 #endif /* PRIVATE */
202 #define ND6_IFF_PROXY_PREFIXES 0x20
203 #define ND6_IFF_IGNORE_NA 0x40
204 #if defined(PRIVATE)
205 #define ND6_IFF_INSECURE 0x80
206 #endif
207 #define ND6_IFF_REPLICATED 0x100 /* sleep proxy registered */
208 #define ND6_IFF_DAD 0x200 /* Perform DAD on the interface */
209
210 extern int dad_enhanced;
211 #define ND6_DAD_ENHANCED_DEFAULT 1
212
213 struct in6_nbrinfo {
214 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
215 struct in6_addr addr; /* IPv6 address of the neighbor */
216 long asked; /* # of queries already sent for this addr */
217 int isrouter; /* if it acts as a router */
218 int state; /* reachability state */
219 int expire; /* lifetime for NDP state transition */
220 };
221
222 #if defined(BSD_KERNEL_PRIVATE)
223 struct in6_nbrinfo_32 {
224 char ifname[IFNAMSIZ];
225 struct in6_addr addr;
226 u_int32_t asked;
227 int isrouter;
228 int state;
229 int expire;
230 };
231
232 struct in6_nbrinfo_64 {
233 char ifname[IFNAMSIZ];
234 struct in6_addr addr;
235 long asked;
236 int isrouter __attribute__((aligned(8)));
237 int state;
238 int expire;
239 } __attribute__((aligned(8)));
240 #endif /* BSD_KERNEL_PRIVATE */
241
242 #if defined(BSD_KERNEL_PRIVATE)
243 #define ND6_PROCESS_RTI_ENABLE 1
244 #define ND6_PROCESS_RTI_DISABLE 0
245 #define ND6_PROCESS_RTI_DEFAULT ND6_PROCESS_RTI_ENABLE
246
247 extern int nd6_process_rti;
248
249 #endif /* BSD_KERNEL_PRIVATE */
250
251 /* valid values for stateflags */
252 #define NDDRF_INSTALLED 0x01 /* installed in the routing table */
253 #define NDDRF_IFSCOPE 0x02 /* installed as a scoped route */
254 #define NDDRF_STATIC 0x04 /* for internal use only */
255 #define NDDRF_MAPPED 0x08 /* Default router addr is mapped to a different one for routing */
256 #define NDDRF_INELIGIBLE 0x10 /* Default router entry is ineligible for default router selection */
257 #define NDDRF_LOCAL 0x20 /* Router's address is locally hosted as well */
258
259 struct in6_defrouter {
260 struct sockaddr_in6 rtaddr;
261 u_char flags;
262 u_char stateflags;
263 u_short rtlifetime;
264 u_long expire;
265 u_short if_index;
266 };
267
268 #if defined(BSD_KERNEL_PRIVATE)
269 struct in6_defrouter_32 {
270 struct sockaddr_in6 rtaddr;
271 u_char flags;
272 u_char stateflags;
273 u_short rtlifetime;
274 u_int32_t expire;
275 u_short if_index;
276 };
277
278 struct in6_defrouter_64 {
279 struct sockaddr_in6 rtaddr;
280 u_char flags;
281 u_char stateflags;
282 u_short rtlifetime;
283 u_long expire __attribute__((aligned(8)));
284 u_short if_index __attribute__((aligned(8)));
285 } __attribute__((aligned(8)));
286 #endif /* BSD_KERNEL_PRIVATE */
287
288 struct in6_prefix {
289 struct sockaddr_in6 prefix;
290 struct prf_ra raflags;
291 u_char prefixlen;
292 u_char origin;
293 u_long vltime;
294 u_long pltime;
295 u_long expire;
296 u_int32_t flags;
297 int refcnt;
298 u_short if_index;
299 u_short advrtrs; /* number of advertisement routers */
300 /* struct sockaddr_in6 advrtr[] */
301 };
302
303 #if defined(BSD_KERNEL_PRIVATE)
304 struct in6_prefix_32 {
305 struct sockaddr_in6 prefix;
306 struct prf_ra raflags;
307 u_char prefixlen;
308 u_char origin;
309 u_int32_t vltime;
310 u_int32_t pltime;
311 u_int32_t expire;
312 u_int32_t flags;
313 int refcnt;
314 u_short if_index;
315 u_short advrtrs; /* number of advertisement routers */
316 /* struct sockaddr_in6 advrtr[] */
317 };
318
319 struct in6_prefix_64 {
320 struct sockaddr_in6 prefix;
321 struct prf_ra raflags;
322 u_char prefixlen;
323 u_char origin;
324 u_long vltime __attribute__((aligned(8)));
325 u_long pltime __attribute__((aligned(8)));
326 u_long expire __attribute__((aligned(8)));
327 u_int32_t flags __attribute__((aligned(8)));
328 int refcnt;
329 u_short if_index;
330 u_short advrtrs;
331 /* struct sockaddr_in6 advrtr[] */
332 };
333 #endif /* BSD_KERNEL_PRIVATE */
334
335 struct in6_ondireq {
336 char ifname[IFNAMSIZ];
337 struct {
338 u_int32_t linkmtu; /* LinkMTU */
339 u_int32_t maxmtu; /* Upper bound of LinkMTU */
340 u_int32_t basereachable; /* BaseReachableTime */
341 u_int32_t reachable; /* Reachable Time */
342 u_int32_t retrans; /* Retrans Timer */
343 u_int32_t flags; /* Flags */
344 int recalctm; /* BaseReacable re-calculation timer */
345 u_int8_t chlim; /* CurHopLimit */
346 /* Number of routers learned on the interface */
347 u_int8_t receivedra;
348 /*
349 * The current collision count value
350 * being used for secure address generation.
351 */
352 u_int8_t collision_count;
353 } ndi;
354 };
355
356 #if !defined(BSD_KERNEL_PRIVATE)
357 struct in6_ndireq {
358 char ifname[IFNAMSIZ];
359 struct nd_ifinfo ndi;
360 };
361 #else
362 struct in6_ndireq {
363 char ifname[IFNAMSIZ];
364 struct nd_ifinfo_compat ndi;
365 };
366 #endif /* !BSD_KERNEL_PRIVATE */
367
368 struct in6_ndifreq {
369 char ifname[IFNAMSIZ];
370 u_long ifindex;
371 };
372
373 #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
374 #define RTR_SOLICITATION_INTERVAL 4 /* 4sec */
375
376 #if defined(BSD_KERNEL_PRIVATE)
377 struct in6_ndifreq_32 {
378 char ifname[IFNAMSIZ];
379 u_int32_t ifindex;
380 };
381
382 struct in6_ndifreq_64 {
383 char ifname[IFNAMSIZ];
384 u_int64_t ifindex __attribute__((aligned(8)));
385 };
386 #endif /* BSD_KERNEL_PRIVATE */
387
388 /* Prefix status */
389 #define NDPRF_ONLINK 0x1
390 #define NDPRF_DETACHED 0x2
391 #define NDPRF_STATIC 0x100
392 #define NDPRF_IFSCOPE 0x1000
393 #define NDPRF_PRPROXY 0x2000
394 #ifdef BSD_KERNEL_PRIVATE
395 #define NDPRF_PROCESSED_ONLINK 0x08000
396 #define NDPRF_PROCESSED_SERVICE 0x10000
397 #define NDPRF_DEFUNCT 0x20000
398 #define NDPRF_CLAT46 0x40000
399
400 #define CLAT46_COLLISION_COUNT_OFFSET 128
401 #endif
402
403 /* protocol constants */
404 #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
405 #define RTR_SOLICITATION_INTERVAL 4 /* 4sec */
406 #define MAX_RTR_SOLICITATIONS 3
407
408 #define ND6_INFINITE_LIFETIME 0xffffffff
409 #define ND6_MAX_LIFETIME 0x7fffffff
410
411 #ifdef BSD_KERNEL_PRIVATE
412 #define ND_IFINFO(ifp) \
413 ((ifp == NULL) ? NULL : \
414 ((IN6_IFEXTRA(ifp) == NULL) ? NULL : \
415 (&IN6_IFEXTRA(ifp)->nd_ifinfo)))
416
417 /*
418 * In a more readable form, we derive linkmtu based on:
419 *
420 * if (ifp == NULL)
421 * linkmtu = IPV6_MMTU
422 * else if (ND_IFINFO(ifp) == NULL || !ND_IFINFO(ifp)->initialized)
423 * linkmtu = ifp->if_mtu;
424 * else if (ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < ifp->if_mtu)
425 * linkmtu = ND_IFINFO(ifp)->linkmtu;
426 * else if ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < ifp->if_mtu))
427 * linkmtu = ND_IFINFO(ifp)->maxmtu;
428 * else
429 * linkmtu = ifp->if_mtu;
430 */
431 #define IN6_LINKMTU(ifp) \
432 (ifp == NULL ? IPV6_MMTU : \
433 (ND_IFINFO(ifp) == NULL || !ND_IFINFO(ifp)->initialized) ? \
434 (ifp)->if_mtu : ((ND_IFINFO(ifp)->linkmtu && \
435 ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) ? ND_IFINFO(ifp)->linkmtu : \
436 ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) ? \
437 ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)))
438
439 /* node constants */
440 #define MAX_REACHABLE_TIME 3600000 /* msec */
441 #define REACHABLE_TIME 30000 /* msec */
442 #define RETRANS_TIMER 1000 /* msec */
443 #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
444 #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
445 #define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
446 #define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
447 #define TEMPADDR_REGEN_ADVANCE 5 /* sec */
448 #define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
449 #define ND_COMPUTE_RTIME(x) \
450 (((MIN_RANDOM_FACTOR * (x >> 10)) + (RandomULong() & \
451 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
452
453 #define IP6_USE_TMPADDR_DEFAULT 1
454 #define IP6_ULA_USE_TMPADDR_DEFAULT 0
455 /* prefix expiry times */
456 #define ND6_PREFIX_EXPIRY_UNSPEC -1
457 #define ND6_PREFIX_EXPIRY_NEVER 0
458
459 TAILQ_HEAD(nd_drhead, nd_defrouter);
460 struct nd_defrouter {
461 decl_lck_mtx_data(, nddr_lock);
462 decl_lck_mtx_data(, nddr_ref_lock);
463 TAILQ_ENTRY(nd_defrouter) dr_entry;
464 struct in6_addr rtaddr;
465 u_int32_t nddr_refcount;
466 u_int32_t nddr_debug;
467 u_int64_t expire;
468 u_int64_t base_calendartime; /* calendar time at creation */
469 u_int64_t base_uptime; /* uptime at creation */
470 u_char flags; /* flags on RA message */
471 u_char stateflags;
472 u_int32_t rtlifetime;
473 int err;
474 struct ifnet *ifp;
475 struct in6_addr rtaddr_mapped; /* Mapped gateway address for routing */
476 boolean_t is_reachable;
477 void (*nddr_trace)(struct nd_defrouter *, int); /* trace callback fn */
478 };
479
480 #define NDDR_LOCK_ASSERT_HELD(_nddr) \
481 LCK_MTX_ASSERT(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_OWNED)
482
483 #define NDDR_LOCK_ASSERT_NOTHELD(_nddr) \
484 LCK_MTX_ASSERT(&(_nddr)->nddr_lock, LCK_MTX_ASSERT_NOTOWNED)
485
486 #define NDDR_LOCK(_nddr) \
487 lck_mtx_lock(&(_nddr)->nddr_lock)
488
489 #define NDDR_LOCK_SPIN(_nddr) \
490 lck_mtx_lock_spin(&(_nddr)->nddr_lock)
491
492 #define NDDR_CONVERT_LOCK(_nddr) do { \
493 NDPR_LOCK_ASSERT_HELD(_nddr); \
494 lck_mtx_convert_spin(&(_nddr)->nddr_lock); \
495 } while (0)
496
497 #define NDDR_UNLOCK(_nddr) \
498 lck_mtx_unlock(&(_nddr)->nddr_lock)
499
500 #define NDDR_REF_LOCK(_nddr) \
501 lck_mtx_lock(&(_nddr)->nddr_ref_lock)
502
503 #define NDDR_REF_LOCK_SPIN(_nddr) \
504 lck_mtx_lock_spin(&(_nddr)->nddr_ref_lock)
505
506 #define NDDR_REF_UNLOCK(_nddr) \
507 lck_mtx_unlock(&(_nddr)->nddr_ref_lock)
508
509 #define NDDR_ADDREF(_nddr) \
510 nddr_addref(_nddr)
511
512 #define NDDR_REMREF(_nddr) \
513 nddr_remref(_nddr) \
514
515 TAILQ_HEAD(nd_rtihead, nd_route_info);
516 /*
517 * The ordering below is important and it should always start
518 * with nd_drhead as the first element.
519 * It gets passed in as the generic nd_drhead to router management code.
520 * The extra information stored here includes the prefix/prefix-length
521 * which the router list belongs to.
522 */
523 struct nd_route_info {
524 struct nd_drhead nd_rti_router_list;
525 TAILQ_ENTRY(nd_route_info) nd_rti_entry;
526 struct in6_addr nd_rti_prefix;
527 u_int8_t nd_rti_prefixlen;
528 };
529
530 struct nd_route_info *ndrti_alloc(void);
531 void nd6_rti_list_wait(const char *);
532 void nd6_rti_list_signal_done(void);
533 void ndrti_free(struct nd_route_info *rti);
534 void nd6_rtilist_remove(struct nd_route_info *);
535 void nd6_rtilist_update(struct nd_route_info *, struct nd_defrouter *);
536 int nd6_rtilist_add(struct nd_route_info *, struct nd_defrouter *,
537 struct nd_route_info **);
538 void nd6_rti_purge(struct nd_route_info *);
539 void nd6_rti_delreq(struct nd_route_info *);
540 void nd6_rti_select(struct nd_route_info *, struct ifnet *);
541
542 /* define struct prproxy_sols_tree */
543 RB_HEAD(prproxy_sols_tree, nd6_prproxy_soltgt);
544
545 struct nd_prefix {
546 decl_lck_mtx_data(, ndpr_lock);
547 decl_lck_mtx_data(, ndpr_ref_lock);
548 u_int32_t ndpr_refcount; /* reference count */
549 u_int32_t ndpr_debug; /* see ifa_debug flags */
550 struct ifnet *ndpr_ifp;
551 struct rtentry *ndpr_rt;
552 LIST_ENTRY(nd_prefix) ndpr_entry;
553 struct sockaddr_in6 ndpr_prefix; /* prefix */
554 struct in6_addr ndpr_mask; /* netmask derived from the prefix */
555 struct in6_addr ndpr_addr; /* address that is derived from the prefix */
556 u_int32_t ndpr_vltime; /* advertised valid lifetime */
557 u_int32_t ndpr_pltime; /* advertised preferred lifetime */
558 u_int64_t ndpr_preferred; /* preferred time of the prefix */
559 u_int64_t ndpr_expire; /* expiration time of the prefix */
560 u_int64_t ndpr_lastupdate; /* rx time of last advertisement */
561 u_int64_t ndpr_base_calendartime; /* calendar time at creation */
562 u_int64_t ndpr_base_uptime; /* uptime at creation */
563 struct prf_ra ndpr_flags;
564 unsigned int ndpr_genid; /* protects ndpr_advrtrs */
565 u_int32_t ndpr_stateflags; /* actual state flags */
566 /* list of routers that advertise the prefix: */
567 LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
568 u_char ndpr_plen;
569 int ndpr_addrcnt; /* reference counter from addresses */
570 int ndpr_manual_addrcnt; /* reference counter non-autoconf addresses */
571 u_int32_t ndpr_allmulti_cnt; /* total all-multi reqs */
572 u_int32_t ndpr_prproxy_sols_cnt; /* total # of proxied NS */
573 struct prproxy_sols_tree ndpr_prproxy_sols; /* tree of proxied NS */
574 void (*ndpr_trace)(struct nd_prefix *, int); /* trace callback fn */
575 };
576
577 #define ndpr_next ndpr_entry.le_next
578
579 #define ndpr_raf ndpr_flags
580 #define ndpr_raf_onlink ndpr_flags.onlink
581 #define ndpr_raf_auto ndpr_flags.autonomous
582 #define ndpr_raf_router ndpr_flags.router
583 /*
584 * We keep expired prefix for certain amount of time, for validation purposes.
585 * 1800s = MaxRtrAdvInterval
586 */
587 #define NDPR_KEEP_EXPIRED (1800 * 2)
588
589 #define NDPR_LOCK_ASSERT_HELD(_ndpr) \
590 LCK_MTX_ASSERT(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_OWNED)
591
592 #define NDPR_LOCK_ASSERT_NOTHELD(_ndpr) \
593 LCK_MTX_ASSERT(&(_ndpr)->ndpr_lock, LCK_MTX_ASSERT_NOTOWNED)
594
595 #define NDPR_LOCK(_ndpr) \
596 lck_mtx_lock(&(_ndpr)->ndpr_lock)
597
598 #define NDPR_LOCK_SPIN(_ndpr) \
599 lck_mtx_lock_spin(&(_ndpr)->ndpr_lock)
600
601 #define NDPR_CONVERT_LOCK(_ndpr) do { \
602 NDPR_LOCK_ASSERT_HELD(_ndpr); \
603 lck_mtx_convert_spin(&(_ndpr)->ndpr_lock); \
604 } while (0)
605
606 #define NDPR_UNLOCK(_ndpr) \
607 lck_mtx_unlock(&(_ndpr)->ndpr_lock)
608
609 #define NDPR_REF_LOCK(_ndpr) \
610 lck_mtx_lock(&(_ndpr)->ndpr_ref_lock)
611
612 #define NDPR_REF_LOCK_SPIN(_ndpr) \
613 lck_mtx_lock_spin(&(_ndpr)->ndpr_ref_lock)
614
615 #define NDPR_REF_UNLOCK(_ndpr) \
616 lck_mtx_unlock(&(_ndpr)->ndpr_ref_lock)
617
618 #define NDPR_ADDREF(_ndpr) \
619 ndpr_addref(_ndpr)
620
621 #define NDPR_REMREF(_ndpr) \
622 ndpr_remref(_ndpr) \
623
624 /*
625 * Message format for use in obtaining information about prefixes
626 * from inet6 sysctl function
627 */
628 struct inet6_ndpr_msghdr {
629 u_short inpm_msglen; /* to skip over non-understood messages */
630 u_char inpm_version; /* future binary compatibility */
631 u_char inpm_type; /* message type */
632 struct in6_addr inpm_prefix;
633 u_int32_t prm_vltim;
634 u_int32_t prm_pltime;
635 u_int32_t prm_expire;
636 u_int32_t prm_preferred;
637 struct in6_prflags prm_flags;
638 u_short prm_index; /* index for associated ifp */
639 u_char prm_plen; /* length of prefix in bits */
640 };
641
642 #define prm_raf_onlink prm_flags.prf_ra.onlink
643 #define prm_raf_auto prm_flags.prf_ra.autonomous
644
645 #define prm_statef_onlink prm_flags.prf_state.onlink
646
647 #define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
648 #define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
649
650 struct nd_pfxrouter {
651 LIST_ENTRY(nd_pfxrouter) pfr_entry;
652 #define pfr_next pfr_entry.le_next
653 struct nd_defrouter *router;
654 };
655
656 LIST_HEAD(nd_prhead, nd_prefix);
657
658 struct nd_prefix_list {
659 struct nd_prefix_list *next;
660 struct nd_prefix pr;
661 };
662 #endif /* BSD_KERNEL_PRIVATE */
663
664 #if defined(PRIVATE)
665 struct kev_nd6_ndfailure {
666 struct net_event_data link_data;
667 };
668
669 struct kev_nd6_ndalive {
670 struct net_event_data link_data;
671 };
672
673 struct nd6_ra_prefix {
674 struct sockaddr_in6 prefix;
675 struct prf_ra raflags;
676 u_int32_t prefixlen;
677 u_int32_t origin;
678 u_int64_t vltime;
679 u_int64_t pltime;
680 u_int64_t expire;
681 u_int32_t flags;
682 u_int32_t refcnt;
683 u_int32_t if_index;
684 u_int32_t pad;
685 };
686
687 /* ND6 router advertisement valid bits */
688 #define KEV_ND6_DATA_VALID_MTU (0x1 << 0)
689 #define KEV_ND6_DATA_VALID_PREFIX (0x1 << 1)
690
691 struct kev_nd6_ra_data {
692 u_int32_t mtu;
693 u_int32_t list_index;
694 u_int32_t list_length;
695 u_int32_t flags;
696 struct nd6_ra_prefix prefix;
697 u_int32_t pad;
698 };
699
700 struct kev_nd6_event {
701 struct net_event_data link_data;
702 struct in6_addr in6_address;
703 uint32_t val;
704 };
705
706 struct nd6_lookup_ipv6_args {
707 char ifname[IFNAMSIZ];
708 struct sockaddr_in6 ip6_dest;
709 u_int32_t ll_dest_len;
710 union {
711 char buffer[256];
712 struct sockaddr_dl _sdl;
713 } ll_dest_;
714 };
715 #define ll_dest_sdl ll_dest_._sdl
716
717 #endif /* PRIVATE */
718
719 #if defined(BSD_KERNEL_PRIVATE)
720 /* nd6.c */
721 extern int nd6_prune;
722 extern int nd6_prune_lazy;
723 extern int nd6_delay;
724 extern int nd6_umaxtries;
725 extern int nd6_mmaxtries;
726 extern int nd6_useloopback;
727 extern int nd6_accept_6to4;
728 extern int nd6_maxnudhint;
729 extern int nd6_gctimer;
730 extern struct llinfo_nd6 llinfo_nd6;
731 extern struct nd_drhead nd_defrouter_list;
732 extern struct nd_rtihead nd_rti_list;
733 extern struct nd_prhead nd_prefix;
734 extern int nd6_debug;
735 extern int nd6_onlink_ns_rfc4861;
736 extern int nd6_optimistic_dad;
737
738 #include <os/log.h>
739
740 #define nd6log0(type, ...) do { os_log_##type(OS_LOG_DEFAULT, ##__VA_ARGS__); } while (0)
741 #define nd6log(type, ...) do { if (nd6_debug >= 1) os_log_##type(OS_LOG_DEFAULT, ##__VA_ARGS__); } while (0)
742 #define nd6log2(type, ...) do { if (nd6_debug >= 2) os_log_##type(OS_LOG_DEFAULT, ##__VA_ARGS__); } while (0)
743 #define nd6log3(type, ...) do { if (nd6_debug >= 3) os_log_##type(OS_LOG_DEFAULT, ##__VA_ARGS__); } while (0)
744
745 #define ND6_OPTIMISTIC_DAD_LINKLOCAL (1 << 0)
746 #define ND6_OPTIMISTIC_DAD_AUTOCONF (1 << 1)
747 #define ND6_OPTIMISTIC_DAD_TEMPORARY (1 << 2)
748 #define ND6_OPTIMISTIC_DAD_DYNAMIC (1 << 3)
749 #define ND6_OPTIMISTIC_DAD_SECURED (1 << 4)
750 #define ND6_OPTIMISTIC_DAD_MANUAL (1 << 5)
751
752 #define ND6_OPTIMISTIC_DAD_DEFAULT \
753 (ND6_OPTIMISTIC_DAD_LINKLOCAL | ND6_OPTIMISTIC_DAD_AUTOCONF | \
754 ND6_OPTIMISTIC_DAD_TEMPORARY | ND6_OPTIMISTIC_DAD_DYNAMIC | \
755 ND6_OPTIMISTIC_DAD_SECURED | ND6_OPTIMISTIC_DAD_MANUAL)
756
757 /* nd6_rtr.c */
758 extern int nd6_defifindex;
759 extern int ip6_desync_factor; /* seconds */
760 /* ND6_INFINITE_LIFETIME does not apply to temporary addresses */
761 extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
762 extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
763 extern int ip6_temp_regen_advance; /* seconds */
764
765 union nd_opts {
766 struct nd_opt_hdr *nd_opt_array[26]; /* max = Route information option */
767 struct {
768 struct nd_opt_hdr *zero;
769 struct nd_opt_hdr *src_lladdr;
770 struct nd_opt_hdr *tgt_lladdr;
771 struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
772 struct nd_opt_rd_hdr *rh;
773 struct nd_opt_mtu *mtu;
774 struct nd_opt_hdr *__res6;
775 struct nd_opt_hdr *__res7;
776 struct nd_opt_hdr *__res8;
777 struct nd_opt_hdr *__res9;
778 struct nd_opt_hdr *__res10;
779 struct nd_opt_hdr *__res11;
780 struct nd_opt_hdr *__res12;
781 struct nd_opt_hdr *__res13;
782 struct nd_opt_nonce *nonce;
783 struct nd_opt_hdr *__res15;
784 struct nd_opt_hdr *__res16;
785 struct nd_opt_hdr *__res17;
786 struct nd_opt_hdr *__res18;
787 struct nd_opt_hdr *__res19;
788 struct nd_opt_hdr *__res20;
789 struct nd_opt_hdr *__res21;
790 struct nd_opt_hdr *__res22;
791 struct nd_opt_hdr *__res23;
792 struct nd_opt_route_info *rti_beg;
793 struct nd_opt_hdr *__res25;
794 struct nd_opt_hdr *__ended_by(last) search; /* multiple opts */
795 struct nd_opt_hdr *last; /* multiple opts */
796 uint8_t done;
797 uint8_t initialized;
798 struct nd_opt_prefix_info *pi_end; /* multiple prefix opts, end */
799 struct nd_opt_route_info *rti_end; /* multiple route info opts, end */
800 } nd_opt_each;
801 };
802 #define nd_opts_src_lladdr nd_opt_each.src_lladdr
803 #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
804 #define nd_opts_pi nd_opt_each.pi_beg
805 #define nd_opts_pi_end nd_opt_each.pi_end
806 #define nd_opts_rh nd_opt_each.rh
807 #define nd_opts_mtu nd_opt_each.mtu
808 #define nd_opts_nonce nd_opt_each.nonce
809 #define nd_opts_rti nd_opt_each.rti_beg
810 #define nd_opts_rti_end nd_opt_each.rti_end
811 #define nd_opts_search nd_opt_each.search
812 #define nd_opts_last nd_opt_each.last
813 #define nd_opts_done nd_opt_each.done
814 #define nd_opts_initialized nd_opt_each.initialized
815
816 #define ND_OPT_LLADDR(opt, optlen, val, vallen) ({ \
817 (vallen) = opt->optlen << 3; \
818 struct nd_opt_hdr* __hdr = __unsafe_forge_bidi_indexable(struct nd_opt_hdr *, \
819 (opt), sizeof(struct nd_opt_hdr) + (vallen)); \
820 (val) = (char *)(__hdr + 1); \
821 })
822
823 #if __has_ptrcheck
824 #define TAKE_ND_NEXT_OPT(opt, start, end) ({ \
825 size_t __ndoptlen = (u_char*)ndopts.end - (u_char*)ndopts.start; \
826 struct nd_opt_hdr* __hdr = __unsafe_forge_bidi_indexable(struct nd_opt_hdr *, (opt), __ndoptlen); \
827 __hdr; \
828 })
829 #else
830 #define TAKE_ND_NEXT_OPT(opt, start, end) ({ \
831 (struct nd_opt_hdr *)opt; \
832 })
833 #endif
834
835 /* XXX: need nd6_var.h?? */
836 /* nd6.c */
837 extern int nd6_sched_timeout_want;
838 extern void nd6_sched_timeout(struct timeval *, struct timeval *);
839 extern void nd6_init(void);
840 extern void nd6_ifreset(struct ifnet *ifp);
841 extern void nd6_ifattach(struct ifnet *);
842 extern int nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *, int);
843 extern void nd6_option_init(void *__sized_by(icmp6len), size_t icmp6len, union nd_opts *);
844 extern struct nd_opt_hdr *nd6_option(union nd_opts *);
845 extern int nd6_options(union nd_opts *);
846 extern struct rtentry *nd6_lookup(struct in6_addr *, int, struct ifnet *, int);
847 extern void nd6_setmtu(struct ifnet *);
848 extern void nd6_purge(struct ifnet *);
849 extern void nd6_free(struct rtentry *);
850 extern void nd6_nud_hint(struct rtentry *, struct in6_addr *, int);
851 extern int nd6_resolve(struct ifnet *, struct rtentry *,
852 struct mbuf *, struct sockaddr *, u_char *);
853 extern void nd6_rtrequest(int, struct rtentry *, struct sockaddr *);
854 extern int nd6_ioctl(u_long cmd, caddr_t __counted_by(IOCPARM_LEN(cmd)), struct ifnet *);
855 extern void nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
856 char *lladdr __sized_by(lladdrlen), int lladdrlen,
857 int, int, int *);
858 extern int nd6_output_list(struct ifnet *, struct ifnet *, struct mbuf *,
859 struct sockaddr_in6 *, struct rtentry *, struct flowadv *);
860 extern int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
861 struct sockaddr_in6 *, struct rtentry *, struct flowadv *);
862 extern int nd6_need_cache(struct ifnet *);
863 extern void nd6_drain(void *);
864 extern void nd6_post_msg(u_int32_t, struct nd_prefix_list *, u_int32_t,
865 u_int32_t);
866 extern int nd6_setifinfo(struct ifnet *, u_int32_t, u_int32_t);
867 extern const char *ndcache_state2str(short);
868 extern void ln_setexpire(struct llinfo_nd6 *, uint64_t);
869
870 /* nd6_nbr.c */
871 extern void nd6_nbr_init(void);
872 extern void nd6_na_input(struct mbuf *, int, int);
873 extern void nd6_na_output(struct ifnet *, const struct in6_addr *,
874 const struct in6_addr *, u_int32_t, int, struct sockaddr *);
875 extern void nd6_ns_input(struct mbuf *, int, int);
876 extern void nd6_ns_output(struct ifnet *, const struct in6_addr *,
877 const struct in6_addr *, struct llinfo_nd6 *,
878 uint8_t *__counted_by(noncelen) nonce, size_t noncelen);
879
880 static inline caddr_t __header_indexable __stateful_pure
nd6_ifptomac(struct ifnet * ifp)881 nd6_ifptomac(struct ifnet *ifp)
882 {
883 switch (ifp->if_type) {
884 case IFT_ARCNET:
885 case IFT_ETHER:
886 case IFT_IEEE8023ADLAG:
887 case IFT_FDDI:
888 case IFT_IEEE1394:
889 #ifdef IFT_L2VLAN
890 case IFT_L2VLAN:
891 #endif
892 #ifdef IFT_IEEE80211
893 case IFT_IEEE80211:
894 #endif
895 #ifdef IFT_CARP
896 case IFT_CARP:
897 #endif
898 case IFT_BRIDGE:
899 case IFT_ISO88025:
900 return (caddr_t)IF_LLADDR(ifp);
901 default:
902 return NULL;
903 }
904 }
905
906 extern void nd6_dad_start(struct ifaddr *, int *);
907 extern void nd6_dad_stop(struct ifaddr *);
908 extern void nd6_llreach_alloc(struct rtentry *, struct ifnet *,
909 void * __sized_by(alen), unsigned int alen, boolean_t);
910 extern void nd6_llreach_set_reachable(struct ifnet *, void *__sized_by(alen) addr, unsigned int alen);
911 extern void nd6_llreach_use(struct llinfo_nd6 *);
912 extern void nd6_alt_node_addr_decompose(struct ifnet *, struct sockaddr *,
913 struct sockaddr_dl *, struct sockaddr_in6 *);
914 extern int nd6_alt_node_present(struct ifnet *, struct sockaddr_in6 *,
915 struct sockaddr_dl *, int32_t, int, int);
916 extern int nd6_alt_node_absent(struct ifnet *, struct sockaddr_in6 *, struct sockaddr_dl *);
917
918 /* nd6_rtr.c */
919 extern struct in6_ifaddr *in6_pfx_newpersistaddr(struct nd_prefix *, int,
920 int *, boolean_t, uint8_t);
921 extern void nd6_rtr_init(void);
922 extern void nd6_rs_input(struct mbuf *, int, int);
923 extern void nd6_ra_input(struct mbuf *, int, int);
924 extern void prelist_del(struct nd_prefix *);
925 extern struct nd_defrouter *defrtrlist_update(struct nd_defrouter *,
926 struct nd_drhead *);
927 extern void defrouter_select(struct ifnet *, struct nd_drhead *);
928 extern void defrouter_reset(void);
929 extern int defrtrlist_ioctl(u_long cmd, caddr_t __sized_by(IOCPARM_LEN(cmd)));
930 extern void defrtrlist_del(struct nd_defrouter *, struct nd_drhead *);
931 extern int defrtrlist_add_static(struct nd_defrouter *);
932 extern int defrtrlist_del_static(struct nd_defrouter *);
933 extern void prelist_remove(struct nd_prefix *);
934 extern int prelist_update(struct nd_prefix *, struct nd_defrouter *,
935 struct mbuf *, int);
936 extern int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
937 struct nd_prefix **, boolean_t);
938 extern int nd6_prefix_onlink(struct nd_prefix *);
939 extern int nd6_prefix_onlink_scoped(struct nd_prefix *, unsigned int);
940 extern int nd6_prefix_offlink(struct nd_prefix *);
941 extern void pfxlist_onlink_check(void);
942 extern void defrouter_set_reachability(struct in6_addr *, struct ifnet *, boolean_t);
943 extern struct nd_defrouter *defrouter_lookup(struct nd_drhead *,
944 struct in6_addr *, struct ifnet *);
945 extern struct nd_pfxrouter *pfxrtr_lookup(struct nd_prefix *, struct nd_defrouter *);
946 extern struct nd_prefix *nd6_prefix_lookup(struct nd_prefix *, int);
947 extern int in6_init_prefix_ltimes(struct nd_prefix *ndpr);
948 extern void rt6_flush(struct in6_addr *, struct ifnet *);
949 extern int nd6_setdefaultiface(int);
950 extern int in6_tmpifadd(const struct in6_ifaddr *, int);
951 extern void nddr_addref(struct nd_defrouter *);
952 extern struct nd_defrouter *nddr_remref(struct nd_defrouter *);
953 extern uint64_t nddr_getexpire(struct nd_defrouter *);
954 extern void ndpr_addref(struct nd_prefix *);
955 extern struct nd_prefix *ndpr_remref(struct nd_prefix *);
956 extern uint64_t ndpr_getexpire(struct nd_prefix *);
957 extern void defrouter_delreq(struct nd_defrouter *, struct nd_route_info *);
958
959 /* nd6_prproxy.c */
960 struct ip6_hdr;
961 extern u_int32_t nd6_prproxy;
962 extern int nd6_if_prproxy(struct ifnet *, boolean_t);
963 extern void nd6_prproxy_prelist_update(struct nd_prefix *, struct nd_prefix *);
964 extern boolean_t nd6_prproxy_ifaddr(struct in6_ifaddr *);
965 extern void nd6_proxy_find_fwdroute(struct ifnet *, struct route_in6 *);
966 extern boolean_t nd6_prproxy_isours(struct mbuf *, struct ip6_hdr *,
967 struct route_in6 *, unsigned int);
968 extern void nd6_prproxy_ns_output(struct ifnet *, struct ifnet *,
969 struct in6_addr *, struct in6_addr *, struct llinfo_nd6 *);
970 extern void nd6_prproxy_ns_input(struct ifnet *, struct in6_addr *,
971 char *__sized_by(lladdrlen) lladdr, int lladdrlen, struct in6_addr *,
972 struct in6_addr *, uint8_t *__counted_by(noncelen) nonce, size_t noncelen);
973 extern void nd6_prproxy_na_input(struct ifnet *, struct in6_addr *,
974 struct in6_addr *, struct in6_addr *, int);
975 extern void nd6_prproxy_sols_reap(struct nd_prefix *);
976 extern void nd6_prproxy_sols_prune(struct nd_prefix *, u_int32_t);
977 extern int nd6_if_disable(struct ifnet *, boolean_t);
978 void in6_ifaddr_set_dadprogress(struct in6_ifaddr *ia);
979 #endif /* BSD_KERNEL_PRIVATE */
980
981 #ifdef KERNEL
982
983 /*
984 * @function nd6_lookup_ipv6
985 * @discussion This function will check the routing table for a cached
986 * neighbor discovery entry or trigger an neighbor discovery query
987 * to resolve the IPv6 address to a link-layer address.
988 * nd entries are stored in the routing table. This function will
989 * lookup the IPv6 destination in the routing table. If the
990 * destination requires forwarding to a gateway, the route of the
991 * gateway will be looked up. The route entry is inspected to
992 * determine if the link layer destination address is known. If
993 * unknown, neighbor discovery will be used to resolve the entry.
994 * @param interface The interface the packet is being sent on.
995 * @param ip6_dest The IPv6 destination of the packet.
996 * @param ll_dest On output, the link-layer destination.
997 * @param ll_dest_len The length of the buffer for ll_dest.
998 * @param hint Any routing hint passed down from the protocol.
999 * @param packet The packet being transmitted.
1000 * @result May return an error such as EHOSTDOWN or ENETUNREACH. If
1001 * this function returns EJUSTRETURN, the packet has been queued
1002 * and will be sent when the address is resolved. If any other
1003 * value is returned, the caller is responsible for disposing of
1004 * the packet.
1005 */
1006 extern errno_t nd6_lookup_ipv6(ifnet_t interface,
1007 const struct sockaddr_in6 *ip6_dest, struct sockaddr_dl *ll_dest,
1008 size_t ll_dest_len, route_t hint, mbuf_t packet);
1009
1010 #endif /* KERNEL */
1011
1012 /* nd6_send.c */
1013 #ifdef BSD_KERNEL_PRIVATE
1014 /*
1015 * nd6_send_opmode
1016 *
1017 * value using CGA tx SEND rx SEND
1018 * -------- --------- ------- -------
1019 * DISABLED NO NO NO
1020 * QUIET YES NO NO
1021 */
1022 extern int nd6_send_opstate;
1023
1024 #define ND6_SEND_OPMODE_DISABLED 0
1025 #define ND6_SEND_OPMODE_CGA_QUIET 1
1026
1027 #endif /* BSD_KERNEL_PRIVATE */
1028 #endif /* _NETINET6_ND6_H_ */
1029