1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the project nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ 32 */ 33 34 /*- 35 * Copyright (c) 1982, 1986, 1990, 1993 36 * The Regents of the University of California. All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. Neither the name of the University nor the names of its contributors 47 * may be used to endorse or promote products derived from this software 48 * without specific prior written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * @(#)in.h 8.3 (Berkeley) 1/3/94 63 * $FreeBSD$ 64 */ 65 66 #ifndef __KAME_NETINET_IN_H_INCLUDED_ 67 #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" 68 #endif 69 70 #ifndef _NETINET6_IN6_H_ 71 #define _NETINET6_IN6_H_ 72 73 /* 74 * Identification of the network protocol stack 75 * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE 76 * has the table of implementation/integration differences. 77 */ 78 #define __KAME__ 79 #define __KAME_VERSION "FreeBSD" 80 81 /* 82 * IPv6 port allocation rules should mirror the IPv4 rules and are controlled 83 * by the net.inet.ip.portrange sysctl tree. The following defines exist 84 * for compatibility with userland applications that need them. 85 */ 86 #if __BSD_VISIBLE 87 #define IPV6PORT_RESERVED 1024 88 #define IPV6PORT_ANONMIN 49152 89 #define IPV6PORT_ANONMAX 65535 90 #define IPV6PORT_RESERVEDMIN 600 91 #define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) 92 #endif 93 94 /* 95 * IPv6 address 96 */ 97 struct in6_addr { 98 union { 99 uint8_t __u6_addr8[16]; 100 uint16_t __u6_addr16[8]; 101 uint32_t __u6_addr32[4]; 102 } __u6_addr; /* 128-bit IP6 address */ 103 }; 104 105 #define s6_addr __u6_addr.__u6_addr8 106 #ifdef _KERNEL /* XXX nonstandard */ 107 #define s6_addr8 __u6_addr.__u6_addr8 108 #define s6_addr16 __u6_addr.__u6_addr16 109 #define s6_addr32 __u6_addr.__u6_addr32 110 #endif 111 112 #define INET6_ADDRSTRLEN 46 113 114 /* 115 * XXX missing POSIX.1-2001 macro IPPROTO_IPV6. 116 */ 117 118 /* 119 * Socket address for IPv6 120 */ 121 #if __BSD_VISIBLE 122 #define SIN6_LEN 123 #endif 124 125 struct sockaddr_in6 { 126 uint8_t sin6_len; /* length of this struct */ 127 sa_family_t sin6_family; /* AF_INET6 */ 128 in_port_t sin6_port; /* Transport layer port # */ 129 uint32_t sin6_flowinfo; /* IP6 flow information */ 130 struct in6_addr sin6_addr; /* IP6 address */ 131 uint32_t sin6_scope_id; /* scope zone index */ 132 }; 133 134 /* 135 * Local definition for masks 136 */ 137 #ifdef _KERNEL /* XXX nonstandard */ 138 #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} 139 #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \ 140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 141 #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 143 #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 144 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} 145 #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 146 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} 147 #endif 148 149 #ifdef _KERNEL 150 extern const struct sockaddr_in6 sa6_any; 151 152 extern const struct in6_addr in6mask0; 153 extern const struct in6_addr in6mask32; 154 extern const struct in6_addr in6mask64; 155 extern const struct in6_addr in6mask96; 156 extern const struct in6_addr in6mask128; 157 #endif /* _KERNEL */ 158 159 /* 160 * Macros started with IPV6_ADDR is KAME local 161 */ 162 #ifdef _KERNEL /* XXX nonstandard */ 163 #if _BYTE_ORDER == _BIG_ENDIAN 164 #define IPV6_ADDR_INT32_ONE 1 165 #define IPV6_ADDR_INT32_TWO 2 166 #define IPV6_ADDR_INT32_MNL 0xff010000 167 #define IPV6_ADDR_INT32_MLL 0xff020000 168 #define IPV6_ADDR_INT32_SMP 0x0000ffff 169 #define IPV6_ADDR_INT16_ULL 0xfe80 170 #define IPV6_ADDR_INT16_USL 0xfec0 171 #define IPV6_ADDR_INT16_MLL 0xff02 172 #elif _BYTE_ORDER == _LITTLE_ENDIAN 173 #define IPV6_ADDR_INT32_ONE 0x01000000 174 #define IPV6_ADDR_INT32_TWO 0x02000000 175 #define IPV6_ADDR_INT32_MNL 0x000001ff 176 #define IPV6_ADDR_INT32_MLL 0x000002ff 177 #define IPV6_ADDR_INT32_SMP 0xffff0000 178 #define IPV6_ADDR_INT16_ULL 0x80fe 179 #define IPV6_ADDR_INT16_USL 0xc0fe 180 #define IPV6_ADDR_INT16_MLL 0x02ff 181 #endif 182 #endif 183 184 /* 185 * Definition of some useful macros to handle IP6 addresses 186 */ 187 #if __BSD_VISIBLE 188 #define IN6ADDR_ANY_INIT \ 189 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 191 #define IN6ADDR_LOOPBACK_INIT \ 192 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 194 #define IN6ADDR_NODELOCAL_ALLNODES_INIT \ 195 {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 197 #define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \ 198 {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 200 #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ 201 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 203 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 204 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} 206 #define IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT \ 207 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16 }}} 209 #endif 210 211 extern const struct in6_addr in6addr_any; 212 extern const struct in6_addr in6addr_loopback; 213 #if __BSD_VISIBLE 214 extern const struct in6_addr in6addr_nodelocal_allnodes; 215 extern const struct in6_addr in6addr_linklocal_allnodes; 216 extern const struct in6_addr in6addr_linklocal_allrouters; 217 extern const struct in6_addr in6addr_linklocal_allv2routers; 218 #endif 219 220 /* 221 * Equality 222 * NOTE: Some of kernel programming environment (for example, openbsd/sparc) 223 * does not supply memcmp(). For userland memcmp() is preferred as it is 224 * in ANSI standard. 225 */ 226 #ifdef _KERNEL 227 #define IN6_ARE_ADDR_EQUAL(a, b) \ 228 (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) 229 #else 230 #if __BSD_VISIBLE 231 #define IN6_ARE_ADDR_EQUAL(a, b) \ 232 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) 233 #endif 234 #endif 235 236 /* 237 * Unspecified 238 */ 239 #define IN6_IS_ADDR_UNSPECIFIED(a) \ 240 ((a)->__u6_addr.__u6_addr32[0] == 0 && \ 241 (a)->__u6_addr.__u6_addr32[1] == 0 && \ 242 (a)->__u6_addr.__u6_addr32[2] == 0 && \ 243 (a)->__u6_addr.__u6_addr32[3] == 0) 244 245 /* 246 * Loopback 247 */ 248 #define IN6_IS_ADDR_LOOPBACK(a) \ 249 ((a)->__u6_addr.__u6_addr32[0] == 0 && \ 250 (a)->__u6_addr.__u6_addr32[1] == 0 && \ 251 (a)->__u6_addr.__u6_addr32[2] == 0 && \ 252 (a)->__u6_addr.__u6_addr32[3] == ntohl(1)) 253 254 /* 255 * IPv4 compatible 256 */ 257 #define IN6_IS_ADDR_V4COMPAT(a) \ 258 ((a)->__u6_addr.__u6_addr32[0] == 0 && \ 259 (a)->__u6_addr.__u6_addr32[1] == 0 && \ 260 (a)->__u6_addr.__u6_addr32[2] == 0 && \ 261 (a)->__u6_addr.__u6_addr32[3] != 0 && \ 262 (a)->__u6_addr.__u6_addr32[3] != ntohl(1)) 263 264 /* 265 * Mapped 266 */ 267 #define IN6_IS_ADDR_V4MAPPED(a) \ 268 ((a)->__u6_addr.__u6_addr32[0] == 0 && \ 269 (a)->__u6_addr.__u6_addr32[1] == 0 && \ 270 (a)->__u6_addr.__u6_addr32[2] == ntohl(0x0000ffff)) 271 272 /* 273 * KAME Scope Values 274 */ 275 276 #ifdef _KERNEL /* XXX nonstandard */ 277 #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 278 #define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 279 #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 280 #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 281 #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ 282 #define IPV6_ADDR_SCOPE_GLOBAL 0x0e 283 #else 284 #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 285 #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 286 #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 287 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 288 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ 289 #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e 290 #endif 291 292 /* 293 * Unicast Scope 294 * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). 295 */ 296 #define IN6_IS_ADDR_LINKLOCAL(a) \ 297 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) 298 #define IN6_IS_ADDR_SITELOCAL(a) \ 299 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) 300 301 /* 302 * Multicast 303 */ 304 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) 305 306 #ifdef _KERNEL /* XXX nonstandard */ 307 #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) 308 #else 309 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) 310 #endif 311 312 /* 313 * Multicast Scope 314 */ 315 #ifdef _KERNEL /* refers nonstandard items */ 316 #define IN6_IS_ADDR_MC_NODELOCAL(a) \ 317 (IN6_IS_ADDR_MULTICAST(a) && \ 318 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL)) 319 #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ 320 (IN6_IS_ADDR_MULTICAST(a) && \ 321 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL)) 322 #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ 323 (IN6_IS_ADDR_MULTICAST(a) && \ 324 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL)) 325 #define IN6_IS_ADDR_MC_SITELOCAL(a) \ 326 (IN6_IS_ADDR_MULTICAST(a) && \ 327 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL)) 328 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ 329 (IN6_IS_ADDR_MULTICAST(a) && \ 330 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL)) 331 #define IN6_IS_ADDR_MC_GLOBAL(a) \ 332 (IN6_IS_ADDR_MULTICAST(a) && \ 333 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL)) 334 #else 335 #define IN6_IS_ADDR_MC_NODELOCAL(a) \ 336 (IN6_IS_ADDR_MULTICAST(a) && \ 337 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) 338 #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ 339 (IN6_IS_ADDR_MULTICAST(a) && \ 340 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) 341 #define IN6_IS_ADDR_MC_SITELOCAL(a) \ 342 (IN6_IS_ADDR_MULTICAST(a) && \ 343 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) 344 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ 345 (IN6_IS_ADDR_MULTICAST(a) && \ 346 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) 347 #define IN6_IS_ADDR_MC_GLOBAL(a) \ 348 (IN6_IS_ADDR_MULTICAST(a) && \ 349 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) 350 #endif 351 352 #ifdef _KERNEL /* nonstandard */ 353 /* 354 * KAME Scope 355 */ 356 #define IN6_IS_SCOPE_LINKLOCAL(a) \ 357 ((IN6_IS_ADDR_LINKLOCAL(a)) || \ 358 (IN6_IS_ADDR_MC_LINKLOCAL(a))) 359 #define IN6_IS_SCOPE_EMBED(a) \ 360 ((IN6_IS_ADDR_LINKLOCAL(a)) || \ 361 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \ 362 (IN6_IS_ADDR_MC_INTFACELOCAL(a))) 363 364 #define IFA6_IS_DEPRECATED(a) \ 365 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \ 366 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ 367 (a)->ia6_lifetime.ia6t_pltime) 368 #define IFA6_IS_INVALID(a) \ 369 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \ 370 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ 371 (a)->ia6_lifetime.ia6t_vltime) 372 #endif /* _KERNEL */ 373 374 /* 375 * IP6 route structure 376 */ 377 #if __BSD_VISIBLE 378 struct nhop_object; 379 struct route_in6 { 380 struct nhop_object *ro_nh; 381 struct llentry *ro_lle; 382 /* 383 * ro_prepend and ro_plen are only used for bpf to pass in a 384 * preformed header. They are not cacheable. 385 */ 386 char *ro_prepend; 387 uint16_t ro_plen; 388 uint16_t ro_flags; 389 uint16_t ro_mtu; /* saved ro_rt mtu */ 390 uint16_t spare; 391 struct sockaddr_in6 ro_dst; 392 }; 393 #endif 394 395 #ifdef _KERNEL 396 #define MTAG_ABI_IPV6 1444287380 /* IPv6 ABI */ 397 #define IPV6_TAG_DIRECT 0 /* direct-dispatch IPv6 */ 398 #endif /* _KERNEL */ 399 400 /* 401 * Options for use with [gs]etsockopt at the IPV6 level. 402 * First word of comment is data type; bool is stored in int. 403 */ 404 /* no hdrincl */ 405 #if 0 /* the followings are relic in IPv4 and hence are disabled */ 406 #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ 407 #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ 408 #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ 409 #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ 410 #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ 411 #endif 412 #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ 413 #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ 414 #define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ 415 #define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ 416 #define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */ 417 #define IPV6_JOIN_GROUP 12 /* ipv6_mreq; join a group membership */ 418 #define IPV6_LEAVE_GROUP 13 /* ipv6_mreq; leave a group membership */ 419 #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ 420 #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ 421 /* RFC2292 options */ 422 #ifdef _KERNEL 423 #define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */ 424 #define IPV6_2292HOPLIMIT 20 /* bool; hop limit */ 425 #define IPV6_2292NEXTHOP 21 /* bool; next hop addr */ 426 #define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */ 427 #define IPV6_2292DSTOPTS 23 /* bool; destinaion option */ 428 #define IPV6_2292RTHDR 24 /* bool; routing header */ 429 #define IPV6_2292PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ 430 #endif 431 432 #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ 433 #define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */ 434 #ifndef _KERNEL 435 #define IPV6_BINDV6ONLY IPV6_V6ONLY 436 #endif 437 438 #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ 439 /* 29; unused; was IPV6_FAITH */ 440 #if 1 /* IPV6FIREWALL */ 441 #define IPV6_FW_ADD 30 /* add a firewall rule to chain */ 442 #define IPV6_FW_DEL 31 /* delete a firewall rule from chain */ 443 #define IPV6_FW_FLUSH 32 /* flush firewall rule chain */ 444 #define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */ 445 #define IPV6_FW_GET 34 /* get entire firewall rule chain */ 446 #endif 447 448 /* new socket options introduced in RFC3542 */ 449 #define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */ 450 451 #define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */ 452 #define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */ 453 #define IPV6_RECVRTHDR 38 /* bool; recv routing header */ 454 #define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */ 455 #define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */ 456 #ifdef _KERNEL 457 #define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */ 458 #endif 459 460 #define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */ 461 #define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */ 462 463 #define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt), 464 4 bytes int; MTU notification (cmsg) */ 465 #if 0 /*obsoleted during 2292bis -> 3542*/ 466 #define IPV6_REACHCONF 45 /* no data; ND reachability confirm 467 (cmsg only/not in of RFC3542) */ 468 #endif 469 470 /* more new socket options introduced in RFC3542 */ 471 #define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */ 472 #define IPV6_HOPLIMIT 47 /* int; send hop limit */ 473 #define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */ 474 #define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */ 475 #define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */ 476 #define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */ 477 #if 0 478 #define IPV6_PKTOPTIONS 52 /* buf/cmsghdr; set/get IPv6 options */ 479 /* obsoleted by RFC3542 */ 480 #endif 481 482 #define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */ 483 484 #define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */ 485 486 #define IPV6_TCLASS 61 /* int; send traffic class value */ 487 #define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */ 488 489 #define IPV6_PREFER_TEMPADDR 63 /* int; prefer temporary addresses as 490 * the source address. 491 */ 492 493 #define IPV6_BINDANY 64 /* bool: allow bind to any address */ 494 495 #define IPV6_BINDMULTI 65 /* bool; allow multibind to same addr/port */ 496 #define IPV6_RSS_LISTEN_BUCKET 66 /* int; set RSS listen bucket */ 497 #define IPV6_FLOWID 67 /* int; flowid of given socket */ 498 #define IPV6_FLOWTYPE 68 /* int; flowtype of given socket */ 499 #define IPV6_RSSBUCKETID 69 /* int; RSS bucket ID of given socket */ 500 #define IPV6_RECVFLOWID 70 /* bool; receive IP6 flowid/flowtype w/ datagram */ 501 #define IPV6_RECVRSSBUCKETID 71 /* bool; receive IP6 RSS bucket id w/ datagram */ 502 503 #define IPV6_ORIGDSTADDR 72 /* bool: allow getting dstaddr /port info */ 504 #define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR 505 506 /* 507 * The following option is private; do not use it from user applications. 508 * It is deliberately defined to the same value as IP_MSFILTER. 509 */ 510 #define IPV6_MSFILTER 74 /* struct __msfilterreq; 511 * set/get multicast source filter list. 512 */ 513 514 /* to define items, should talk with KAME guys first, for *BSD compatibility */ 515 516 #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ 517 #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ 518 #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ 519 520 /* 521 * Defaults and limits for options 522 */ 523 #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ 524 #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 525 526 /* 527 * Limit for IPv6 multicast memberships 528 */ 529 #define IPV6_MAX_MEMBERSHIPS 4095 530 531 /* 532 * Default resource limits for IPv6 multicast source filtering. 533 * These may be modified by sysctl. 534 */ 535 #define IPV6_MAX_GROUP_SRC_FILTER 512 /* sources per group */ 536 #define IPV6_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ 537 538 /* 539 * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. 540 */ 541 struct ipv6_mreq { 542 struct in6_addr ipv6mr_multiaddr; 543 unsigned int ipv6mr_interface; 544 }; 545 546 /* 547 * IPV6_PKTINFO: Packet information(RFC2292 sec 5) 548 */ 549 struct in6_pktinfo { 550 struct in6_addr ipi6_addr; /* src/dst IPv6 address */ 551 unsigned int ipi6_ifindex; /* send/recv interface index */ 552 }; 553 554 /* 555 * Control structure for IPV6_RECVPATHMTU socket option. 556 */ 557 struct ip6_mtuinfo { 558 struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */ 559 uint32_t ip6m_mtu; 560 }; 561 562 /* 563 * Argument for IPV6_PORTRANGE: 564 * - which range to search when port is unspecified at bind() or connect() 565 */ 566 #define IPV6_PORTRANGE_DEFAULT 0 /* default range */ 567 #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 568 #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 569 570 #if __BSD_VISIBLE 571 /* 572 * Definitions for inet6 sysctl operations. 573 * 574 * Third level is protocol number. 575 * Fourth level is desired variable within that protocol. 576 */ 577 #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ 578 579 /* 580 * Names for IP sysctl objects 581 */ 582 #define IPV6CTL_FORWARDING 1 /* act as router */ 583 #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ 584 #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ 585 #ifdef notyet 586 #define IPV6CTL_DEFMTU 4 /* default MTU */ 587 #endif 588 #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ 589 #define IPV6CTL_STATS 6 /* stats */ 590 #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ 591 #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ 592 #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ 593 #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ 594 #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ 595 #define IPV6CTL_ACCEPT_RTADV 12 596 /* 13; unused; was: IPV6CTL_KEEPFAITH */ 597 #define IPV6CTL_LOG_INTERVAL 14 598 #define IPV6CTL_HDRNESTLIMIT 15 599 #define IPV6CTL_DAD_COUNT 16 600 #define IPV6CTL_AUTO_FLOWLABEL 17 601 #define IPV6CTL_DEFMCASTHLIM 18 602 #define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ 603 #define IPV6CTL_KAME_VERSION 20 604 #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ 605 #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ 606 #if 0 /* obsolete */ 607 #define IPV6CTL_MAPPED_ADDR 23 608 #endif 609 #define IPV6CTL_V6ONLY 24 610 /* IPV6CTL_RTEXPIRE 25 deprecated */ 611 /* IPV6CTL_RTMINEXPIRE 26 deprecated */ 612 /* IPV6CTL_RTMAXCACHE 27 deprecated */ 613 614 #define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */ 615 #define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */ 616 #define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */ 617 #define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ 618 #define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */ 619 #define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */ 620 #define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */ 621 #define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */ 622 623 #define IPV6CTL_MAXFRAGS 41 /* max fragments */ 624 #if 0 625 #define IPV6CTL_IFQ 42 /* ip6intrq node */ 626 #define IPV6CTL_ISATAPRTR 43 /* isatap router */ 627 #endif 628 #define IPV6CTL_MCAST_PMTU 44 /* enable pMTU discovery for multicast? */ 629 630 /* New entries should be added here from current IPV6CTL_MAXID value. */ 631 /* to define items, should talk with KAME guys first, for *BSD compatibility */ 632 #define IPV6CTL_STEALTH 45 633 634 #define ICMPV6CTL_ND6_ONLINKNSRFC4861 47 635 #define IPV6CTL_NO_RADR 48 /* No defroute from RA */ 636 #define IPV6CTL_NORBIT_RAIF 49 /* Disable R-bit in NA on RA 637 * receiving IF. */ 638 #define IPV6CTL_RFC6204W3 50 /* Accept defroute even when forwarding 639 enabled */ 640 #define IPV6CTL_INTRQMAXLEN 51 /* max length of IPv6 netisr queue */ 641 #define IPV6CTL_INTRDQMAXLEN 52 /* max length of direct IPv6 netisr 642 * queue */ 643 #define IPV6CTL_MAXFRAGSPERPACKET 53 /* Max fragments per packet */ 644 #define IPV6CTL_MAXFRAGBUCKETSIZE 54 /* Max reassembly queues per bucket */ 645 #define IPV6CTL_MAXID 55 646 #endif /* __BSD_VISIBLE */ 647 648 /* 649 * Since both netinet/ and netinet6/ call into netipsec/ and netpfil/, 650 * the protocol specific mbuf flags are shared between them. 651 */ 652 #define M_FASTFWD_OURS M_PROTO1 /* changed dst to local */ 653 #define M_IP6_NEXTHOP M_PROTO2 /* explicit ip nexthop */ 654 #define M_IP_NEXTHOP M_PROTO2 /* explicit ip nexthop */ 655 #define M_SKIP_FIREWALL M_PROTO3 /* skip firewall processing */ 656 #define M_AUTHIPHDR M_PROTO4 657 #define M_DECRYPTED M_PROTO5 658 #define M_LOOP M_PROTO6 659 #define M_AUTHIPDGM M_PROTO7 660 #define M_RTALERT_MLD M_PROTO8 661 #define M_FRAGMENTED M_PROTO9 /* contained fragment header */ 662 663 #ifdef _KERNEL 664 struct cmsghdr; 665 struct ip6_hdr; 666 667 int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t); 668 int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t); 669 int in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t, 670 u_int32_t); 671 int in6_localaddr(struct in6_addr *); 672 int in6_localip(struct in6_addr *); 673 int in6_ifhasaddr(struct ifnet *, struct in6_addr *); 674 int in6_addrscope(const struct in6_addr *); 675 char *ip6_sprintf(char *, const struct in6_addr *); 676 struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *); 677 extern void in6_if_up(struct ifnet *); 678 struct sockaddr; 679 extern u_char ip6_protox[]; 680 681 void in6_sin6_2_sin(struct sockaddr_in *sin, 682 struct sockaddr_in6 *sin6); 683 void in6_sin_2_v4mapsin6(struct sockaddr_in *sin, 684 struct sockaddr_in6 *sin6); 685 void in6_sin6_2_sin_in_sock(struct sockaddr *nam); 686 void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam); 687 extern void addrsel_policy_init(void); 688 689 #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) 690 #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) 691 #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) 692 693 #endif /* _KERNEL */ 694 695 #ifndef _SIZE_T_DECLARED 696 typedef __size_t size_t; 697 #define _SIZE_T_DECLARED 698 #endif 699 700 #ifndef _SOCKLEN_T_DECLARED 701 typedef __socklen_t socklen_t; 702 #define _SOCKLEN_T_DECLARED 703 #endif 704 705 #if __BSD_VISIBLE 706 707 __BEGIN_DECLS 708 struct cmsghdr; 709 710 extern int inet6_option_space(int); 711 extern int inet6_option_init(void *, struct cmsghdr **, int); 712 extern int inet6_option_append(struct cmsghdr *, const uint8_t *, 713 int, int); 714 extern uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int); 715 extern int inet6_option_next(const struct cmsghdr *, uint8_t **); 716 extern int inet6_option_find(const struct cmsghdr *, uint8_t **, int); 717 718 extern size_t inet6_rthdr_space(int, int); 719 extern struct cmsghdr *inet6_rthdr_init(void *, int); 720 extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, 721 unsigned int); 722 extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int); 723 #if 0 /* not implemented yet */ 724 extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *); 725 #endif 726 extern int inet6_rthdr_segments(const struct cmsghdr *); 727 extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int); 728 extern int inet6_rthdr_getflags(const struct cmsghdr *, int); 729 730 extern int inet6_opt_init(void *, socklen_t); 731 extern int inet6_opt_append(void *, socklen_t, int, uint8_t, socklen_t, 732 uint8_t, void **); 733 extern int inet6_opt_finish(void *, socklen_t, int); 734 extern int inet6_opt_set_val(void *, int, void *, socklen_t); 735 736 extern int inet6_opt_next(void *, socklen_t, int, uint8_t *, socklen_t *, 737 void **); 738 extern int inet6_opt_find(void *, socklen_t, int, uint8_t, socklen_t *, 739 void **); 740 extern int inet6_opt_get_val(void *, int, void *, socklen_t); 741 extern socklen_t inet6_rth_space(int, int); 742 extern void *inet6_rth_init(void *, socklen_t, int, int); 743 extern int inet6_rth_add(void *, const struct in6_addr *); 744 extern int inet6_rth_reverse(const void *, void *); 745 extern int inet6_rth_segments(const void *); 746 extern struct in6_addr *inet6_rth_getaddr(const void *, int); 747 __END_DECLS 748 749 #endif /* __BSD_VISIBLE */ 750 751 #endif /* !_NETINET6_IN6_H_ */ 752