2 * Copyright (c) 2000-2012 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
61 * $FreeBSD: src/sys/net/if.h,v 1.58.2.2 2001/07/24 19:10:18 brooks Exp $
67 #include <sys/cdefs.h>
69 #define IF_NAMESIZE 16
71 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
72 #include <sys/appleapiopts.h>
75 * Define Data-Link event subclass, and associated
79 #define KEV_DL_SUBCLASS 2
81 #define KEV_DL_SIFFLAGS 1
82 #define KEV_DL_SIFMETRICS 2
83 #define KEV_DL_SIFMTU 3
84 #define KEV_DL_SIFPHYS 4
85 #define KEV_DL_SIFMEDIA 5
86 #define KEV_DL_SIFGENERIC 6
87 #define KEV_DL_ADDMULTI 7
88 #define KEV_DL_DELMULTI 8
89 #define KEV_DL_IF_ATTACHED 9
90 #define KEV_DL_IF_DETACHING 10
91 #define KEV_DL_IF_DETACHED 11
92 #define KEV_DL_LINK_OFF 12
93 #define KEV_DL_LINK_ON 13
94 #define KEV_DL_PROTO_ATTACHED 14
95 #define KEV_DL_PROTO_DETACHED 15
96 #define KEV_DL_LINK_ADDRESS_CHANGED 16
97 #define KEV_DL_WAKEFLAGS_CHANGED 17
98 #define KEV_DL_IF_IDLE_ROUTE_REFCNT 18
99 #define KEV_DL_IFCAP_CHANGED 19
100 #define KEV_DL_LINK_QUALITY_METRIC_CHANGED 20
101 #define KEV_DL_NODE_PRESENCE 21
102 #define KEV_DL_NODE_ABSENCE 22
103 #define KEV_DL_MASTER_ELECTED 23
105 #include <net/if_var.h>
106 #include <sys/types.h>
109 #include <net/if_dl.h>
110 #include <netinet/in.h>
114 #ifdef KERNEL_PRIVATE
115 #define IF_MAXUNIT 0x7fff /* historical value */
118 int ifcr_total
; /* total cloners (out) */
119 int ifcr_count
; /* room for this many in user buffer */
120 char *ifcr_buffer
; /* buffer for cloner names */
123 struct if_clonereq64
{
124 int ifcr_total
; /* total cloners (out) */
125 int ifcr_count
; /* room for this many in user buffer */
126 user64_addr_t ifcru_buffer
__attribute__((aligned(8)));
129 struct if_clonereq32
{
130 int ifcr_total
; /* total cloners (out) */
131 int ifcr_count
; /* room for this many in user buffer */
132 user32_addr_t ifcru_buffer
;
134 #endif /* KERNEL_PRIVATE */
136 #define IFF_UP 0x1 /* interface is up */
137 #define IFF_BROADCAST 0x2 /* broadcast address valid */
138 #define IFF_DEBUG 0x4 /* turn on debugging */
139 #define IFF_LOOPBACK 0x8 /* is a loopback net */
140 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
141 #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
142 #define IFF_RUNNING 0x40 /* resources allocated */
143 #define IFF_NOARP 0x80 /* no address resolution protocol */
144 #define IFF_PROMISC 0x100 /* receive all packets */
145 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
146 #define IFF_OACTIVE 0x400 /* transmission in progress */
147 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
148 #define IFF_LINK0 0x1000 /* per link layer defined bit */
149 #define IFF_LINK1 0x2000 /* per link layer defined bit */
150 #define IFF_LINK2 0x4000 /* per link layer defined bit */
151 #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
152 #define IFF_MULTICAST 0x8000 /* supports multicast */
155 /* extended flags definitions: (all bits are reserved for internal/future use) */
156 #define IFEF_AUTOCONFIGURING 0x1 /* allow BOOTP/DHCP replies to enter */
157 #define _IFEF_DVR_REENTRY_OK 0x20 /* deprecated */
158 #define IFEF_ACCEPT_RTADV 0x40 /* set to accept IPv6 Router Advertisement on the interface */
159 #define IFEF_TXSTART 0x80 /* interface has start callback */
160 #define IFEF_RXPOLL 0x100 /* interface supports opportunistic input polling */
161 #define IFEF_VLAN 0x200 /* interface has one or more vlans */
162 #define IFEF_BOND 0x400 /* interface is part of bond */
163 #define IFEF_ARPLL 0x800 /* ARP for IPv4LL addresses on this port */
164 #define IFEF_NOWINDOWSCALE 0x1000 /* Don't scale TCP window on iface */
165 #define IFEF_NOAUTOIPV6LL 0x2000 /* Interface IPv6 LinkLocal address not provided by kernel */
166 #define IFEF_IPV4_ROUTER 0x8000 /* set on internal-network-facing interface when in IPv4 router mode */
167 #define IFEF_IPV6_ROUTER 0x10000 /* set on internal-network-facing interface when in IPv6 router mode */
168 #define IFEF_LOCALNET_PRIVATE 0x20000 /* local private network */
169 #define IFEF_IPV6_ND6ALT 0x40000 /* alternative KPI for IPv6 neighbor discovery */
170 #define IFEF_SERVICE_TRIGGERED IFEF_LOCALNET_PRIVATE
171 #define IFEF_RESTRICTED_RECV 0x80000 /* interface restricts inbound pkts */
172 #define IFEF_AWDL 0x100000 /* Apple Wireless Direct Link */
173 #define IFEF_NOACKPRI 0x200000 /* Don't use TCP ACK prioritization on interface */
174 #define IFEF_SENDLIST 0x10000000 /* Interface supports sending a list of packets */
175 #define _IFEF_REUSE 0x20000000 /* deprecated */
176 #define _IFEF_INUSE 0x40000000 /* deprecated */
177 #define IFEF_UPDOWNCHANGE 0x80000000 /* Interface's up/down state is changing */
178 #ifdef XNU_KERNEL_PRIVATE
180 * Current requirements for an AWDL interface. Setting/clearing IFEF_AWDL
181 * will also trigger the setting/clearing of the rest of the flags. Once
182 * IFEF_AWDL is set, the rest of flags cannot be cleared, by definition.
184 #define IFEF_AWDL_MASK \
185 (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \
187 #endif /* XNU_KERNEL_PRIVATE */
190 #ifdef KERNEL_PRIVATE
194 * if_idle_flags definitions: (all bits are reserved for internal/future
195 * use). Setting these flags MUST be done via the ifnet_set_idle_flags()
196 * KPI due to the associated reference counting. Clearing them may be done by
197 * calling the KPI, otherwise implicitly at interface detach time. Setting
198 * the if_idle_flags field to a non-zero value will cause the networking
199 * stack to aggressively purge expired objects (routes, etc.)
201 #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */
203 /* flags set internally only: */
204 #define IFF_CANTCHANGE \
205 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
206 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
207 #endif /* KERNEL_PRIVATE */
210 * Capabilities that interfaces can advertise.
212 * struct ifnet.if_capabilities
213 * contains the optional features & capabilities a particular interface
214 * supports (not only the driver but also the detected hw revision).
215 * Capabilities are defined by IFCAP_* below.
216 * struct ifnet.if_capenable
217 * contains the enabled (either by default or through ifconfig) optional
218 * features & capabilities on this interface.
219 * Capabilities are defined by IFCAP_* below.
220 * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h,
221 * contains the enabled optional features & capabilites that can be used
222 * individually per packet and are specified in the mbuf pkthdr.csum_flags
223 * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be
224 * more detailed or differenciated than IFCAP_*.
225 * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h
227 #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
228 #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
229 #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */
230 #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */
231 #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */
232 #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */
233 #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */
234 #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */
235 #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */
237 #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
238 #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
240 #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \
241 IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV)
243 #define IFQ_MAXLEN 128
244 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
247 * Message format for use in obtaining information about interfaces
248 * from sysctl and the routing socket
251 unsigned short ifm_msglen
; /* to skip over non-understood messages */
252 unsigned char ifm_version
; /* future binary compatability */
253 unsigned char ifm_type
; /* message type */
254 int ifm_addrs
; /* like rtm_addrs */
255 int ifm_flags
; /* value of if_flags */
256 unsigned short ifm_index
; /* index for associated ifp */
257 struct if_data ifm_data
; /* statistics and other data about if */
261 * Message format for use in obtaining information about interface addresses
262 * from sysctl and the routing socket
265 unsigned short ifam_msglen
; /* to skip over non-understood messages */
266 unsigned char ifam_version
; /* future binary compatability */
267 unsigned char ifam_type
; /* message type */
268 int ifam_addrs
; /* like rtm_addrs */
269 int ifam_flags
; /* value of ifa_flags */
270 unsigned short ifam_index
; /* index for associated ifp */
271 int ifam_metric
; /* value of ifa_metric */
275 * Message format for use in obtaining information about multicast addresses
276 * from the routing socket
279 unsigned short ifmam_msglen
; /* to skip over non-understood messages */
280 unsigned char ifmam_version
; /* future binary compatability */
281 unsigned char ifmam_type
; /* message type */
282 int ifmam_addrs
; /* like rtm_addrs */
283 int ifmam_flags
; /* value of ifa_flags */
284 unsigned short ifmam_index
; /* index for associated ifp */
288 * Message format for use in obtaining information about interfaces
292 u_short ifm_msglen
; /* to skip over non-understood messages */
293 u_char ifm_version
; /* future binary compatability */
294 u_char ifm_type
; /* message type */
295 int ifm_addrs
; /* like rtm_addrs */
296 int ifm_flags
; /* value of if_flags */
297 u_short ifm_index
; /* index for associated ifp */
298 int ifm_snd_len
; /* instantaneous length of send queue */
299 int ifm_snd_maxlen
; /* maximum length of send queue */
300 int ifm_snd_drops
; /* number of drops in send queue */
301 int ifm_timer
; /* time until if_watchdog called */
302 struct if_data64 ifm_data
; /* statistics and other data about if */
306 * Message format for use in obtaining information about multicast addresses
309 struct ifma_msghdr2
{
310 u_short ifmam_msglen
; /* to skip over non-understood messages */
311 u_char ifmam_version
; /* future binary compatability */
312 u_char ifmam_type
; /* message type */
313 int ifmam_addrs
; /* like rtm_addrs */
314 int ifmam_flags
; /* value of ifa_flags */
315 u_short ifmam_index
; /* index for associated ifp */
316 int32_t ifmam_refcount
;
320 * ifdevmtu: interface device mtu
321 * Used with SIOCGIFDEVMTU to get the current mtu in use by the device,
322 * as well as the minimum and maximum mtu allowed by the device.
333 ifkpi: interface kpi ioctl
334 Used with SIOCSIFKPI and SIOCGIFKPI.
336 ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From
337 user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket.
338 ifk_type - The type. Types are specific to each module id.
339 ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes.
341 Copying data between user space and kernel space is done using copyin
342 and copyout. A process may be running in 64bit mode. In such a case,
343 the pointer will be a 64bit pointer, not a 32bit pointer. The following
344 sample is a safe way to copy the data in to the kernel from either a
345 32bit or 64bit process:
348 if (IS_64BIT_PROCESS(current_proc())) {
349 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64);
352 tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr);
354 error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer);
358 unsigned int ifk_module_id
;
359 unsigned int ifk_type
;
369 /* Wake capabilities of a interface */
370 #define IF_WAKE_ON_MAGIC_PACKET 0x01
371 #ifdef KERNEL_PRIVATE
372 #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET
373 #endif /* KERNEL_PRIVATE */
379 * Interface request structure used for socket
380 * ioctl's. All interface ioctl's must have parameter
381 * definitions which begin with ifr_name. The
382 * remainder may be interface specific.
386 #define IFNAMSIZ IF_NAMESIZE
388 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
390 struct sockaddr ifru_addr
;
391 struct sockaddr ifru_dstaddr
;
392 struct sockaddr ifru_broadaddr
;
400 #ifdef KERNEL_PRIVATE
401 u_int64_t ifru_data64
; /* 64-bit ifru_data */
402 #endif /* KERNEL_PRIVATE */
403 struct ifdevmtu ifru_devmtu
;
404 struct ifkpi ifru_kpi
;
405 u_int32_t ifru_wake_flags
;
406 u_int32_t ifru_route_refcnt
;
408 int ifru_link_quality_metric
;
414 #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001
416 } ifru_opportunistic
;
417 u_int64_t ifru_eflags
;
420 #define ifr_addr ifr_ifru.ifru_addr /* address */
421 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
422 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
424 #define ifr_flags ifr_ifru.ifru_flags /* flags */
426 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
427 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
428 #endif /* __APPLE__ */
429 #define ifr_metric ifr_ifru.ifru_metric /* metric */
430 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
431 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
432 #define ifr_media ifr_ifru.ifru_media /* physical media */
433 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
434 #define ifr_devmtu ifr_ifru.ifru_devmtu
435 #define ifr_intval ifr_ifru.ifru_intval /* integer value */
436 #ifdef KERNEL_PRIVATE
437 #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */
438 #endif /* KERNEL_PRIVATE */
439 #define ifr_kpi ifr_ifru.ifru_kpi
440 #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities of devive */
441 #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references on interface */
443 #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */
445 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
446 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
448 #define ifr_opportunistic ifr_ifru.ifru_opportunistic /* current capabilities */
449 #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */
453 #define _SIZEOF_ADDR_IFREQ(ifr) \
454 ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
455 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
456 (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
459 char ifra_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
460 struct sockaddr ifra_addr
;
461 struct sockaddr ifra_broadaddr
;
462 struct sockaddr ifra_mask
;
465 struct rslvmulti_req
{
467 struct sockaddr
**llsa
;
470 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
474 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
475 int ifm_current
; /* current media options */
476 int ifm_mask
; /* don't care mask */
477 int ifm_status
; /* media status */
478 int ifm_active
; /* active options */
479 int ifm_count
; /* # entries in ifm_ulist array */
480 int *ifm_ulist
; /* media words */
484 #endif /* !KERNEL || KERNEL_PRIVATE */
486 #ifdef KERNEL_PRIVATE
488 struct ifmediareq64
{
489 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
490 int ifm_current
; /* current media options */
491 int ifm_mask
; /* don't care mask */
492 int ifm_status
; /* media status */
493 int ifm_active
; /* active options */
494 int ifm_count
; /* # entries in ifm_ulist array */
495 user64_addr_t ifmu_ulist
__attribute__((aligned(8)));
498 struct ifmediareq32
{
499 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
500 int ifm_current
; /* current media options */
501 int ifm_mask
; /* don't care mask */
502 int ifm_status
; /* media status */
503 int ifm_active
; /* active options */
504 int ifm_count
; /* # entries in ifm_ulist array */
505 user32_addr_t ifmu_ulist
; /* 32-bit pointer */
508 #endif /* KERNEL_PRIVATE */
513 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
514 unsigned long ifd_cmd
;
520 #ifdef KERNEL_PRIVATE
523 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
526 user32_addr_t ifd_data
;
530 char ifd_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
533 user64_addr_t ifd_data
;
536 #endif /* KERNEL_PRIVATE */
539 * Structure used to retrieve aux status data from interfaces.
540 * Kernel suppliers to this interface should respect the formatting
541 * needed by ifconfig(8): each line starts with a TAB and ends with
542 * a newline. The canonical example to copy and paste is in if_tun.c.
545 #define IFSTATMAX 800 /* 10 lines of text */
547 char ifs_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
548 char ascii
[IFSTATMAX
+ 1];
551 #if !defined(KERNEL) || defined(KERNEL_PRIVATE)
553 * Structure used in SIOCGIFCONF request.
554 * Used to retrieve interface configuration
555 * for machine (useful for programs which
556 * must know all networks accessible).
560 int ifc_len
; /* size of associated buffer */
563 struct ifreq
*ifcu_req
;
567 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
568 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
569 #endif /* !KERNEL || KERNEL_PRIVATE */
571 #if defined(KERNEL_PRIVATE)
574 int ifc_len
; /* size of associated buffer */
576 user32_addr_t ifcu_req
;
581 int ifc_len
; /* size of associated buffer */
583 user64_addr_t ifcu_req
__attribute__((aligned(8)));
587 #endif /* KERNEL_PRIVATE */
590 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
592 struct kev_dl_proto_data
{
593 struct net_event_data link_data
;
594 u_int32_t proto_family
;
595 u_int32_t proto_remaining_count
;
599 * Structure for SIOC[AGD]LIFADDR
602 char iflr_name
[IFNAMSIZ
];
604 #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
605 unsigned int prefixlen
; /* in/out */
606 struct sockaddr_storage addr
; /* in/out */
607 struct sockaddr_storage dstaddr
; /* out */
612 * Link Quality Metrics
614 * IFNET_LQM_THRESH_OFF Metric is not available; device is off.
615 * IFNET_LQM_THRESH_UNKNOWN Metric is not (yet) known.
616 * IFNET_LQM_THRESH_POOR Link quality is considered poor by driver.
617 * IFNET_LQM_THRESH_GOOD Link quality is considered good by driver.
620 IFNET_LQM_THRESH_OFF
= (-2),
621 IFNET_LQM_THRESH_UNKNOWN
= (-1),
622 IFNET_LQM_THRESH_POOR
= 50,
623 IFNET_LQM_THRESH_GOOD
= 100
625 #ifdef XNU_KERNEL_PRIVATE
626 #define IFNET_LQM_MIN IFNET_LQM_THRESH_OFF
627 #define IFNET_LQM_MAX IFNET_LQM_THRESH_GOOD
628 #endif /* XNU_KERNEL_PRIVATE */
631 * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure
633 struct kev_dl_link_quality_metric_data
{
634 struct net_event_data link_data
;
635 int link_quality_metric
;
638 #define IF_DESCSIZE 128
641 * Structure for SIOC[SG]IFDESC
644 char ifdr_name
[IFNAMSIZ
]; /* interface name */
645 u_int32_t ifdr_len
; /* up to IF_DESCSIZE */
646 u_int8_t ifdr_desc
[IF_DESCSIZE
]; /* opaque data */
650 * Output packet scheduling models
652 * IFNET_SCHED_MODEL_NORMAL The default output packet scheduling model
653 * where the driver or media does not require strict scheduling
654 * strategy, and that the networking stack is free to choose the
655 * most appropriate scheduling and queueing algorithm, including
657 * IFNET_SCHED_MODEL_DRIVER_MANAGED The alternative output packet
658 * scheduling model where the driver or media requires strict
659 * scheduling strategy (e.g. 802.11 WMM), and that the networking
660 * stack is only responsible for creating multiple queues for the
661 * corresponding service classes.
664 IFNET_SCHED_MODEL_NORMAL
= 0,
665 IFNET_SCHED_MODEL_DRIVER_MANAGED
= 1,
666 #ifdef XNU_KERNEL_PRIVATE
667 IFNET_SCHED_MODEL_MAX
= 2,
668 #endif /* XNU_KERNEL_PRIVATE */
672 * Values for iflpr_flags
674 #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */
675 #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */
678 * Structure for SIOCGIFLINKPARAMS
680 struct if_linkparamsreq
{
681 char iflpr_name
[IFNAMSIZ
]; /* interface name */
682 u_int32_t iflpr_flags
;
683 u_int32_t iflpr_output_sched
;
684 u_int64_t iflpr_output_tbr_rate
;
685 u_int32_t iflpr_output_tbr_percent
;
686 struct if_bandwidths iflpr_output_bw
;
687 struct if_bandwidths iflpr_input_bw
;
691 * Structure for SIOCGIFQUEUESTATS
693 struct if_qstatsreq
{
694 char ifqr_name
[IFNAMSIZ
]; /* interface name */
696 void *ifqr_buf
__attribute__((aligned(8)));
697 int ifqr_len
__attribute__((aligned(8)));
701 * Node Proximity Metrics
704 IFNET_NPM_THRESH_UNKNOWN
= (-1),
705 IFNET_NPM_THRESH_NEAR
= 30,
706 IFNET_NPM_THRESH_GENERAL
= 70,
707 IFNET_NPM_THRESH_FAR
= 100,
711 * Received Signal Strength Indication [special values]
713 * IFNET_RSSI_UNKNOWN Metric is not (yet) known.
716 IFNET_RSSI_UNKNOWN
= ((-2147483647)-1), /* INT32_MIN */
721 * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures
723 struct kev_dl_node_presence
{
724 struct net_event_data link_data
;
725 struct sockaddr_in6 sin6_node_address
;
726 struct sockaddr_dl sdl_node_address
;
728 int link_quality_metric
;
729 int node_proximity_metric
;
730 u_int8_t node_service_info
[48];
733 struct kev_dl_node_absence
{
734 struct net_event_data link_data
;
735 struct sockaddr_in6 sin6_node_address
;
736 struct sockaddr_dl sdl_node_address
;
740 * Structure for SIOC[SG]IFTHROTTLE
742 struct if_throttlereq
{
743 char ifthr_name
[IFNAMSIZ
]; /* interface name */
744 u_int32_t ifthr_level
;
748 * Interface throttling levels
750 * IFNET_THROTTLE_OFF The default throttling level (no throttling.)
751 * All service class queues operate normally according to the
752 * standard packet scheduler configuration.
753 * IFNET_THROTTLE_OPPORTUNISTIC One or more service class queues that
754 * are responsible for managing "opportunistic" traffics are
755 * suspended. Packets enqueued on those queues will be dropped
756 * and a flow advisory error will be generated to the data
757 * source. Existing packets in the queues will stay enqueued
758 * until the interface is no longer throttled, or until they
759 * are explicitly flushed.
762 IFNET_THROTTLE_OFF
= 0,
763 IFNET_THROTTLE_OPPORTUNISTIC
= 1,
764 #ifdef XNU_KERNEL_PRIVATE
765 IFNET_THROTTLE_MAX
= 2,
766 #endif /* XNU_KERNEL_PRIVATE */
771 #ifdef MALLOC_DECLARE
772 MALLOC_DECLARE(M_IFADDR
);
773 MALLOC_DECLARE(M_IFMADDR
);
776 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
779 struct if_nameindex
{
780 unsigned int if_index
; /* 1, 2, ... */
781 char *if_name
; /* null terminated name: "le0", ... */
785 unsigned int if_nametoindex(const char *);
786 char *if_indextoname(unsigned int, char *);
787 struct if_nameindex
*if_nameindex(void);
788 void if_freenameindex(struct if_nameindex
*);
793 #include <net/kpi_interface.h>
796 #endif /* !_NET_IF_H_ */