xref: /xnu-10002.61.3/bsd/net/if_private.h (revision 0f4c859e951fba394238ab619495c4e1d54d0f34)
1 /*
2  * Copyright (c) 2000-2023 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * Copyright (c) 1982, 1986, 1989, 1993
30  *    The Regents of the University of California.  All rights reserved.
31  *
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions
34  * are met:
35  * 1. Redistributions of source code must retain the above copyright
36  *    notice, this list of conditions and the following disclaimer.
37  * 2. Redistributions in binary form must reproduce the above copyright
38  *    notice, this list of conditions and the following disclaimer in the
39  *    documentation and/or other materials provided with the distribution.
40  * 3. All advertising materials mentioning features or use of this software
41  *    must display the following acknowledgement:
42  *    This product includes software developed by the University of
43  *    California, Berkeley and its contributors.
44  * 4. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  *    @(#)if.h    8.1 (Berkeley) 6/10/93
61  */
62 
63 #ifndef _NET_IF_PRIVATE_H_
64 #define _NET_IF_PRIVATE_H_
65 
66 #include <mach/vm_types.h>
67 #include <net/if.h>
68 #include <net/if_dl.h>
69 #include <net/if_var.h>
70 #include <net/if_var_private.h>
71 #include <netinet/in.h>
72 #include <sys/types.h>
73 #include <uuid/uuid.h>
74 
75 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
76 #ifndef DRIVERKIT
77 #ifdef KERNEL_PRIVATE
78 #define IF_MAXUNIT      0x7fff  /* historical value */
79 
80 struct if_clonereq64 {
81 	int     ifcr_total;                 /* total cloners (out) */
82 	int     ifcr_count;                 /* room for this many in user buffer */
83 	user64_addr_t ifcru_buffer      __attribute__((aligned(8)));
84 };
85 
86 struct if_clonereq32 {
87 	int     ifcr_total;                 /* total cloners (out) */
88 	int     ifcr_count;                 /* room for this many in user buffer */
89 	user32_addr_t ifcru_buffer;
90 };
91 #endif /* KERNEL_PRIVATE */
92 
93 /* extended flags definitions:  (all bits reserved for internal/future use) */
94 #define IFEF_AUTOCONFIGURING    0x00000001      /* allow BOOTP/DHCP replies to enter */
95 #define IFEF_ENQUEUE_MULTI      0x00000002      /* enqueue multiple packets at once */
96 #define IFEF_DELAY_START        0x00000004      /* delay start callback */
97 #define IFEF_PROBE_CONNECTIVITY 0x00000008      /* Probe connections going over this interface */
98 #define IFEF_ADV_REPORT         0x00000010      /* Supports interface advisory report */
99 #define IFEF_IPV6_DISABLED      0x00000020      /* coupled to ND6_IFF_IFDISABLED */
100 #define IFEF_ACCEPT_RTADV       0x00000040      /* accepts IPv6 RA on the interface */
101 #define IFEF_TXSTART            0x00000080      /* has start callback */
102 #define IFEF_RXPOLL             0x00000100      /* supports opportunistic input poll */
103 #define IFEF_VLAN               0x00000200      /* interface has one or more vlans */
104 #define IFEF_BOND               0x00000400      /* interface is part of bond */
105 #define IFEF_ARPLL              0x00000800      /* ARP for IPv4LL addresses */
106 #define IFEF_CLAT46             0x00001000      /* CLAT46 RFC 6877 */
107 
108 #define IS_INTF_CLAT46(ifp)     ((ifp) != NULL && ((ifp)->if_eflags & IFEF_CLAT46))
109 #define INTF_ADJUST_MTU_FOR_CLAT46(intf)                \
110     (IS_INTF_CLAT46((intf)) ||                          \
111      IS_INTF_CLAT46((intf)->if_delegated.ifp))          \
112 
113 /*
114  * XXX IFEF_NOAUTOIPV6LL is deprecated and should be done away with.
115  * Configd pretty much manages the interface configuration.
116  * Rather than looking at the flag we check if a specific LLA
117  * has to be configured or the IID has to be generated by kernel.
118  */
119 #define IFEF_NOAUTOIPV6LL       0x00002000      /* Need explicit IPv6 LL address */
120 #define IFEF_EXPENSIVE          0x00004000      /* Data access has a cost */
121 #define IFEF_IPV4_ROUTER        0x00008000      /* interior when in IPv4 router mode */
122 #define IFEF_CLONE              0x00010000      /* created using if_clone */
123 #define IFEF_LOCALNET_PRIVATE   0x00020000      /* local private network */
124 #define IFEF_SERVICE_TRIGGERED  IFEF_LOCALNET_PRIVATE
125 #define IFEF_IPV6_ND6ALT        0x00040000      /* alternative. KPI for ND6 */
126 #define IFEF_RESTRICTED_RECV    0x00080000      /* interface restricts inbound pkts */
127 #define IFEF_AWDL               0x00100000      /* Apple Wireless Direct Link */
128 #define IFEF_NOACKPRI           0x00200000      /* No TCP ACK prioritization */
129 #define IFEF_AWDL_RESTRICTED    0x00400000      /* Restricted AWDL mode */
130 #define IFEF_2KCL               0x00800000      /* prefers 2K cluster (socket based tunnel) */
131 #define IFEF_ECN_ENABLE         0x01000000      /* use ECN for TCP connections on the interface */
132 #define IFEF_ECN_DISABLE        0x02000000      /* do not use ECN for TCP connections on the interface */
133 #define IFEF_SKYWALK_NATIVE     0x04000000      /* Native Skywalk support */
134 #define IFEF_3CA                0x08000000      /* Capable of 3CA */
135 #define IFEF_SENDLIST           0x10000000      /* Supports tx packet lists */
136 #define IFEF_DIRECTLINK         0x20000000      /* point-to-point topology */
137 #define IFEF_QOSMARKING_ENABLED 0x40000000      /* QoS marking is enabled */
138 #define IFEF_UPDOWNCHANGE       0x80000000      /* up/down state is changing */
139 
140 #ifdef XNU_KERNEL_PRIVATE
141 /*
142  * Extra flags
143  */
144 #define IFXF_WAKE_ON_MAGIC_PACKET       0x00000001 /* wake on magic packet */
145 #define IFXF_TIMESTAMP_ENABLED          0x00000002 /* time stamping enabled */
146 #define IFXF_NX_NOAUTO                  0x00000004 /* no auto config nexus */
147 #define IFXF_LEGACY                     0x00000008 /* legacy (non-netif) mode */
148 #define IFXF_LOW_INTERNET_UL            0x00000010 /* Uplink Low Internet is confirmed */
149 #define IFXF_LOW_INTERNET_DL            0x00000020 /* Downlink Low Internet is confirmed */
150 #define IFXF_ALLOC_KPI                  0x00000040 /* Allocated via the ifnet_alloc KPI */
151 #define IFXF_LOW_POWER                  0x00000080 /* Low Power Mode */
152 #define IFXF_MPK_LOG                    0x00000100 /* Multi-layer Packet Logging */
153 #define IFXF_CONSTRAINED                0x00000200 /* Constrained - Save Data Mode */
154 #define IFXF_LOW_LATENCY                0x00000400 /* Low latency interface */
155 #define IFXF_MARK_WAKE_PKT              0x00000800 /* Mark next input packet as wake packet */
156 #define IFXF_FAST_PKT_DELIVERY          0x00001000 /* Fast Packet Delivery */
157 #define IFXF_NO_TRAFFIC_SHAPING         0x00002000 /* Skip dummynet and netem traffic shaping */
158 #define IFXF_MANAGEMENT                 0x00004000 /* Management interface */
159 
160 /*
161  * Current requirements for an AWDL interface.  Setting/clearing IFEF_AWDL
162  * will also trigger the setting/clearing of the rest of the flags.  Once
163  * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
164  */
165 #define IFEF_AWDL_MASK \
166     (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
167     IFEF_AWDL)
168 #endif /* XNU_KERNEL_PRIVATE */
169 
170 #ifdef KERNEL_PRIVATE
171 /*
172  * !!! NOTE !!!
173  *
174  * if_idle_flags definitions: (all bits are reserved for internal/future
175  * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
176  * KPI due to the associated reference counting.  Clearing them may be done by
177  * calling the KPI, otherwise implicitly at interface detach time.  Setting
178  * the if_idle_flags field to a non-zero value will cause the networking
179  * stack to aggressively purge expired objects (routes, etc.)
180  */
181 #define IFRF_IDLE_NOTIFY        0x1     /* Generate notifications on idle */
182 
183 /* flags set internally only: */
184 #define IFF_CANTCHANGE \
185     (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
186 	IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
187 
188 #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET
189 #endif /* KERNEL_PRIVATE */
190 
191 #ifdef IFREQ_OPAQUE
192 /*
193  * This is the private version of the ifreq structure, the
194  * public version lives in if.h. If you make any changes
195  * here, you probably also need to make them in if.h!
196  */
197 struct  ifreq {
198 	char    ifr_name[IFNAMSIZ];         /* if name, e.g. "en0" */
199 	union {
200 		struct  sockaddr ifru_addr;
201 		struct  sockaddr ifru_dstaddr;
202 		struct  sockaddr ifru_broadaddr;
203 		short   ifru_flags;
204 		int     ifru_metric;
205 		int     ifru_mtu;
206 		int     ifru_phys;
207 		int     ifru_media;
208 		int     ifru_intval;
209 		caddr_t ifru_data;
210 #ifdef KERNEL_PRIVATE
211 		u_int64_t ifru_data64; /* 64-bit ifru_data */
212 #endif /* KERNEL_PRIVATE */
213 		struct  ifdevmtu ifru_devmtu;
214 		struct  ifkpi   ifru_kpi;
215 		u_int32_t ifru_wake_flags;
216 		u_int32_t ifru_route_refcnt;
217 		int     ifru_link_quality_metric;
218 		int     ifru_cap[2];
219 		struct {
220 			uint32_t        ifo_flags;
221 #define IFRIFOF_BLOCK_OPPORTUNISTIC     0x00000001
222 			uint32_t        ifo_inuse;
223 		} ifru_opportunistic;
224 		u_int64_t ifru_eflags;
225 		u_int64_t ifru_xflags;
226 		struct {
227 			int32_t         ifl_level;
228 			uint32_t        ifl_flags;
229 #define IFRLOGF_DLIL                    0x00000001
230 #define IFRLOGF_FAMILY                  0x00010000
231 #define IFRLOGF_DRIVER                  0x01000000
232 #define IFRLOGF_FIRMWARE                0x10000000
233 			int32_t         ifl_category;
234 #define IFRLOGCAT_CONNECTIVITY          1
235 #define IFRLOGCAT_QUALITY               2
236 #define IFRLOGCAT_PERFORMANCE           3
237 			int32_t         ifl_subcategory;
238 		} ifru_log;
239 		u_int32_t ifru_delegated;
240 		struct {
241 			uint32_t        ift_type;
242 			uint32_t        ift_family;
243 #define IFRTYPE_FAMILY_ANY              0
244 #define IFRTYPE_FAMILY_LOOPBACK         1
245 #define IFRTYPE_FAMILY_ETHERNET         2
246 #define IFRTYPE_FAMILY_SLIP             3
247 #define IFRTYPE_FAMILY_TUN              4
248 #define IFRTYPE_FAMILY_VLAN             5
249 #define IFRTYPE_FAMILY_PPP              6
250 #define IFRTYPE_FAMILY_PVC              7
251 #define IFRTYPE_FAMILY_DISC             8
252 #define IFRTYPE_FAMILY_MDECAP           9
253 #define IFRTYPE_FAMILY_GIF              10
254 #define IFRTYPE_FAMILY_FAITH            11
255 #define IFRTYPE_FAMILY_STF              12
256 #define IFRTYPE_FAMILY_FIREWIRE         13
257 #define IFRTYPE_FAMILY_BOND             14
258 #define IFRTYPE_FAMILY_CELLULAR         15
259 #define IFRTYPE_FAMILY_UNUSED_16        16    /* Un-used */
260 #define IFRTYPE_FAMILY_UTUN             17
261 #define IFRTYPE_FAMILY_IPSEC            18
262 			uint32_t        ift_subfamily;
263 #define IFRTYPE_SUBFAMILY_ANY           0
264 #define IFRTYPE_SUBFAMILY_USB           1
265 #define IFRTYPE_SUBFAMILY_BLUETOOTH     2
266 #define IFRTYPE_SUBFAMILY_WIFI          3
267 #define IFRTYPE_SUBFAMILY_THUNDERBOLT   4
268 #define IFRTYPE_SUBFAMILY_RESERVED      5
269 #define IFRTYPE_SUBFAMILY_INTCOPROC     6
270 #define IFRTYPE_SUBFAMILY_QUICKRELAY    7
271 #define IFRTYPE_SUBFAMILY_DEFAULT       8
272 #define IFRTYPE_SUBFAMILY_VMNET         9
273 #define IFRTYPE_SUBFAMILY_SIMCELL       10
274 #define IFRTYPE_SUBFAMILY_REDIRECT      11
275 #define IFRTYPE_SUBFAMILY_MANAGEMENT    12
276 		} ifru_type;
277 		u_int32_t ifru_functional_type;
278 #define IFRTYPE_FUNCTIONAL_UNKNOWN              0
279 #define IFRTYPE_FUNCTIONAL_LOOPBACK             1
280 #define IFRTYPE_FUNCTIONAL_WIRED                2
281 #define IFRTYPE_FUNCTIONAL_WIFI_INFRA           3
282 #define IFRTYPE_FUNCTIONAL_WIFI_AWDL            4
283 #define IFRTYPE_FUNCTIONAL_CELLULAR             5
284 #define IFRTYPE_FUNCTIONAL_INTCOPROC            6
285 #define IFRTYPE_FUNCTIONAL_COMPANIONLINK        7
286 #define IFRTYPE_FUNCTIONAL_MANAGEMENT           8
287 #define IFRTYPE_FUNCTIONAL_LAST                 8
288 		u_int32_t ifru_expensive;
289 		u_int32_t ifru_constrained;
290 		u_int32_t ifru_2kcl;
291 		struct {
292 			u_int32_t qlen;
293 			u_int32_t timeout;
294 		} ifru_start_delay;
295 		struct if_interface_state       ifru_interface_state;
296 		u_int32_t ifru_probe_connectivity;
297 		u_int32_t ifru_ecn_mode;
298 #define IFRTYPE_ECN_DEFAULT             0
299 #define IFRTYPE_ECN_ENABLE              1
300 #define IFRTYPE_ECN_DISABLE             2
301 		u_int32_t ifru_qosmarking_mode;
302 #define IFRTYPE_QOSMARKING_MODE_NONE            0
303 #define IFRTYPE_QOSMARKING_FASTLANE     1       /* supported: socket/channel */
304 #define IFRTYPE_QOSMARKING_RFC4594      2       /* supported: channel only */
305 #define IFRTYPE_QOSMARKING_CUSTOM       3       /* supported: socket/channel */
306 		u_int32_t ifru_qosmarking_enabled;
307 		u_int32_t ifru_disable_output;
308 		u_int32_t ifru_low_internet;
309 #define IFRTYPE_LOW_INTERNET_DISABLE_UL_DL      0x0000
310 #define IFRTYPE_LOW_INTERNET_ENABLE_UL          0x0001
311 #define IFRTYPE_LOW_INTERNET_ENABLE_DL          0x0002
312 		int ifru_low_power_mode;
313 		u_int32_t ifru_tcp_kao_max;
314 		int ifru_mpk_log; /* Multi Layer Packet Log */
315 		u_int32_t ifru_noack_prio;
316 		struct {
317 			u_int8_t up_bucket;
318 			u_int8_t down_bucket;
319 		} ifru_estimated_throughput;
320 		struct {
321 			u_int8_t technology;
322 			u_int8_t channel;
323 		} ifru_radio_details;
324 		uint64_t ifru_creation_generation_id;
325 	} ifr_ifru;
326 #define ifr_addr        ifr_ifru.ifru_addr      /* address */
327 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
328 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
329 #ifdef __APPLE__
330 #define ifr_flags       ifr_ifru.ifru_flags     /* flags */
331 #else
332 #define ifr_flags       ifr_ifru.ifru_flags[0]  /* flags */
333 #define ifr_prevflags   ifr_ifru.ifru_flags[1]  /* flags */
334 #endif /* __APPLE__ */
335 #define ifr_metric      ifr_ifru.ifru_metric    /* metric */
336 #define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
337 #define ifr_phys        ifr_ifru.ifru_phys      /* physical wire */
338 #define ifr_media       ifr_ifru.ifru_media     /* physical media */
339 #define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
340 #define ifr_devmtu      ifr_ifru.ifru_devmtu
341 #define ifr_intval      ifr_ifru.ifru_intval    /* integer value */
342 #ifdef KERNEL_PRIVATE
343 #define ifr_data64      ifr_ifru.ifru_data64    /* 64-bit pointer */
344 #endif /* KERNEL_PRIVATE */
345 #define ifr_kpi         ifr_ifru.ifru_kpi
346 #define ifr_wake_flags  ifr_ifru.ifru_wake_flags /* wake capabilities */
347 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */
348 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
349 #define ifr_reqcap      ifr_ifru.ifru_cap[0]    /* requested capabilities */
350 #define ifr_curcap      ifr_ifru.ifru_cap[1]    /* current capabilities */
351 #define ifr_opportunistic       ifr_ifru.ifru_opportunistic
352 #define ifr_eflags      ifr_ifru.ifru_eflags    /* extended flags  */
353 #define ifr_xflags      ifr_ifru.ifru_xflags    /* extra flags  */
354 #define ifr_log         ifr_ifru.ifru_log       /* logging level/flags */
355 #define ifr_delegated   ifr_ifru.ifru_delegated /* delegated interface index */
356 #define ifr_expensive   ifr_ifru.ifru_expensive
357 #define ifr_constrained   ifr_ifru.ifru_constrained
358 #define ifr_type        ifr_ifru.ifru_type      /* interface type */
359 #define ifr_functional_type     ifr_ifru.ifru_functional_type
360 #define ifr_2kcl        ifr_ifru.ifru_2kcl
361 #define ifr_start_delay_qlen    ifr_ifru.ifru_start_delay.qlen
362 #define ifr_start_delay_timeout ifr_ifru.ifru_start_delay.timeout
363 #define ifr_interface_state     ifr_ifru.ifru_interface_state
364 #define ifr_probe_connectivity  ifr_ifru.ifru_probe_connectivity
365 #define ifr_ecn_mode    ifr_ifru.ifru_ecn_mode
366 #define ifr_qosmarking_mode     ifr_ifru.ifru_qosmarking_mode
367 #define ifr_fastlane_capable    ifr_qosmarking_mode
368 #define ifr_qosmarking_enabled  ifr_ifru.ifru_qosmarking_enabled
369 #define ifr_fastlane_enabled    ifr_qosmarking_enabled
370 #define ifr_disable_output      ifr_ifru.ifru_disable_output
371 #define ifr_low_internet        ifr_ifru.ifru_low_internet
372 #define ifr_low_power_mode      ifr_ifru.ifru_low_power_mode
373 #define ifr_tcp_kao_max         ifr_ifru.ifru_tcp_kao_max
374 #define ifr_mpk_log             ifr_ifru.ifru_mpk_log
375 #define ifr_noack_prio          ifr_ifru.ifru_noack_prio
376 #define ifr_estimated_throughput  ifr_ifru.ifru_estimated_throughput
377 #define ifr_radio_details       ifr_ifru.ifru_radio_details
378 #define ifr_creation_generation_id       ifr_ifru.ifru_creation_generation_id
379 };
380 
381 #define _SIZEOF_ADDR_IFREQ(ifr) \
382     ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \
383     (sizeof (struct ifreq) - sizeof (struct sockaddr) + \
384     (ifr).ifr_addr.sa_len) : sizeof (struct ifreq))
385 #endif /* IFREQ_OPAQUE */
386 
387 #ifdef KERNEL_PRIVATE
388 #pragma pack(4)
389 struct ifmediareq64 {
390 	char    ifm_name[IFNAMSIZ];     /* if name, e.g. "en0" */
391 	int     ifm_current;            /* current media options */
392 	int     ifm_mask;               /* don't care mask */
393 	int     ifm_status;             /* media status */
394 	int     ifm_active;             /* active options */
395 	int     ifm_count;              /* # entries in ifm_ulist array */
396 	user64_addr_t ifmu_ulist __attribute__((aligned(8)));
397 };
398 
399 struct ifmediareq32 {
400 	char    ifm_name[IFNAMSIZ];     /* if name, e.g. "en0" */
401 	int     ifm_current;            /* current media options */
402 	int     ifm_mask;               /* don't care mask */
403 	int     ifm_status;             /* media status */
404 	int     ifm_active;             /* active options */
405 	int     ifm_count;              /* # entries in ifm_ulist array */
406 	user32_addr_t ifmu_ulist;       /* 32-bit pointer */
407 };
408 
409 struct ifdrv32 {
410 	char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
411 	u_int32_t       ifd_cmd;
412 	u_int32_t       ifd_len;
413 	user32_addr_t   ifd_data;
414 };
415 
416 struct  ifdrv64 {
417 	char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
418 	u_int64_t       ifd_cmd;
419 	u_int64_t       ifd_len;
420 	user64_addr_t   ifd_data;
421 };
422 
423 struct ifconf32 {
424 	int     ifc_len;                /* size of associated buffer */
425 	struct {
426 		user32_addr_t ifcu_req;
427 	} ifc_ifcu;
428 };
429 
430 struct ifconf64 {
431 	int     ifc_len;                /* size of associated buffer */
432 	struct {
433 		user64_addr_t ifcu_req  __attribute__((aligned(8)));
434 	} ifc_ifcu;
435 };
436 #pragma pack()
437 #endif /* KERNEL_PRIVATE */
438 
439 /*
440  * Link Quality Metrics
441  *
442  *	IFNET_LQM_THRESH_OFF      Metric is not available; device is off.
443  *	IFNET_LQM_THRESH_UNKNOWN  Metric is not (yet) known.
444  *	IFNET_LQM_THRESH_BAD	  Link quality is considered bad by driver.
445  *	IFNET_LQM_THRESH_POOR     Link quality is considered poor by driver.
446  *	IFNET_LQM_THRESH_GOOD     Link quality is considered good by driver.
447  */
448 enum {
449 	IFNET_LQM_THRESH_OFF            = (-2),
450 	IFNET_LQM_THRESH_UNKNOWN        = (-1),
451 	IFNET_LQM_THRESH_ABORT          = 10,
452 	IFNET_LQM_THRESH_MINIMALLY_VIABLE = 20,
453 	IFNET_LQM_THRESH_POOR           = 50,
454 	IFNET_LQM_THRESH_GOOD           = 100
455 };
456 #define IFNET_LQM_THRESH_BAD    IFNET_LQM_THRESH_ABORT
457 
458 #ifdef XNU_KERNEL_PRIVATE
459 #define IFNET_LQM_MIN   IFNET_LQM_THRESH_OFF
460 #define IFNET_LQM_MAX   IFNET_LQM_THRESH_GOOD
461 #endif /* XNU_KERNEL_PRIVATE */
462 
463 /*
464  * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure
465  */
466 struct kev_dl_link_quality_metric_data {
467 	struct net_event_data   link_data;
468 	int                     link_quality_metric;
469 };
470 
471 #define IF_DESCSIZE     128
472 
473 /*
474  * Structure for SIOC[SG]IFDESC
475  */
476 struct if_descreq {
477 	char                    ifdr_name[IFNAMSIZ];    /* interface name */
478 	u_int32_t               ifdr_len;               /* up to IF_DESCSIZE */
479 	u_int8_t                ifdr_desc[IF_DESCSIZE]; /* opaque data */
480 };
481 
482 /*
483  *	Output packet scheduling models
484  *
485  *	IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model
486  *		where the driver or media does not require strict scheduling
487  *		strategy, and that the networking stack is free to choose the
488  *		most appropriate scheduling and queueing algorithm, including
489  *		shaping traffics.
490  *	IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet
491  *		scheduling model where the driver or media requires strict
492  *		scheduling strategy (e.g. 802.11 WMM), and that the networking
493  *		stack is only responsible for creating multiple queues for the
494  *		corresponding service classes.
495  */
496 enum {
497 	IFNET_SCHED_MODEL_NORMAL                = 0,
498 	IFNET_SCHED_MODEL_DRIVER_MANAGED        = 1,
499 	IFNET_SCHED_MODEL_FQ_CODEL              = 2,
500 #ifdef XNU_KERNEL_PRIVATE
501 	IFNET_SCHED_MODEL_MAX                   = 3,
502 #endif /* XNU_KERNEL_PRIVATE */
503 };
504 
505 /*
506  * Values for iflpr_flags
507  */
508 #define IFLPRF_ALTQ             0x1     /* configured via PF/ALTQ */
509 #define IFLPRF_DRVMANAGED       0x2     /* output queue scheduled by drv */
510 
511 /*
512  * Structure for SIOCGIFLINKPARAMS
513  */
514 struct if_linkparamsreq {
515 	char            iflpr_name[IFNAMSIZ];   /* interface name */
516 	u_int32_t       iflpr_flags;
517 	u_int32_t       iflpr_output_sched;
518 	u_int64_t       iflpr_output_tbr_rate;
519 	u_int32_t       iflpr_output_tbr_percent;
520 	u_int64_t       iflpr_input_tbr_rate;
521 	struct if_bandwidths iflpr_output_bw;
522 	struct if_bandwidths iflpr_input_bw;
523 	struct if_latencies iflpr_output_lt;
524 	struct if_latencies iflpr_input_lt;
525 	struct if_netem_params iflpr_input_netem;
526 	struct if_netem_params iflpr_output_netem;
527 };
528 
529 /*
530  * Structure for SIOCGIFQUEUESTATS
531  */
532 struct if_qstatsreq {
533 	char            ifqr_name[IFNAMSIZ];    /* interface name */
534 	u_int32_t       ifqr_grp_idx;
535 	u_int32_t       ifqr_slot;
536 	void            *ifqr_buf               __attribute__((aligned(8)));
537 	int              ifqr_len               __attribute__((aligned(8)));
538 };
539 
540 /*
541  * Node Proximity Metrics
542  */
543 enum {
544 	IFNET_NPM_THRESH_UNKNOWN        = (-1),
545 	IFNET_NPM_THRESH_NEAR           = 30,
546 	IFNET_NPM_THRESH_GENERAL        = 70,
547 	IFNET_NPM_THRESH_FAR            = 100,
548 };
549 
550 /*
551  *	Received Signal Strength Indication [special values]
552  *
553  *	IFNET_RSSI_UNKNOWN	Metric is not (yet) known.
554  */
555 enum {
556 	IFNET_RSSI_UNKNOWN      = ((-2147483647) - 1),    /* INT32_MIN */
557 };
558 
559 
560 #if !__has_ptrcheck
561 /*
562  * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
563  */
564 struct kev_dl_node_presence {
565 	struct net_event_data   link_data;
566 	struct sockaddr_in6     sin6_node_address;
567 	struct sockaddr_dl      sdl_node_address;
568 	int32_t                 rssi;
569 	int                     link_quality_metric;
570 	int                     node_proximity_metric;
571 	u_int8_t                node_service_info[48];
572 };
573 
574 struct kev_dl_node_absence {
575 	struct net_event_data   link_data;
576 	struct sockaddr_in6     sin6_node_address;
577 	struct sockaddr_dl      sdl_node_address;
578 };
579 #endif
580 
581 /*
582  * Structure for SIOC[SG]IFTHROTTLE
583  */
584 struct if_throttlereq {
585 	char            ifthr_name[IFNAMSIZ];   /* interface name */
586 	u_int32_t       ifthr_level;
587 };
588 
589 /*
590  *	Interface throttling levels
591  *
592  *	IFNET_THROTTLE_OFF The default throttling level (no throttling.)
593  *		All service class queues operate normally according to the
594  *		standard packet scheduler configuration.
595  *	IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
596  *		are responsible for managing "opportunistic" traffics are
597  *		suspended.  Packets enqueued on those queues will be dropped
598  *		and a flow advisory error will be generated to the data
599  *		source.  Existing packets in the queues will stay enqueued
600  *		until the interface is no longer throttled, or until they
601  *		are explicitly flushed.
602  */
603 enum {
604 	IFNET_THROTTLE_OFF                      = 0,
605 	IFNET_THROTTLE_OPPORTUNISTIC            = 1,
606 #ifdef XNU_KERNEL_PRIVATE
607 	IFNET_THROTTLE_MAX                      = 2,
608 #endif /* XNU_KERNEL_PRIVATE */
609 };
610 
611 /*
612  * Structure for SIOC[A/D]IFAGENTID
613  */
614 struct if_agentidreq {
615 	char            ifar_name[IFNAMSIZ];    /* interface name */
616 	uuid_t          ifar_uuid;              /* agent UUID to add or delete */
617 };
618 
619 /*
620  * Structure for SIOCGIFAGENTIDS
621  */
622 struct if_agentidsreq {
623 	char            ifar_name[IFNAMSIZ];    /* interface name */
624 	u_int32_t       ifar_count;             /* number of agent UUIDs */
625 	uuid_t          *ifar_uuids;            /* array of agent UUIDs */
626 };
627 
628 #ifdef BSD_KERNEL_PRIVATE
629 struct if_agentidsreq32 {
630 	char            ifar_name[IFNAMSIZ];
631 	u_int32_t       ifar_count;
632 	user32_addr_t ifar_uuids;
633 };
634 struct if_agentidsreq64 {
635 	char            ifar_name[IFNAMSIZ];
636 	u_int32_t       ifar_count;
637 	user64_addr_t ifar_uuids __attribute__((aligned(8)));
638 };
639 #endif /* BSD_KERNEL_PRIVATE */
640 
641 /*
642  * Structure for SIOCGIFNEXUS
643  */
644 struct if_nexusreq {
645 	char            ifnr_name[IFNAMSIZ];    /* interface name */
646 	uint64_t        ifnr_flags;             /* unused, must be zero */
647 	uuid_t          ifnr_netif;             /* netif nexus instance UUID */
648 	uuid_t          ifnr_flowswitch;        /* flowswitch nexus UUID */
649 	uint64_t        ifnr_reserved[5];
650 };
651 
652 #define DLIL_MODIDLEN   20      /* same as IFNET_MODIDLEN */
653 #define DLIL_MODARGLEN  12      /* same as IFNET_MODARGLEN */
654 
655 /*
656  * DLIL KEV_DL_ISSUES event structure
657  */
658 struct kev_dl_issues {
659 	struct net_event_data   link_data;
660 	u_int8_t                modid[DLIL_MODIDLEN];
661 	u_int64_t               timestamp;
662 	u_int8_t                info[DLIL_MODARGLEN];
663 };
664 
665 /*
666  * DLIL KEV_DL_RRC_STATE_CHANGED structure
667  */
668 struct kev_dl_rrc_state {
669 	struct net_event_data   link_data;
670 	u_int32_t               rrc_state;
671 };
672 
673 /*
674  * KEV_DL_LOW_POWER_MODE_CHANGED
675  */
676 struct kev_dl_low_power_mode {
677 	struct net_event_data   link_data;
678 	int                     low_power_event;
679 };
680 
681 /*
682  * Length of network signature/fingerprint blob.
683  */
684 #define IFNET_SIGNATURELEN      20
685 
686 /*
687  * Structure for SIOC[S/G]IFNETSIGNATURE
688  */
689 struct if_nsreq {
690 	char            ifnsr_name[IFNAMSIZ];
691 	u_int8_t        ifnsr_family;   /* address family */
692 	u_int8_t        ifnsr_len;      /* data length */
693 	u_int16_t       ifnsr_flags;    /* for future */
694 	u_int8_t        ifnsr_data[IFNET_SIGNATURELEN];
695 };
696 
697 /* Structure for SIOCSIFNETWORKID */
698 struct if_netidreq {
699 	char            ifnetid_name[IFNAMSIZ];
700 	u_int8_t        ifnetid_len;
701 	u_int8_t        ifnetid[IFNET_NETWORK_ID_LEN];
702 };
703 
704 #define NAT64_PREFIX_LEN_32     4
705 #define NAT64_PREFIX_LEN_40     5
706 #define NAT64_PREFIX_LEN_48     6
707 #define NAT64_PREFIX_LEN_56     7
708 #define NAT64_PREFIX_LEN_64     8
709 #define NAT64_PREFIX_LEN_96     12
710 #define NAT64_PREFIX_LEN_MAX    NAT64_PREFIX_LEN_96
711 
712 #define NAT64_MAX_NUM_PREFIXES  4
713 
714 struct ipv6_prefix {
715 	struct in6_addr ipv6_prefix;
716 	uint32_t        prefix_len;
717 };
718 
719 struct if_ipv6_address {
720 	struct in6_addr v6_address;
721 	uint32_t        v6_prefixlen;
722 };
723 
724 /* Structure for SIOC[S/G]IFNAT64PREFIX */
725 struct if_nat64req {
726 	char                    ifnat64_name[IFNAMSIZ];
727 	struct ipv6_prefix      ifnat64_prefixes[NAT64_MAX_NUM_PREFIXES];
728 };
729 
730 /* Structure for SIOCGIFCLAT46ADDR */
731 struct if_clat46req {
732 	char                    ifclat46_name[IFNAMSIZ];
733 	struct if_ipv6_address  ifclat46_addr;
734 };
735 
736 /*
737  * Structure for SIOC[S/G]IFORDER
738  *
739  * When setting, ifo_count is the number of u_int32_t interface indices
740  * in the ifo_ordered_indices array.
741  *
742  * When getting, if ifo_count is 0, the length of the ordered list will
743  * be returned. If the ifo_count is non-0, it is the number of u_int32_t
744  * interface indices allocated. Upon return, ifo_count will contain the number
745  * of indices copied into the array.
746  */
747 struct if_order {
748 	u_int32_t                       ifo_count;
749 	u_int32_t                       ifo_reserved;
750 	mach_vm_address_t       ifo_ordered_indices; /* array of u_int32_t */
751 };
752 
753 /*
754  * Struct for traffic class to DSCP mapping
755  */
756 struct if_tdmreq {
757 	char                            iftdm_name[IFNAMSIZ];
758 	u_int32_t                       iftdm_len;      /* byte length of the table */
759 	struct netsvctype_dscp_map      *iftdm_table;
760 };
761 
762 #ifdef BSD_KERNEL_PRIVATE
763 struct if_tdmreq32 {
764 	char                    iftdm_name[IFNAMSIZ];
765 	u_int32_t               iftdm_len;      /* byte length of the table */
766 	user32_addr_t           iftdm_table;
767 };
768 
769 struct if_tdmreq64 {
770 	char                    iftdm_name[IFNAMSIZ];
771 	u_int32_t               iftdm_len;      /* byte length of the table */
772 	user64_addr_t           iftdm_table __attribute__((aligned(8)));
773 };
774 #endif
775 
776 /*
777  * Structure for SIOCGIFPROTOLIST.
778  */
779 struct if_protolistreq {
780 	char                    ifpl_name[IFNAMSIZ];
781 	u_int32_t               ifpl_count;
782 	u_int32_t               ifpl_reserved; /* must be zero */
783 	u_int32_t               *ifpl_list;
784 };
785 
786 #ifdef BSD_KERNEL_PRIVATE
787 struct if_protolistreq32 {
788 	char                    ifpl_name[IFNAMSIZ];
789 	u_int32_t               ifpl_count;
790 	u_int32_t               ifpl_reserved; /* must be zero */
791 	user32_addr_t           ifpl_list;
792 };
793 
794 struct if_protolistreq64 {
795 	char                    ifpl_name[IFNAMSIZ];
796 	u_int32_t               ifpl_count;
797 	u_int32_t               ifpl_reserved; /* must be zero */
798 	user64_addr_t           ifpl_list;
799 };
800 #endif /* BSD_KERNEL_PRIVATE */
801 
802 
803 /*
804  * Entitlement to send/receive data on an INTCOPROC interface
805  */
806 #define INTCOPROC_RESTRICTED_ENTITLEMENT "com.apple.private.network.intcoproc.restricted"
807 #define INTCOPROC_RESTRICTED_ENTITLEMENT_DEVELOPMENT "com.apple.private.network.intcoproc.restricted.development"
808 
809 /*
810  * Entitlement to send/receive data on a management interface
811  */
812 #define MANAGEMENT_DATA_ENTITLEMENT "com.apple.private.network.management.data"
813 #define MANAGEMENT_DATA_ENTITLEMENT_DEVELOPMENT "com.apple.private.network.management.data.development"
814 
815 /*
816  * Entitlement to make change to a management interface
817  */
818 #define MANAGEMENT_CONTROL_ENTITLEMENT "com.apple.private.network.management.control"
819 
820 #endif /* DRIVERKIT */
821 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
822 
823 #endif /* !_NET_IF_PRIVATE_H_ */
824