2 * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1986, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
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.
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
60 * @(#)if.h 8.1 (Berkeley) 6/10/93
66 #include <sys/cdefs.h>
68 #define IF_NAMESIZE 16
70 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
71 #include <sys/appleapiopts.h>
74 * Define Data-Link event subclass, and associated
78 #define KEV_DL_SUBCLASS 2
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
106 #include <net/if_var.h>
107 #include <sys/types.h>
108 #include <sys/socket.h>
111 #include <net/if_dl.h>
112 #include <netinet/in.h>
117 int ifcr_total
; /* total cloners (out) */
118 int ifcr_count
; /* room for this many in user buffer */
119 char *ifcr_buffer
; /* buffer for cloner names */
122 #ifdef KERNEL_PRIVATE
123 #define IF_MAXUNIT 0x7fff /* historical value */
125 struct if_clonereq64
{
126 int ifcr_total
; /* total cloners (out) */
127 int ifcr_count
; /* room for this many in user buffer */
128 user64_addr_t ifcru_buffer
__attribute__((aligned(8)));
131 struct if_clonereq32
{
132 int ifcr_total
; /* total cloners (out) */
133 int ifcr_count
; /* room for this many in user buffer */
134 user32_addr_t ifcru_buffer
;
136 #endif /* KERNEL_PRIVATE */
138 #define IFF_UP 0x1 /* interface is up */
139 #define IFF_BROADCAST 0x2 /* broadcast address valid */
140 #define IFF_DEBUG 0x4 /* turn on debugging */
141 #define IFF_LOOPBACK 0x8 /* is a loopback net */
142 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
143 #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
144 #define IFF_RUNNING 0x40 /* resources allocated */
145 #define IFF_NOARP 0x80 /* no address resolution protocol */
146 #define IFF_PROMISC 0x100 /* receive all packets */
147 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
148 #define IFF_OACTIVE 0x400 /* transmission in progress */
149 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
150 #define IFF_LINK0 0x1000 /* per link layer defined bit */
151 #define IFF_LINK1 0x2000 /* per link layer defined bit */
152 #define IFF_LINK2 0x4000 /* per link layer defined bit */
153 #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
154 #define IFF_MULTICAST 0x8000 /* supports multicast */
157 /* extended flags definitions: (all bits reserved for internal/future use) */
158 #define IFEF_AUTOCONFIGURING 0x1 /* allow BOOTP/DHCP replies to enter */
159 #define IFEF_IPV6_DISABLED 0x20 /* coupled to ND6_IFF_IFDISABLED */
160 #define IFEF_ACCEPT_RTADV 0x40 /* accepts IPv6 RA on the interface */
161 #define IFEF_TXSTART 0x80 /* has start callback */
162 #define IFEF_RXPOLL 0x100 /* supports opportunistic input poll */
163 #define IFEF_VLAN 0x200 /* interface has one or more vlans */
164 #define IFEF_BOND 0x400 /* interface is part of bond */
165 #define IFEF_ARPLL 0x800 /* ARP for IPv4LL addresses */
166 #define IFEF_NOWINDOWSCALE 0x1000 /* Don't scale TCP window on iface */
167 #define IFEF_NOAUTOIPV6LL 0x2000 /* Need explicit IPv6 LL address */
168 #define IFEF_IPV4_ROUTER 0x8000 /* interior when in IPv4 router mode */
169 #define IFEF_IPV6_ROUTER 0x10000 /* interior when in IPv6 router mode */
170 #define IFEF_LOCALNET_PRIVATE 0x20000 /* local private network */
171 #define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE
172 #define IFEF_IPV6_ND6ALT 0x40000 /* alternative. KPI for ND6 */
173 #define IFEF_RESTRICTED_RECV 0x80000 /* interface restricts inbound pkts */
174 #define IFEF_AWDL 0x100000 /* Apple Wireless Direct Link */
175 #define IFEF_NOACKPRI 0x200000 /* No TCP ACK prioritization */
176 #define IFEF_SENDLIST 0x10000000 /* Supports tx packet lists */
177 #define IFEF_DIRECTLINK 0x20000000 /* point-to-point topology */
178 #define _IFEF_INUSE 0x40000000 /* deprecated */
179 #define IFEF_UPDOWNCHANGE 0x80000000 /* up/down state is changing */
180 #ifdef XNU_KERNEL_PRIVATE
182 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL
183 * will also trigger the setting/clearing of the rest of the flags. Once
184 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
186 #define IFEF_AWDL_MASK \
187 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
189 #endif /* XNU_KERNEL_PRIVATE */
192 #ifdef KERNEL_PRIVATE
196 * if_idle_flags definitions: (all bits are reserved for internal/future
197 * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
198 * KPI due to the associated reference counting. Clearing them may be done by
199 * calling the KPI, otherwise implicitly at interface detach time. Setting
200 * the if_idle_flags field to a non-zero value will cause the networking
201 * stack to aggressively purge expired objects (routes, etc.)
203 #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */
205 /* flags set internally only: */
206 #define IFF_CANTCHANGE \
207 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
208 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
209 #endif /* KERNEL_PRIVATE */
212 * Capabilities that interfaces can advertise.
214 * struct ifnet.if_capabilities
215 * contains the optional features & capabilities a particular interface
216 * supports (not only the driver but also the detected hw revision).
217 * Capabilities are defined by IFCAP_* below.
218 * struct ifnet.if_capenable
219 * contains the enabled (either by default or through ifconfig) optional
220 * features & capabilities on this interface.
221 * Capabilities are defined by IFCAP_* below.
222 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h,
223 * contains the enabled optional features & capabilites that can be used
224 * individually per packet and are specified in the mbuf pkthdr.csum_flags
225 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be
226 * more detailed or differenciated than IFCAP_*.
227 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h
229 #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
230 #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
231 #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */
232 #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */
233 #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */
234 #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */
235 #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */
236 #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */
237 #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */
238 #define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */
240 #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
241 #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
243 #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \
244 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS)
246 #define IFQ_MAXLEN 128
247 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
250 * Message format for use in obtaining information about interfaces
251 * from sysctl and the routing socket
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 */
264 * Message format for use in obtaining information about interface addresses
265 * from sysctl and the routing socket
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 */
278 * Message format for use in obtaining information about multicast addresses
279 * from the routing socket
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 */
291 * Message format for use in obtaining information about interfaces
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 */
309 * Message format for use in obtaining information about multicast addresses
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
;
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.
336 ifkpi: interface kpi ioctl
337 Used with SIOCSIFKPI and SIOCGIFKPI.
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.
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:
351 if (IS_64BIT_PROCESS(current_proc())) {
352 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64);
355 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr);
357 error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer);
361 unsigned int ifk_module_id
;
362 unsigned int ifk_type
;
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 */
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.
389 #define IFNAMSIZ IF_NAMESIZE
391 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
393 struct sockaddr ifru_addr
;
394 struct sockaddr ifru_dstaddr
;
395 struct sockaddr ifru_broadaddr
;
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
;
411 int ifru_link_quality_metric
;
417 #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001
419 } ifru_opportunistic
;
420 u_int64_t ifru_eflags
;
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
;
434 u_int32_t ifru_delegated
;
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
463 #define ifr_addr ifr_ifru.ifru_addr /* address */
464 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
465 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
467 #define ifr_flags ifr_ifru.ifru_flags /* flags */
469 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
470 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
471 #endif /* __APPLE__ */
472 #define ifr_metric ifr_ifru.ifru_metric /* metric */
473 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
474 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
475 #define ifr_media ifr_ifru.ifru_media /* physical media */
476 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
477 #define ifr_devmtu ifr_ifru.ifru_devmtu
478 #define ifr_intval ifr_ifru.ifru_intval /* integer value */
479 #ifdef KERNEL_PRIVATE
480 #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */
481 #endif /* KERNEL_PRIVATE */
482 #define ifr_kpi ifr_ifru.ifru_kpi
483 #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */
484 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */
486 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
488 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
489 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
491 #define ifr_opportunistic ifr_ifru.ifru_opportunistic
492 #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */
493 #define ifr_log ifr_ifru.ifru_log /* logging level/flags */
494 #define ifr_delegated ifr_ifru.ifru_delegated /* delegated interface index */
495 #define ifr_type ifr_ifru.ifru_type /* interface type */
499 #define _SIZEOF_ADDR_IFREQ(ifr) \
500 ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \
501 (sizeof (struct ifreq) - sizeof (struct sockaddr) + \
502 (ifr).ifr_addr.sa_len) : sizeof (struct ifreq))
505 char ifra_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
506 struct sockaddr ifra_addr
;
507 struct sockaddr ifra_broadaddr
;
508 struct sockaddr ifra_mask
;
511 struct rslvmulti_req
{
513 struct sockaddr
**llsa
;
516 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
520 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
521 int ifm_current
; /* current media options */
522 int ifm_mask
; /* don't care mask */
523 int ifm_status
; /* media status */
524 int ifm_active
; /* active options */
525 int ifm_count
; /* # entries in ifm_ulist array */
526 int *ifm_ulist
; /* media words */
530 #endif /* !KERNEL || KERNEL_PRIVATE */
532 #ifdef KERNEL_PRIVATE
534 struct ifmediareq64
{
535 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
536 int ifm_current
; /* current media options */
537 int ifm_mask
; /* don't care mask */
538 int ifm_status
; /* media status */
539 int ifm_active
; /* active options */
540 int ifm_count
; /* # entries in ifm_ulist array */
541 user64_addr_t ifmu_ulist
__attribute__((aligned(8)));
544 struct ifmediareq32
{
545 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
546 int ifm_current
; /* current media options */
547 int ifm_mask
; /* don't care mask */
548 int ifm_status
; /* media status */
549 int ifm_active
; /* active options */
550 int ifm_count
; /* # entries in ifm_ulist array */
551 user32_addr_t ifmu_ulist
; /* 32-bit pointer */
554 #endif /* KERNEL_PRIVATE */
559 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
560 unsigned long ifd_cmd
;
561 size_t ifd_len
; /* length of ifd_data buffer */
566 #ifdef KERNEL_PRIVATE
569 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
572 user32_addr_t ifd_data
;
576 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
579 user64_addr_t ifd_data
;
582 #endif /* KERNEL_PRIVATE */
585 * Structure used to retrieve aux status data from interfaces.
586 * Kernel suppliers to this interface should respect the formatting
587 * needed by ifconfig(8): each line starts with a TAB and ends with
591 #define IFSTATMAX 800 /* 10 lines of text */
593 char ifs_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
594 char ascii
[IFSTATMAX
+ 1];
597 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
599 * Structure used in SIOCGIFCONF request.
600 * Used to retrieve interface configuration
601 * for machine (useful for programs which
602 * must know all networks accessible).
606 int ifc_len
; /* size of associated buffer */
609 struct ifreq
*ifcu_req
;
613 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
614 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
615 #endif /* !KERNEL || KERNEL_PRIVATE */
617 #if defined(KERNEL_PRIVATE)
620 int ifc_len
; /* size of associated buffer */
622 user32_addr_t ifcu_req
;
627 int ifc_len
; /* size of associated buffer */
629 user64_addr_t ifcu_req
__attribute__((aligned(8)));
633 #endif /* KERNEL_PRIVATE */
636 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
638 struct kev_dl_proto_data
{
639 struct net_event_data link_data
;
640 u_int32_t proto_family
;
641 u_int32_t proto_remaining_count
;
645 * Structure for SIOC[AGD]LIFADDR
648 char iflr_name
[IFNAMSIZ
];
650 #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
651 unsigned int prefixlen
; /* in/out */
652 struct sockaddr_storage addr
; /* in/out */
653 struct sockaddr_storage dstaddr
; /* out */
658 * Link Quality Metrics
660 * IFNET_LQM_THRESH_OFF Metric is not available; device is off.
661 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known.
662 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver.
663 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver.
666 IFNET_LQM_THRESH_OFF
= (-2),
667 IFNET_LQM_THRESH_UNKNOWN
= (-1),
668 IFNET_LQM_THRESH_POOR
= 50,
669 IFNET_LQM_THRESH_GOOD
= 100
671 #ifdef XNU_KERNEL_PRIVATE
672 #define IFNET_LQM_MIN IFNET_LQM_THRESH_OFF
673 #define IFNET_LQM_MAX IFNET_LQM_THRESH_GOOD
674 #endif /* XNU_KERNEL_PRIVATE */
677 * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure
679 struct kev_dl_link_quality_metric_data
{
680 struct net_event_data link_data
;
681 int link_quality_metric
;
684 #define IF_DESCSIZE 128
687 * Structure for SIOC[SG]IFDESC
690 char ifdr_name
[IFNAMSIZ
]; /* interface name */
691 u_int32_t ifdr_len
; /* up to IF_DESCSIZE */
692 u_int8_t ifdr_desc
[IF_DESCSIZE
]; /* opaque data */
696 * Output packet scheduling models
698 * IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model
699 * where the driver or media does not require strict scheduling
700 * strategy, and that the networking stack is free to choose the
701 * most appropriate scheduling and queueing algorithm, including
703 * IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet
704 * scheduling model where the driver or media requires strict
705 * scheduling strategy (e.g. 802.11 WMM), and that the networking
706 * stack is only responsible for creating multiple queues for the
707 * corresponding service classes.
710 IFNET_SCHED_MODEL_NORMAL
= 0,
711 IFNET_SCHED_MODEL_DRIVER_MANAGED
= 1,
712 #ifdef XNU_KERNEL_PRIVATE
713 IFNET_SCHED_MODEL_MAX
= 2,
714 #endif /* XNU_KERNEL_PRIVATE */
718 * Values for iflpr_flags
720 #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */
721 #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */
724 * Structure for SIOCGIFLINKPARAMS
726 struct if_linkparamsreq
{
727 char iflpr_name
[IFNAMSIZ
]; /* interface name */
728 u_int32_t iflpr_flags
;
729 u_int32_t iflpr_output_sched
;
730 u_int64_t iflpr_output_tbr_rate
;
731 u_int32_t iflpr_output_tbr_percent
;
732 struct if_bandwidths iflpr_output_bw
;
733 struct if_bandwidths iflpr_input_bw
;
734 struct if_latencies iflpr_output_lt
;
735 struct if_latencies iflpr_input_lt
;
739 * Structure for SIOCGIFQUEUESTATS
741 struct if_qstatsreq
{
742 char ifqr_name
[IFNAMSIZ
]; /* interface name */
744 void *ifqr_buf
__attribute__((aligned(8)));
745 int ifqr_len
__attribute__((aligned(8)));
749 * Node Proximity Metrics
752 IFNET_NPM_THRESH_UNKNOWN
= (-1),
753 IFNET_NPM_THRESH_NEAR
= 30,
754 IFNET_NPM_THRESH_GENERAL
= 70,
755 IFNET_NPM_THRESH_FAR
= 100,
759 * Received Signal Strength Indication [special values]
761 * IFNET_RSSI_UNKNOWN Metric is not (yet) known.
764 IFNET_RSSI_UNKNOWN
= ((-2147483647)-1), /* INT32_MIN */
769 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
771 struct kev_dl_node_presence
{
772 struct net_event_data link_data
;
773 struct sockaddr_in6 sin6_node_address
;
774 struct sockaddr_dl sdl_node_address
;
776 int link_quality_metric
;
777 int node_proximity_metric
;
778 u_int8_t node_service_info
[48];
781 struct kev_dl_node_absence
{
782 struct net_event_data link_data
;
783 struct sockaddr_in6 sin6_node_address
;
784 struct sockaddr_dl sdl_node_address
;
788 * Structure for SIOC[SG]IFTHROTTLE
790 struct if_throttlereq
{
791 char ifthr_name
[IFNAMSIZ
]; /* interface name */
792 u_int32_t ifthr_level
;
796 * Interface throttling levels
798 * IFNET_THROTTLE_OFF The default throttling level (no throttling.)
799 * All service class queues operate normally according to the
800 * standard packet scheduler configuration.
801 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
802 * are responsible for managing "opportunistic" traffics are
803 * suspended. Packets enqueued on those queues will be dropped
804 * and a flow advisory error will be generated to the data
805 * source. Existing packets in the queues will stay enqueued
806 * until the interface is no longer throttled, or until they
807 * are explicitly flushed.
810 IFNET_THROTTLE_OFF
= 0,
811 IFNET_THROTTLE_OPPORTUNISTIC
= 1,
812 #ifdef XNU_KERNEL_PRIVATE
813 IFNET_THROTTLE_MAX
= 2,
814 #endif /* XNU_KERNEL_PRIVATE */
817 #define DLIL_MODIDLEN 20 /* same as IFNET_MODIDLEN */
818 #define DLIL_MODARGLEN 12 /* same as IFNET_MODARGLEN */
821 * DLIL KEV_DL_ISSUES event structure
823 struct kev_dl_issues
{
824 struct net_event_data link_data
;
825 u_int8_t modid
[DLIL_MODIDLEN
];
827 u_int8_t info
[DLIL_MODARGLEN
];
832 #ifdef MALLOC_DECLARE
833 MALLOC_DECLARE(M_IFADDR
);
834 MALLOC_DECLARE(M_IFMADDR
);
837 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
840 struct if_nameindex
{
841 unsigned int if_index
; /* 1, 2, ... */
842 char *if_name
; /* null terminated name: "le0", ... */
846 unsigned int if_nametoindex(const char *);
847 char *if_indextoname(unsigned int, char *);
848 struct if_nameindex
*if_nameindex(void);
849 void if_freenameindex(struct if_nameindex
*);
854 #include <net/kpi_interface.h>
857 #endif /* !_NET_IF_H_ */