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