]> git.saurik.com Git - apple/xnu.git/blob - bsd/net/if.h
xnu-3789.51.2.tar.gz
[apple/xnu.git] / bsd / net / if.h
1 /*
2 * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (c) 1982, 1986, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)if.h 8.1 (Berkeley) 6/10/93
61 */
62
63 #ifndef _NET_IF_H_
64 #define _NET_IF_H_
65
66 #include <sys/cdefs.h>
67 #include <net/net_kev.h>
68
69 #define IF_NAMESIZE 16
70
71 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
72 #include <sys/appleapiopts.h>
73 #ifdef __APPLE__
74
75 #include <net/if_var.h>
76 #include <sys/types.h>
77 #include <sys/socket.h>
78
79 #ifdef PRIVATE
80 #include <net/if_dl.h>
81 #include <netinet/in.h>
82 #include <mach/vm_types.h>
83 #endif /* PRIVATE */
84 #endif
85
86 struct if_clonereq {
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 */
90 };
91
92 #ifdef KERNEL_PRIVATE
93 #define IF_MAXUNIT 0x7fff /* historical value */
94
95 struct if_clonereq64 {
96 int ifcr_total; /* total cloners (out) */
97 int ifcr_count; /* room for this many in user buffer */
98 user64_addr_t ifcru_buffer __attribute__((aligned(8)));
99 };
100
101 struct if_clonereq32 {
102 int ifcr_total; /* total cloners (out) */
103 int ifcr_count; /* room for this many in user buffer */
104 user32_addr_t ifcru_buffer;
105 };
106 #endif /* KERNEL_PRIVATE */
107
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 */
125
126 #ifdef PRIVATE
127 /* extended flags definitions: (all bits reserved for internal/future use) */
128 #define IFEF_AUTOCONFIGURING 0x00000001 /* allow BOOTP/DHCP replies to enter */
129 #define IFEF_ENQUEUE_MULTI 0x00000002 /* enqueue multiple packets at once */
130 #define IFEF_DELAY_START 0x00000004 /* delay start callback */
131 #define IFEF_PROBE_CONNECTIVITY 0x00000008 /* Probe connections going over this interface */
132 #define IFEF_QOSMARKING_CAPABLE 0x00000010 /* XXX Obsolete, to be removed */
133 #define IFEF_IPV6_DISABLED 0x00000020 /* coupled to ND6_IFF_IFDISABLED */
134 #define IFEF_ACCEPT_RTADV 0x00000040 /* accepts IPv6 RA on the interface */
135 #define IFEF_TXSTART 0x00000080 /* has start callback */
136 #define IFEF_RXPOLL 0x00000100 /* supports opportunistic input poll */
137 #define IFEF_VLAN 0x00000200 /* interface has one or more vlans */
138 #define IFEF_BOND 0x00000400 /* interface is part of bond */
139 #define IFEF_ARPLL 0x00000800 /* ARP for IPv4LL addresses */
140 /* #define IFEF_NOWINDOWSCALE 0x00001000 */ /* Don't scale TCP window on iface */
141 /*
142 * XXX IFEF_NOAUTOIPV6LL is deprecated and should be done away with.
143 * Configd pretty much manages the interface configuration.
144 * Rather than looking at the flag we check if a specific LLA
145 * has to be configured or the IID has to be generated by kernel.
146 */
147 #define IFEF_NOAUTOIPV6LL 0x00002000 /* Need explicit IPv6 LL address */
148 #define IFEF_EXPENSIVE 0x00004000 /* Data access has a cost */
149 #define IFEF_IPV4_ROUTER 0x00008000 /* interior when in IPv4 router mode */
150 #define IFEF_IPV6_ROUTER 0x00010000 /* interior when in IPv6 router mode */
151 #define IFEF_LOCALNET_PRIVATE 0x00020000 /* local private network */
152 #define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE
153 #define IFEF_IPV6_ND6ALT 0x00040000 /* alternative. KPI for ND6 */
154 #define IFEF_RESTRICTED_RECV 0x00080000 /* interface restricts inbound pkts */
155 #define IFEF_AWDL 0x00100000 /* Apple Wireless Direct Link */
156 #define IFEF_NOACKPRI 0x00200000 /* No TCP ACK prioritization */
157 #define IFEF_AWDL_RESTRICTED 0x00400000 /* Restricted AWDL mode */
158 #define IFEF_2KCL 0x00800000 /* prefers 2K cluster (socket based tunnel) */
159 #define IFEF_ECN_ENABLE 0x01000000 /* use ECN for TCP connections on the interface */
160 #define IFEF_ECN_DISABLE 0x02000000 /* do not use ECN for TCP connections on the interface */
161 #define IFEF_SKYWALK_NATIVE 0x04000000 /* Native Skywalk support */
162 #define IFEF_3CA 0x08000000 /* Capable of 3CA */
163 #define IFEF_SENDLIST 0x10000000 /* Supports tx packet lists */
164 #define IFEF_DIRECTLINK 0x20000000 /* point-to-point topology */
165 #define IFEF_QOSMARKING_ENABLED 0x40000000 /* OoS marking is enabled */
166 #define IFEF_UPDOWNCHANGE 0x80000000 /* up/down state is changing */
167
168 #ifdef XNU_KERNEL_PRIVATE
169 /*
170 * Extra flags
171 */
172 #define IFXF_WAKE_ON_MAGIC_PACKET 0x00000001 /* wake on magic packet */
173 #define IFXF_TIMESTAMP_ENABLED 0x00000002 /* time stamping enabled */
174
175 /*
176 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL
177 * will also trigger the setting/clearing of the rest of the flags. Once
178 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
179 */
180 #define IFEF_AWDL_MASK \
181 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
182 IFEF_AWDL)
183 #endif /* XNU_KERNEL_PRIVATE */
184 #endif /* PRIVATE */
185
186 #ifdef KERNEL_PRIVATE
187 /*
188 * !!! NOTE !!!
189 *
190 * if_idle_flags definitions: (all bits are reserved for internal/future
191 * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
192 * KPI due to the associated reference counting. Clearing them may be done by
193 * calling the KPI, otherwise implicitly at interface detach time. Setting
194 * the if_idle_flags field to a non-zero value will cause the networking
195 * stack to aggressively purge expired objects (routes, etc.)
196 */
197 #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */
198
199 /* flags set internally only: */
200 #define IFF_CANTCHANGE \
201 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
202 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
203 #endif /* KERNEL_PRIVATE */
204
205 /*
206 * Capabilities that interfaces can advertise.
207 *
208 * struct ifnet.if_capabilities
209 * contains the optional features & capabilities a particular interface
210 * supports (not only the driver but also the detected hw revision).
211 * Capabilities are defined by IFCAP_* below.
212 * struct ifnet.if_capenable
213 * contains the enabled (either by default or through ifconfig) optional
214 * features & capabilities on this interface.
215 * Capabilities are defined by IFCAP_* below.
216 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h,
217 * contains the enabled optional features & capabilites that can be used
218 * individually per packet and are specified in the mbuf pkthdr.csum_flags
219 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be
220 * more detailed or differenciated than IFCAP_*.
221 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h
222 */
223 #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
224 #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
225 #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */
226 #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */
227 #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */
228 #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */
229 #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */
230 #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */
231 #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */
232 #define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */
233 #define IFCAP_SKYWALK 0x00400 /* Skywalk mode supported/enabled */
234 #define IFCAP_HW_TIMESTAMP 0x00800 /* Time stamping in hardware */
235 #define IFCAP_SW_TIMESTAMP 0x01000 /* Time stamping in software */
236
237 #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
238 #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
239
240 #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \
241 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS | \
242 IFCAP_SKYWALK | IFCAP_SW_TIMESTAMP | IFCAP_HW_TIMESTAMP)
243
244 #define IFQ_MAXLEN 128
245 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
246 #define IFQ_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */
247 #define IFQ_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
248
249 /*
250 * Message format for use in obtaining information about interfaces
251 * from sysctl and the routing socket
252 */
253 struct if_msghdr {
254 unsigned short ifm_msglen; /* to skip non-understood messages */
255 unsigned char ifm_version; /* future binary compatability */
256 unsigned char ifm_type; /* message type */
257 int ifm_addrs; /* like rtm_addrs */
258 int ifm_flags; /* value of if_flags */
259 unsigned short ifm_index; /* index for associated ifp */
260 struct if_data ifm_data; /* statistics and other data about if */
261 };
262
263 /*
264 * Message format for use in obtaining information about interface addresses
265 * from sysctl and the routing socket
266 */
267 struct ifa_msghdr {
268 unsigned short ifam_msglen; /* to skip non-understood messages */
269 unsigned char ifam_version; /* future binary compatability */
270 unsigned char ifam_type; /* message type */
271 int ifam_addrs; /* like rtm_addrs */
272 int ifam_flags; /* value of ifa_flags */
273 unsigned short ifam_index; /* index for associated ifp */
274 int ifam_metric; /* value of ifa_metric */
275 };
276
277 /*
278 * Message format for use in obtaining information about multicast addresses
279 * from the routing socket
280 */
281 struct ifma_msghdr {
282 unsigned short ifmam_msglen; /* to skip non-understood messages */
283 unsigned char ifmam_version; /* future binary compatability */
284 unsigned char ifmam_type; /* message type */
285 int ifmam_addrs; /* like rtm_addrs */
286 int ifmam_flags; /* value of ifa_flags */
287 unsigned short ifmam_index; /* index for associated ifp */
288 };
289
290 /*
291 * Message format for use in obtaining information about interfaces
292 * from sysctl
293 */
294 struct if_msghdr2 {
295 u_short ifm_msglen; /* to skip over non-understood messages */
296 u_char ifm_version; /* future binary compatability */
297 u_char ifm_type; /* message type */
298 int ifm_addrs; /* like rtm_addrs */
299 int ifm_flags; /* value of if_flags */
300 u_short ifm_index; /* index for associated ifp */
301 int ifm_snd_len; /* instantaneous length of send queue */
302 int ifm_snd_maxlen; /* maximum length of send queue */
303 int ifm_snd_drops; /* number of drops in send queue */
304 int ifm_timer; /* time until if_watchdog called */
305 struct if_data64 ifm_data; /* statistics and other data */
306 };
307
308 /*
309 * Message format for use in obtaining information about multicast addresses
310 * from sysctl
311 */
312 struct ifma_msghdr2 {
313 u_short ifmam_msglen; /* to skip over non-understood messages */
314 u_char ifmam_version; /* future binary compatability */
315 u_char ifmam_type; /* message type */
316 int ifmam_addrs; /* like rtm_addrs */
317 int ifmam_flags; /* value of ifa_flags */
318 u_short ifmam_index; /* index for associated ifp */
319 int32_t ifmam_refcount;
320 };
321
322 /*
323 * ifdevmtu: interface device mtu
324 * Used with SIOCGIFDEVMTU to get the current mtu in use by the device,
325 * as well as the minimum and maximum mtu allowed by the device.
326 */
327 struct ifdevmtu {
328 int ifdm_current;
329 int ifdm_min;
330 int ifdm_max;
331 };
332
333 #pragma pack(4)
334
335 /*
336 ifkpi: interface kpi ioctl
337 Used with SIOCSIFKPI and SIOCGIFKPI.
338
339 ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From
340 user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket.
341 ifk_type - The type. Types are specific to each module id.
342 ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes.
343
344 Copying data between user space and kernel space is done using copyin
345 and copyout. A process may be running in 64bit mode. In such a case,
346 the pointer will be a 64bit pointer, not a 32bit pointer. The following
347 sample is a safe way to copy the data in to the kernel from either a
348 32bit or 64bit process:
349
350 user_addr_t tmp_ptr;
351 if (IS_64BIT_PROCESS(current_proc())) {
352 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64);
353 }
354 else {
355 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr);
356 }
357 error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer);
358 */
359
360 struct ifkpi {
361 unsigned int ifk_module_id;
362 unsigned int ifk_type;
363 union {
364 void *ifk_ptr;
365 int ifk_value;
366 #ifdef KERNEL
367 u_int64_t ifk_ptr64;
368 #endif /* KERNEL */
369 } ifk_data;
370 };
371
372 /* Wake capabilities of a interface */
373 #define IF_WAKE_ON_MAGIC_PACKET 0x01
374 #ifdef KERNEL_PRIVATE
375 #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET
376 #endif /* KERNEL_PRIVATE */
377
378
379 #pragma pack()
380
381 /*
382 * Interface request structure used for socket
383 * ioctl's. All interface ioctl's must have parameter
384 * definitions which begin with ifr_name. The
385 * remainder may be interface specific.
386 */
387 struct ifreq {
388 #ifndef IFNAMSIZ
389 #define IFNAMSIZ IF_NAMESIZE
390 #endif
391 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
392 union {
393 struct sockaddr ifru_addr;
394 struct sockaddr ifru_dstaddr;
395 struct sockaddr ifru_broadaddr;
396 short ifru_flags;
397 int ifru_metric;
398 int ifru_mtu;
399 int ifru_phys;
400 int ifru_media;
401 int ifru_intval;
402 caddr_t ifru_data;
403 #ifdef KERNEL_PRIVATE
404 u_int64_t ifru_data64; /* 64-bit ifru_data */
405 #endif /* KERNEL_PRIVATE */
406 struct ifdevmtu ifru_devmtu;
407 struct ifkpi ifru_kpi;
408 u_int32_t ifru_wake_flags;
409 u_int32_t ifru_route_refcnt;
410 #ifdef PRIVATE
411 int ifru_link_quality_metric;
412 #endif /* PRIVATE */
413 int ifru_cap[2];
414 #ifdef PRIVATE
415 struct {
416 uint32_t ifo_flags;
417 #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001
418 uint32_t ifo_inuse;
419 } ifru_opportunistic;
420 u_int64_t ifru_eflags;
421 struct {
422 int32_t ifl_level;
423 uint32_t ifl_flags;
424 #define IFRLOGF_DLIL 0x00000001
425 #define IFRLOGF_FAMILY 0x00010000
426 #define IFRLOGF_DRIVER 0x01000000
427 #define IFRLOGF_FIRMWARE 0x10000000
428 int32_t ifl_category;
429 #define IFRLOGCAT_CONNECTIVITY 1
430 #define IFRLOGCAT_QUALITY 2
431 #define IFRLOGCAT_PERFORMANCE 3
432 int32_t ifl_subcategory;
433 } ifru_log;
434 u_int32_t ifru_delegated;
435 struct {
436 uint32_t ift_type;
437 uint32_t ift_family;
438 #define IFRTYPE_FAMILY_ANY 0
439 #define IFRTYPE_FAMILY_LOOPBACK 1
440 #define IFRTYPE_FAMILY_ETHERNET 2
441 #define IFRTYPE_FAMILY_SLIP 3
442 #define IFRTYPE_FAMILY_TUN 4
443 #define IFRTYPE_FAMILY_VLAN 5
444 #define IFRTYPE_FAMILY_PPP 6
445 #define IFRTYPE_FAMILY_PVC 7
446 #define IFRTYPE_FAMILY_DISC 8
447 #define IFRTYPE_FAMILY_MDECAP 9
448 #define IFRTYPE_FAMILY_GIF 10
449 #define IFRTYPE_FAMILY_FAITH 11
450 #define IFRTYPE_FAMILY_STF 12
451 #define IFRTYPE_FAMILY_FIREWIRE 13
452 #define IFRTYPE_FAMILY_BOND 14
453 #define IFRTYPE_FAMILY_CELLULAR 15
454 uint32_t ift_subfamily;
455 #define IFRTYPE_SUBFAMILY_ANY 0
456 #define IFRTYPE_SUBFAMILY_USB 1
457 #define IFRTYPE_SUBFAMILY_BLUETOOTH 2
458 #define IFRTYPE_SUBFAMILY_WIFI 3
459 #define IFRTYPE_SUBFAMILY_THUNDERBOLT 4
460 #define IFRTYPE_SUBFAMILY_RESERVED 5
461 #define IFRTYPE_SUBFAMILY_INTCOPROC 6
462 } ifru_type;
463 u_int32_t ifru_functional_type;
464 #define IFRTYPE_FUNCTIONAL_UNKNOWN 0
465 #define IFRTYPE_FUNCTIONAL_LOOPBACK 1
466 #define IFRTYPE_FUNCTIONAL_WIRED 2
467 #define IFRTYPE_FUNCTIONAL_WIFI_INFRA 3
468 #define IFRTYPE_FUNCTIONAL_WIFI_AWDL 4
469 #define IFRTYPE_FUNCTIONAL_CELLULAR 5
470 #define IFRTYPE_FUNCTIONAL_INTCOPROC 6
471 #define IFRTYPE_FUNCTIONAL_LAST 6
472 u_int32_t ifru_expensive;
473 u_int32_t ifru_2kcl;
474 struct {
475 u_int32_t qlen;
476 u_int32_t timeout;
477 } ifru_start_delay;
478 struct if_interface_state ifru_interface_state;
479 u_int32_t ifru_probe_connectivity;
480 u_int32_t ifru_ecn_mode;
481 #define IFRTYPE_ECN_DEFAULT 0
482 #define IFRTYPE_ECN_ENABLE 1
483 #define IFRTYPE_ECN_DISABLE 2
484 u_int32_t ifru_qosmarking_mode;
485 #define IFRTYPE_QOSMARKING_MODE_NONE 0
486 #define IFRTYPE_QOSMARKING_FASTLANE 1
487 u_int32_t ifru_qosmarking_enabled;
488 u_int32_t ifru_disable_output;
489 #endif /* PRIVATE */
490 } ifr_ifru;
491 #define ifr_addr ifr_ifru.ifru_addr /* address */
492 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
493 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
494 #ifdef __APPLE__
495 #define ifr_flags ifr_ifru.ifru_flags /* flags */
496 #else
497 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
498 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
499 #endif /* __APPLE__ */
500 #define ifr_metric ifr_ifru.ifru_metric /* metric */
501 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
502 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
503 #define ifr_media ifr_ifru.ifru_media /* physical media */
504 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
505 #define ifr_devmtu ifr_ifru.ifru_devmtu
506 #define ifr_intval ifr_ifru.ifru_intval /* integer value */
507 #ifdef KERNEL_PRIVATE
508 #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */
509 #endif /* KERNEL_PRIVATE */
510 #define ifr_kpi ifr_ifru.ifru_kpi
511 #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */
512 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */
513 #ifdef PRIVATE
514 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
515 #endif /* PRIVATE */
516 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
517 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
518 #ifdef PRIVATE
519 #define ifr_opportunistic ifr_ifru.ifru_opportunistic
520 #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */
521 #define ifr_log ifr_ifru.ifru_log /* logging level/flags */
522 #define ifr_delegated ifr_ifru.ifru_delegated /* delegated interface index */
523 #define ifr_expensive ifr_ifru.ifru_expensive
524 #define ifr_type ifr_ifru.ifru_type /* interface type */
525 #define ifr_functional_type ifr_ifru.ifru_functional_type
526 #define ifr_2kcl ifr_ifru.ifru_2kcl
527 #define ifr_start_delay_qlen ifr_ifru.ifru_start_delay.qlen
528 #define ifr_start_delay_timeout ifr_ifru.ifru_start_delay.timeout
529 #define ifr_interface_state ifr_ifru.ifru_interface_state
530 #define ifr_probe_connectivity ifr_ifru.ifru_probe_connectivity
531 #define ifr_ecn_mode ifr_ifru.ifru_ecn_mode
532 #define ifr_qosmarking_mode ifr_ifru.ifru_qosmarking_mode
533 #define ifr_fastlane_capable ifr_qosmarking_mode
534 #define ifr_qosmarking_enabled ifr_ifru.ifru_qosmarking_enabled
535 #define ifr_fastlane_enabled ifr_qosmarking_enabled
536 #define ifr_disable_output ifr_ifru.ifru_disable_output
537
538 #endif /* PRIVATE */
539 };
540
541 #define _SIZEOF_ADDR_IFREQ(ifr) \
542 ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \
543 (sizeof (struct ifreq) - sizeof (struct sockaddr) + \
544 (ifr).ifr_addr.sa_len) : sizeof (struct ifreq))
545
546 struct ifaliasreq {
547 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
548 struct sockaddr ifra_addr;
549 struct sockaddr ifra_broadaddr;
550 struct sockaddr ifra_mask;
551 };
552
553 struct rslvmulti_req {
554 struct sockaddr *sa;
555 struct sockaddr **llsa;
556 };
557
558 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
559 #pragma pack(4)
560
561 struct ifmediareq {
562 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
563 int ifm_current; /* current media options */
564 int ifm_mask; /* don't care mask */
565 int ifm_status; /* media status */
566 int ifm_active; /* active options */
567 int ifm_count; /* # entries in ifm_ulist array */
568 int *ifm_ulist; /* media words */
569 };
570
571 #pragma pack()
572 #endif /* !KERNEL || KERNEL_PRIVATE */
573
574 #ifdef KERNEL_PRIVATE
575 #pragma pack(4)
576 struct ifmediareq64 {
577 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
578 int ifm_current; /* current media options */
579 int ifm_mask; /* don't care mask */
580 int ifm_status; /* media status */
581 int ifm_active; /* active options */
582 int ifm_count; /* # entries in ifm_ulist array */
583 user64_addr_t ifmu_ulist __attribute__((aligned(8)));
584 };
585
586 struct ifmediareq32 {
587 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
588 int ifm_current; /* current media options */
589 int ifm_mask; /* don't care mask */
590 int ifm_status; /* media status */
591 int ifm_active; /* active options */
592 int ifm_count; /* # entries in ifm_ulist array */
593 user32_addr_t ifmu_ulist; /* 32-bit pointer */
594 };
595 #pragma pack()
596 #endif /* KERNEL_PRIVATE */
597
598
599 #pragma pack(4)
600 struct ifdrv {
601 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
602 unsigned long ifd_cmd;
603 size_t ifd_len; /* length of ifd_data buffer */
604 void *ifd_data;
605 };
606 #pragma pack()
607
608 #ifdef KERNEL_PRIVATE
609 #pragma pack(4)
610 struct ifdrv32 {
611 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
612 u_int32_t ifd_cmd;
613 u_int32_t ifd_len;
614 user32_addr_t ifd_data;
615 };
616
617 struct ifdrv64 {
618 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
619 u_int64_t ifd_cmd;
620 u_int64_t ifd_len;
621 user64_addr_t ifd_data;
622 };
623 #pragma pack()
624 #endif /* KERNEL_PRIVATE */
625
626 /*
627 * Structure used to retrieve aux status data from interfaces.
628 * Kernel suppliers to this interface should respect the formatting
629 * needed by ifconfig(8): each line starts with a TAB and ends with
630 * a newline.
631 */
632
633 #define IFSTATMAX 800 /* 10 lines of text */
634 struct ifstat {
635 char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */
636 char ascii[IFSTATMAX + 1];
637 };
638
639 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
640 /*
641 * Structure used in SIOCGIFCONF request.
642 * Used to retrieve interface configuration
643 * for machine (useful for programs which
644 * must know all networks accessible).
645 */
646 #pragma pack(4)
647 struct ifconf {
648 int ifc_len; /* size of associated buffer */
649 union {
650 caddr_t ifcu_buf;
651 struct ifreq *ifcu_req;
652 } ifc_ifcu;
653 };
654 #pragma pack()
655 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
656 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
657 #endif /* !KERNEL || KERNEL_PRIVATE */
658
659 #if defined(KERNEL_PRIVATE)
660 #pragma pack(4)
661 struct ifconf32 {
662 int ifc_len; /* size of associated buffer */
663 struct {
664 user32_addr_t ifcu_req;
665 } ifc_ifcu;
666 };
667
668 struct ifconf64 {
669 int ifc_len; /* size of associated buffer */
670 struct {
671 user64_addr_t ifcu_req __attribute__((aligned(8)));
672 } ifc_ifcu;
673 };
674 #pragma pack()
675 #endif /* KERNEL_PRIVATE */
676
677 /*
678 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
679 */
680 struct kev_dl_proto_data {
681 struct net_event_data link_data;
682 u_int32_t proto_family;
683 u_int32_t proto_remaining_count;
684 };
685
686 #ifdef PRIVATE
687 /*
688 * Link Quality Metrics
689 *
690 * IFNET_LQM_THRESH_OFF Metric is not available; device is off.
691 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known.
692 * IFNET_LQM_THRESH_BAD Link quality is considered bad by driver.
693 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver.
694 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver.
695 */
696 enum {
697 IFNET_LQM_THRESH_OFF = (-2),
698 IFNET_LQM_THRESH_UNKNOWN = (-1),
699 IFNET_LQM_THRESH_BAD = 10,
700 IFNET_LQM_THRESH_POOR = 50,
701 IFNET_LQM_THRESH_GOOD = 100
702 };
703 #ifdef XNU_KERNEL_PRIVATE
704 #define IFNET_LQM_MIN IFNET_LQM_THRESH_OFF
705 #define IFNET_LQM_MAX IFNET_LQM_THRESH_GOOD
706 #endif /* XNU_KERNEL_PRIVATE */
707
708 /*
709 * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure
710 */
711 struct kev_dl_link_quality_metric_data {
712 struct net_event_data link_data;
713 int link_quality_metric;
714 };
715
716 #define IF_DESCSIZE 128
717
718 /*
719 * Structure for SIOC[SG]IFDESC
720 */
721 struct if_descreq {
722 char ifdr_name[IFNAMSIZ]; /* interface name */
723 u_int32_t ifdr_len; /* up to IF_DESCSIZE */
724 u_int8_t ifdr_desc[IF_DESCSIZE]; /* opaque data */
725 };
726
727 /*
728 * Output packet scheduling models
729 *
730 * IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model
731 * where the driver or media does not require strict scheduling
732 * strategy, and that the networking stack is free to choose the
733 * most appropriate scheduling and queueing algorithm, including
734 * shaping traffics.
735 * IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet
736 * scheduling model where the driver or media requires strict
737 * scheduling strategy (e.g. 802.11 WMM), and that the networking
738 * stack is only responsible for creating multiple queues for the
739 * corresponding service classes.
740 */
741 enum {
742 IFNET_SCHED_MODEL_NORMAL = 0,
743 IFNET_SCHED_MODEL_DRIVER_MANAGED = 1,
744 IFNET_SCHED_MODEL_FQ_CODEL = 2,
745 #ifdef XNU_KERNEL_PRIVATE
746 IFNET_SCHED_MODEL_MAX = 3,
747 #endif /* XNU_KERNEL_PRIVATE */
748 };
749
750 /*
751 * Values for iflpr_flags
752 */
753 #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */
754 #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */
755
756 /*
757 * Structure for SIOCGIFLINKPARAMS
758 */
759 struct if_linkparamsreq {
760 char iflpr_name[IFNAMSIZ]; /* interface name */
761 u_int32_t iflpr_flags;
762 u_int32_t iflpr_output_sched;
763 u_int64_t iflpr_output_tbr_rate;
764 u_int32_t iflpr_output_tbr_percent;
765 struct if_bandwidths iflpr_output_bw;
766 struct if_bandwidths iflpr_input_bw;
767 struct if_latencies iflpr_output_lt;
768 struct if_latencies iflpr_input_lt;
769 };
770
771 /*
772 * Structure for SIOCGIFQUEUESTATS
773 */
774 struct if_qstatsreq {
775 char ifqr_name[IFNAMSIZ]; /* interface name */
776 u_int32_t ifqr_slot;
777 void *ifqr_buf __attribute__((aligned(8)));
778 int ifqr_len __attribute__((aligned(8)));
779 };
780
781 /*
782 * Node Proximity Metrics
783 */
784 enum {
785 IFNET_NPM_THRESH_UNKNOWN = (-1),
786 IFNET_NPM_THRESH_NEAR = 30,
787 IFNET_NPM_THRESH_GENERAL = 70,
788 IFNET_NPM_THRESH_FAR = 100,
789 };
790
791 /*
792 * Received Signal Strength Indication [special values]
793 *
794 * IFNET_RSSI_UNKNOWN Metric is not (yet) known.
795 */
796 enum {
797 IFNET_RSSI_UNKNOWN = ((-2147483647)-1), /* INT32_MIN */
798 };
799
800
801 /*
802 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
803 */
804 struct kev_dl_node_presence {
805 struct net_event_data link_data;
806 struct sockaddr_in6 sin6_node_address;
807 struct sockaddr_dl sdl_node_address;
808 int32_t rssi;
809 int link_quality_metric;
810 int node_proximity_metric;
811 u_int8_t node_service_info[48];
812 };
813
814 struct kev_dl_node_absence {
815 struct net_event_data link_data;
816 struct sockaddr_in6 sin6_node_address;
817 struct sockaddr_dl sdl_node_address;
818 };
819
820 /*
821 * Structure for SIOC[SG]IFTHROTTLE
822 */
823 struct if_throttlereq {
824 char ifthr_name[IFNAMSIZ]; /* interface name */
825 u_int32_t ifthr_level;
826 };
827
828 /*
829 * Interface throttling levels
830 *
831 * IFNET_THROTTLE_OFF The default throttling level (no throttling.)
832 * All service class queues operate normally according to the
833 * standard packet scheduler configuration.
834 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
835 * are responsible for managing "opportunistic" traffics are
836 * suspended. Packets enqueued on those queues will be dropped
837 * and a flow advisory error will be generated to the data
838 * source. Existing packets in the queues will stay enqueued
839 * until the interface is no longer throttled, or until they
840 * are explicitly flushed.
841 */
842 enum {
843 IFNET_THROTTLE_OFF = 0,
844 IFNET_THROTTLE_OPPORTUNISTIC = 1,
845 #ifdef XNU_KERNEL_PRIVATE
846 IFNET_THROTTLE_MAX = 2,
847 #endif /* XNU_KERNEL_PRIVATE */
848 };
849
850 /*
851 * Structure for SIOC[A/D]IFAGENTID
852 */
853 struct if_agentidreq {
854 char ifar_name[IFNAMSIZ]; /* interface name */
855 uuid_t ifar_uuid; /* agent UUID to add or delete */
856 };
857
858 /*
859 * Structure for SIOCGIFAGENTIDS
860 */
861 struct if_agentidsreq {
862 char ifar_name[IFNAMSIZ]; /* interface name */
863 u_int32_t ifar_count; /* number of agent UUIDs */
864 uuid_t *ifar_uuids; /* array of agent UUIDs */
865 };
866
867 #ifdef BSD_KERNEL_PRIVATE
868 struct if_agentidsreq32 {
869 char ifar_name[IFNAMSIZ];
870 u_int32_t ifar_count;
871 user32_addr_t ifar_uuids;
872 };
873 struct if_agentidsreq64 {
874 char ifar_name[IFNAMSIZ];
875 u_int32_t ifar_count;
876 user64_addr_t ifar_uuids __attribute__((aligned(8)));
877 };
878 #endif /* BSD_KERNEL_PRIVATE */
879
880 #define DLIL_MODIDLEN 20 /* same as IFNET_MODIDLEN */
881 #define DLIL_MODARGLEN 12 /* same as IFNET_MODARGLEN */
882
883 /*
884 * DLIL KEV_DL_ISSUES event structure
885 */
886 struct kev_dl_issues {
887 struct net_event_data link_data;
888 u_int8_t modid[DLIL_MODIDLEN];
889 u_int64_t timestamp;
890 u_int8_t info[DLIL_MODARGLEN];
891 };
892
893 /*
894 * DLIL KEV_DL_RRC_STATE_CHANGED structure
895 */
896 struct kev_dl_rrc_state {
897 struct net_event_data link_data;
898 u_int32_t rrc_state;
899 };
900
901 /*
902 * Length of network signature/fingerprint blob.
903 */
904 #define IFNET_SIGNATURELEN 20
905
906 /*
907 * Structure for SIOC[S/G]IFNETSIGNATURE
908 */
909 struct if_nsreq {
910 char ifnsr_name[IFNAMSIZ];
911 u_int8_t ifnsr_family; /* address family */
912 u_int8_t ifnsr_len; /* data length */
913 u_int16_t ifnsr_flags; /* for future */
914 u_int8_t ifnsr_data[IFNET_SIGNATURELEN];
915 };
916
917 /*
918 * Structure for SIOC[S/G]IFORDER
919 *
920 * When setting, ifo_count is the number of u_int32_t interface indices
921 * in the ifo_ordered_indices array.
922 *
923 * When getting, if ifo_count is 0, the length of the ordered list will
924 * be returned. If the ifo_count is non-0, it is the number of u_int32_t
925 * interface indices allocated. Upon return, ifo_count will contain the number
926 * of indices copied into the array.
927 */
928 struct if_order {
929 u_int32_t ifo_count;
930 u_int32_t ifo_reserved;
931 mach_vm_address_t ifo_ordered_indices; /* array of u_int32_t */
932 };
933
934 /*
935 * Struct for traffic class to DSCP mapping
936 */
937 struct if_tdmreq {
938 char iftdm_name[IFNAMSIZ];
939 u_int32_t iftdm_len; /* byte length of the table */
940 struct netsvctype_dscp_map *iftdm_table;
941 };
942
943 #ifdef BSD_KERNEL_PRIVATE
944 struct if_tdmreq32 {
945 char iftdm_name[IFNAMSIZ];
946 u_int32_t iftdm_len; /* byte length of the table */
947 user32_addr_t iftdm_table;
948 };
949
950 struct if_tdmreq64 {
951 char iftdm_name[IFNAMSIZ];
952 u_int32_t iftdm_len; /* byte length of the table */
953 user64_addr_t iftdm_table __attribute__((aligned(8)));
954 };
955 #endif
956
957 #endif /* PRIVATE */
958
959 #ifdef KERNEL
960 #ifdef MALLOC_DECLARE
961 MALLOC_DECLARE(M_IFADDR);
962 MALLOC_DECLARE(M_IFMADDR);
963 #endif
964 #endif
965 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
966
967 #ifndef KERNEL
968 struct if_nameindex {
969 unsigned int if_index; /* 1, 2, ... */
970 char *if_name; /* null terminated name: "le0", ... */
971 };
972
973 __BEGIN_DECLS
974 unsigned int if_nametoindex(const char *);
975 char *if_indextoname(unsigned int, char *);
976 struct if_nameindex *if_nameindex(void);
977 void if_freenameindex(struct if_nameindex *);
978 __END_DECLS
979 #endif
980
981 #ifdef KERNEL
982 #include <net/kpi_interface.h>
983 #endif
984
985 #endif /* !_NET_IF_H_ */