2 * Copyright (c) 2000-2018 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1986, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
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.
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
60 * @(#)if.h 8.1 (Berkeley) 6/10/93
66 #include <sys/cdefs.h>
67 #include <net/net_kev.h>
69 #define IF_NAMESIZE 16
71 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
72 #include <sys/appleapiopts.h>
75 #include <net/if_var.h>
76 #include <sys/types.h>
77 #include <sys/socket.h>
80 #include <net/if_dl.h>
81 #include <netinet/in.h>
82 #include <mach/vm_types.h>
87 int ifcr_total
; /* total cloners (out) */
88 int ifcr_count
; /* room for this many in user buffer */
89 char *ifcr_buffer
; /* buffer for cloner names */
93 #define IF_MAXUNIT 0x7fff /* historical value */
95 struct if_clonereq64
{
96 int ifcr_total
; /* total cloners (out) */
97 int ifcr_count
; /* room for this many in user buffer */
98 user64_addr_t ifcru_buffer
__attribute__((aligned(8)));
101 struct if_clonereq32
{
102 int ifcr_total
; /* total cloners (out) */
103 int ifcr_count
; /* room for this many in user buffer */
104 user32_addr_t ifcru_buffer
;
106 #endif /* KERNEL_PRIVATE */
108 #define IFF_UP 0x1 /* interface is up */
109 #define IFF_BROADCAST 0x2 /* broadcast address valid */
110 #define IFF_DEBUG 0x4 /* turn on debugging */
111 #define IFF_LOOPBACK 0x8 /* is a loopback net */
112 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
113 #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
114 #define IFF_RUNNING 0x40 /* resources allocated */
115 #define IFF_NOARP 0x80 /* no address resolution protocol */
116 #define IFF_PROMISC 0x100 /* receive all packets */
117 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
118 #define IFF_OACTIVE 0x400 /* transmission in progress */
119 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
120 #define IFF_LINK0 0x1000 /* per link layer defined bit */
121 #define IFF_LINK1 0x2000 /* per link layer defined bit */
122 #define IFF_LINK2 0x4000 /* per link layer defined bit */
123 #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
124 #define IFF_MULTICAST 0x8000 /* supports multicast */
127 /* extended flags definitions: (all bits reserved for internal/future use) */
128 #define IFEF_AUTOCONFIGURING 0x00000001 /* allow BOOTP/DHCP replies to enter */
129 #define IFEF_ENQUEUE_MULTI 0x00000002 /* enqueue multiple packets at once */
130 #define IFEF_DELAY_START 0x00000004 /* delay start callback */
131 #define IFEF_PROBE_CONNECTIVITY 0x00000008 /* Probe connections going over this interface */
132 #define IFEF_QOSMARKING_CAPABLE 0x00000010 /* XXX Obsolete, to be removed */
133 #define IFEF_IPV6_DISABLED 0x00000020 /* coupled to ND6_IFF_IFDISABLED */
134 #define IFEF_ACCEPT_RTADV 0x00000040 /* accepts IPv6 RA on the interface */
135 #define IFEF_TXSTART 0x00000080 /* has start callback */
136 #define IFEF_RXPOLL 0x00000100 /* supports opportunistic input poll */
137 #define IFEF_VLAN 0x00000200 /* interface has one or more vlans */
138 #define IFEF_BOND 0x00000400 /* interface is part of bond */
139 #define IFEF_ARPLL 0x00000800 /* ARP for IPv4LL addresses */
140 #define IFEF_CLAT46 0x00001000 /* CLAT46 RFC 6877 */
142 #define IS_INTF_CLAT46(ifp) ((ifp) != NULL && ((ifp)->if_eflags & IFEF_CLAT46))
143 #define INTF_ADJUST_MTU_FOR_CLAT46(intf) \
144 (IS_INTF_CLAT46((intf)) || \
145 IS_INTF_CLAT46((intf)->if_delegated.ifp)) \
148 * XXX IFEF_NOAUTOIPV6LL is deprecated and should be done away with.
149 * Configd pretty much manages the interface configuration.
150 * Rather than looking at the flag we check if a specific LLA
151 * has to be configured or the IID has to be generated by kernel.
153 #define IFEF_NOAUTOIPV6LL 0x00002000 /* Need explicit IPv6 LL address */
154 #define IFEF_EXPENSIVE 0x00004000 /* Data access has a cost */
155 #define IFEF_IPV4_ROUTER 0x00008000 /* interior when in IPv4 router mode */
156 #define IFEF_IPV6_ROUTER 0x00010000 /* interior when in IPv6 router mode */
157 #define IFEF_LOCALNET_PRIVATE 0x00020000 /* local private network */
158 #define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE
159 #define IFEF_IPV6_ND6ALT 0x00040000 /* alternative. KPI for ND6 */
160 #define IFEF_RESTRICTED_RECV 0x00080000 /* interface restricts inbound pkts */
161 #define IFEF_AWDL 0x00100000 /* Apple Wireless Direct Link */
162 #define IFEF_NOACKPRI 0x00200000 /* No TCP ACK prioritization */
163 #define IFEF_AWDL_RESTRICTED 0x00400000 /* Restricted AWDL mode */
164 #define IFEF_2KCL 0x00800000 /* prefers 2K cluster (socket based tunnel) */
165 #define IFEF_ECN_ENABLE 0x01000000 /* use ECN for TCP connections on the interface */
166 #define IFEF_ECN_DISABLE 0x02000000 /* do not use ECN for TCP connections on the interface */
167 #define IFEF_SKYWALK_NATIVE 0x04000000 /* Native Skywalk support */
168 #define IFEF_3CA 0x08000000 /* Capable of 3CA */
169 #define IFEF_SENDLIST 0x10000000 /* Supports tx packet lists */
170 #define IFEF_DIRECTLINK 0x20000000 /* point-to-point topology */
171 #define IFEF_QOSMARKING_ENABLED 0x40000000 /* OoS marking is enabled */
172 #define IFEF_UPDOWNCHANGE 0x80000000 /* up/down state is changing */
174 #ifdef XNU_KERNEL_PRIVATE
178 #define IFXF_WAKE_ON_MAGIC_PACKET 0x00000001 /* wake on magic packet */
179 #define IFXF_TIMESTAMP_ENABLED 0x00000002 /* time stamping enabled */
180 #define IFXF_NX_NOAUTO 0x00000004 /* no auto config nexus */
181 #define IFXF_MULTISTACK_BPF_TAP 0x00000008 /* multistack bpf tap */
182 #define IFXF_LOW_INTERNET_UL 0x00000010 /* Uplink Low Internet is confirmed */
183 #define IFXF_LOW_INTERNET_DL 0x00000020 /* Downlink Low Internet is confirmed */
184 #define IFXF_ALLOC_KPI 0x00000040 /* Allocated via the ifnet_alloc KPI */
185 #define IFXF_LOW_POWER 0x00000080 /* Low Power Mode */
188 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL
189 * will also trigger the setting/clearing of the rest of the flags. Once
190 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
192 #define IFEF_AWDL_MASK \
193 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
195 #endif /* XNU_KERNEL_PRIVATE */
198 #ifdef KERNEL_PRIVATE
202 * if_idle_flags definitions: (all bits are reserved for internal/future
203 * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
204 * KPI due to the associated reference counting. Clearing them may be done by
205 * calling the KPI, otherwise implicitly at interface detach time. Setting
206 * the if_idle_flags field to a non-zero value will cause the networking
207 * stack to aggressively purge expired objects (routes, etc.)
209 #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */
211 /* flags set internally only: */
212 #define IFF_CANTCHANGE \
213 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
214 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
215 #endif /* KERNEL_PRIVATE */
218 * Capabilities that interfaces can advertise.
220 * struct ifnet.if_capabilities
221 * contains the optional features & capabilities a particular interface
222 * supports (not only the driver but also the detected hw revision).
223 * Capabilities are defined by IFCAP_* below.
224 * struct ifnet.if_capenable
225 * contains the enabled (either by default or through ifconfig) optional
226 * features & capabilities on this interface.
227 * Capabilities are defined by IFCAP_* below.
228 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h,
229 * contains the enabled optional features & capabilites that can be used
230 * individually per packet and are specified in the mbuf pkthdr.csum_flags
231 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be
232 * more detailed or differentiated than IFCAP_*.
233 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h
235 #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
236 #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
237 #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */
238 #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */
239 #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */
240 #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */
241 #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */
242 #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */
243 #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */
244 #define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */
245 #define IFCAP_SKYWALK 0x00400 /* Skywalk mode supported/enabled */
246 #define IFCAP_HW_TIMESTAMP 0x00800 /* Time stamping in hardware */
247 #define IFCAP_SW_TIMESTAMP 0x01000 /* Time stamping in software */
248 #define IFCAP_CSUM_PARTIAL 0x02000 /* can offload partial checksum */
249 #define IFCAP_CSUM_ZERO_INVERT 0x04000 /* can invert 0 to -0 (0xffff) */
251 #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
252 #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
254 #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \
255 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS | \
256 IFCAP_SKYWALK | IFCAP_SW_TIMESTAMP | IFCAP_HW_TIMESTAMP | \
257 IFCAP_CSUM_PARTIAL | IFCAP_CSUM_ZERO_INVERT)
259 #define IFQ_MAXLEN 128
260 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
261 #define IFQ_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */
262 #define IFQ_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
265 * Message format for use in obtaining information about interfaces
266 * from sysctl and the routing socket
269 unsigned short ifm_msglen
; /* to skip non-understood messages */
270 unsigned char ifm_version
; /* future binary compatability */
271 unsigned char ifm_type
; /* message type */
272 int ifm_addrs
; /* like rtm_addrs */
273 int ifm_flags
; /* value of if_flags */
274 unsigned short ifm_index
; /* index for associated ifp */
275 struct if_data ifm_data
; /* statistics and other data about if */
279 * Message format for use in obtaining information about interface addresses
280 * from sysctl and the routing socket
283 unsigned short ifam_msglen
; /* to skip non-understood messages */
284 unsigned char ifam_version
; /* future binary compatability */
285 unsigned char ifam_type
; /* message type */
286 int ifam_addrs
; /* like rtm_addrs */
287 int ifam_flags
; /* value of ifa_flags */
288 unsigned short ifam_index
; /* index for associated ifp */
289 int ifam_metric
; /* value of ifa_metric */
293 * Message format for use in obtaining information about multicast addresses
294 * from the routing socket
297 unsigned short ifmam_msglen
; /* to skip non-understood messages */
298 unsigned char ifmam_version
; /* future binary compatability */
299 unsigned char ifmam_type
; /* message type */
300 int ifmam_addrs
; /* like rtm_addrs */
301 int ifmam_flags
; /* value of ifa_flags */
302 unsigned short ifmam_index
; /* index for associated ifp */
306 * Message format for use in obtaining information about interfaces
310 u_short ifm_msglen
; /* to skip over non-understood messages */
311 u_char ifm_version
; /* future binary compatability */
312 u_char ifm_type
; /* message type */
313 int ifm_addrs
; /* like rtm_addrs */
314 int ifm_flags
; /* value of if_flags */
315 u_short ifm_index
; /* index for associated ifp */
316 int ifm_snd_len
; /* instantaneous length of send queue */
317 int ifm_snd_maxlen
; /* maximum length of send queue */
318 int ifm_snd_drops
; /* number of drops in send queue */
319 int ifm_timer
; /* time until if_watchdog called */
320 struct if_data64 ifm_data
; /* statistics and other data */
324 * Message format for use in obtaining information about multicast addresses
327 struct ifma_msghdr2
{
328 u_short ifmam_msglen
; /* to skip over non-understood messages */
329 u_char ifmam_version
; /* future binary compatability */
330 u_char ifmam_type
; /* message type */
331 int ifmam_addrs
; /* like rtm_addrs */
332 int ifmam_flags
; /* value of ifa_flags */
333 u_short ifmam_index
; /* index for associated ifp */
334 int32_t ifmam_refcount
;
338 * ifdevmtu: interface device mtu
339 * Used with SIOCGIFDEVMTU to get the current mtu in use by the device,
340 * as well as the minimum and maximum mtu allowed by the device.
351 ifkpi: interface kpi ioctl
352 Used with SIOCSIFKPI and SIOCGIFKPI.
354 ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From
355 user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket.
356 ifk_type - The type. Types are specific to each module id.
357 ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes.
359 Copying data between user space and kernel space is done using copyin
360 and copyout. A process may be running in 64bit mode. In such a case,
361 the pointer will be a 64bit pointer, not a 32bit pointer. The following
362 sample is a safe way to copy the data in to the kernel from either a
363 32bit or 64bit process:
366 if (IS_64BIT_PROCESS(current_proc())) {
367 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64);
370 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr);
372 error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer);
376 unsigned int ifk_module_id
;
377 unsigned int ifk_type
;
387 /* Wake capabilities of a interface */
388 #define IF_WAKE_ON_MAGIC_PACKET 0x01
389 #ifdef KERNEL_PRIVATE
390 #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET
391 #endif /* KERNEL_PRIVATE */
397 * Interface request structure used for socket
398 * ioctl's. All interface ioctl's must have parameter
399 * definitions which begin with ifr_name. The
400 * remainder may be interface specific.
404 #define IFNAMSIZ IF_NAMESIZE
406 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
408 struct sockaddr ifru_addr
;
409 struct sockaddr ifru_dstaddr
;
410 struct sockaddr ifru_broadaddr
;
418 #ifdef KERNEL_PRIVATE
419 u_int64_t ifru_data64
; /* 64-bit ifru_data */
420 #endif /* KERNEL_PRIVATE */
421 struct ifdevmtu ifru_devmtu
;
422 struct ifkpi ifru_kpi
;
423 u_int32_t ifru_wake_flags
;
424 u_int32_t ifru_route_refcnt
;
426 int ifru_link_quality_metric
;
432 #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001
434 } ifru_opportunistic
;
435 u_int64_t ifru_eflags
;
439 #define IFRLOGF_DLIL 0x00000001
440 #define IFRLOGF_FAMILY 0x00010000
441 #define IFRLOGF_DRIVER 0x01000000
442 #define IFRLOGF_FIRMWARE 0x10000000
443 int32_t ifl_category
;
444 #define IFRLOGCAT_CONNECTIVITY 1
445 #define IFRLOGCAT_QUALITY 2
446 #define IFRLOGCAT_PERFORMANCE 3
447 int32_t ifl_subcategory
;
449 u_int32_t ifru_delegated
;
453 #define IFRTYPE_FAMILY_ANY 0
454 #define IFRTYPE_FAMILY_LOOPBACK 1
455 #define IFRTYPE_FAMILY_ETHERNET 2
456 #define IFRTYPE_FAMILY_SLIP 3
457 #define IFRTYPE_FAMILY_TUN 4
458 #define IFRTYPE_FAMILY_VLAN 5
459 #define IFRTYPE_FAMILY_PPP 6
460 #define IFRTYPE_FAMILY_PVC 7
461 #define IFRTYPE_FAMILY_DISC 8
462 #define IFRTYPE_FAMILY_MDECAP 9
463 #define IFRTYPE_FAMILY_GIF 10
464 #define IFRTYPE_FAMILY_FAITH 11
465 #define IFRTYPE_FAMILY_STF 12
466 #define IFRTYPE_FAMILY_FIREWIRE 13
467 #define IFRTYPE_FAMILY_BOND 14
468 #define IFRTYPE_FAMILY_CELLULAR 15
469 uint32_t ift_subfamily
;
470 #define IFRTYPE_SUBFAMILY_ANY 0
471 #define IFRTYPE_SUBFAMILY_USB 1
472 #define IFRTYPE_SUBFAMILY_BLUETOOTH 2
473 #define IFRTYPE_SUBFAMILY_WIFI 3
474 #define IFRTYPE_SUBFAMILY_THUNDERBOLT 4
475 #define IFRTYPE_SUBFAMILY_RESERVED 5
476 #define IFRTYPE_SUBFAMILY_INTCOPROC 6
479 u_int32_t ifru_functional_type
;
480 #define IFRTYPE_FUNCTIONAL_UNKNOWN 0
481 #define IFRTYPE_FUNCTIONAL_LOOPBACK 1
482 #define IFRTYPE_FUNCTIONAL_WIRED 2
483 #define IFRTYPE_FUNCTIONAL_WIFI_INFRA 3
484 #define IFRTYPE_FUNCTIONAL_WIFI_AWDL 4
485 #define IFRTYPE_FUNCTIONAL_CELLULAR 5
486 #define IFRTYPE_FUNCTIONAL_INTCOPROC 6
487 #define IFRTYPE_FUNCTIONAL_LAST 6
489 u_int32_t ifru_expensive
;
495 struct if_interface_state ifru_interface_state
;
496 u_int32_t ifru_probe_connectivity
;
497 u_int32_t ifru_ecn_mode
;
498 #define IFRTYPE_ECN_DEFAULT 0
499 #define IFRTYPE_ECN_ENABLE 1
500 #define IFRTYPE_ECN_DISABLE 2
501 u_int32_t ifru_qosmarking_mode
;
502 #define IFRTYPE_QOSMARKING_MODE_NONE 0
503 #define IFRTYPE_QOSMARKING_FASTLANE 1
504 u_int32_t ifru_qosmarking_enabled
;
505 u_int32_t ifru_disable_output
;
506 u_int32_t ifru_low_internet
;
507 #define IFRTYPE_LOW_INTERNET_DISABLE_UL_DL 0x0000
508 #define IFRTYPE_LOW_INTERNET_ENABLE_UL 0x0001
509 #define IFRTYPE_LOW_INTERNET_ENABLE_DL 0x0002
510 int ifru_low_power_mode
;
513 #define ifr_addr ifr_ifru.ifru_addr /* address */
514 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
515 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
517 #define ifr_flags ifr_ifru.ifru_flags /* flags */
519 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
520 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
521 #endif /* __APPLE__ */
522 #define ifr_metric ifr_ifru.ifru_metric /* metric */
523 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
524 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
525 #define ifr_media ifr_ifru.ifru_media /* physical media */
526 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
527 #define ifr_devmtu ifr_ifru.ifru_devmtu
528 #define ifr_intval ifr_ifru.ifru_intval /* integer value */
529 #ifdef KERNEL_PRIVATE
530 #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */
531 #endif /* KERNEL_PRIVATE */
532 #define ifr_kpi ifr_ifru.ifru_kpi
533 #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */
534 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */
536 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
538 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
539 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
541 #define ifr_opportunistic ifr_ifru.ifru_opportunistic
542 #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */
543 #define ifr_log ifr_ifru.ifru_log /* logging level/flags */
544 #define ifr_delegated ifr_ifru.ifru_delegated /* delegated interface index */
545 #define ifr_expensive ifr_ifru.ifru_expensive
546 #define ifr_type ifr_ifru.ifru_type /* interface type */
547 #define ifr_functional_type ifr_ifru.ifru_functional_type
548 #define ifr_2kcl ifr_ifru.ifru_2kcl
549 #define ifr_start_delay_qlen ifr_ifru.ifru_start_delay.qlen
550 #define ifr_start_delay_timeout ifr_ifru.ifru_start_delay.timeout
551 #define ifr_interface_state ifr_ifru.ifru_interface_state
552 #define ifr_probe_connectivity ifr_ifru.ifru_probe_connectivity
553 #define ifr_ecn_mode ifr_ifru.ifru_ecn_mode
554 #define ifr_qosmarking_mode ifr_ifru.ifru_qosmarking_mode
555 #define ifr_fastlane_capable ifr_qosmarking_mode
556 #define ifr_qosmarking_enabled ifr_ifru.ifru_qosmarking_enabled
557 #define ifr_fastlane_enabled ifr_qosmarking_enabled
558 #define ifr_disable_output ifr_ifru.ifru_disable_output
559 #define ifr_low_internet ifr_ifru.ifru_low_internet
560 #define ifr_low_power_mode ifr_ifru.ifru_low_power_mode
565 #define _SIZEOF_ADDR_IFREQ(ifr) \
566 ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \
567 (sizeof (struct ifreq) - sizeof (struct sockaddr) + \
568 (ifr).ifr_addr.sa_len) : sizeof (struct ifreq))
571 char ifra_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
572 struct sockaddr ifra_addr
;
573 struct sockaddr ifra_broadaddr
;
574 struct sockaddr ifra_mask
;
577 struct rslvmulti_req
{
579 struct sockaddr
**llsa
;
582 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
586 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
587 int ifm_current
; /* current media options */
588 int ifm_mask
; /* don't care mask */
589 int ifm_status
; /* media status */
590 int ifm_active
; /* active options */
591 int ifm_count
; /* # entries in ifm_ulist array */
592 int *ifm_ulist
; /* media words */
596 #endif /* !KERNEL || KERNEL_PRIVATE */
598 #ifdef KERNEL_PRIVATE
600 struct ifmediareq64
{
601 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
602 int ifm_current
; /* current media options */
603 int ifm_mask
; /* don't care mask */
604 int ifm_status
; /* media status */
605 int ifm_active
; /* active options */
606 int ifm_count
; /* # entries in ifm_ulist array */
607 user64_addr_t ifmu_ulist
__attribute__((aligned(8)));
610 struct ifmediareq32
{
611 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
612 int ifm_current
; /* current media options */
613 int ifm_mask
; /* don't care mask */
614 int ifm_status
; /* media status */
615 int ifm_active
; /* active options */
616 int ifm_count
; /* # entries in ifm_ulist array */
617 user32_addr_t ifmu_ulist
; /* 32-bit pointer */
620 #endif /* KERNEL_PRIVATE */
625 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
626 unsigned long ifd_cmd
;
627 size_t ifd_len
; /* length of ifd_data buffer */
632 #ifdef KERNEL_PRIVATE
635 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
638 user32_addr_t ifd_data
;
642 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
645 user64_addr_t ifd_data
;
648 #endif /* KERNEL_PRIVATE */
651 * Structure used to retrieve aux status data from interfaces.
652 * Kernel suppliers to this interface should respect the formatting
653 * needed by ifconfig(8): each line starts with a TAB and ends with
657 #define IFSTATMAX 800 /* 10 lines of text */
659 char ifs_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
660 char ascii
[IFSTATMAX
+ 1];
663 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
665 * Structure used in SIOCGIFCONF request.
666 * Used to retrieve interface configuration
667 * for machine (useful for programs which
668 * must know all networks accessible).
672 int ifc_len
; /* size of associated buffer */
675 struct ifreq
*ifcu_req
;
679 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
680 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
681 #endif /* !KERNEL || KERNEL_PRIVATE */
683 #if defined(KERNEL_PRIVATE)
686 int ifc_len
; /* size of associated buffer */
688 user32_addr_t ifcu_req
;
693 int ifc_len
; /* size of associated buffer */
695 user64_addr_t ifcu_req
__attribute__((aligned(8)));
699 #endif /* KERNEL_PRIVATE */
702 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
704 struct kev_dl_proto_data
{
705 struct net_event_data link_data
;
706 u_int32_t proto_family
;
707 u_int32_t proto_remaining_count
;
712 * Link Quality Metrics
714 * IFNET_LQM_THRESH_OFF Metric is not available; device is off.
715 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known.
716 * IFNET_LQM_THRESH_BAD Link quality is considered bad by driver.
717 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver.
718 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver.
721 IFNET_LQM_THRESH_OFF
= (-2),
722 IFNET_LQM_THRESH_UNKNOWN
= (-1),
723 IFNET_LQM_THRESH_ABORT
= 10,
724 IFNET_LQM_THRESH_MINIMALLY_VIABLE
= 20,
725 IFNET_LQM_THRESH_POOR
= 50,
726 IFNET_LQM_THRESH_GOOD
= 100
728 #define IFNET_LQM_THRESH_BAD IFNET_LQM_THRESH_ABORT
730 #ifdef XNU_KERNEL_PRIVATE
731 #define IFNET_LQM_MIN IFNET_LQM_THRESH_OFF
732 #define IFNET_LQM_MAX IFNET_LQM_THRESH_GOOD
733 #endif /* XNU_KERNEL_PRIVATE */
736 * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure
738 struct kev_dl_link_quality_metric_data
{
739 struct net_event_data link_data
;
740 int link_quality_metric
;
743 #define IF_DESCSIZE 128
746 * Structure for SIOC[SG]IFDESC
749 char ifdr_name
[IFNAMSIZ
]; /* interface name */
750 u_int32_t ifdr_len
; /* up to IF_DESCSIZE */
751 u_int8_t ifdr_desc
[IF_DESCSIZE
]; /* opaque data */
755 * Output packet scheduling models
757 * IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model
758 * where the driver or media does not require strict scheduling
759 * strategy, and that the networking stack is free to choose the
760 * most appropriate scheduling and queueing algorithm, including
762 * IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet
763 * scheduling model where the driver or media requires strict
764 * scheduling strategy (e.g. 802.11 WMM), and that the networking
765 * stack is only responsible for creating multiple queues for the
766 * corresponding service classes.
769 IFNET_SCHED_MODEL_NORMAL
= 0,
770 IFNET_SCHED_MODEL_DRIVER_MANAGED
= 1,
771 IFNET_SCHED_MODEL_FQ_CODEL
= 2,
772 #ifdef XNU_KERNEL_PRIVATE
773 IFNET_SCHED_MODEL_MAX
= 3,
774 #endif /* XNU_KERNEL_PRIVATE */
778 * Values for iflpr_flags
780 #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */
781 #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */
784 * Structure for SIOCGIFLINKPARAMS
786 struct if_linkparamsreq
{
787 char iflpr_name
[IFNAMSIZ
]; /* interface name */
788 u_int32_t iflpr_flags
;
789 u_int32_t iflpr_output_sched
;
790 u_int64_t iflpr_output_tbr_rate
;
791 u_int32_t iflpr_output_tbr_percent
;
792 u_int64_t iflpr_input_tbr_rate
;
793 struct if_bandwidths iflpr_output_bw
;
794 struct if_bandwidths iflpr_input_bw
;
795 struct if_latencies iflpr_output_lt
;
796 struct if_latencies iflpr_input_lt
;
800 * Structure for SIOCGIFQUEUESTATS
802 struct if_qstatsreq
{
803 char ifqr_name
[IFNAMSIZ
]; /* interface name */
805 void *ifqr_buf
__attribute__((aligned(8)));
806 int ifqr_len
__attribute__((aligned(8)));
810 * Node Proximity Metrics
813 IFNET_NPM_THRESH_UNKNOWN
= (-1),
814 IFNET_NPM_THRESH_NEAR
= 30,
815 IFNET_NPM_THRESH_GENERAL
= 70,
816 IFNET_NPM_THRESH_FAR
= 100,
820 * Received Signal Strength Indication [special values]
822 * IFNET_RSSI_UNKNOWN Metric is not (yet) known.
825 IFNET_RSSI_UNKNOWN
= ((-2147483647)-1), /* INT32_MIN */
830 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
832 struct kev_dl_node_presence
{
833 struct net_event_data link_data
;
834 struct sockaddr_in6 sin6_node_address
;
835 struct sockaddr_dl sdl_node_address
;
837 int link_quality_metric
;
838 int node_proximity_metric
;
839 u_int8_t node_service_info
[48];
842 struct kev_dl_node_absence
{
843 struct net_event_data link_data
;
844 struct sockaddr_in6 sin6_node_address
;
845 struct sockaddr_dl sdl_node_address
;
849 * Structure for SIOC[SG]IFTHROTTLE
851 struct if_throttlereq
{
852 char ifthr_name
[IFNAMSIZ
]; /* interface name */
853 u_int32_t ifthr_level
;
857 * Interface throttling levels
859 * IFNET_THROTTLE_OFF The default throttling level (no throttling.)
860 * All service class queues operate normally according to the
861 * standard packet scheduler configuration.
862 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
863 * are responsible for managing "opportunistic" traffics are
864 * suspended. Packets enqueued on those queues will be dropped
865 * and a flow advisory error will be generated to the data
866 * source. Existing packets in the queues will stay enqueued
867 * until the interface is no longer throttled, or until they
868 * are explicitly flushed.
871 IFNET_THROTTLE_OFF
= 0,
872 IFNET_THROTTLE_OPPORTUNISTIC
= 1,
873 #ifdef XNU_KERNEL_PRIVATE
874 IFNET_THROTTLE_MAX
= 2,
875 #endif /* XNU_KERNEL_PRIVATE */
879 * Structure for SIOC[A/D]IFAGENTID
881 struct if_agentidreq
{
882 char ifar_name
[IFNAMSIZ
]; /* interface name */
883 uuid_t ifar_uuid
; /* agent UUID to add or delete */
887 * Structure for SIOCGIFAGENTIDS
889 struct if_agentidsreq
{
890 char ifar_name
[IFNAMSIZ
]; /* interface name */
891 u_int32_t ifar_count
; /* number of agent UUIDs */
892 uuid_t
*ifar_uuids
; /* array of agent UUIDs */
895 #ifdef BSD_KERNEL_PRIVATE
896 struct if_agentidsreq32
{
897 char ifar_name
[IFNAMSIZ
];
898 u_int32_t ifar_count
;
899 user32_addr_t ifar_uuids
;
901 struct if_agentidsreq64
{
902 char ifar_name
[IFNAMSIZ
];
903 u_int32_t ifar_count
;
904 user64_addr_t ifar_uuids
__attribute__((aligned(8)));
906 #endif /* BSD_KERNEL_PRIVATE */
909 * Structure for SIOCGIFNEXUS
912 char ifnr_name
[IFNAMSIZ
]; /* interface name */
913 uint64_t ifnr_flags
; /* unused, must be zero */
914 uuid_t ifnr_netif
; /* netif nexus instance UUID */
915 uuid_t ifnr_multistack
; /* multistack nexus UUID */
916 uint64_t ifnr_reserved
[5];
919 #define DLIL_MODIDLEN 20 /* same as IFNET_MODIDLEN */
920 #define DLIL_MODARGLEN 12 /* same as IFNET_MODARGLEN */
923 * DLIL KEV_DL_ISSUES event structure
925 struct kev_dl_issues
{
926 struct net_event_data link_data
;
927 u_int8_t modid
[DLIL_MODIDLEN
];
929 u_int8_t info
[DLIL_MODARGLEN
];
933 * DLIL KEV_DL_RRC_STATE_CHANGED structure
935 struct kev_dl_rrc_state
{
936 struct net_event_data link_data
;
941 * KEV_DL_LOW_POWER_MODE_CHANGED
943 struct kev_dl_low_power_mode
{
944 struct net_event_data link_data
;
949 * Length of network signature/fingerprint blob.
951 #define IFNET_SIGNATURELEN 20
954 * Structure for SIOC[S/G]IFNETSIGNATURE
957 char ifnsr_name
[IFNAMSIZ
];
958 u_int8_t ifnsr_family
; /* address family */
959 u_int8_t ifnsr_len
; /* data length */
960 u_int16_t ifnsr_flags
; /* for future */
961 u_int8_t ifnsr_data
[IFNET_SIGNATURELEN
];
965 #define NAT64_PREFIX_LEN_32 4
966 #define NAT64_PREFIX_LEN_40 5
967 #define NAT64_PREFIX_LEN_48 6
968 #define NAT64_PREFIX_LEN_56 7
969 #define NAT64_PREFIX_LEN_64 8
970 #define NAT64_PREFIX_LEN_96 12
971 #define NAT64_PREFIX_LEN_MAX NAT64_PREFIX_LEN_96
973 #define NAT64_MAX_NUM_PREFIXES 4
976 struct in6_addr ipv6_prefix
;
980 struct if_ipv6_address
{
981 struct in6_addr v6_address
;
982 uint32_t v6_prefixlen
;
985 /* Structure for SIOC[S/G]IFNAT64PREFIX */
987 char ifnat64_name
[IFNAMSIZ
];
988 struct ipv6_prefix ifnat64_prefixes
[NAT64_MAX_NUM_PREFIXES
];
991 /* Structure for SIOCGIFCLAT46ADDR */
992 struct if_clat46req
{
993 char ifclat46_name
[IFNAMSIZ
];
994 struct if_ipv6_address ifclat46_addr
;
998 * Structure for SIOC[S/G]IFORDER
1000 * When setting, ifo_count is the number of u_int32_t interface indices
1001 * in the ifo_ordered_indices array.
1003 * When getting, if ifo_count is 0, the length of the ordered list will
1004 * be returned. If the ifo_count is non-0, it is the number of u_int32_t
1005 * interface indices allocated. Upon return, ifo_count will contain the number
1006 * of indices copied into the array.
1009 u_int32_t ifo_count
;
1010 u_int32_t ifo_reserved
;
1011 mach_vm_address_t ifo_ordered_indices
; /* array of u_int32_t */
1015 * Struct for traffic class to DSCP mapping
1018 char iftdm_name
[IFNAMSIZ
];
1019 u_int32_t iftdm_len
; /* byte length of the table */
1020 struct netsvctype_dscp_map
*iftdm_table
;
1023 #ifdef BSD_KERNEL_PRIVATE
1024 struct if_tdmreq32
{
1025 char iftdm_name
[IFNAMSIZ
];
1026 u_int32_t iftdm_len
; /* byte length of the table */
1027 user32_addr_t iftdm_table
;
1030 struct if_tdmreq64
{
1031 char iftdm_name
[IFNAMSIZ
];
1032 u_int32_t iftdm_len
; /* byte length of the table */
1033 user64_addr_t iftdm_table
__attribute__((aligned(8)));
1038 * Structure for SIOCGIFPROTOLIST.
1040 struct if_protolistreq
{
1041 char ifpl_name
[IFNAMSIZ
];
1042 u_int32_t ifpl_count
;
1043 u_int32_t ifpl_reserved
; /* must be zero */
1044 u_int32_t
*ifpl_list
;
1047 #ifdef BSD_KERNEL_PRIVATE
1048 struct if_protolistreq32
{
1049 char ifpl_name
[IFNAMSIZ
];
1050 u_int32_t ifpl_count
;
1051 u_int32_t ifpl_reserved
; /* must be zero */
1052 user32_addr_t ifpl_list
;
1055 struct if_protolistreq64
{
1056 char ifpl_name
[IFNAMSIZ
];
1057 u_int32_t ifpl_count
;
1058 u_int32_t ifpl_reserved
; /* must be zero */
1059 user64_addr_t ifpl_list
;
1061 #endif /* BSD_KERNEL_PRIVATE */
1063 #endif /* PRIVATE */
1066 #ifdef MALLOC_DECLARE
1067 MALLOC_DECLARE(M_IFADDR
);
1068 MALLOC_DECLARE(M_IFMADDR
);
1071 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
1074 struct if_nameindex
{
1075 unsigned int if_index
; /* 1, 2, ... */
1076 char *if_name
; /* null terminated name: "le0", ... */
1080 unsigned int if_nametoindex(const char *);
1081 char *if_indextoname(unsigned int, char *);
1082 struct if_nameindex
*if_nameindex(void);
1083 void if_freenameindex(struct if_nameindex
*);
1088 #include <net/kpi_interface.h>
1091 #endif /* !_NET_IF_H_ */