1 /* 2 * Copyright (c) 2000-2020 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) 1982, 1986, 1989, 1993 30 * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software 41 * must display the following acknowledgement: 42 * This product includes software developed by the University of 43 * California, Berkeley and its contributors. 44 * 4. Neither the name of the University 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. 47 * 48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 58 * SUCH DAMAGE. 59 * 60 * @(#)if.h 8.1 (Berkeley) 6/10/93 61 */ 62 63 #ifndef _NET_IF_H_ 64 #define _NET_IF_H_ 65 66 #define IF_NAMESIZE 16 67 68 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 69 #ifdef DRIVERKIT 70 #include <stddef.h> 71 #else 72 #include <sys/cdefs.h> 73 #include <sys/appleapiopts.h> 74 #ifdef __APPLE__ 75 76 #include <net/if_var.h> 77 #include <net/net_kev.h> 78 #include <sys/types.h> 79 #include <sys/socket.h> 80 81 #ifdef PRIVATE 82 #include <net/if_dl.h> 83 #include <netinet/in.h> 84 #include <mach/vm_types.h> 85 #endif /* PRIVATE */ 86 #endif 87 #endif /* DRIVERKIT */ 88 89 #ifndef IFNAMSIZ 90 #define IFNAMSIZ IF_NAMESIZE 91 #endif 92 93 #ifndef DRIVERKIT 94 struct if_clonereq { 95 int ifcr_total; /* total cloners (out) */ 96 int ifcr_count; /* room for this many in user buffer */ 97 char *ifcr_buffer; /* buffer for cloner names */ 98 }; 99 100 #ifdef KERNEL_PRIVATE 101 #define IF_MAXUNIT 0x7fff /* historical value */ 102 103 struct if_clonereq64 { 104 int ifcr_total; /* total cloners (out) */ 105 int ifcr_count; /* room for this many in user buffer */ 106 user64_addr_t ifcru_buffer __attribute__((aligned(8))); 107 }; 108 109 struct if_clonereq32 { 110 int ifcr_total; /* total cloners (out) */ 111 int ifcr_count; /* room for this many in user buffer */ 112 user32_addr_t ifcru_buffer; 113 }; 114 #endif /* KERNEL_PRIVATE */ 115 116 #define IFF_UP 0x1 /* interface is up */ 117 #define IFF_BROADCAST 0x2 /* broadcast address valid */ 118 #define IFF_DEBUG 0x4 /* turn on debugging */ 119 #define IFF_LOOPBACK 0x8 /* is a loopback net */ 120 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ 121 #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */ 122 #define IFF_RUNNING 0x40 /* resources allocated */ 123 #define IFF_NOARP 0x80 /* no address resolution protocol */ 124 #define IFF_PROMISC 0x100 /* receive all packets */ 125 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */ 126 #define IFF_OACTIVE 0x400 /* transmission in progress */ 127 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ 128 #define IFF_LINK0 0x1000 /* per link layer defined bit */ 129 #define IFF_LINK1 0x2000 /* per link layer defined bit */ 130 #define IFF_LINK2 0x4000 /* per link layer defined bit */ 131 #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ 132 #define IFF_MULTICAST 0x8000 /* supports multicast */ 133 134 #ifdef PRIVATE 135 /* extended flags definitions: (all bits reserved for internal/future use) */ 136 #define IFEF_AUTOCONFIGURING 0x00000001 /* allow BOOTP/DHCP replies to enter */ 137 #define IFEF_ENQUEUE_MULTI 0x00000002 /* enqueue multiple packets at once */ 138 #define IFEF_DELAY_START 0x00000004 /* delay start callback */ 139 #define IFEF_PROBE_CONNECTIVITY 0x00000008 /* Probe connections going over this interface */ 140 #define IFEF_ADV_REPORT 0x00000010 /* Supports interface advisory report */ 141 #define IFEF_IPV6_DISABLED 0x00000020 /* coupled to ND6_IFF_IFDISABLED */ 142 #define IFEF_ACCEPT_RTADV 0x00000040 /* accepts IPv6 RA on the interface */ 143 #define IFEF_TXSTART 0x00000080 /* has start callback */ 144 #define IFEF_RXPOLL 0x00000100 /* supports opportunistic input poll */ 145 #define IFEF_VLAN 0x00000200 /* interface has one or more vlans */ 146 #define IFEF_BOND 0x00000400 /* interface is part of bond */ 147 #define IFEF_ARPLL 0x00000800 /* ARP for IPv4LL addresses */ 148 #define IFEF_CLAT46 0x00001000 /* CLAT46 RFC 6877 */ 149 150 #define IS_INTF_CLAT46(ifp) ((ifp) != NULL && ((ifp)->if_eflags & IFEF_CLAT46)) 151 #define INTF_ADJUST_MTU_FOR_CLAT46(intf) \ 152 (IS_INTF_CLAT46((intf)) || \ 153 IS_INTF_CLAT46((intf)->if_delegated.ifp)) \ 154 155 /* 156 * XXX IFEF_NOAUTOIPV6LL is deprecated and should be done away with. 157 * Configd pretty much manages the interface configuration. 158 * Rather than looking at the flag we check if a specific LLA 159 * has to be configured or the IID has to be generated by kernel. 160 */ 161 #define IFEF_NOAUTOIPV6LL 0x00002000 /* Need explicit IPv6 LL address */ 162 #define IFEF_EXPENSIVE 0x00004000 /* Data access has a cost */ 163 #define IFEF_IPV4_ROUTER 0x00008000 /* interior when in IPv4 router mode */ 164 #define IFEF_LOCALNET_PRIVATE 0x00020000 /* local private network */ 165 #define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE 166 #define IFEF_IPV6_ND6ALT 0x00040000 /* alternative. KPI for ND6 */ 167 #define IFEF_RESTRICTED_RECV 0x00080000 /* interface restricts inbound pkts */ 168 #define IFEF_AWDL 0x00100000 /* Apple Wireless Direct Link */ 169 #define IFEF_NOACKPRI 0x00200000 /* No TCP ACK prioritization */ 170 #define IFEF_AWDL_RESTRICTED 0x00400000 /* Restricted AWDL mode */ 171 #define IFEF_2KCL 0x00800000 /* prefers 2K cluster (socket based tunnel) */ 172 #define IFEF_ECN_ENABLE 0x01000000 /* use ECN for TCP connections on the interface */ 173 #define IFEF_ECN_DISABLE 0x02000000 /* do not use ECN for TCP connections on the interface */ 174 #define IFEF_SKYWALK_NATIVE 0x04000000 /* Native Skywalk support */ 175 #define IFEF_3CA 0x08000000 /* Capable of 3CA */ 176 #define IFEF_SENDLIST 0x10000000 /* Supports tx packet lists */ 177 #define IFEF_DIRECTLINK 0x20000000 /* point-to-point topology */ 178 #define IFEF_QOSMARKING_ENABLED 0x40000000 /* QoS marking is enabled */ 179 #define IFEF_UPDOWNCHANGE 0x80000000 /* up/down state is changing */ 180 181 #ifdef XNU_KERNEL_PRIVATE 182 /* 183 * Extra flags 184 */ 185 #define IFXF_WAKE_ON_MAGIC_PACKET 0x00000001 /* wake on magic packet */ 186 #define IFXF_TIMESTAMP_ENABLED 0x00000002 /* time stamping enabled */ 187 #define IFXF_NX_NOAUTO 0x00000004 /* no auto config nexus */ 188 #define IFXF_LEGACY 0x00000008 /* legacy (non-netif) mode */ 189 #define IFXF_LOW_INTERNET_UL 0x00000010 /* Uplink Low Internet is confirmed */ 190 #define IFXF_LOW_INTERNET_DL 0x00000020 /* Downlink Low Internet is confirmed */ 191 #define IFXF_ALLOC_KPI 0x00000040 /* Allocated via the ifnet_alloc KPI */ 192 #define IFXF_LOW_POWER 0x00000080 /* Low Power Mode */ 193 #define IFXF_MPK_LOG 0x00000100 /* Multi-layer Packet Logging */ 194 #define IFXF_CONSTRAINED 0x00000200 /* Constrained - Save Data Mode */ 195 #define IFXF_LOW_LATENCY 0x00000400 /* Low latency interface */ 196 #define IFXF_MARK_WAKE_PKT 0x00000800 /* Mark next input packet as wake packet */ 197 /* 198 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL 199 * will also trigger the setting/clearing of the rest of the flags. Once 200 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition. 201 */ 202 #define IFEF_AWDL_MASK \ 203 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \ 204 IFEF_AWDL) 205 #endif /* XNU_KERNEL_PRIVATE */ 206 #endif /* PRIVATE */ 207 208 #ifdef KERNEL_PRIVATE 209 /* 210 * !!! NOTE !!! 211 * 212 * if_idle_flags definitions: (all bits are reserved for internal/future 213 * use). Setting these flags MUST be done via the ifnet_set_idle_flags() 214 * KPI due to the associated reference counting. Clearing them may be done by 215 * calling the KPI, otherwise implicitly at interface detach time. Setting 216 * the if_idle_flags field to a non-zero value will cause the networking 217 * stack to aggressively purge expired objects (routes, etc.) 218 */ 219 #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */ 220 221 /* flags set internally only: */ 222 #define IFF_CANTCHANGE \ 223 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ 224 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) 225 #endif /* KERNEL_PRIVATE */ 226 227 /* 228 * Capabilities that interfaces can advertise. 229 * 230 * struct ifnet.if_capabilities 231 * contains the optional features & capabilities a particular interface 232 * supports (not only the driver but also the detected hw revision). 233 * Capabilities are defined by IFCAP_* below. 234 * struct ifnet.if_capenable 235 * contains the enabled (either by default or through ifconfig) optional 236 * features & capabilities on this interface. 237 * Capabilities are defined by IFCAP_* below. 238 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h, 239 * contains the enabled optional features & capabilites that can be used 240 * individually per packet and are specified in the mbuf pkthdr.csum_flags 241 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be 242 * more detailed or differentiated than IFCAP_*. 243 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h 244 */ 245 #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ 246 #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ 247 #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */ 248 #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */ 249 #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */ 250 #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */ 251 #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */ 252 #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */ 253 #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */ 254 #define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */ 255 #define IFCAP_SKYWALK 0x00400 /* Skywalk mode supported/enabled */ 256 #define IFCAP_HW_TIMESTAMP 0x00800 /* Time stamping in hardware */ 257 #define IFCAP_SW_TIMESTAMP 0x01000 /* Time stamping in software */ 258 #define IFCAP_CSUM_PARTIAL 0x02000 /* can offload partial checksum */ 259 #define IFCAP_CSUM_ZERO_INVERT 0x04000 /* can invert 0 to -0 (0xffff) */ 260 261 #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) 262 #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) 263 264 #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \ 265 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS | \ 266 IFCAP_SKYWALK | IFCAP_SW_TIMESTAMP | IFCAP_HW_TIMESTAMP | \ 267 IFCAP_CSUM_PARTIAL | IFCAP_CSUM_ZERO_INVERT) 268 269 #define IFQ_MAXLEN 128 270 #define IFNET_SLOWHZ 1 /* granularity is 1 second */ 271 #define IFQ_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */ 272 #define IFQ_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */ 273 274 /* 275 * Message format for use in obtaining information about interfaces 276 * from sysctl and the routing socket 277 */ 278 struct if_msghdr { 279 unsigned short ifm_msglen; /* to skip non-understood messages */ 280 unsigned char ifm_version; /* future binary compatability */ 281 unsigned char ifm_type; /* message type */ 282 int ifm_addrs; /* like rtm_addrs */ 283 int ifm_flags; /* value of if_flags */ 284 unsigned short ifm_index; /* index for associated ifp */ 285 struct if_data ifm_data; /* statistics and other data about if */ 286 }; 287 288 /* 289 * Message format for use in obtaining information about interface addresses 290 * from sysctl and the routing socket 291 */ 292 struct ifa_msghdr { 293 unsigned short ifam_msglen; /* to skip non-understood messages */ 294 unsigned char ifam_version; /* future binary compatability */ 295 unsigned char ifam_type; /* message type */ 296 int ifam_addrs; /* like rtm_addrs */ 297 int ifam_flags; /* value of ifa_flags */ 298 unsigned short ifam_index; /* index for associated ifp */ 299 int ifam_metric; /* value of ifa_metric */ 300 }; 301 302 /* 303 * Message format for use in obtaining information about multicast addresses 304 * from the routing socket 305 */ 306 struct ifma_msghdr { 307 unsigned short ifmam_msglen; /* to skip non-understood messages */ 308 unsigned char ifmam_version; /* future binary compatability */ 309 unsigned char ifmam_type; /* message type */ 310 int ifmam_addrs; /* like rtm_addrs */ 311 int ifmam_flags; /* value of ifa_flags */ 312 unsigned short ifmam_index; /* index for associated ifp */ 313 }; 314 315 /* 316 * Message format for use in obtaining information about interfaces 317 * from sysctl 318 */ 319 struct if_msghdr2 { 320 u_short ifm_msglen; /* to skip over non-understood messages */ 321 u_char ifm_version; /* future binary compatability */ 322 u_char ifm_type; /* message type */ 323 int ifm_addrs; /* like rtm_addrs */ 324 int ifm_flags; /* value of if_flags */ 325 u_short ifm_index; /* index for associated ifp */ 326 int ifm_snd_len; /* instantaneous length of send queue */ 327 int ifm_snd_maxlen; /* maximum length of send queue */ 328 int ifm_snd_drops; /* number of drops in send queue */ 329 int ifm_timer; /* time until if_watchdog called */ 330 struct if_data64 ifm_data; /* statistics and other data */ 331 }; 332 333 /* 334 * Message format for use in obtaining information about multicast addresses 335 * from sysctl 336 */ 337 struct ifma_msghdr2 { 338 u_short ifmam_msglen; /* to skip over non-understood messages */ 339 u_char ifmam_version; /* future binary compatability */ 340 u_char ifmam_type; /* message type */ 341 int ifmam_addrs; /* like rtm_addrs */ 342 int ifmam_flags; /* value of ifa_flags */ 343 u_short ifmam_index; /* index for associated ifp */ 344 int32_t ifmam_refcount; 345 }; 346 347 /* 348 * ifdevmtu: interface device mtu 349 * Used with SIOCGIFDEVMTU to get the current mtu in use by the device, 350 * as well as the minimum and maximum mtu allowed by the device. 351 */ 352 struct ifdevmtu { 353 int ifdm_current; 354 int ifdm_min; 355 int ifdm_max; 356 }; 357 358 #pragma pack(4) 359 360 /* 361 * ifkpi: interface kpi ioctl 362 * Used with SIOCSIFKPI and SIOCGIFKPI. 363 * 364 * ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From 365 * user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket. 366 * ifk_type - The type. Types are specific to each module id. 367 * ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes. 368 * 369 * Copying data between user space and kernel space is done using copyin 370 * and copyout. A process may be running in 64bit mode. In such a case, 371 * the pointer will be a 64bit pointer, not a 32bit pointer. The following 372 * sample is a safe way to copy the data in to the kernel from either a 373 * 32bit or 64bit process: 374 * 375 * user_addr_t tmp_ptr; 376 * if (IS_64BIT_PROCESS(current_proc())) { 377 * tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64); 378 * } 379 * else { 380 * tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr); 381 * } 382 * error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer); 383 */ 384 385 struct ifkpi { 386 unsigned int ifk_module_id; 387 unsigned int ifk_type; 388 union { 389 void *ifk_ptr; 390 int ifk_value; 391 #ifdef KERNEL 392 u_int64_t ifk_ptr64; 393 #endif /* KERNEL */ 394 } ifk_data; 395 }; 396 397 /* Wake capabilities of a interface */ 398 #define IF_WAKE_ON_MAGIC_PACKET 0x01 399 #ifdef KERNEL_PRIVATE 400 #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET 401 #endif /* KERNEL_PRIVATE */ 402 403 404 #pragma pack() 405 406 /* 407 * Interface request structure used for socket 408 * ioctl's. All interface ioctl's must have parameter 409 * definitions which begin with ifr_name. The 410 * remainder may be interface specific. 411 */ 412 struct ifreq { 413 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 414 union { 415 struct sockaddr ifru_addr; 416 struct sockaddr ifru_dstaddr; 417 struct sockaddr ifru_broadaddr; 418 short ifru_flags; 419 int ifru_metric; 420 int ifru_mtu; 421 int ifru_phys; 422 int ifru_media; 423 int ifru_intval; 424 caddr_t ifru_data; 425 #ifdef KERNEL_PRIVATE 426 u_int64_t ifru_data64; /* 64-bit ifru_data */ 427 #endif /* KERNEL_PRIVATE */ 428 struct ifdevmtu ifru_devmtu; 429 struct ifkpi ifru_kpi; 430 u_int32_t ifru_wake_flags; 431 u_int32_t ifru_route_refcnt; 432 #ifdef PRIVATE 433 int ifru_link_quality_metric; 434 #endif /* PRIVATE */ 435 int ifru_cap[2]; 436 #ifdef PRIVATE 437 struct { 438 uint32_t ifo_flags; 439 #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001 440 uint32_t ifo_inuse; 441 } ifru_opportunistic; 442 u_int64_t ifru_eflags; 443 u_int64_t ifru_xflags; 444 struct { 445 int32_t ifl_level; 446 uint32_t ifl_flags; 447 #define IFRLOGF_DLIL 0x00000001 448 #define IFRLOGF_FAMILY 0x00010000 449 #define IFRLOGF_DRIVER 0x01000000 450 #define IFRLOGF_FIRMWARE 0x10000000 451 int32_t ifl_category; 452 #define IFRLOGCAT_CONNECTIVITY 1 453 #define IFRLOGCAT_QUALITY 2 454 #define IFRLOGCAT_PERFORMANCE 3 455 int32_t ifl_subcategory; 456 } ifru_log; 457 u_int32_t ifru_delegated; 458 struct { 459 uint32_t ift_type; 460 uint32_t ift_family; 461 #define IFRTYPE_FAMILY_ANY 0 462 #define IFRTYPE_FAMILY_LOOPBACK 1 463 #define IFRTYPE_FAMILY_ETHERNET 2 464 #define IFRTYPE_FAMILY_SLIP 3 465 #define IFRTYPE_FAMILY_TUN 4 466 #define IFRTYPE_FAMILY_VLAN 5 467 #define IFRTYPE_FAMILY_PPP 6 468 #define IFRTYPE_FAMILY_PVC 7 469 #define IFRTYPE_FAMILY_DISC 8 470 #define IFRTYPE_FAMILY_MDECAP 9 471 #define IFRTYPE_FAMILY_GIF 10 472 #define IFRTYPE_FAMILY_FAITH 11 473 #define IFRTYPE_FAMILY_STF 12 474 #define IFRTYPE_FAMILY_FIREWIRE 13 475 #define IFRTYPE_FAMILY_BOND 14 476 #define IFRTYPE_FAMILY_CELLULAR 15 477 #define IFRTYPE_FAMILY_6LOWPAN 16 478 #define IFRTYPE_FAMILY_UTUN 17 479 #define IFRTYPE_FAMILY_IPSEC 18 480 uint32_t ift_subfamily; 481 #define IFRTYPE_SUBFAMILY_ANY 0 482 #define IFRTYPE_SUBFAMILY_USB 1 483 #define IFRTYPE_SUBFAMILY_BLUETOOTH 2 484 #define IFRTYPE_SUBFAMILY_WIFI 3 485 #define IFRTYPE_SUBFAMILY_THUNDERBOLT 4 486 #define IFRTYPE_SUBFAMILY_RESERVED 5 487 #define IFRTYPE_SUBFAMILY_INTCOPROC 6 488 #define IFRTYPE_SUBFAMILY_QUICKRELAY 7 489 #define IFRTYPE_SUBFAMILY_DEFAULT 8 490 } ifru_type; 491 #endif /* PRIVATE */ 492 u_int32_t ifru_functional_type; 493 #define IFRTYPE_FUNCTIONAL_UNKNOWN 0 494 #define IFRTYPE_FUNCTIONAL_LOOPBACK 1 495 #define IFRTYPE_FUNCTIONAL_WIRED 2 496 #define IFRTYPE_FUNCTIONAL_WIFI_INFRA 3 497 #define IFRTYPE_FUNCTIONAL_WIFI_AWDL 4 498 #define IFRTYPE_FUNCTIONAL_CELLULAR 5 499 #define IFRTYPE_FUNCTIONAL_INTCOPROC 6 500 #define IFRTYPE_FUNCTIONAL_COMPANIONLINK 7 501 #define IFRTYPE_FUNCTIONAL_LAST 7 502 #ifdef PRIVATE 503 u_int32_t ifru_expensive; 504 u_int32_t ifru_constrained; 505 u_int32_t ifru_2kcl; 506 struct { 507 u_int32_t qlen; 508 u_int32_t timeout; 509 } ifru_start_delay; 510 struct if_interface_state ifru_interface_state; 511 u_int32_t ifru_probe_connectivity; 512 u_int32_t ifru_ecn_mode; 513 #define IFRTYPE_ECN_DEFAULT 0 514 #define IFRTYPE_ECN_ENABLE 1 515 #define IFRTYPE_ECN_DISABLE 2 516 u_int32_t ifru_qosmarking_mode; 517 #define IFRTYPE_QOSMARKING_MODE_NONE 0 518 #define IFRTYPE_QOSMARKING_FASTLANE 1 /* supported: socket/channel */ 519 #define IFRTYPE_QOSMARKING_RFC4594 2 /* supported: channel only */ 520 #define IFRTYPE_QOSMARKING_CUSTOM 3 /* supported: socket/channel */ 521 u_int32_t ifru_qosmarking_enabled; 522 u_int32_t ifru_disable_output; 523 u_int32_t ifru_low_internet; 524 #define IFRTYPE_LOW_INTERNET_DISABLE_UL_DL 0x0000 525 #define IFRTYPE_LOW_INTERNET_ENABLE_UL 0x0001 526 #define IFRTYPE_LOW_INTERNET_ENABLE_DL 0x0002 527 int ifru_low_power_mode; 528 u_int32_t ifru_tcp_kao_max; 529 int ifru_mpk_log; /* Multi Layer Packet Log */ 530 u_int32_t ifru_noack_prio; 531 struct { 532 u_int8_t up_bucket; 533 u_int8_t down_bucket; 534 } ifru_estimated_throughput; 535 struct { 536 u_int8_t technology; 537 u_int8_t channel; 538 } ifru_radio_details; 539 #endif /* PRIVATE */ 540 } ifr_ifru; 541 #define ifr_addr ifr_ifru.ifru_addr /* address */ 542 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ 543 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 544 #ifdef __APPLE__ 545 #define ifr_flags ifr_ifru.ifru_flags /* flags */ 546 #else 547 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ 548 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ 549 #endif /* __APPLE__ */ 550 #define ifr_metric ifr_ifru.ifru_metric /* metric */ 551 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ 552 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ 553 #define ifr_media ifr_ifru.ifru_media /* physical media */ 554 #define ifr_data ifr_ifru.ifru_data /* for use by interface */ 555 #define ifr_devmtu ifr_ifru.ifru_devmtu 556 #define ifr_intval ifr_ifru.ifru_intval /* integer value */ 557 #ifdef KERNEL_PRIVATE 558 #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */ 559 #endif /* KERNEL_PRIVATE */ 560 #define ifr_kpi ifr_ifru.ifru_kpi 561 #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */ 562 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */ 563 #ifdef PRIVATE 564 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */ 565 #endif /* PRIVATE */ 566 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ 567 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ 568 #ifdef PRIVATE 569 #define ifr_opportunistic ifr_ifru.ifru_opportunistic 570 #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */ 571 #define ifr_xflags ifr_ifru.ifru_xflags /* extra flags */ 572 #define ifr_log ifr_ifru.ifru_log /* logging level/flags */ 573 #define ifr_delegated ifr_ifru.ifru_delegated /* delegated interface index */ 574 #define ifr_expensive ifr_ifru.ifru_expensive 575 #define ifr_constrained ifr_ifru.ifru_constrained 576 #define ifr_type ifr_ifru.ifru_type /* interface type */ 577 #define ifr_functional_type ifr_ifru.ifru_functional_type 578 #define ifr_2kcl ifr_ifru.ifru_2kcl 579 #define ifr_start_delay_qlen ifr_ifru.ifru_start_delay.qlen 580 #define ifr_start_delay_timeout ifr_ifru.ifru_start_delay.timeout 581 #define ifr_interface_state ifr_ifru.ifru_interface_state 582 #define ifr_probe_connectivity ifr_ifru.ifru_probe_connectivity 583 #define ifr_ecn_mode ifr_ifru.ifru_ecn_mode 584 #define ifr_qosmarking_mode ifr_ifru.ifru_qosmarking_mode 585 #define ifr_fastlane_capable ifr_qosmarking_mode 586 #define ifr_qosmarking_enabled ifr_ifru.ifru_qosmarking_enabled 587 #define ifr_fastlane_enabled ifr_qosmarking_enabled 588 #define ifr_disable_output ifr_ifru.ifru_disable_output 589 #define ifr_low_internet ifr_ifru.ifru_low_internet 590 #define ifr_low_power_mode ifr_ifru.ifru_low_power_mode 591 #define ifr_tcp_kao_max ifr_ifru.ifru_tcp_kao_max 592 #define ifr_mpk_log ifr_ifru.ifru_mpk_log 593 #define ifr_noack_prio ifr_ifru.ifru_noack_prio 594 #define ifr_estimated_throughput ifr_ifru.ifru_estimated_throughput 595 #define ifr_radio_details ifr_ifru.ifru_radio_details 596 597 #endif /* PRIVATE */ 598 }; 599 600 #define _SIZEOF_ADDR_IFREQ(ifr) \ 601 ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \ 602 (sizeof (struct ifreq) - sizeof (struct sockaddr) + \ 603 (ifr).ifr_addr.sa_len) : sizeof (struct ifreq)) 604 605 struct ifaliasreq { 606 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 607 struct sockaddr ifra_addr; 608 struct sockaddr ifra_broadaddr; 609 struct sockaddr ifra_mask; 610 }; 611 612 struct rslvmulti_req { 613 struct sockaddr *sa; 614 struct sockaddr **llsa; 615 }; 616 617 #if !defined(KERNEL) || defined(KERNEL_PRIVATE) 618 #pragma pack(4) 619 620 struct ifmediareq { 621 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 622 int ifm_current; /* current media options */ 623 int ifm_mask; /* don't care mask */ 624 int ifm_status; /* media status */ 625 int ifm_active; /* active options */ 626 int ifm_count; /* # entries in ifm_ulist array */ 627 int *ifm_ulist; /* media words */ 628 }; 629 630 #pragma pack() 631 #endif /* !KERNEL || KERNEL_PRIVATE */ 632 633 #ifdef KERNEL_PRIVATE 634 #pragma pack(4) 635 struct ifmediareq64 { 636 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 637 int ifm_current; /* current media options */ 638 int ifm_mask; /* don't care mask */ 639 int ifm_status; /* media status */ 640 int ifm_active; /* active options */ 641 int ifm_count; /* # entries in ifm_ulist array */ 642 user64_addr_t ifmu_ulist __attribute__((aligned(8))); 643 }; 644 645 struct ifmediareq32 { 646 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 647 int ifm_current; /* current media options */ 648 int ifm_mask; /* don't care mask */ 649 int ifm_status; /* media status */ 650 int ifm_active; /* active options */ 651 int ifm_count; /* # entries in ifm_ulist array */ 652 user32_addr_t ifmu_ulist; /* 32-bit pointer */ 653 }; 654 #pragma pack() 655 #endif /* KERNEL_PRIVATE */ 656 #endif /* DRIVERKIT */ 657 658 #pragma pack(4) 659 struct ifdrv { 660 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 661 unsigned long ifd_cmd; 662 size_t ifd_len; /* length of ifd_data buffer */ 663 void *ifd_data; 664 }; 665 #pragma pack() 666 667 #ifndef DRIVERKIT 668 #ifdef KERNEL_PRIVATE 669 #pragma pack(4) 670 struct ifdrv32 { 671 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 672 u_int32_t ifd_cmd; 673 u_int32_t ifd_len; 674 user32_addr_t ifd_data; 675 }; 676 677 struct ifdrv64 { 678 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 679 u_int64_t ifd_cmd; 680 u_int64_t ifd_len; 681 user64_addr_t ifd_data; 682 }; 683 #pragma pack() 684 #endif /* KERNEL_PRIVATE */ 685 686 /* 687 * Structure used to retrieve aux status data from interfaces. 688 * Kernel suppliers to this interface should respect the formatting 689 * needed by ifconfig(8): each line starts with a TAB and ends with 690 * a newline. 691 */ 692 693 #define IFSTATMAX 800 /* 10 lines of text */ 694 struct ifstat { 695 char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 696 char ascii[IFSTATMAX + 1]; 697 }; 698 699 #if !defined(KERNEL) || defined(KERNEL_PRIVATE) 700 /* 701 * Structure used in SIOCGIFCONF request. 702 * Used to retrieve interface configuration 703 * for machine (useful for programs which 704 * must know all networks accessible). 705 */ 706 #pragma pack(4) 707 struct ifconf { 708 int ifc_len; /* size of associated buffer */ 709 union { 710 caddr_t ifcu_buf; 711 struct ifreq *ifcu_req; 712 } ifc_ifcu; 713 }; 714 #pragma pack() 715 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 716 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ 717 #endif /* !KERNEL || KERNEL_PRIVATE */ 718 719 #if defined(KERNEL_PRIVATE) 720 #pragma pack(4) 721 struct ifconf32 { 722 int ifc_len; /* size of associated buffer */ 723 struct { 724 user32_addr_t ifcu_req; 725 } ifc_ifcu; 726 }; 727 728 struct ifconf64 { 729 int ifc_len; /* size of associated buffer */ 730 struct { 731 user64_addr_t ifcu_req __attribute__((aligned(8))); 732 } ifc_ifcu; 733 }; 734 #pragma pack() 735 #endif /* KERNEL_PRIVATE */ 736 737 /* 738 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure 739 */ 740 struct kev_dl_proto_data { 741 struct net_event_data link_data; 742 u_int32_t proto_family; 743 u_int32_t proto_remaining_count; 744 }; 745 746 #ifdef PRIVATE 747 /* 748 * Link Quality Metrics 749 * 750 * IFNET_LQM_THRESH_OFF Metric is not available; device is off. 751 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known. 752 * IFNET_LQM_THRESH_BAD Link quality is considered bad by driver. 753 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver. 754 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver. 755 */ 756 enum { 757 IFNET_LQM_THRESH_OFF = (-2), 758 IFNET_LQM_THRESH_UNKNOWN = (-1), 759 IFNET_LQM_THRESH_ABORT = 10, 760 IFNET_LQM_THRESH_MINIMALLY_VIABLE = 20, 761 IFNET_LQM_THRESH_POOR = 50, 762 IFNET_LQM_THRESH_GOOD = 100 763 }; 764 #define IFNET_LQM_THRESH_BAD IFNET_LQM_THRESH_ABORT 765 766 #ifdef XNU_KERNEL_PRIVATE 767 #define IFNET_LQM_MIN IFNET_LQM_THRESH_OFF 768 #define IFNET_LQM_MAX IFNET_LQM_THRESH_GOOD 769 #endif /* XNU_KERNEL_PRIVATE */ 770 771 /* 772 * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure 773 */ 774 struct kev_dl_link_quality_metric_data { 775 struct net_event_data link_data; 776 int link_quality_metric; 777 }; 778 779 #define IF_DESCSIZE 128 780 781 /* 782 * Structure for SIOC[SG]IFDESC 783 */ 784 struct if_descreq { 785 char ifdr_name[IFNAMSIZ]; /* interface name */ 786 u_int32_t ifdr_len; /* up to IF_DESCSIZE */ 787 u_int8_t ifdr_desc[IF_DESCSIZE]; /* opaque data */ 788 }; 789 790 /* 791 * Output packet scheduling models 792 * 793 * IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model 794 * where the driver or media does not require strict scheduling 795 * strategy, and that the networking stack is free to choose the 796 * most appropriate scheduling and queueing algorithm, including 797 * shaping traffics. 798 * IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet 799 * scheduling model where the driver or media requires strict 800 * scheduling strategy (e.g. 802.11 WMM), and that the networking 801 * stack is only responsible for creating multiple queues for the 802 * corresponding service classes. 803 */ 804 enum { 805 IFNET_SCHED_MODEL_NORMAL = 0, 806 IFNET_SCHED_MODEL_DRIVER_MANAGED = 1, 807 IFNET_SCHED_MODEL_FQ_CODEL = 2, 808 #ifdef XNU_KERNEL_PRIVATE 809 IFNET_SCHED_MODEL_MAX = 3, 810 #endif /* XNU_KERNEL_PRIVATE */ 811 }; 812 813 /* 814 * Values for iflpr_flags 815 */ 816 #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */ 817 #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */ 818 819 /* 820 * Structure for SIOCGIFLINKPARAMS 821 */ 822 struct if_linkparamsreq { 823 char iflpr_name[IFNAMSIZ]; /* interface name */ 824 u_int32_t iflpr_flags; 825 u_int32_t iflpr_output_sched; 826 u_int64_t iflpr_output_tbr_rate; 827 u_int32_t iflpr_output_tbr_percent; 828 u_int64_t iflpr_input_tbr_rate; 829 struct if_bandwidths iflpr_output_bw; 830 struct if_bandwidths iflpr_input_bw; 831 struct if_latencies iflpr_output_lt; 832 struct if_latencies iflpr_input_lt; 833 struct if_netem_params iflpr_input_netem; 834 struct if_netem_params iflpr_output_netem; 835 }; 836 837 /* 838 * Structure for SIOCGIFQUEUESTATS 839 */ 840 struct if_qstatsreq { 841 char ifqr_name[IFNAMSIZ]; /* interface name */ 842 u_int32_t ifqr_slot; 843 void *ifqr_buf __attribute__((aligned(8))); 844 int ifqr_len __attribute__((aligned(8))); 845 }; 846 847 /* 848 * Node Proximity Metrics 849 */ 850 enum { 851 IFNET_NPM_THRESH_UNKNOWN = (-1), 852 IFNET_NPM_THRESH_NEAR = 30, 853 IFNET_NPM_THRESH_GENERAL = 70, 854 IFNET_NPM_THRESH_FAR = 100, 855 }; 856 857 /* 858 * Received Signal Strength Indication [special values] 859 * 860 * IFNET_RSSI_UNKNOWN Metric is not (yet) known. 861 */ 862 enum { 863 IFNET_RSSI_UNKNOWN = ((-2147483647) - 1), /* INT32_MIN */ 864 }; 865 866 867 /* 868 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures 869 */ 870 struct kev_dl_node_presence { 871 struct net_event_data link_data; 872 struct sockaddr_in6 sin6_node_address; 873 struct sockaddr_dl sdl_node_address; 874 int32_t rssi; 875 int link_quality_metric; 876 int node_proximity_metric; 877 u_int8_t node_service_info[48]; 878 }; 879 880 struct kev_dl_node_absence { 881 struct net_event_data link_data; 882 struct sockaddr_in6 sin6_node_address; 883 struct sockaddr_dl sdl_node_address; 884 }; 885 886 /* 887 * Structure for SIOC[SG]IFTHROTTLE 888 */ 889 struct if_throttlereq { 890 char ifthr_name[IFNAMSIZ]; /* interface name */ 891 u_int32_t ifthr_level; 892 }; 893 894 /* 895 * Interface throttling levels 896 * 897 * IFNET_THROTTLE_OFF The default throttling level (no throttling.) 898 * All service class queues operate normally according to the 899 * standard packet scheduler configuration. 900 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that 901 * are responsible for managing "opportunistic" traffics are 902 * suspended. Packets enqueued on those queues will be dropped 903 * and a flow advisory error will be generated to the data 904 * source. Existing packets in the queues will stay enqueued 905 * until the interface is no longer throttled, or until they 906 * are explicitly flushed. 907 */ 908 enum { 909 IFNET_THROTTLE_OFF = 0, 910 IFNET_THROTTLE_OPPORTUNISTIC = 1, 911 #ifdef XNU_KERNEL_PRIVATE 912 IFNET_THROTTLE_MAX = 2, 913 #endif /* XNU_KERNEL_PRIVATE */ 914 }; 915 916 /* 917 * Structure for SIOC[A/D]IFAGENTID 918 */ 919 struct if_agentidreq { 920 char ifar_name[IFNAMSIZ]; /* interface name */ 921 uuid_t ifar_uuid; /* agent UUID to add or delete */ 922 }; 923 924 /* 925 * Structure for SIOCGIFAGENTIDS 926 */ 927 struct if_agentidsreq { 928 char ifar_name[IFNAMSIZ]; /* interface name */ 929 u_int32_t ifar_count; /* number of agent UUIDs */ 930 uuid_t *ifar_uuids; /* array of agent UUIDs */ 931 }; 932 933 #ifdef BSD_KERNEL_PRIVATE 934 struct if_agentidsreq32 { 935 char ifar_name[IFNAMSIZ]; 936 u_int32_t ifar_count; 937 user32_addr_t ifar_uuids; 938 }; 939 struct if_agentidsreq64 { 940 char ifar_name[IFNAMSIZ]; 941 u_int32_t ifar_count; 942 user64_addr_t ifar_uuids __attribute__((aligned(8))); 943 }; 944 #endif /* BSD_KERNEL_PRIVATE */ 945 946 /* 947 * Structure for SIOCGIFNEXUS 948 */ 949 struct if_nexusreq { 950 char ifnr_name[IFNAMSIZ]; /* interface name */ 951 uint64_t ifnr_flags; /* unused, must be zero */ 952 uuid_t ifnr_netif; /* netif nexus instance UUID */ 953 uuid_t ifnr_flowswitch; /* flowswitch nexus UUID */ 954 uint64_t ifnr_reserved[5]; 955 }; 956 957 #define DLIL_MODIDLEN 20 /* same as IFNET_MODIDLEN */ 958 #define DLIL_MODARGLEN 12 /* same as IFNET_MODARGLEN */ 959 960 /* 961 * DLIL KEV_DL_ISSUES event structure 962 */ 963 struct kev_dl_issues { 964 struct net_event_data link_data; 965 u_int8_t modid[DLIL_MODIDLEN]; 966 u_int64_t timestamp; 967 u_int8_t info[DLIL_MODARGLEN]; 968 }; 969 970 /* 971 * DLIL KEV_DL_RRC_STATE_CHANGED structure 972 */ 973 struct kev_dl_rrc_state { 974 struct net_event_data link_data; 975 u_int32_t rrc_state; 976 }; 977 978 /* 979 * KEV_DL_LOW_POWER_MODE_CHANGED 980 */ 981 struct kev_dl_low_power_mode { 982 struct net_event_data link_data; 983 int low_power_event; 984 }; 985 986 /* 987 * Length of network signature/fingerprint blob. 988 */ 989 #define IFNET_SIGNATURELEN 20 990 991 /* 992 * Structure for SIOC[S/G]IFNETSIGNATURE 993 */ 994 struct if_nsreq { 995 char ifnsr_name[IFNAMSIZ]; 996 u_int8_t ifnsr_family; /* address family */ 997 u_int8_t ifnsr_len; /* data length */ 998 u_int16_t ifnsr_flags; /* for future */ 999 u_int8_t ifnsr_data[IFNET_SIGNATURELEN]; 1000 }; 1001 1002 /* Structure for SIOCSIFNETWORKID */ 1003 struct if_netidreq { 1004 char ifnetid_name[IFNAMSIZ]; 1005 u_int8_t ifnetid_len; 1006 u_int8_t ifnetid[IFNET_NETWORK_ID_LEN]; 1007 }; 1008 1009 #define NAT64_PREFIX_LEN_32 4 1010 #define NAT64_PREFIX_LEN_40 5 1011 #define NAT64_PREFIX_LEN_48 6 1012 #define NAT64_PREFIX_LEN_56 7 1013 #define NAT64_PREFIX_LEN_64 8 1014 #define NAT64_PREFIX_LEN_96 12 1015 #define NAT64_PREFIX_LEN_MAX NAT64_PREFIX_LEN_96 1016 1017 #define NAT64_MAX_NUM_PREFIXES 4 1018 1019 struct ipv6_prefix { 1020 struct in6_addr ipv6_prefix; 1021 uint32_t prefix_len; 1022 }; 1023 1024 struct if_ipv6_address { 1025 struct in6_addr v6_address; 1026 uint32_t v6_prefixlen; 1027 }; 1028 1029 /* Structure for SIOC[S/G]IFNAT64PREFIX */ 1030 struct if_nat64req { 1031 char ifnat64_name[IFNAMSIZ]; 1032 struct ipv6_prefix ifnat64_prefixes[NAT64_MAX_NUM_PREFIXES]; 1033 }; 1034 1035 /* Structure for SIOCGIFCLAT46ADDR */ 1036 struct if_clat46req { 1037 char ifclat46_name[IFNAMSIZ]; 1038 struct if_ipv6_address ifclat46_addr; 1039 }; 1040 1041 /* 1042 * Structure for SIOC[S/G]IFORDER 1043 * 1044 * When setting, ifo_count is the number of u_int32_t interface indices 1045 * in the ifo_ordered_indices array. 1046 * 1047 * When getting, if ifo_count is 0, the length of the ordered list will 1048 * be returned. If the ifo_count is non-0, it is the number of u_int32_t 1049 * interface indices allocated. Upon return, ifo_count will contain the number 1050 * of indices copied into the array. 1051 */ 1052 struct if_order { 1053 u_int32_t ifo_count; 1054 u_int32_t ifo_reserved; 1055 mach_vm_address_t ifo_ordered_indices; /* array of u_int32_t */ 1056 }; 1057 1058 /* 1059 * Struct for traffic class to DSCP mapping 1060 */ 1061 struct if_tdmreq { 1062 char iftdm_name[IFNAMSIZ]; 1063 u_int32_t iftdm_len; /* byte length of the table */ 1064 struct netsvctype_dscp_map *iftdm_table; 1065 }; 1066 1067 #ifdef BSD_KERNEL_PRIVATE 1068 struct if_tdmreq32 { 1069 char iftdm_name[IFNAMSIZ]; 1070 u_int32_t iftdm_len; /* byte length of the table */ 1071 user32_addr_t iftdm_table; 1072 }; 1073 1074 struct if_tdmreq64 { 1075 char iftdm_name[IFNAMSIZ]; 1076 u_int32_t iftdm_len; /* byte length of the table */ 1077 user64_addr_t iftdm_table __attribute__((aligned(8))); 1078 }; 1079 #endif 1080 1081 /* 1082 * Structure for SIOCGIFPROTOLIST. 1083 */ 1084 struct if_protolistreq { 1085 char ifpl_name[IFNAMSIZ]; 1086 u_int32_t ifpl_count; 1087 u_int32_t ifpl_reserved; /* must be zero */ 1088 u_int32_t *ifpl_list; 1089 }; 1090 1091 #ifdef BSD_KERNEL_PRIVATE 1092 struct if_protolistreq32 { 1093 char ifpl_name[IFNAMSIZ]; 1094 u_int32_t ifpl_count; 1095 u_int32_t ifpl_reserved; /* must be zero */ 1096 user32_addr_t ifpl_list; 1097 }; 1098 1099 struct if_protolistreq64 { 1100 char ifpl_name[IFNAMSIZ]; 1101 u_int32_t ifpl_count; 1102 u_int32_t ifpl_reserved; /* must be zero */ 1103 user64_addr_t ifpl_list; 1104 }; 1105 #endif /* BSD_KERNEL_PRIVATE */ 1106 1107 #endif /* PRIVATE */ 1108 1109 #ifdef KERNEL 1110 #ifdef MALLOC_DECLARE 1111 MALLOC_DECLARE(M_IFADDR); 1112 MALLOC_DECLARE(M_IFMADDR); 1113 #endif 1114 #endif 1115 #endif /* DRIVERKIT */ 1116 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ 1117 1118 #ifndef DRIVERKIT 1119 #ifndef KERNEL 1120 struct if_nameindex { 1121 unsigned int if_index; /* 1, 2, ... */ 1122 char *if_name; /* null terminated name: "le0", ... */ 1123 }; 1124 1125 __BEGIN_DECLS 1126 unsigned int if_nametoindex(const char *); 1127 char *if_indextoname(unsigned int, char *); 1128 struct if_nameindex *if_nameindex(void); 1129 void if_freenameindex(struct if_nameindex *); 1130 __END_DECLS 1131 #endif /* KERNEL */ 1132 #endif /* DRIVERKIT */ 1133 1134 #ifdef KERNEL 1135 #include <net/kpi_interface.h> 1136 #endif 1137 1138 #endif /* !_NET_IF_H_ */ 1139