2 * Copyright (c) 2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 /* $FreeBSD: src/sys/netinet6/in6_var.h,v 1.3.2.2 2001/07/03 11:01:52 ume Exp $ */
30 /* $KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $ */
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * Copyright (c) 1985, 1986, 1993
63 * The Regents of the University of California. All rights reserved.
65 * Redistribution and use in source and binary forms, with or without
66 * modification, are permitted provided that the following conditions
68 * 1. Redistributions of source code must retain the above copyright
69 * notice, this list of conditions and the following disclaimer.
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in the
72 * documentation and/or other materials provided with the distribution.
73 * 3. All advertising materials mentioning features or use of this software
74 * must display the following acknowledgement:
75 * This product includes software developed by the University of
76 * California, Berkeley and its contributors.
77 * 4. Neither the name of the University nor the names of its contributors
78 * may be used to endorse or promote products derived from this software
79 * without specific prior written permission.
81 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
82 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
84 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
85 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
93 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
96 #ifndef _NETINET6_IN6_VAR_H_
97 #define _NETINET6_IN6_VAR_H_
98 #include <sys/appleapiopts.h>
101 #include <sys/kern_event.h>
105 * pltime/vltime are just for future reference (required to implements 2
106 * hour rule for hosts). they should never be modified by nd6_timeout or
108 * userland -> kernel: accept pltime/vltime
109 * kernel -> userland: throw up everything
110 * in kernel: modify preferred/expire only
112 struct in6_addrlifetime
{
113 time_t ia6t_expire
; /* valid lifetime expiration time */
114 time_t ia6t_preferred
; /* preferred lifetime expiration time */
115 u_int32_t ia6t_vltime
; /* valid lifetime */
116 u_int32_t ia6t_pltime
; /* prefix lifetime */
119 #if defined(KERNEL_PRIVATE)
120 struct in6_addrlifetime_32
{
121 u_int32_t ia6t_expire
;
122 u_int32_t ia6t_preferred
;
123 u_int32_t ia6t_vltime
;
124 u_int32_t ia6t_pltime
;
127 struct in6_addrlifetime_64
{
129 time_t ia6t_preferred
__attribute__((aligned(8)));
130 u_int32_t ia6t_vltime
__attribute__((aligned(8)));
131 u_int32_t ia6t_pltime
;
135 * Interface address, IPv6 version. One of these structures
136 * is allocated for each interface with an IPv6 address.
137 * The ifaddr structure contains the protocol-independent part
138 * of the structure and is assumed to be first.
141 struct ifaddr ia_ifa
; /* protocol-independent info */
142 #define ia_ifp ia_ifa.ifa_ifp
143 #define ia_flags ia_ifa.ifa_flags
144 struct sockaddr_in6 ia_addr
; /* interface address */
145 struct sockaddr_in6 ia_net
; /* network number of interface */
146 struct sockaddr_in6 ia_dstaddr
; /* space for destination addr */
147 struct sockaddr_in6 ia_prefixmask
; /* prefix mask */
148 u_int32_t ia_plen
; /* prefix length */
149 struct in6_ifaddr
*ia_next
; /* next in6 list of IP6 addresses */
152 struct in6_addrlifetime ia6_lifetime
;
153 struct ifprefix
*ia6_ifpr
; /* back pointer to ifprefix */
155 struct nd_prefix
*ia6_ndpr
; /* back pointer to the ND prefix
156 * (for autoconfigured addresses only)
159 #endif /* KERNEL_PRIVATE */
162 * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
165 u_quad_t ifs6_in_receive
; /* # of total input datagram */
166 u_quad_t ifs6_in_hdrerr
; /* # of datagrams with invalid hdr */
167 u_quad_t ifs6_in_toobig
; /* # of datagrams exceeded MTU */
168 u_quad_t ifs6_in_noroute
; /* # of datagrams with no route */
169 u_quad_t ifs6_in_addrerr
; /* # of datagrams with invalid dst */
170 u_quad_t ifs6_in_protounknown
; /* # of datagrams with unknown proto */
171 /* NOTE: increment on final dst if */
172 u_quad_t ifs6_in_truncated
; /* # of truncated datagrams */
173 u_quad_t ifs6_in_discard
; /* # of discarded datagrams */
174 /* NOTE: fragment timeout is not here */
175 u_quad_t ifs6_in_deliver
; /* # of datagrams delivered to ULP */
176 /* NOTE: increment on final dst if */
177 u_quad_t ifs6_out_forward
; /* # of datagrams forwarded */
178 /* NOTE: increment on outgoing if */
179 u_quad_t ifs6_out_request
; /* # of outgoing datagrams from ULP */
180 /* NOTE: does not include forwrads */
181 u_quad_t ifs6_out_discard
; /* # of discarded datagrams */
182 u_quad_t ifs6_out_fragok
; /* # of datagrams fragmented */
183 u_quad_t ifs6_out_fragfail
; /* # of datagrams failed on fragment */
184 u_quad_t ifs6_out_fragcreat
; /* # of fragment datagrams */
185 /* NOTE: this is # after fragment */
186 u_quad_t ifs6_reass_reqd
; /* # of incoming fragmented packets */
187 /* NOTE: increment on final dst if */
188 u_quad_t ifs6_reass_ok
; /* # of reassembled packets */
189 /* NOTE: this is # after reass */
190 /* NOTE: increment on final dst if */
191 u_quad_t ifs6_reass_fail
; /* # of reass failures */
192 /* NOTE: may not be packet count */
193 /* NOTE: increment on final dst if */
194 u_quad_t ifs6_in_mcast
; /* # of inbound multicast datagrams */
195 u_quad_t ifs6_out_mcast
; /* # of outbound multicast datagrams */
199 * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
200 * XXX: I'm not sure if this file is the right place for this structure...
202 struct icmp6_ifstat
{
206 /* ipv6IfIcmpInMsgs, total # of input messages */
207 u_quad_t ifs6_in_msg
;
208 /* ipv6IfIcmpInErrors, # of input error messages */
209 u_quad_t ifs6_in_error
;
210 /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
211 u_quad_t ifs6_in_dstunreach
;
212 /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
213 u_quad_t ifs6_in_adminprohib
;
214 /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
215 u_quad_t ifs6_in_timeexceed
;
216 /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
217 u_quad_t ifs6_in_paramprob
;
218 /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
219 u_quad_t ifs6_in_pkttoobig
;
220 /* ipv6IfIcmpInEchos, # of input echo requests */
221 u_quad_t ifs6_in_echo
;
222 /* ipv6IfIcmpInEchoReplies, # of input echo replies */
223 u_quad_t ifs6_in_echoreply
;
224 /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
225 u_quad_t ifs6_in_routersolicit
;
226 /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
227 u_quad_t ifs6_in_routeradvert
;
228 /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
229 u_quad_t ifs6_in_neighborsolicit
;
230 /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
231 u_quad_t ifs6_in_neighboradvert
;
232 /* ipv6IfIcmpInRedirects, # of input redirects */
233 u_quad_t ifs6_in_redirect
;
234 /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
235 u_quad_t ifs6_in_mldquery
;
236 /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
237 u_quad_t ifs6_in_mldreport
;
238 /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
239 u_quad_t ifs6_in_mlddone
;
242 * Output statistics. We should solve unresolved routing problem...
244 /* ipv6IfIcmpOutMsgs, total # of output messages */
245 u_quad_t ifs6_out_msg
;
246 /* ipv6IfIcmpOutErrors, # of output error messages */
247 u_quad_t ifs6_out_error
;
248 /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
249 u_quad_t ifs6_out_dstunreach
;
250 /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
251 u_quad_t ifs6_out_adminprohib
;
252 /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
253 u_quad_t ifs6_out_timeexceed
;
254 /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
255 u_quad_t ifs6_out_paramprob
;
256 /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
257 u_quad_t ifs6_out_pkttoobig
;
258 /* ipv6IfIcmpOutEchos, # of output echo requests */
259 u_quad_t ifs6_out_echo
;
260 /* ipv6IfIcmpOutEchoReplies, # of output echo replies */
261 u_quad_t ifs6_out_echoreply
;
262 /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
263 u_quad_t ifs6_out_routersolicit
;
264 /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
265 u_quad_t ifs6_out_routeradvert
;
266 /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
267 u_quad_t ifs6_out_neighborsolicit
;
268 /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
269 u_quad_t ifs6_out_neighboradvert
;
270 /* ipv6IfIcmpOutRedirects, # of output redirects */
271 u_quad_t ifs6_out_redirect
;
272 /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
273 u_quad_t ifs6_out_mldquery
;
274 /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
275 u_quad_t ifs6_out_mldreport
;
276 /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
277 u_quad_t ifs6_out_mlddone
;
281 char ifr_name
[IFNAMSIZ
];
283 struct sockaddr_in6 ifru_addr
;
284 struct sockaddr_in6 ifru_dstaddr
;
289 struct in6_addrlifetime ifru_lifetime
;
290 struct in6_ifstat ifru_stat
;
291 struct icmp6_ifstat ifru_icmp6stat
;
292 u_int32_t ifru_scope_id
[16];
296 struct in6_aliasreq
{
297 char ifra_name
[IFNAMSIZ
];
298 struct sockaddr_in6 ifra_addr
;
299 struct sockaddr_in6 ifra_dstaddr
;
300 struct sockaddr_in6 ifra_prefixmask
;
302 struct in6_addrlifetime ifra_lifetime
;
305 #if defined(KERNEL_PRIVATE)
306 struct in6_aliasreq_32
{
307 char ifra_name
[IFNAMSIZ
];
308 struct sockaddr_in6 ifra_addr
;
309 struct sockaddr_in6 ifra_dstaddr
;
310 struct sockaddr_in6 ifra_prefixmask
;
312 struct in6_addrlifetime_32 ifra_lifetime
;
315 struct in6_aliasreq_64
{
316 char ifra_name
[IFNAMSIZ
];
317 struct sockaddr_in6 ifra_addr
;
318 struct sockaddr_in6 ifra_dstaddr
;
319 struct sockaddr_in6 ifra_prefixmask
;
321 struct in6_addrlifetime_64 ifra_lifetime
;
323 #endif /* KERNEL_PRIVATE */
325 /* prefix type macro */
326 #define IN6_PREFIX_ND 1
327 #define IN6_PREFIX_RR 2
330 * prefix related flags passed between kernel(NDP related part) and
331 * user land command(ifconfig) and daemon(rtadvd).
336 u_char autonomous
: 1;
339 u_char prf_reserved1
;
340 u_short prf_reserved2
;
341 /* want to put this on 4byte offset */
343 u_char decrvalid
: 1;
344 u_char decrprefd
: 1;
347 u_char prf_reserved3
;
348 u_short prf_reserved4
;
351 struct in6_prefixreq
{
352 char ipr_name
[IFNAMSIZ
];
355 u_int32_t ipr_vltime
;
356 u_int32_t ipr_pltime
;
357 struct in6_prflags ipr_flags
;
358 struct sockaddr_in6 ipr_prefix
;
363 #define PR_ORIG_STATIC 2
364 #define PR_ORIG_KERNEL 3
366 #define ipr_raf_onlink ipr_flags.prf_ra.onlink
367 #define ipr_raf_auto ipr_flags.prf_ra.autonomous
369 #define ipr_statef_onlink ipr_flags.prf_state.onlink
371 #define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid
372 #define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd
374 struct in6_rrenumreq
{
375 char irr_name
[IFNAMSIZ
];
377 u_char irr_m_len
; /* match len for matchprefix */
378 u_char irr_m_minlen
; /* minlen for matching prefix */
379 u_char irr_m_maxlen
; /* maxlen for matching prefix */
380 u_char irr_u_uselen
; /* uselen for adding prefix */
381 u_char irr_u_keeplen
; /* keeplen from matching prefix */
382 struct irr_raflagmask
{
384 u_char autonomous
: 1;
387 u_int32_t irr_vltime
;
388 u_int32_t irr_pltime
;
389 struct in6_prflags irr_flags
;
390 struct sockaddr_in6 irr_matchprefix
;
391 struct sockaddr_in6 irr_useprefix
;
394 #define irr_raf_mask_onlink irr_raflagmask.onlink
395 #define irr_raf_mask_auto irr_raflagmask.autonomous
396 #define irr_raf_mask_reserved irr_raflagmask.reserved
398 #define irr_raf_onlink irr_flags.prf_ra.onlink
399 #define irr_raf_auto irr_flags.prf_ra.autonomous
401 #define irr_statef_onlink irr_flags.prf_state.onlink
403 #define irr_rrf irr_flags.prf_rr
404 #define irr_rrf_decrvalid irr_flags.prf_rr.decrvalid
405 #define irr_rrf_decrprefd irr_flags.prf_rr.decrprefd
407 #ifdef KERNEL_PRIVATE
409 * Given a pointer to an in6_ifaddr (ifaddr),
410 * return a pointer to the addr as a sockaddr_in6
412 #define IA6_IN6(ia) (&((ia)->ia_addr.sin6_addr))
413 #define IA6_DSTIN6(ia) (&((ia)->ia_dstaddr.sin6_addr))
414 #define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr))
415 #define IA6_SIN6(ia) (&((ia)->ia_addr))
416 #define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr))
417 #define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
418 #define IFA_DSTIN6(x) (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
420 #define IFPR_IN6(x) (&((struct sockaddr_in6 *)((x)->ifpr_prefix))->sin6_addr)
421 #endif /* KERNEL_PRIVATE */
424 * Event data, internet6 style.
427 struct kev_in6_addrlifetime
{
428 u_int32_t ia6t_expire
;
429 u_int32_t ia6t_preferred
;
430 u_int32_t ia6t_vltime
;
431 u_int32_t ia6t_pltime
;
434 struct kev_in6_data
{
435 struct net_event_data link_data
;
436 struct sockaddr_in6 ia_addr
; /* interface address */
437 struct sockaddr_in6 ia_net
; /* network number of interface */
438 struct sockaddr_in6 ia_dstaddr
; /* space for destination addr */
439 struct sockaddr_in6 ia_prefixmask
; /* prefix mask */
440 u_int32_t ia_plen
; /* prefix length */
441 u_int32_t ia6_flags
; /* address flags from in6_ifaddr */
442 struct kev_in6_addrlifetime ia_lifetime
; /* address life info */
446 * Define inet6 event subclass and specific inet6 events.
449 #define KEV_INET6_SUBCLASS 6 /* inet6 subclass identifier */
451 #define KEV_INET6_NEW_USER_ADDR 1 /* Userland configured IPv6 address */
452 #define KEV_INET6_CHANGED_ADDR 2 /* Address changed event (future) */
453 #define KEV_INET6_ADDR_DELETED 3 /* IPv6 add. in ia_addr field was deleted */
454 #define KEV_INET6_NEW_LL_ADDR 4 /* Autoconfigured linklocal address has appeared */
455 #define KEV_INET6_NEW_RTADV_ADDR 5 /* Autoconf router advertised address has appeared */
456 #define KEV_INET6_DEFROUTER 6 /* Default router dectected by kernel */
458 #ifdef KERNEL_PRIVATE
459 /* Utility function used inside netinet6 kernel code for generating events */
460 void in6_post_msg(struct ifnet
*, u_int32_t
, struct in6_ifaddr
*);
461 #endif /* KERNEL_PRIVATE */
463 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
464 (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
465 (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
466 (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
467 (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
469 #define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq)
470 #define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq)
473 * SIOCSxxx ioctls should be unused (see comments in in6.c), but
474 * we do not shift numbers for binary compatibility.
476 #define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq)
477 #define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq)
479 #define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
480 #define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
482 #define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
483 #define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
484 #ifdef KERNEL_PRIVATE
485 #define SIOCAIFADDR_IN6_32 _IOW('i', 26, struct in6_aliasreq_32)
486 #define SIOCAIFADDR_IN6_64 _IOW('i', 26, struct in6_aliasreq_64)
487 #endif /* KERNEL_PRIVATE */
489 #define SIOCSIFPHYADDR_IN6 _IOW('i', 62, struct in6_aliasreq)
490 #ifdef KERNEL_PRIVATE
491 #define SIOCSIFPHYADDR_IN6_32 _IOW('i', 62, struct in6_aliasreq_32)
492 #define SIOCSIFPHYADDR_IN6_64 _IOW('i', 62, struct in6_aliasreq_64)
493 #endif /* KERNEL_PRIVATE */
494 #define SIOCGIFPSRCADDR_IN6 _IOWR('i', 63, struct in6_ifreq)
495 #define SIOCGIFPDSTADDR_IN6 _IOWR('i', 64, struct in6_ifreq)
496 #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
497 #define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist)
498 #ifdef KERNEL_PRIVATE
499 #define SIOCGDRLST_IN6_32 _IOWR('i', 74, struct in6_drlist_32)
500 #define SIOCGDRLST_IN6_64 _IOWR('i', 74, struct in6_drlist_64)
501 #endif /* KERNEL_PRIVATE */
502 #define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_prlist)
503 #ifdef KERNEL_PRIVATE
504 #define SIOCGPRLST_IN6_32 _IOWR('i', 75, struct in6_prlist_32)
505 #define SIOCGPRLST_IN6_64 _IOWR('i', 75, struct in6_prlist_64)
506 #endif /* KERNEL_PRIVATE */
507 #define OSIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ondireq)
508 #define SIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq)
509 #define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
510 #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
511 #ifdef KERNEL_PRIVATE
512 #define SIOCGNBRINFO_IN6_32 _IOWR('i', 78, struct in6_nbrinfo_32)
513 #define SIOCGNBRINFO_IN6_64 _IOWR('i', 78, struct in6_nbrinfo_64)
514 #endif /* KERNEL_PRIVATE */
515 #define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq)
516 #define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
518 #define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq)
519 #define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq)
520 #define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq)
521 #define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq)
523 #define SIOCSDEFIFACE_IN6 _IOWR('i', 85, struct in6_ndifreq)
524 #define SIOCGDEFIFACE_IN6 _IOWR('i', 86, struct in6_ndifreq)
525 #ifdef KERNEL_PRIVATE
526 #define SIOCSDEFIFACE_IN6_32 _IOWR('i', 85, struct in6_ndifreq_32)
527 #define SIOCSDEFIFACE_IN6_64 _IOWR('i', 85, struct in6_ndifreq_64)
528 #define SIOCGDEFIFACE_IN6_32 _IOWR('i', 86, struct in6_ndifreq_32)
529 #define SIOCGDEFIFACE_IN6_64 _IOWR('i', 86, struct in6_ndifreq_64)
530 #endif /* KERNEL_PRIVATE */
532 #define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */
534 #define SIOCSSCOPE6 _IOW('i', 88, struct in6_ifreq)
535 #define SIOCGSCOPE6 _IOWR('i', 89, struct in6_ifreq)
536 #define SIOCGSCOPE6DEF _IOWR('i', 90, struct in6_ifreq)
538 #define SIOCSIFPREFIX_IN6 _IOW('i', 100, struct in6_prefixreq) /* set */
539 #define SIOCGIFPREFIX_IN6 _IOWR('i', 101, struct in6_prefixreq) /* get */
540 #define SIOCDIFPREFIX_IN6 _IOW('i', 102, struct in6_prefixreq) /* del */
541 #define SIOCAIFPREFIX_IN6 _IOW('i', 103, struct in6_rrenumreq) /* add */
542 #define SIOCCIFPREFIX_IN6 _IOW('i', 104, \
543 struct in6_rrenumreq) /* change */
544 #define SIOCSGIFPREFIX_IN6 _IOW('i', 105, \
545 struct in6_rrenumreq) /* set global */
547 #define SIOCGETSGCNT_IN6 _IOWR('u', 28, \
548 struct sioc_sg_req6) /* get s,g pkt cnt */
549 #define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \
550 struct sioc_mif_req6) /* get pkt cnt per if */
551 #ifdef KERNEL_PRIVATE
552 #define SIOCGETMIFCNT_IN6_32 _IOWR('u', 107, struct sioc_mif_req6_32)
553 #define SIOCGETMIFCNT_IN6_64 _IOWR('u', 107, struct sioc_mif_req6_64)
554 #endif /* KERNEL_PRIVATE */
558 * temporary control calls to attach/detach IP to/from an ethernet interface
560 #define SIOCPROTOATTACH_IN6 _IOWR('i', 110, struct in6_aliasreq) /* attach proto to interface */
561 #ifdef KERNEL_PRIVATE
562 #define SIOCPROTOATTACH_IN6_32 _IOWR('i', 110, struct in6_aliasreq_32)
563 #define SIOCPROTOATTACH_IN6_64 _IOWR('i', 110, struct in6_aliasreq_64)
564 #endif /* KERNEL_PRIVATE */
565 #define SIOCPROTODETACH_IN6 _IOWR('i', 111, struct in6_ifreq) /* detach proto from interface */
567 #define SIOCLL_START _IOWR('i', 130, struct in6_aliasreq) /* start aquiring linklocal on interface */
568 #ifdef KERNEL_PRIVATE
569 #define SIOCLL_START_32 _IOWR('i', 130, struct in6_aliasreq_32)
570 #define SIOCLL_START_64 _IOWR('i', 130, struct in6_aliasreq_64)
571 #endif /* KERNEL_PRIVATE */
572 #define SIOCLL_STOP _IOWR('i', 131, struct in6_ifreq) /* deconfigure linklocal from interface */
573 #define SIOCAUTOCONF_START _IOWR('i', 132, struct in6_ifreq) /* accept rtadvd on this interface */
574 #define SIOCAUTOCONF_STOP _IOWR('i', 133, struct in6_ifreq) /* stop accepting rtadv for this interface */
577 #define IN6_IFF_ANYCAST 0x01 /* anycast address */
578 #define IN6_IFF_TENTATIVE 0x02 /* tentative address */
579 #define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */
580 #define IN6_IFF_DETACHED 0x08 /* may be detached from the link */
581 #define IN6_IFF_DEPRECATED 0x10 /* deprecated address */
582 #define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address
583 * (used only at first SIOC* call)
585 #define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
586 #define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */
587 #define IN6_IFF_NOPFX 0x8000 /* skip kernel prefix management.
588 * XXX: this should be temporary.
591 /* do not input/output */
592 #define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
595 #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
596 #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
599 #ifdef KERNEL_PRIVATE
600 extern struct in6_ifaddr
*in6_ifaddrs
;
602 extern struct in6_ifstat
**in6_ifstat
;
603 extern size_t in6_ifstatmax
;
604 extern struct icmp6stat icmp6stat
;
605 extern struct icmp6_ifstat
**icmp6_ifstat
;
606 extern size_t icmp6_ifstatmax
;
607 #define in6_ifstat_inc(ifp, tag) \
609 int _z_index = ifp ? ifp->if_index : 0; \
610 if ((_z_index) && _z_index <= if_index \
611 && _z_index < (signed)in6_ifstatmax \
612 && in6_ifstat && in6_ifstat[_z_index]) { \
613 in6_ifstat[_z_index]->tag++; \
617 extern struct ifqueue ip6intrq
; /* IP6 packet input queue */
618 extern struct in6_addr zeroin6_addr
;
619 extern u_char inet6ctlerrmap
[];
620 extern u_int32_t in6_maxmtu
;
621 #ifdef MALLOC_DECLARE
622 MALLOC_DECLARE(M_IPMADDR
);
623 #endif /* MALLOC_DECLARE */
626 * Macro for finding the internet address structure (in6_ifaddr) corresponding
627 * to a given interface (ifnet structure).
630 #define IFP_TO_IA6(ifp, ia) \
631 /* struct ifnet *ifp; */ \
632 /* struct in6_ifaddr *ia; */ \
634 struct ifaddr *ifa; \
635 for (ifa = (ifp)->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) { \
636 if (!ifa->ifa_addr) \
638 if (ifa->ifa_addr->sa_family == AF_INET6) \
641 (ia) = (struct in6_ifaddr *)ifa; \
645 * Multi-cast membership entry. One for each group/ifp that a PCB
648 struct in6_multi_mship
{
649 struct in6_multi
*i6mm_maddr
; /* Multicast address pointer */
650 LIST_ENTRY(in6_multi_mship
) i6mm_chain
; /* multicast options chain */
654 LIST_ENTRY(in6_multi
) in6m_entry
; /* list glue */
655 struct in6_addr in6m_addr
; /* IP6 multicast address */
656 struct ifnet
*in6m_ifp
; /* back pointer to ifnet */
657 struct ifmultiaddr
*in6m_ifma
; /* back pointer to ifmultiaddr */
658 u_int in6m_refcount
; /* # membership claims by sockets */
659 u_int in6m_state
; /* state of the membership */
660 u_int in6m_timer
; /* MLD6 listener report timer */
663 extern LIST_HEAD(in6_multihead
, in6_multi
) in6_multihead
;
666 * Structure used by macros below to remember position when stepping through
667 * all of the in6_multi records.
669 struct in6_multistep
{
670 struct in6_ifaddr
*i_ia
;
671 struct in6_multi
*i_in6m
;
675 * Macros for looking up the in6_multi record for a given IP6 multicast
676 * address on a given interface. If no matching record is found, "in6m"
680 #define IN6_LOOKUP_MULTI(addr, ifp, in6m) \
681 /* struct in6_addr addr; */ \
682 /* struct ifnet *ifp; */ \
683 /* struct in6_multi *in6m; */ \
685 struct ifmultiaddr *_ifma; \
686 for (_ifma = (ifp)->if_multiaddrs.lh_first; _ifma; \
687 _ifma = _ifma->ifma_link.le_next) { \
688 if (_ifma->ifma_addr->sa_family == AF_INET6 \
689 && IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6 *)_ifma->ifma_addr)->sin6_addr, \
693 (in6m) = (struct in6_multi *)(_ifma ? _ifma->ifma_protospec : 0); \
697 * Macro to step through all of the in6_multi records, one at a time.
698 * The current position is remembered in "step", which the caller must
699 * provide. IN6_FIRST_MULTI(), below, must be called to initialize "step"
700 * and get the first record. Both macros return a NULL "in6m" when there
701 * are no remaining records.
703 #define IN6_NEXT_MULTI(step, in6m) \
704 /* struct in6_multistep step; */ \
705 /* struct in6_multi *in6m; */ \
707 if (((in6m) = (step).i_in6m) != NULL) \
708 (step).i_in6m = (step).i_in6m->in6m_entry.le_next; \
711 #define IN6_FIRST_MULTI(step, in6m) \
712 /* struct in6_multistep step; */ \
713 /* struct in6_multi *in6m */ \
715 (step).i_in6m = in6_multihead.lh_first; \
716 IN6_NEXT_MULTI((step), (in6m)); \
719 extern struct in6_multi
*in6_addmulti(struct in6_addr
*, struct ifnet
*,
721 extern void in6_delmulti(struct in6_multi
*, int);
722 extern int in6_ifindex2scopeid(int);
723 extern int in6_mask2len(struct in6_addr
*, u_char
*);
724 extern void in6_len2mask(struct in6_addr
*, int);
725 extern int in6_control(struct socket
*, u_long
, caddr_t
, struct ifnet
*,
727 extern int in6_update_ifa(struct ifnet
*, struct in6_aliasreq
*,
728 struct in6_ifaddr
*, int);
729 extern void in6_purgeaddr(struct ifaddr
*, int);
730 extern int in6if_do_dad(struct ifnet
*);
731 extern void in6_purgeif(struct ifnet
*);
732 extern void in6_savemkludge(struct in6_ifaddr
*);
733 extern void in6_setmaxmtu(void);
734 extern void in6_restoremkludge(struct in6_ifaddr
*, struct ifnet
*);
735 extern void in6_purgemkludge(struct ifnet
*);
736 extern struct in6_ifaddr
*in6ifa_ifpforlinklocal(struct ifnet
*, int);
737 extern struct in6_ifaddr
*in6ifa_ifpwithaddr(struct ifnet
*, struct in6_addr
*);
738 extern char *ip6_sprintf(const struct in6_addr
*);
739 extern int in6_addr2scopeid(struct ifnet
*, struct in6_addr
*);
740 extern int in6_matchlen(struct in6_addr
*, struct in6_addr
*);
741 extern int in6_are_prefix_equal(struct in6_addr
*p1
, struct in6_addr
*p2
,
743 extern void in6_prefixlen2mask(struct in6_addr
*maskp
, int len
);
744 extern int in6_prefix_add_ifid(int iilen
, struct in6_ifaddr
*ia
);
745 extern void in6_prefix_remove_ifid(int iilen
, struct in6_ifaddr
*ia
);
746 extern void in6_purgeprefix(struct ifnet
*);
748 extern int in6_is_addr_deprecated(struct sockaddr_in6
*);
752 extern int in6_embedscope(struct in6_addr
*, const struct sockaddr_in6
*,
753 struct inpcb
*, struct ifnet
**);
754 extern int in6_recoverscope(struct sockaddr_in6
*, const struct in6_addr
*,
756 extern void in6_clearscope(struct in6_addr
*);
757 extern void in6_aliasreq_64_to_32(struct in6_aliasreq_64
*,
758 struct in6_aliasreq_32
*);
759 extern void in6_aliasreq_32_to_64(struct in6_aliasreq_32
*,
760 struct in6_aliasreq_64
*);
761 extern void in6_ifaddr_init(void);
762 #endif /* KERNEL_PRIVATE */
763 #endif /* _NETINET6_IN6_VAR_H_ */