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