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 /* 30 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 31 * All rights reserved. 32 * 33 * Redistribution and use in source and binary forms, with or without 34 * modification, are permitted provided that the following conditions 35 * are met: 36 * 1. Redistributions of source code must retain the above copyright 37 * notice, this list of conditions and the following disclaimer. 38 * 2. Redistributions in binary form must reproduce the above copyright 39 * notice, this list of conditions and the following disclaimer in the 40 * documentation and/or other materials provided with the distribution. 41 * 3. Neither the name of the project nor the names of its contributors 42 * may be used to endorse or promote products derived from this software 43 * without specific prior written permission. 44 * 45 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 */ 57 58 /* 59 * Copyright (c) 1982, 1986, 1993 60 * The Regents of the University of California. All rights reserved. 61 * 62 * Redistribution and use in source and binary forms, with or without 63 * modification, are permitted provided that the following conditions 64 * are met: 65 * 1. Redistributions of source code must retain the above copyright 66 * notice, this list of conditions and the following disclaimer. 67 * 2. Redistributions in binary form must reproduce the above copyright 68 * notice, this list of conditions and the following disclaimer in the 69 * documentation and/or other materials provided with the distribution. 70 * 3. All advertising materials mentioning features or use of this software 71 * must display the following acknowledgement: 72 * This product includes software developed by the University of 73 * California, Berkeley and its contributors. 74 * 4. Neither the name of the University nor the names of its contributors 75 * may be used to endorse or promote products derived from this software 76 * without specific prior written permission. 77 * 78 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 79 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 80 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 81 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 82 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 84 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 85 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 88 * SUCH DAMAGE. 89 * 90 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93 91 */ 92 93 #ifndef _NETINET6_IP6_VAR_H_ 94 #define _NETINET6_IP6_VAR_H_ 95 #include <sys/appleapiopts.h> 96 97 #ifdef BSD_KERNEL_PRIVATE 98 #include <kern/zalloc.h> 99 #include <net/ethernet.h> 100 101 struct ip6asfrag; 102 /* 103 * IP6 reassembly queue structure. Each fragment 104 * being reassembled is attached to one of these structures. 105 */ 106 struct ip6q { 107 struct ip6asfrag *ip6q_down; 108 struct ip6asfrag *ip6q_up; 109 u_int32_t ip6q_ident; 110 u_int8_t ip6q_nxt; 111 u_int8_t ip6q_ecn; 112 u_int8_t ip6q_ttl; 113 struct in6_addr ip6q_src, ip6q_dst; 114 struct ip6q *ip6q_next; 115 struct ip6q *ip6q_prev; 116 int ip6q_unfrglen; /* len of unfragmentable part */ 117 int ip6q_nfrag; /* # of fragments */ 118 uint32_t ip6q_csum_flags; /* checksum flags */ 119 uint32_t ip6q_csum; /* partial checksum value */ 120 uint32_t ip6q_flags; 121 uint32_t ip6q_dst_ifscope, ip6q_src_ifscope; 122 #define IP6QF_DIRTY 0x00000001 123 }; 124 125 struct ip6_moptions { 126 decl_lck_mtx_data(, im6o_lock); 127 uint32_t im6o_refcnt; /* ref count */ 128 uint32_t im6o_debug; /* see ifa_debug flags */ 129 struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */ 130 u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */ 131 u_char im6o_multicast_loop; /* 1 >= hear sends if a member */ 132 u_short im6o_num_memberships; /* no. memberships this socket */ 133 u_short im6o_max_memberships; /* max memberships this socket */ 134 struct in6_multi **__counted_by(im6o_max_memberships) im6o_membership; 135 /* group memberships */ 136 struct in6_mfilter *__counted_by(im6o_max_memberships) im6o_mfilters; 137 /* source filters */ 138 void (*im6o_trace) /* callback fn for tracing refs */ 139 (struct ip6_moptions *, int); 140 }; 141 142 #define IM6O_LOCK_ASSERT_HELD(_im6o) \ 143 LCK_MTX_ASSERT(&(_im6o)->im6o_lock, LCK_MTX_ASSERT_OWNED) 144 145 #define IM6O_LOCK_ASSERT_NOTHELD(_im6o) \ 146 LCK_MTX_ASSERT(&(_im6o)->im6o_lock, LCK_MTX_ASSERT_NOTOWNED) 147 148 #define IM6O_LOCK(_im6o) \ 149 lck_mtx_lock(&(_im6o)->im6o_lock) 150 151 #define IM6O_LOCK_SPIN(_im6o) \ 152 lck_mtx_lock_spin(&(_im6o)->im6o_lock) 153 154 #define IM6O_CONVERT_LOCK(_im6o) do { \ 155 IM6O_LOCK_ASSERT_HELD(_im6o); \ 156 lck_mtx_convert_spin(&(_im6o)->im6o_lock); \ 157 } while (0) 158 159 #define IM6O_UNLOCK(_im6o) \ 160 lck_mtx_unlock(&(_im6o)->im6o_lock) 161 162 #define IM6O_ADDREF(_im6o) \ 163 im6o_addref(_im6o, 0) 164 165 #define IM6O_ADDREF_LOCKED(_im6o) \ 166 im6o_addref(_im6o, 1) 167 168 #define IM6O_REMREF(_im6o) \ 169 im6o_remref(_im6o) 170 171 struct ip6_exthdrs { 172 struct mbuf *ip6e_ip6; 173 struct mbuf *ip6e_hbh; 174 struct mbuf *ip6e_dest1; 175 struct mbuf *ip6e_rthdr; 176 struct mbuf *ip6e_dest2; 177 boolean_t merged; 178 }; 179 180 /* 181 * Control options for outgoing packets 182 */ 183 184 /* Routing header related info */ 185 struct ip6po_rhinfo { 186 struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */ 187 struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */ 188 }; 189 #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr 190 #define ip6po_route ip6po_rhinfo.ip6po_rhi_route 191 192 /* Nexthop related info */ 193 struct ip6po_nhinfo { 194 struct sockaddr *ip6po_nhi_nexthop; 195 struct route_in6 ip6po_nhi_route; /* Route to the nexthop */ 196 }; 197 #define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop 198 #define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route 199 200 struct ip6_pktopts { 201 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ 202 int ip6po_hlim; /* Hoplimit for outgoing packets */ 203 204 /* Outgoing IF/address information */ 205 struct in6_pktinfo *ip6po_pktinfo; 206 207 /* Next-hop address information */ 208 struct ip6po_nhinfo ip6po_nhinfo; 209 210 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ 211 212 /* Destination options header (before a routing header) */ 213 struct ip6_dest *ip6po_dest1; 214 215 /* Routing header related info. */ 216 struct ip6po_rhinfo ip6po_rhinfo; 217 218 /* Destination options header (after a routing header) */ 219 struct ip6_dest *ip6po_dest2; 220 221 int ip6po_tclass; /* traffic class */ 222 223 int ip6po_minmtu; /* fragment vs PMTU discovery policy */ 224 #define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast */ 225 #define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */ 226 #define IP6PO_MINMTU_ALL 1 /* always send at min MTU */ 227 228 /* whether temporary addresses are preferred as source address */ 229 int ip6po_prefer_tempaddr; 230 231 #define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */ 232 #define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */ 233 #define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */ 234 235 int ip6po_flags; 236 #if 0 /* parameters in this block is obsolete. do not reuse the values. */ 237 #define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */ 238 #define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */ 239 #endif 240 #define IP6PO_DONTFRAG 0x04 /* no fragmentation (IPV6_DONTFRAG) */ 241 #define IP6PO_USECOA 0x08 /* use care of address */ 242 }; 243 244 /* 245 * Control options for incoming packets 246 */ 247 #endif /* BSD_KERNEL_PRIVATE */ 248 249 #define IP6S_SRCRULE_COUNT 16 250 #include <netinet6/scope6_var.h> 251 252 struct ip6stat { 253 u_quad_t ip6s_total; /* total packets received */ 254 u_quad_t ip6s_tooshort; /* packet too short */ 255 u_quad_t ip6s_toosmall; /* not enough data */ 256 u_quad_t ip6s_fragments; /* fragments received */ 257 u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */ 258 u_quad_t ip6s_fragtimeout; /* fragments timed out */ 259 u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */ 260 u_quad_t ip6s_forward; /* packets forwarded */ 261 u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */ 262 u_quad_t ip6s_redirectsent; /* packets forwarded on same net */ 263 u_quad_t ip6s_delivered; /* datagrams delivered to upper level */ 264 u_quad_t ip6s_localout; /* total ip packets generated here */ 265 u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */ 266 u_quad_t ip6s_reassembled; /* total packets reassembled ok */ 267 u_quad_t ip6s_atmfrag_rcvd; /* atomic fragments received */ 268 u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */ 269 u_quad_t ip6s_ofragments; /* output fragments created */ 270 u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */ 271 u_quad_t ip6s_badoptions; /* error in option processing */ 272 u_quad_t ip6s_noroute; /* packets discarded due to no route */ 273 u_quad_t ip6s_badvers; /* ip6 version != 6 */ 274 u_quad_t ip6s_rawout; /* total raw ip packets generated */ 275 u_quad_t ip6s_badscope; /* scope error */ 276 u_quad_t ip6s_notmember; /* don't join this multicast group */ 277 u_quad_t ip6s_nxthist[256]; /* next header history */ 278 u_quad_t ip6s_m1; /* one mbuf */ 279 u_quad_t ip6s_m2m[32]; /* two or more mbuf */ 280 u_quad_t ip6s_mext1; /* one ext mbuf */ 281 u_quad_t ip6s_mext2m; /* two or more ext mbuf */ 282 u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */ 283 u_quad_t ip6s_nogif; /* no match gif found */ 284 u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */ 285 286 /* 287 * statistics for improvement of the source address selection 288 * algorithm: 289 */ 290 /* number of times that address selection fails */ 291 u_quad_t ip6s_sources_none; 292 /* number of times that an address on the outgoing I/F is chosen */ 293 u_quad_t ip6s_sources_sameif[SCOPE6_ID_MAX]; 294 /* number of times that an address on a non-outgoing I/F is chosen */ 295 u_quad_t ip6s_sources_otherif[SCOPE6_ID_MAX]; 296 /* 297 * number of times that an address that has the same scope 298 * from the destination is chosen. 299 */ 300 u_quad_t ip6s_sources_samescope[SCOPE6_ID_MAX]; 301 /* 302 * number of times that an address that has a different scope 303 * from the destination is chosen. 304 */ 305 u_quad_t ip6s_sources_otherscope[SCOPE6_ID_MAX]; 306 /* number of times that a deprecated address is chosen */ 307 u_quad_t ip6s_sources_deprecated[SCOPE6_ID_MAX]; 308 309 u_quad_t ip6s_forward_cachehit; 310 u_quad_t ip6s_forward_cachemiss; 311 312 /* number of times that each rule of source selection is applied. */ 313 u_quad_t ip6s_sources_rule[IP6S_SRCRULE_COUNT]; 314 315 /* number of times we ignored address on expensive secondary interfaces */ 316 u_quad_t ip6s_sources_skip_expensive_secondary_if; 317 318 /* pkt dropped, no mbufs for control data */ 319 u_quad_t ip6s_pktdropcntrl; 320 321 /* total packets trimmed/adjusted */ 322 u_quad_t ip6s_adj; 323 /* hwcksum info discarded during adjustment */ 324 u_quad_t ip6s_adj_hwcsum_clr; 325 326 /* duplicate address detection collisions */ 327 u_quad_t ip6s_dad_collide; 328 329 /* DAD NS looped back */ 330 u_quad_t ip6s_dad_loopcount; 331 332 /* NECP policy related drop */ 333 u_quad_t ip6s_necp_policy_drop; 334 335 /* CLAT46 stats */ 336 u_quad_t ip6s_clat464_in_tooshort_drop; 337 u_quad_t ip6s_clat464_in_nov6addr_drop; 338 u_quad_t ip6s_clat464_in_nov4addr_drop; 339 u_quad_t ip6s_clat464_in_v4synthfail_drop; 340 u_quad_t ip6s_clat464_in_64transfail_drop; 341 u_quad_t ip6s_clat464_in_64proto_transfail_drop; 342 u_quad_t ip6s_clat464_in_64frag_transfail_drop; 343 u_quad_t ip6s_clat464_in_invalpbuf_drop; 344 u_quad_t ip6s_clat464_in_success; 345 u_quad_t ip6s_clat464_in_drop; 346 u_quad_t ip6s_clat464_in_v4_drop; 347 348 u_quad_t ip6s_clat464_out_nov6addr_drop; 349 u_quad_t ip6s_clat464_out_v6synthfail_drop; 350 u_quad_t ip6s_clat464_out_46transfail_drop; 351 u_quad_t ip6s_clat464_out_46proto_transfail_drop; 352 u_quad_t ip6s_clat464_out_46frag_transfail_drop; 353 u_quad_t ip6s_clat464_out_invalpbuf_drop; 354 u_quad_t ip6s_clat464_out_success; 355 u_quad_t ip6s_clat464_out_drop; 356 357 u_quad_t ip6s_clat464_v6addr_conffail; 358 u_quad_t ip6s_clat464_plat64_pfx_setfail; 359 u_quad_t ip6s_clat464_plat64_pfx_getfail; 360 361 u_quad_t ip6s_overlap_frag_drop; 362 363 u_quad_t ip6s_rcv_if_weak_match; 364 u_quad_t ip6s_rcv_if_no_match; 365 }; 366 367 enum ip6s_sources_rule_index { 368 IP6S_SRCRULE_0, IP6S_SRCRULE_1, IP6S_SRCRULE_2, IP6S_SRCRULE_3, IP6S_SRCRULE_4, 369 IP6S_SRCRULE_5, IP6S_SRCRULE_5_5, IP6S_SRCRULE_6, IP6S_SRCRULE_7, 370 IP6S_SRCRULE_7x, IP6S_SRCRULE_8 371 }; 372 373 #ifdef BSD_KERNEL_PRIVATE 374 /* 375 * IPv6 onion peeling state. 376 * 377 * This is currently allocated for packets destined to the all-nodes 378 * multicast address over Ethernet. IPv6 destination address information 379 * is now stored in the mbuf itself. 380 */ 381 struct ip6aux { 382 u_int32_t ip6a_flags; 383 #define IP6A_HASEEN 0x01 /* HA was present */ 384 385 #ifdef notyet 386 #define IP6A_SWAP 0x02 /* swapped home/care-of on packet */ 387 #define IP6A_BRUID 0x04 /* BR Unique Identifier was present */ 388 #define IP6A_RTALERTSEEN 0x08 /* rtalert present */ 389 390 /* ip6.ip6_src */ 391 struct in6_addr ip6a_careof; /* care-of address of the peer */ 392 struct in6_addr ip6a_home; /* home address of the peer */ 393 u_int16_t ip6a_bruid; /* BR unique identifier */ 394 395 /* rtalert */ 396 u_int16_t ip6a_rtalert; /* rtalert option value */ 397 #endif /* notyet */ 398 399 /* ether source address if all-nodes multicast destination */ 400 u_char ip6a_ehsrc[ETHER_ADDR_LEN]; 401 }; 402 403 /* flags passed to ip6_output as last parameter */ 404 #define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */ 405 #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */ 406 #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */ 407 #define IPV6_FLAG_NOSRCIFSEL 0x80 /* bypas source address selection */ 408 #define IPV6_OUTARGS 0x100 /* has ancillary output info */ 409 410 #ifdef BSD_KERNEL_PRIVATE 411 #define IP6_HDR_ALIGNED_P(_ip6) ((((uintptr_t)(_ip6)) & ((uintptr_t)3)) == 0) 412 413 /* 414 * On platforms which require strict alignment (currently for anything but 415 * i386 or x86_64 or arm64), this macro checks whether the pointer to the IP header 416 * is 32-bit aligned, and assert otherwise. 417 */ 418 #if defined(__i386__) || defined(__x86_64__) || defined(__arm64__) 419 #define IP6_HDR_STRICT_ALIGNMENT_CHECK(_ip6) do { } while (0) 420 #else /* !__i386__ && !__x86_64__ && !__arm64__ */ 421 #define IP6_HDR_STRICT_ALIGNMENT_CHECK(_ip6) do { \ 422 if (!IP_HDR_ALIGNED_P(_ip6)) { \ 423 panic_plain("\n%s: Unaligned IPv6 header %p\n", \ 424 __func__, _ip6); \ 425 } \ 426 } while (0) 427 #endif /* !__i386__ && !__x86_64__ && !__arm64__ */ 428 #endif /* BSD_KERNEL_PRIVATE */ 429 430 #include <net/flowadv.h> 431 432 /* 433 * Extra information passed to ip6_output when IPV6_OUTARGS is set. 434 */ 435 struct ip6_out_args { 436 unsigned int ip6oa_boundif; /* bound outgoing interface */ 437 struct flowadv ip6oa_flowadv; /* flow advisory code */ 438 u_int32_t ip6oa_flags; /* IP6OAF flags (see below) */ 439 #define IP6OAF_SELECT_SRCIF 0x00000001 /* src interface selection */ 440 #define IP6OAF_BOUND_IF 0x00000002 /* boundif value is valid */ 441 #define IP6OAF_BOUND_SRCADDR 0x00000004 /* bound to src address */ 442 #define IP6OAF_NO_CELLULAR 0x00000010 /* skip IFT_CELLULAR */ 443 #define IP6OAF_NO_EXPENSIVE 0x00000020 /* skip IFEF_EXPENSIVE */ 444 #define IP6OAF_AWDL_UNRESTRICTED 0x00000040 /* privileged AWDL */ 445 #define IP6OAF_QOSMARKING_ALLOWED 0x00000080 /* policy allows Fastlane DSCP marking */ 446 #define IP6OAF_INTCOPROC_ALLOWED 0x00000100 /* access to internal coproc interfaces */ 447 #define IP6OAF_NO_LOW_POWER 0x00000200 /* skip low power */ 448 #define IP6OAF_NO_CONSTRAINED 0x00000400 /* skip IFXF_CONSTRAINED */ 449 #define IP6OAF_SKIP_PF 0x00000800 /* skip PF */ 450 #define IP6OAF_DONT_FRAG 0x00001000 /* Don't fragment */ 451 #define IP6OAF_REDO_QOSMARKING_POLICY 0x00002000 /* Re-evaluate QOS marking policy */ 452 #define IP6OAF_R_IFDENIED 0x00004000 /* return flag: denied access to interface */ 453 #define IP6OAF_MANAGEMENT_ALLOWED 0x00004000 /* access to management to interface */ 454 int ip6oa_sotc; /* traffic class for Fastlane DSCP mapping */ 455 int ip6oa_netsvctype; 456 int32_t qos_marking_gencount; 457 }; 458 459 #define IP6OAF_RET_MASK (IP6OAF_R_IFDENIED) 460 461 extern struct ip6stat ip6stat; /* statistics */ 462 extern int ip6_defhlim; /* default hop limit */ 463 extern int ip6_defmcasthlim; /* default multicast hop limit */ 464 extern int ip6_forwarding; /* act as router? */ 465 extern int ip6_gif_hlim; /* Hop limit for gif encap packet */ 466 extern int ip6_use_deprecated; /* allow deprecated addr as source */ 467 extern int ip6_rr_prune; /* router renumbering prefix */ 468 /* walk list every 5 sec. */ 469 extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */ 470 #define ip6_mapped_addr_on (!ip6_v6only) 471 extern int ip6_v6only; 472 473 extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */ 474 extern int ip6_maxifprefixes; /* Max acceptable prefixes via RA per IF */ 475 extern int ip6_maxifdefrouters; /* Max acceptable def routers via RA */ 476 extern int ip6_maxdynroutes; /* Max # of routes created via redirect */ 477 extern int ip6_sendredirects; /* send IP redirects when forwarding? */ 478 extern int ip6_accept_rtadv; /* deprecated */ 479 extern int ip6_log_interval; 480 extern uint64_t ip6_log_time; 481 extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */ 482 extern int ip6_dad_count; /* DupAddrDetectionTransmits */ 483 484 /* RFC4193 Unique Local Unicast Prefixes only */ 485 extern int ip6_only_allow_rfc4193_prefix; 486 487 extern int ip6_auto_flowlabel; 488 extern int ip6_auto_linklocal; 489 490 extern int ip6_anonportmin; /* minimum ephemeral port */ 491 extern int ip6_anonportmax; /* maximum ephemeral port */ 492 extern int ip6_lowportmin; /* minimum reserved port */ 493 extern int ip6_lowportmax; /* maximum reserved port */ 494 495 extern int ip6_use_tempaddr; /* whether to use temporary addresses. */ 496 extern int ip6_ula_use_tempaddr; /* whether to use temporary ULA addresses */ 497 498 /* whether to prefer temporary addresses in the source address selection */ 499 extern int ip6_prefer_tempaddr; 500 501 /* whether to use the default scope zone when unspecified */ 502 extern int ip6_use_defzone; 503 504 /* how many times to try allocating cga address after conflict */ 505 extern int ip6_cga_conflict_retries; 506 #define IPV6_CGA_CONFLICT_RETRIES_DEFAULT 3 507 #define IPV6_CGA_CONFLICT_RETRIES_MAX 10 508 509 extern struct pr_usrreqs rip6_usrreqs; 510 extern struct pr_usrreqs icmp6_dgram_usrreqs; 511 512 struct sockopt; 513 struct inpcb; 514 struct ip6_hdr; 515 struct in6_ifaddr; 516 struct ip6protosw; 517 struct domain; 518 519 extern int icmp6_ctloutput(struct socket *, struct sockopt *); 520 extern int icmp6_dgram_ctloutput(struct socket *, struct sockopt *); 521 extern int icmp6_dgram_send(struct socket *, int, struct mbuf *, 522 struct sockaddr *, struct mbuf *, struct proc *); 523 extern int icmp6_dgram_attach(struct socket *, int, struct proc *); 524 525 extern void ip6_register_m_tag(void); 526 527 extern void ip6_init(struct ip6protosw *, struct domain *); 528 extern void ip6_input(struct mbuf *); 529 extern void ip6_setsrcifaddr_info(struct mbuf *, uint32_t, struct in6_ifaddr *); 530 extern void ip6_setdstifaddr_info(struct mbuf *, uint32_t, struct in6_ifaddr *); 531 extern int ip6_getsrcifaddr_info(struct mbuf *, uint32_t *, uint32_t *); 532 extern int ip6_getdstifaddr_info(struct mbuf *, uint32_t *, uint32_t *); 533 extern uint32_t ip6_input_getsrcifscope(struct mbuf *); 534 extern uint32_t ip6_input_getdstifscope(struct mbuf *); 535 extern void ip6_output_setsrcifscope(struct mbuf *, uint32_t, struct in6_ifaddr *); 536 extern void ip6_output_setdstifscope(struct mbuf *, uint32_t, struct in6_ifaddr *); 537 extern uint32_t ip6_output_getsrcifscope(struct mbuf *); 538 extern uint32_t ip6_output_getdstifscope(struct mbuf *); 539 540 extern void ip6_freepcbopts(struct ip6_pktopts *); 541 extern int ip6_unknown_opt(u_int8_t *, struct mbuf *, size_t); 542 extern char *ip6_get_prevhdr(struct mbuf *, int); 543 extern int ip6_nexthdr(struct mbuf *, int, int, int *); 544 extern int ip6_lasthdr(struct mbuf *, int, int, int *); 545 extern boolean_t ip6_pkt_has_ulp(struct mbuf *m); 546 547 extern void ip6_moptions_init(void); 548 extern struct ip6_moptions *ip6_allocmoptions(zalloc_flags_t); 549 extern void im6o_addref(struct ip6_moptions *, int); 550 extern void im6o_remref(struct ip6_moptions *); 551 552 extern struct ip6aux *ip6_addaux(struct mbuf *); 553 extern struct ip6aux *ip6_findaux(struct mbuf *); 554 extern void ip6_delaux(struct mbuf *); 555 556 extern int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *, 557 u_int32_t *); 558 extern struct mbuf **ip6_savecontrol_v4(struct inpcb *, struct mbuf *, 559 struct mbuf **, int *); 560 extern int ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **); 561 extern struct mbuf *ip6_forward(struct mbuf *, struct route_in6 *, int); 562 extern void ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *, u_int32_t *); 563 extern void ip6_mloopback(struct ifnet *, struct ifnet *, struct mbuf *, 564 struct sockaddr_in6 *, uint32_t, int32_t); 565 extern int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route_in6 *, 566 int, struct ip6_moptions *, struct ifnet **, struct ip6_out_args *); 567 extern int ip6_output_list(struct mbuf *, int, struct ip6_pktopts *, 568 struct route_in6 *, int, struct ip6_moptions *, struct ifnet **, 569 struct ip6_out_args *); 570 extern int ip6_ctloutput(struct socket *, struct sockopt *); 571 extern int ip6_raw_ctloutput(struct socket *, struct sockopt *); 572 extern void ip6_initpktopts(struct ip6_pktopts *); 573 extern int ip6_setpktoptions(struct mbuf *, struct ip6_pktopts *, int, int); 574 extern void ip6_clearpktopts(struct ip6_pktopts *, int); 575 extern struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, zalloc_flags_t); 576 extern int ip6_optlen(struct inpcb *); 577 extern void ip6_drain(void); 578 extern int ip6_do_fragmentation(struct mbuf **, uint32_t, struct ifnet *, uint32_t, 579 struct ip6_hdr *, uint8_t *, uint32_t, int, uint32_t); 580 581 extern int route6_input(struct mbuf **, int *, int); 582 583 extern void frag6_init(void); 584 extern int frag6_input(struct mbuf **, int *, int); 585 extern void frag6_drain(void); 586 587 extern int rip6_input(struct mbuf **, int *, int); 588 extern void rip6_ctlinput(int, struct sockaddr *, void *, struct ifnet *); 589 extern int rip6_ctloutput(struct socket *so, struct sockopt *sopt); 590 extern int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *, 591 struct mbuf *, int); 592 593 extern int dest6_input(struct mbuf **, int *, int); 594 /* 595 * IPv6 source address selection hints 596 */ 597 #define IPV6_SRCSEL_HINT_PREFER_TMPADDR 0x00000001 598 599 extern struct ifaddr * in6_selectsrc_core_ifa(struct sockaddr_in6 *, struct ifnet *, int); 600 extern struct in6_addr * in6_selectsrc_core(struct sockaddr_in6 *, 601 uint32_t, struct ifnet *, int, struct in6_addr *, 602 struct ifnet **, int *, struct ifaddr **, struct route_in6 *, boolean_t); 603 extern struct in6_addr *in6_selectsrc(struct sockaddr_in6 *, 604 struct ip6_pktopts *, struct inpcb *, struct route_in6 *, 605 struct ifnet **, struct in6_addr *, unsigned int, int *); 606 extern struct in6_addrpolicy *in6_addrsel_lookup_policy(struct sockaddr_in6 *); 607 extern int in6_selectroute(struct sockaddr_in6 *, struct sockaddr_in6 *, 608 struct ip6_pktopts *, struct ip6_moptions *, struct in6_ifaddr **, 609 struct route_in6 *, struct ifnet **, struct rtentry **, int, 610 struct ip6_out_args *); 611 extern int ip6_setpktopts(struct mbuf *control, struct ip6_pktopts *opt, 612 struct ip6_pktopts *stickyopt, int uproto); 613 extern uint32_t ip6_randomid(uint64_t); 614 extern uint32_t ip6_randomflowlabel(void); 615 #endif /* BSD_KERNEL_PRIVATE */ 616 #endif /* !_NETINET6_IP6_VAR_H_ */ 617