]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/if.h
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / net / if.h
CommitLineData
1c79356b 1/*
3e170ce0 2 * Copyright (c) 2000-2015 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_
64#define _NET_IF_H_
65
2d21ac55
A
66#include <sys/cdefs.h>
67
91447636
A
68#define IF_NAMESIZE 16
69
2d21ac55 70#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
91447636 71#include <sys/appleapiopts.h>
9bccf70c 72#ifdef __APPLE__
1c79356b
A
73/*
74 * Define Data-Link event subclass, and associated
75 * events.
76 */
77
39236c6e
A
78#define KEV_DL_SUBCLASS 2
79
80#define KEV_DL_SIFFLAGS 1
81#define KEV_DL_SIFMETRICS 2
82#define KEV_DL_SIFMTU 3
83#define KEV_DL_SIFPHYS 4
84#define KEV_DL_SIFMEDIA 5
85#define KEV_DL_SIFGENERIC 6
86#define KEV_DL_ADDMULTI 7
87#define KEV_DL_DELMULTI 8
88#define KEV_DL_IF_ATTACHED 9
89#define KEV_DL_IF_DETACHING 10
90#define KEV_DL_IF_DETACHED 11
91#define KEV_DL_LINK_OFF 12
92#define KEV_DL_LINK_ON 13
93#define KEV_DL_PROTO_ATTACHED 14
94#define KEV_DL_PROTO_DETACHED 15
95#define KEV_DL_LINK_ADDRESS_CHANGED 16
96#define KEV_DL_WAKEFLAGS_CHANGED 17
97#define KEV_DL_IF_IDLE_ROUTE_REFCNT 18
98#define KEV_DL_IFCAP_CHANGED 19
99#define KEV_DL_LINK_QUALITY_METRIC_CHANGED 20
100#define KEV_DL_NODE_PRESENCE 21
101#define KEV_DL_NODE_ABSENCE 22
102#define KEV_DL_MASTER_ELECTED 23
103#define KEV_DL_ISSUES 24
104#define KEV_DL_IFDELEGATE_CHANGED 25
fe8ab488
A
105#define KEV_DL_AWDL_RESTRICTED 26
106#define KEV_DL_AWDL_UNRESTRICTED 27
3e170ce0 107#define KEV_DL_RRC_STATE_CHANGED 28
4a249263 108
1c79356b 109#include <net/if_var.h>
91447636 110#include <sys/types.h>
39236c6e 111#include <sys/socket.h>
316670eb
A
112
113#ifdef PRIVATE
114#include <net/if_dl.h>
115#include <netinet/in.h>
116#endif
9bccf70c 117#endif
1c79356b 118
4a249263
A
119struct if_clonereq {
120 int ifcr_total; /* total cloners (out) */
121 int ifcr_count; /* room for this many in user buffer */
122 char *ifcr_buffer; /* buffer for cloner names */
123};
91447636 124
39236c6e
A
125#ifdef KERNEL_PRIVATE
126#define IF_MAXUNIT 0x7fff /* historical value */
127
91447636
A
128struct if_clonereq64 {
129 int ifcr_total; /* total cloners (out) */
130 int ifcr_count; /* room for this many in user buffer */
b0d623f7
A
131 user64_addr_t ifcru_buffer __attribute__((aligned(8)));
132};
133
134struct if_clonereq32 {
135 int ifcr_total; /* total cloners (out) */
136 int ifcr_count; /* room for this many in user buffer */
137 user32_addr_t ifcru_buffer;
91447636 138};
b0d623f7 139#endif /* KERNEL_PRIVATE */
1c79356b
A
140
141#define IFF_UP 0x1 /* interface is up */
142#define IFF_BROADCAST 0x2 /* broadcast address valid */
143#define IFF_DEBUG 0x4 /* turn on debugging */
144#define IFF_LOOPBACK 0x8 /* is a loopback net */
145#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
39236c6e 146#define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
1c79356b
A
147#define IFF_RUNNING 0x40 /* resources allocated */
148#define IFF_NOARP 0x80 /* no address resolution protocol */
149#define IFF_PROMISC 0x100 /* receive all packets */
150#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
151#define IFF_OACTIVE 0x400 /* transmission in progress */
152#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
153#define IFF_LINK0 0x1000 /* per link layer defined bit */
154#define IFF_LINK1 0x2000 /* per link layer defined bit */
155#define IFF_LINK2 0x4000 /* per link layer defined bit */
156#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
157#define IFF_MULTICAST 0x8000 /* supports multicast */
1c79356b 158
316670eb 159#ifdef PRIVATE
39236c6e 160/* extended flags definitions: (all bits reserved for internal/future use) */
fe8ab488 161#define IFEF_AUTOCONFIGURING 0x00000001 /* allow BOOTP/DHCP replies to enter */
3e170ce0
A
162#define IFEF_ENQUEUE_MULTI 0x00000002 /* enqueue multiple packets at once */
163#define IFEF_DELAY_START 0x00000004 /* delay start callback */
164#define IFEF_PROBE_CONNECTIVITY 0x00000008 /* Probe connections going over this interface */
fe8ab488
A
165#define IFEF_IPV6_DISABLED 0x00000020 /* coupled to ND6_IFF_IFDISABLED */
166#define IFEF_ACCEPT_RTADV 0x00000040 /* accepts IPv6 RA on the interface */
167#define IFEF_TXSTART 0x00000080 /* has start callback */
168#define IFEF_RXPOLL 0x00000100 /* supports opportunistic input poll */
169#define IFEF_VLAN 0x00000200 /* interface has one or more vlans */
170#define IFEF_BOND 0x00000400 /* interface is part of bond */
171#define IFEF_ARPLL 0x00000800 /* ARP for IPv4LL addresses */
172#define IFEF_NOWINDOWSCALE 0x00001000 /* Don't scale TCP window on iface */
173#define IFEF_NOAUTOIPV6LL 0x00002000 /* Need explicit IPv6 LL address */
174#define IFEF_EXPENSIVE 0x00004000 /* Data access has a cost */
175#define IFEF_IPV4_ROUTER 0x00008000 /* interior when in IPv4 router mode */
176#define IFEF_IPV6_ROUTER 0x00010000 /* interior when in IPv6 router mode */
177#define IFEF_LOCALNET_PRIVATE 0x00020000 /* local private network */
39236c6e 178#define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE
fe8ab488
A
179#define IFEF_IPV6_ND6ALT 0x00040000 /* alternative. KPI for ND6 */
180#define IFEF_RESTRICTED_RECV 0x00080000 /* interface restricts inbound pkts */
181#define IFEF_AWDL 0x00100000 /* Apple Wireless Direct Link */
182#define IFEF_NOACKPRI 0x00200000 /* No TCP ACK prioritization */
183#define IFEF_AWDL_RESTRICTED 0x00400000 /* Restricted AWDL mode */
184#define IFEF_2KCL 0x00800000 /* prefers 2K cluster (socket based tunnel) */
4bd07ac2
A
185#define IFEF_ECN_ENABLE 0x01000000 /* use ECN for TCP connections on the interface */
186#define IFEF_ECN_DISABLE 0x02000000 /* do not use ECN for TCP connections on the interface */
39236c6e
A
187#define IFEF_SENDLIST 0x10000000 /* Supports tx packet lists */
188#define IFEF_DIRECTLINK 0x20000000 /* point-to-point topology */
189#define _IFEF_INUSE 0x40000000 /* deprecated */
190#define IFEF_UPDOWNCHANGE 0x80000000 /* up/down state is changing */
316670eb
A
191#ifdef XNU_KERNEL_PRIVATE
192/*
193 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL
194 * will also trigger the setting/clearing of the rest of the flags. Once
195 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
196 */
197#define IFEF_AWDL_MASK \
198 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
199 IFEF_AWDL)
200#endif /* XNU_KERNEL_PRIVATE */
201#endif /* PRIVATE */
1c79356b 202
316670eb 203#ifdef KERNEL_PRIVATE
d1ecb069
A
204/*
205 * !!! NOTE !!!
206 *
207 * if_idle_flags definitions: (all bits are reserved for internal/future
208 * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
209 * KPI due to the associated reference counting. Clearing them may be done by
210 * calling the KPI, otherwise implicitly at interface detach time. Setting
211 * the if_idle_flags field to a non-zero value will cause the networking
212 * stack to aggressively purge expired objects (routes, etc.)
213 */
39236c6e 214#define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */
d1ecb069 215
1c79356b
A
216/* flags set internally only: */
217#define IFF_CANTCHANGE \
218 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
219 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
91447636
A
220#endif /* KERNEL_PRIVATE */
221
6d2010ae
A
222/*
223 * Capabilities that interfaces can advertise.
224 *
225 * struct ifnet.if_capabilities
226 * contains the optional features & capabilities a particular interface
227 * supports (not only the driver but also the detected hw revision).
228 * Capabilities are defined by IFCAP_* below.
229 * struct ifnet.if_capenable
230 * contains the enabled (either by default or through ifconfig) optional
231 * features & capabilities on this interface.
232 * Capabilities are defined by IFCAP_* below.
233 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h,
234 * contains the enabled optional features & capabilites that can be used
235 * individually per packet and are specified in the mbuf pkthdr.csum_flags
236 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be
237 * more detailed or differenciated than IFCAP_*.
238 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h
39236c6e
A
239 */
240#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
241#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
242#define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */
243#define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */
244#define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */
245#define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */
246#define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */
247#define IFCAP_LRO 0x00080 /* can do Large Receive Offload */
248#define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */
249#define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */
250
251#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
252#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
253
254#define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \
255 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS)
6d2010ae 256
316670eb 257#define IFQ_MAXLEN 128
fe8ab488
A
258#define IFNET_SLOWHZ 1 /* granularity is 1 second */
259#define IFQ_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */
260#define IFQ_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
1c79356b
A
261
262/*
263 * Message format for use in obtaining information about interfaces
91447636 264 * from sysctl and the routing socket
1c79356b
A
265 */
266struct if_msghdr {
39236c6e 267 unsigned short ifm_msglen; /* to skip non-understood messages */
91447636
A
268 unsigned char ifm_version; /* future binary compatability */
269 unsigned char ifm_type; /* message type */
270 int ifm_addrs; /* like rtm_addrs */
271 int ifm_flags; /* value of if_flags */
272 unsigned short ifm_index; /* index for associated ifp */
273 struct if_data ifm_data; /* statistics and other data about if */
1c79356b
A
274};
275
276/*
277 * Message format for use in obtaining information about interface addresses
91447636 278 * from sysctl and the routing socket
1c79356b
A
279 */
280struct ifa_msghdr {
39236c6e 281 unsigned short ifam_msglen; /* to skip non-understood messages */
91447636
A
282 unsigned char ifam_version; /* future binary compatability */
283 unsigned char ifam_type; /* message type */
284 int ifam_addrs; /* like rtm_addrs */
285 int ifam_flags; /* value of ifa_flags */
286 unsigned short ifam_index; /* index for associated ifp */
287 int ifam_metric; /* value of ifa_metric */
1c79356b
A
288};
289
290/*
291 * Message format for use in obtaining information about multicast addresses
292 * from the routing socket
293 */
294struct ifma_msghdr {
39236c6e 295 unsigned short ifmam_msglen; /* to skip non-understood messages */
91447636
A
296 unsigned char ifmam_version; /* future binary compatability */
297 unsigned char ifmam_type; /* message type */
298 int ifmam_addrs; /* like rtm_addrs */
299 int ifmam_flags; /* value of ifa_flags */
300 unsigned short ifmam_index; /* index for associated ifp */
301};
302
303/*
304 * Message format for use in obtaining information about interfaces
39236c6e 305 * from sysctl
91447636
A
306 */
307struct if_msghdr2 {
308 u_short ifm_msglen; /* to skip over non-understood messages */
309 u_char ifm_version; /* future binary compatability */
310 u_char ifm_type; /* message type */
311 int ifm_addrs; /* like rtm_addrs */
312 int ifm_flags; /* value of if_flags */
313 u_short ifm_index; /* index for associated ifp */
314 int ifm_snd_len; /* instantaneous length of send queue */
315 int ifm_snd_maxlen; /* maximum length of send queue */
316 int ifm_snd_drops; /* number of drops in send queue */
317 int ifm_timer; /* time until if_watchdog called */
39236c6e 318 struct if_data64 ifm_data; /* statistics and other data */
91447636
A
319};
320
321/*
322 * Message format for use in obtaining information about multicast addresses
323 * from sysctl
324 */
325struct ifma_msghdr2 {
1c79356b
A
326 u_short ifmam_msglen; /* to skip over non-understood messages */
327 u_char ifmam_version; /* future binary compatability */
328 u_char ifmam_type; /* message type */
329 int ifmam_addrs; /* like rtm_addrs */
330 int ifmam_flags; /* value of ifa_flags */
331 u_short ifmam_index; /* index for associated ifp */
91447636
A
332 int32_t ifmam_refcount;
333};
334
335/*
336 * ifdevmtu: interface device mtu
337 * Used with SIOCGIFDEVMTU to get the current mtu in use by the device,
338 * as well as the minimum and maximum mtu allowed by the device.
339 */
340struct ifdevmtu {
341 int ifdm_current;
342 int ifdm_min;
343 int ifdm_max;
1c79356b
A
344};
345
2d21ac55
A
346#pragma pack(4)
347
348/*
349 ifkpi: interface kpi ioctl
350 Used with SIOCSIFKPI and SIOCGIFKPI.
351
352 ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From
353 user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket.
354 ifk_type - The type. Types are specific to each module id.
355 ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes.
39236c6e 356
2d21ac55
A
357 Copying data between user space and kernel space is done using copyin
358 and copyout. A process may be running in 64bit mode. In such a case,
359 the pointer will be a 64bit pointer, not a 32bit pointer. The following
360 sample is a safe way to copy the data in to the kernel from either a
361 32bit or 64bit process:
39236c6e 362
2d21ac55
A
363 user_addr_t tmp_ptr;
364 if (IS_64BIT_PROCESS(current_proc())) {
365 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64);
366 }
367 else {
368 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr);
369 }
370 error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer);
371 */
372
373struct ifkpi {
374 unsigned int ifk_module_id;
375 unsigned int ifk_type;
376 union {
377 void *ifk_ptr;
378 int ifk_value;
379#ifdef KERNEL
380 u_int64_t ifk_ptr64;
381#endif /* KERNEL */
382 } ifk_data;
383};
384
39236c6e
A
385/* Wake capabilities of a interface */
386#define IF_WAKE_ON_MAGIC_PACKET 0x01
b0d623f7 387#ifdef KERNEL_PRIVATE
39236c6e 388#define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET
b0d623f7
A
389#endif /* KERNEL_PRIVATE */
390
391
2d21ac55
A
392#pragma pack()
393
1c79356b
A
394/*
395 * Interface request structure used for socket
396 * ioctl's. All interface ioctl's must have parameter
397 * definitions which begin with ifr_name. The
398 * remainder may be interface specific.
399 */
1c79356b 400struct ifreq {
91447636
A
401#ifndef IFNAMSIZ
402#define IFNAMSIZ IF_NAMESIZE
403#endif
1c79356b
A
404 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
405 union {
406 struct sockaddr ifru_addr;
407 struct sockaddr ifru_dstaddr;
408 struct sockaddr ifru_broadaddr;
409 short ifru_flags;
410 int ifru_metric;
411 int ifru_mtu;
412 int ifru_phys;
413 int ifru_media;
316670eb 414 int ifru_intval;
1c79356b 415 caddr_t ifru_data;
91447636
A
416#ifdef KERNEL_PRIVATE
417 u_int64_t ifru_data64; /* 64-bit ifru_data */
b0d623f7 418#endif /* KERNEL_PRIVATE */
91447636 419 struct ifdevmtu ifru_devmtu;
2d21ac55 420 struct ifkpi ifru_kpi;
b0d623f7 421 u_int32_t ifru_wake_flags;
d1ecb069 422 u_int32_t ifru_route_refcnt;
316670eb
A
423#ifdef PRIVATE
424 int ifru_link_quality_metric;
425#endif /* PRIVATE */
39236c6e 426 int ifru_cap[2];
316670eb
A
427#ifdef PRIVATE
428 struct {
429 uint32_t ifo_flags;
39236c6e 430#define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001
316670eb
A
431 uint32_t ifo_inuse;
432 } ifru_opportunistic;
433 u_int64_t ifru_eflags;
39236c6e
A
434 struct {
435 int32_t ifl_level;
436 uint32_t ifl_flags;
437#define IFRLOGF_DLIL 0x00000001
438#define IFRLOGF_FAMILY 0x00010000
439#define IFRLOGF_DRIVER 0x01000000
440#define IFRLOGF_FIRMWARE 0x10000000
441 int32_t ifl_category;
442#define IFRLOGCAT_CONNECTIVITY 1
443#define IFRLOGCAT_QUALITY 2
444#define IFRLOGCAT_PERFORMANCE 3
445 int32_t ifl_subcategory;
446 } ifru_log;
447 u_int32_t ifru_delegated;
448 struct {
449 uint32_t ift_type;
450 uint32_t ift_family;
451#define IFRTYPE_FAMILY_ANY 0
452#define IFRTYPE_FAMILY_LOOPBACK 1
453#define IFRTYPE_FAMILY_ETHERNET 2
454#define IFRTYPE_FAMILY_SLIP 3
455#define IFRTYPE_FAMILY_TUN 4
456#define IFRTYPE_FAMILY_VLAN 5
457#define IFRTYPE_FAMILY_PPP 6
458#define IFRTYPE_FAMILY_PVC 7
459#define IFRTYPE_FAMILY_DISC 8
460#define IFRTYPE_FAMILY_MDECAP 9
461#define IFRTYPE_FAMILY_GIF 10
462#define IFRTYPE_FAMILY_FAITH 11
463#define IFRTYPE_FAMILY_STF 12
464#define IFRTYPE_FAMILY_FIREWIRE 13
465#define IFRTYPE_FAMILY_BOND 14
466#define IFRTYPE_FAMILY_CELLULAR 15
467 uint32_t ift_subfamily;
468#define IFRTYPE_SUBFAMILY_ANY 0
469#define IFRTYPE_SUBFAMILY_USB 1
470#define IFRTYPE_SUBFAMILY_BLUETOOTH 2
471#define IFRTYPE_SUBFAMILY_WIFI 3
472#define IFRTYPE_SUBFAMILY_THUNDERBOLT 4
fe8ab488 473#define IFRTYPE_SUBFAMILY_RESERVED 5
39236c6e 474 } ifru_type;
3e170ce0
A
475 u_int32_t ifru_functional_type;
476#define IFRTYPE_FUNCTIONAL_UNKNOWN 0
477#define IFRTYPE_FUNCTIONAL_LOOPBACK 1
478#define IFRTYPE_FUNCTIONAL_WIRED 2
479#define IFRTYPE_FUNCTIONAL_WIFI_INFRA 3
480#define IFRTYPE_FUNCTIONAL_WIFI_AWDL 4
481#define IFRTYPE_FUNCTIONAL_CELLULAR 5
482#define IFRTYPE_FUNCTIONAL_LAST 5
fe8ab488 483 u_int32_t ifru_expensive;
fe8ab488 484 u_int32_t ifru_2kcl;
3e170ce0
A
485 struct {
486 u_int32_t qlen;
487 u_int32_t timeout;
488 } ifru_start_delay;
489 struct if_interface_state ifru_interface_state;
490 u_int32_t ifru_probe_connectivity;
4bd07ac2
A
491 u_int32_t ifru_ecn_mode;
492#define IFRTYPE_ECN_DEFAULT 0
493#define IFRTYPE_ECN_ENABLE 1
494#define IFRTYPE_ECN_DISABLE 2
316670eb 495#endif /* PRIVATE */
1c79356b
A
496 } ifr_ifru;
497#define ifr_addr ifr_ifru.ifru_addr /* address */
498#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
499#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
9bccf70c 500#ifdef __APPLE__
1c79356b 501#define ifr_flags ifr_ifru.ifru_flags /* flags */
9bccf70c
A
502#else
503#define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
504#define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
505#endif /* __APPLE__ */
1c79356b
A
506#define ifr_metric ifr_ifru.ifru_metric /* metric */
507#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
39236c6e
A
508#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
509#define ifr_media ifr_ifru.ifru_media /* physical media */
1c79356b 510#define ifr_data ifr_ifru.ifru_data /* for use by interface */
39236c6e
A
511#define ifr_devmtu ifr_ifru.ifru_devmtu
512#define ifr_intval ifr_ifru.ifru_intval /* integer value */
91447636 513#ifdef KERNEL_PRIVATE
39236c6e 514#define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */
b0d623f7 515#endif /* KERNEL_PRIVATE */
39236c6e
A
516#define ifr_kpi ifr_ifru.ifru_kpi
517#define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */
518#define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */
316670eb 519#ifdef PRIVATE
39236c6e 520#define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
316670eb 521#endif /* PRIVATE */
39236c6e
A
522#define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
523#define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
316670eb 524#ifdef PRIVATE
39236c6e 525#define ifr_opportunistic ifr_ifru.ifru_opportunistic
316670eb 526#define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */
39236c6e
A
527#define ifr_log ifr_ifru.ifru_log /* logging level/flags */
528#define ifr_delegated ifr_ifru.ifru_delegated /* delegated interface index */
fe8ab488 529#define ifr_expensive ifr_ifru.ifru_expensive
39236c6e 530#define ifr_type ifr_ifru.ifru_type /* interface type */
3e170ce0 531#define ifr_functional_type ifr_ifru.ifru_functional_type
fe8ab488 532#define ifr_2kcl ifr_ifru.ifru_2kcl
3e170ce0
A
533#define ifr_start_delay_qlen ifr_ifru.ifru_start_delay.qlen
534#define ifr_start_delay_timeout ifr_ifru.ifru_start_delay.timeout
535#define ifr_interface_state ifr_ifru.ifru_interface_state
536#define ifr_probe_connectivity ifr_ifru.ifru_probe_connectivity
4bd07ac2 537#define ifr_ecn_mode ifr_ifru.ifru_ecn_mode
39236c6e 538#endif /* PRIVATE */
1c79356b
A
539};
540
541#define _SIZEOF_ADDR_IFREQ(ifr) \
39236c6e
A
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))
1c79356b
A
545
546struct 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
553struct rslvmulti_req {
39236c6e
A
554 struct sockaddr *sa;
555 struct sockaddr **llsa;
1c79356b
A
556};
557
b0d623f7 558#if !defined(KERNEL) || defined(KERNEL_PRIVATE)
2d21ac55
A
559#pragma pack(4)
560
1c79356b
A
561struct 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};
9bccf70c 570
2d21ac55 571#pragma pack()
b0d623f7 572#endif /* !KERNEL || KERNEL_PRIVATE */
2d21ac55 573
91447636 574#ifdef KERNEL_PRIVATE
b0d623f7 575#pragma pack(4)
91447636
A
576struct 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 */
b0d623f7 583 user64_addr_t ifmu_ulist __attribute__((aligned(8)));
91447636 584};
b0d623f7
A
585
586struct 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 */
91447636 597
b7266188
A
598
599#pragma pack(4)
600struct ifdrv {
39236c6e 601 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
b7266188 602 unsigned long ifd_cmd;
39236c6e 603 size_t ifd_len; /* length of ifd_data buffer */
b7266188
A
604 void *ifd_data;
605};
606#pragma pack()
607
608#ifdef KERNEL_PRIVATE
609#pragma pack(4)
610struct ifdrv32 {
39236c6e 611 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
b7266188
A
612 u_int32_t ifd_cmd;
613 u_int32_t ifd_len;
614 user32_addr_t ifd_data;
615};
616
617struct ifdrv64 {
39236c6e 618 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
b7266188
A
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
39236c6e 626/*
9bccf70c
A
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
39236c6e 630 * a newline.
9bccf70c
A
631 */
632
633#define IFSTATMAX 800 /* 10 lines of text */
634struct ifstat {
635 char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */
636 char ascii[IFSTATMAX + 1];
637};
638
b0d623f7 639#if !defined(KERNEL) || defined(KERNEL_PRIVATE)
1c79356b
A
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 */
b0d623f7 646#pragma pack(4)
1c79356b
A
647struct ifconf {
648 int ifc_len; /* size of associated buffer */
649 union {
650 caddr_t ifcu_buf;
651 struct ifreq *ifcu_req;
652 } ifc_ifcu;
2d21ac55 653};
b0d623f7 654#pragma pack()
1c79356b
A
655#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
656#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
b0d623f7 657#endif /* !KERNEL || KERNEL_PRIVATE */
2d21ac55 658
b0d623f7
A
659#if defined(KERNEL_PRIVATE)
660#pragma pack(4)
661struct ifconf32 {
39236c6e 662 int ifc_len; /* size of associated buffer */
b0d623f7
A
663 struct {
664 user32_addr_t ifcu_req;
665 } ifc_ifcu;
666};
1c79356b 667
91447636 668struct ifconf64 {
39236c6e 669 int ifc_len; /* size of associated buffer */
b0d623f7
A
670 struct {
671 user64_addr_t ifcu_req __attribute__((aligned(8)));
91447636
A
672 } ifc_ifcu;
673};
b0d623f7
A
674#pragma pack()
675#endif /* KERNEL_PRIVATE */
91447636 676
0b4e3aa0
A
677/*
678 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
679 */
680struct kev_dl_proto_data {
39236c6e
A
681 struct net_event_data link_data;
682 u_int32_t proto_family;
683 u_int32_t proto_remaining_count;
0b4e3aa0 684};
0b4e3aa0 685
316670eb
A
686#ifdef PRIVATE
687/*
39236c6e 688 * Link Quality Metrics
316670eb 689 *
39236c6e
A
690 * IFNET_LQM_THRESH_OFF Metric is not available; device is off.
691 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known.
fe8ab488 692 * IFNET_LQM_THRESH_BAD Link quality is considered bad by driver.
39236c6e
A
693 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver.
694 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver.
316670eb
A
695 */
696enum {
697 IFNET_LQM_THRESH_OFF = (-2),
698 IFNET_LQM_THRESH_UNKNOWN = (-1),
fe8ab488 699 IFNET_LQM_THRESH_BAD = 10,
316670eb
A
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 */
711struct 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 */
721struct 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 */
741enum {
742 IFNET_SCHED_MODEL_NORMAL = 0,
743 IFNET_SCHED_MODEL_DRIVER_MANAGED = 1,
744#ifdef XNU_KERNEL_PRIVATE
745 IFNET_SCHED_MODEL_MAX = 2,
746#endif /* XNU_KERNEL_PRIVATE */
747};
748
749/*
750 * Values for iflpr_flags
751 */
752#define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */
753#define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */
754
755/*
756 * Structure for SIOCGIFLINKPARAMS
757 */
758struct if_linkparamsreq {
759 char iflpr_name[IFNAMSIZ]; /* interface name */
760 u_int32_t iflpr_flags;
761 u_int32_t iflpr_output_sched;
762 u_int64_t iflpr_output_tbr_rate;
763 u_int32_t iflpr_output_tbr_percent;
764 struct if_bandwidths iflpr_output_bw;
765 struct if_bandwidths iflpr_input_bw;
39236c6e
A
766 struct if_latencies iflpr_output_lt;
767 struct if_latencies iflpr_input_lt;
316670eb
A
768};
769
770/*
771 * Structure for SIOCGIFQUEUESTATS
772 */
773struct if_qstatsreq {
774 char ifqr_name[IFNAMSIZ]; /* interface name */
775 u_int32_t ifqr_slot;
776 void *ifqr_buf __attribute__((aligned(8)));
777 int ifqr_len __attribute__((aligned(8)));
778};
779
780/*
781 * Node Proximity Metrics
782 */
783enum {
784 IFNET_NPM_THRESH_UNKNOWN = (-1),
785 IFNET_NPM_THRESH_NEAR = 30,
786 IFNET_NPM_THRESH_GENERAL = 70,
787 IFNET_NPM_THRESH_FAR = 100,
788};
789
790/*
791 * Received Signal Strength Indication [special values]
792 *
793 * IFNET_RSSI_UNKNOWN Metric is not (yet) known.
794 */
795enum {
796 IFNET_RSSI_UNKNOWN = ((-2147483647)-1), /* INT32_MIN */
797};
798
799
800/*
801 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
802 */
803struct kev_dl_node_presence {
804 struct net_event_data link_data;
805 struct sockaddr_in6 sin6_node_address;
806 struct sockaddr_dl sdl_node_address;
807 int32_t rssi;
808 int link_quality_metric;
809 int node_proximity_metric;
810 u_int8_t node_service_info[48];
811};
812
813struct kev_dl_node_absence {
814 struct net_event_data link_data;
815 struct sockaddr_in6 sin6_node_address;
816 struct sockaddr_dl sdl_node_address;
817};
818
819/*
820 * Structure for SIOC[SG]IFTHROTTLE
821 */
822struct if_throttlereq {
823 char ifthr_name[IFNAMSIZ]; /* interface name */
824 u_int32_t ifthr_level;
825};
826
827/*
828 * Interface throttling levels
829 *
830 * IFNET_THROTTLE_OFF The default throttling level (no throttling.)
831 * All service class queues operate normally according to the
832 * standard packet scheduler configuration.
833 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
834 * are responsible for managing "opportunistic" traffics are
835 * suspended. Packets enqueued on those queues will be dropped
836 * and a flow advisory error will be generated to the data
837 * source. Existing packets in the queues will stay enqueued
838 * until the interface is no longer throttled, or until they
839 * are explicitly flushed.
840 */
841enum {
842 IFNET_THROTTLE_OFF = 0,
843 IFNET_THROTTLE_OPPORTUNISTIC = 1,
844#ifdef XNU_KERNEL_PRIVATE
845 IFNET_THROTTLE_MAX = 2,
846#endif /* XNU_KERNEL_PRIVATE */
847};
39236c6e 848
3e170ce0
A
849/*
850 * Structure for SIOC[A/D]IFAGENTID
851 */
852struct if_agentidreq {
853 char ifar_name[IFNAMSIZ]; /* interface name */
854 uuid_t ifar_uuid; /* agent UUID to add or delete */
855};
856
857/*
858 * Structure for SIOCGIFAGENTIDS
859 */
860struct if_agentidsreq {
861 char ifar_name[IFNAMSIZ]; /* interface name */
862 u_int32_t ifar_count; /* number of agent UUIDs */
863 uuid_t *ifar_uuids; /* array of agent UUIDs */
864};
865
866#ifdef BSD_KERNEL_PRIVATE
867struct if_agentidsreq32 {
868 char ifar_name[IFNAMSIZ];
869 u_int32_t ifar_count;
870 user32_addr_t ifar_uuids;
871};
872struct if_agentidsreq64 {
873 char ifar_name[IFNAMSIZ];
874 u_int32_t ifar_count;
875 user64_addr_t ifar_uuids __attribute__((aligned(8)));
876};
877#endif /* BSD_KERNEL_PRIVATE */
878
39236c6e
A
879#define DLIL_MODIDLEN 20 /* same as IFNET_MODIDLEN */
880#define DLIL_MODARGLEN 12 /* same as IFNET_MODARGLEN */
881
882/*
883 * DLIL KEV_DL_ISSUES event structure
884 */
885struct kev_dl_issues {
886 struct net_event_data link_data;
887 u_int8_t modid[DLIL_MODIDLEN];
888 u_int64_t timestamp;
889 u_int8_t info[DLIL_MODARGLEN];
890};
3e170ce0
A
891
892/*
893 * DLIL KEV_DL_RRC_STATE_CHANGED structure
894 */
895struct kev_dl_rrc_state {
896 struct net_event_data link_data;
897 u_int32_t rrc_state;
898};
899
900/*
901 * Length of network signature/fingerprint blob.
902 */
903#define IFNET_SIGNATURELEN 20
904
905/*
906 * Structure for SIOC[S/G]IFNETSIGNATURE
907 */
908struct if_nsreq {
909 char ifnsr_name[IFNAMSIZ];
910 u_int8_t ifnsr_family; /* address family */
911 u_int8_t ifnsr_len; /* data length */
912 u_int16_t ifnsr_flags; /* for future */
913 u_int8_t ifnsr_data[IFNET_SIGNATURELEN];
914};
316670eb
A
915#endif /* PRIVATE */
916
1c79356b
A
917#ifdef KERNEL
918#ifdef MALLOC_DECLARE
919MALLOC_DECLARE(M_IFADDR);
920MALLOC_DECLARE(M_IFMADDR);
921#endif
922#endif
2d21ac55 923#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
1c79356b
A
924
925#ifndef KERNEL
9bccf70c 926struct if_nameindex {
91447636
A
927 unsigned int if_index; /* 1, 2, ... */
928 char *if_name; /* null terminated name: "le0", ... */
9bccf70c
A
929};
930
1c79356b 931__BEGIN_DECLS
91447636
A
932unsigned int if_nametoindex(const char *);
933char *if_indextoname(unsigned int, char *);
934struct if_nameindex *if_nameindex(void);
935void if_freenameindex(struct if_nameindex *);
1c79356b
A
936__END_DECLS
937#endif
938
1c79356b 939#ifdef KERNEL
91447636 940#include <net/kpi_interface.h>
1c79356b
A
941#endif
942
943#endif /* !_NET_IF_H_ */