]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
316670eb | 2 | * Copyright (c) 2000-2012 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 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. | |
8f6c56a5 | 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. | |
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 | |
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. | |
8f6c56a5 | 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 | |
9bccf70c | 61 | * $FreeBSD: src/sys/net/if.h,v 1.58.2.2 2001/07/24 19:10:18 brooks Exp $ |
1c79356b A |
62 | */ |
63 | ||
64 | #ifndef _NET_IF_H_ | |
65 | #define _NET_IF_H_ | |
66 | ||
2d21ac55 A |
67 | #include <sys/cdefs.h> |
68 | ||
91447636 A |
69 | #define IF_NAMESIZE 16 |
70 | ||
2d21ac55 | 71 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
91447636 | 72 | #include <sys/appleapiopts.h> |
9bccf70c | 73 | #ifdef __APPLE__ |
1c79356b A |
74 | /* |
75 | * Define Data-Link event subclass, and associated | |
76 | * events. | |
77 | */ | |
78 | ||
79 | #define KEV_DL_SUBCLASS 2 | |
80 | ||
316670eb A |
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 | |
4a249263 | 104 | |
1c79356b | 105 | #include <net/if_var.h> |
91447636 | 106 | #include <sys/types.h> |
316670eb A |
107 | |
108 | #ifdef PRIVATE | |
109 | #include <net/if_dl.h> | |
110 | #include <netinet/in.h> | |
111 | #endif | |
9bccf70c | 112 | #endif |
1c79356b | 113 | |
4a249263 | 114 | #ifdef KERNEL_PRIVATE |
b7266188 A |
115 | #define IF_MAXUNIT 0x7fff /* historical value */ |
116 | ||
4a249263 A |
117 | struct if_clonereq { |
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 */ | |
121 | }; | |
91447636 | 122 | |
91447636 A |
123 | struct if_clonereq64 { |
124 | int ifcr_total; /* total cloners (out) */ | |
125 | int ifcr_count; /* room for this many in user buffer */ | |
b0d623f7 A |
126 | user64_addr_t ifcru_buffer __attribute__((aligned(8))); |
127 | }; | |
128 | ||
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; | |
91447636 | 133 | }; |
b0d623f7 | 134 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
135 | |
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 */ | |
1c79356b | 153 | |
316670eb | 154 | #ifdef PRIVATE |
0b4e3aa0 | 155 | /* extended flags definitions: (all bits are reserved for internal/future use) */ |
316670eb A |
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 */ | |
91447636 A |
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 */ | |
b0d623f7 A |
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 */ | |
316670eb A |
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 */ | |
6d2010ae A |
174 | #define IFEF_SENDLIST 0x10000000 /* Interface supports sending a list of packets */ |
175 | #define _IFEF_REUSE 0x20000000 /* deprecated */ | |
176 | #define _IFEF_INUSE 0x40000000 /* deprecated */ | |
91447636 | 177 | #define IFEF_UPDOWNCHANGE 0x80000000 /* Interface's up/down state is changing */ |
316670eb A |
178 | #ifdef XNU_KERNEL_PRIVATE |
179 | /* | |
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. | |
183 | */ | |
184 | #define IFEF_AWDL_MASK \ | |
185 | (IFEF_LOCALNET_PRIVATE | IFEF_IPV6_ND6ALT | IFEF_RESTRICTED_RECV | \ | |
186 | IFEF_AWDL) | |
187 | #endif /* XNU_KERNEL_PRIVATE */ | |
188 | #endif /* PRIVATE */ | |
1c79356b | 189 | |
316670eb | 190 | #ifdef KERNEL_PRIVATE |
d1ecb069 A |
191 | /* |
192 | * !!! NOTE !!! | |
193 | * | |
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.) | |
200 | */ | |
201 | #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */ | |
202 | ||
1c79356b A |
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) | |
91447636 A |
207 | #endif /* KERNEL_PRIVATE */ |
208 | ||
6d2010ae A |
209 | /* |
210 | * Capabilities that interfaces can advertise. | |
211 | * | |
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 | |
226 | */ | |
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 */ | |
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) | |
242 | ||
316670eb | 243 | #define IFQ_MAXLEN 128 |
1c79356b A |
244 | #define IFNET_SLOWHZ 1 /* granularity is 1 second */ |
245 | ||
246 | /* | |
247 | * Message format for use in obtaining information about interfaces | |
91447636 | 248 | * from sysctl and the routing socket |
1c79356b A |
249 | */ |
250 | struct if_msghdr { | |
91447636 A |
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 */ | |
1c79356b A |
258 | }; |
259 | ||
260 | /* | |
261 | * Message format for use in obtaining information about interface addresses | |
91447636 | 262 | * from sysctl and the routing socket |
1c79356b A |
263 | */ |
264 | struct ifa_msghdr { | |
91447636 A |
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 */ | |
1c79356b A |
272 | }; |
273 | ||
274 | /* | |
275 | * Message format for use in obtaining information about multicast addresses | |
276 | * from the routing socket | |
277 | */ | |
278 | struct ifma_msghdr { | |
91447636 A |
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 */ | |
285 | }; | |
286 | ||
287 | /* | |
288 | * Message format for use in obtaining information about interfaces | |
289 | * from sysctl | |
290 | */ | |
291 | struct if_msghdr2 { | |
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 */ | |
303 | }; | |
304 | ||
305 | /* | |
306 | * Message format for use in obtaining information about multicast addresses | |
307 | * from sysctl | |
308 | */ | |
309 | struct ifma_msghdr2 { | |
1c79356b A |
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 */ | |
91447636 A |
316 | int32_t ifmam_refcount; |
317 | }; | |
318 | ||
319 | /* | |
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. | |
323 | */ | |
324 | struct ifdevmtu { | |
325 | int ifdm_current; | |
326 | int ifdm_min; | |
327 | int ifdm_max; | |
1c79356b A |
328 | }; |
329 | ||
2d21ac55 A |
330 | #pragma pack(4) |
331 | ||
332 | /* | |
333 | ifkpi: interface kpi ioctl | |
334 | Used with SIOCSIFKPI and SIOCGIFKPI. | |
335 | ||
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. | |
340 | ||
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: | |
346 | ||
347 | user_addr_t tmp_ptr; | |
348 | if (IS_64BIT_PROCESS(current_proc())) { | |
349 | tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64); | |
350 | } | |
351 | else { | |
352 | tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr); | |
353 | } | |
354 | error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer); | |
355 | */ | |
356 | ||
357 | struct ifkpi { | |
358 | unsigned int ifk_module_id; | |
359 | unsigned int ifk_type; | |
360 | union { | |
361 | void *ifk_ptr; | |
362 | int ifk_value; | |
363 | #ifdef KERNEL | |
364 | u_int64_t ifk_ptr64; | |
365 | #endif /* KERNEL */ | |
366 | } ifk_data; | |
367 | }; | |
368 | ||
b0d623f7 A |
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 */ | |
374 | ||
375 | ||
2d21ac55 A |
376 | #pragma pack() |
377 | ||
1c79356b A |
378 | /* |
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. | |
383 | */ | |
1c79356b | 384 | struct ifreq { |
91447636 A |
385 | #ifndef IFNAMSIZ |
386 | #define IFNAMSIZ IF_NAMESIZE | |
387 | #endif | |
1c79356b A |
388 | char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
389 | union { | |
390 | struct sockaddr ifru_addr; | |
391 | struct sockaddr ifru_dstaddr; | |
392 | struct sockaddr ifru_broadaddr; | |
393 | short ifru_flags; | |
394 | int ifru_metric; | |
395 | int ifru_mtu; | |
396 | int ifru_phys; | |
397 | int ifru_media; | |
316670eb | 398 | int ifru_intval; |
1c79356b | 399 | caddr_t ifru_data; |
91447636 A |
400 | #ifdef KERNEL_PRIVATE |
401 | u_int64_t ifru_data64; /* 64-bit ifru_data */ | |
b0d623f7 | 402 | #endif /* KERNEL_PRIVATE */ |
91447636 | 403 | struct ifdevmtu ifru_devmtu; |
2d21ac55 | 404 | struct ifkpi ifru_kpi; |
b0d623f7 | 405 | u_int32_t ifru_wake_flags; |
d1ecb069 | 406 | u_int32_t ifru_route_refcnt; |
316670eb A |
407 | #ifdef PRIVATE |
408 | int ifru_link_quality_metric; | |
409 | #endif /* PRIVATE */ | |
6d2010ae | 410 | int ifru_cap[2]; |
316670eb A |
411 | #ifdef PRIVATE |
412 | struct { | |
413 | uint32_t ifo_flags; | |
414 | #define IFRIFOF_BLOCK_OPPORTUNISTIC 0x00000001 | |
415 | uint32_t ifo_inuse; | |
416 | } ifru_opportunistic; | |
417 | u_int64_t ifru_eflags; | |
418 | #endif /* PRIVATE */ | |
1c79356b A |
419 | } ifr_ifru; |
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 */ | |
9bccf70c | 423 | #ifdef __APPLE__ |
1c79356b | 424 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
9bccf70c A |
425 | #else |
426 | #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ | |
427 | #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ | |
428 | #endif /* __APPLE__ */ | |
1c79356b A |
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 */ | |
91447636 A |
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 */ | |
b0d623f7 | 438 | #endif /* KERNEL_PRIVATE */ |
2d21ac55 | 439 | #define ifr_kpi ifr_ifru.ifru_kpi |
b0d623f7 | 440 | #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities of devive */ |
d1ecb069 | 441 | #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references on interface */ |
316670eb A |
442 | #ifdef PRIVATE |
443 | #define ifr_link_quality_metric ifr_ifru.ifru_link_quality_metric /* LQM */ | |
444 | #endif /* PRIVATE */ | |
6d2010ae A |
445 | #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ |
446 | #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ | |
316670eb A |
447 | #ifdef PRIVATE |
448 | #define ifr_opportunistic ifr_ifru.ifru_opportunistic /* current capabilities */ | |
449 | #define ifr_eflags ifr_ifru.ifru_eflags /* extended flags */ | |
450 | #endif | |
1c79356b A |
451 | }; |
452 | ||
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)) | |
457 | ||
458 | struct ifaliasreq { | |
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; | |
463 | }; | |
464 | ||
465 | struct rslvmulti_req { | |
466 | struct sockaddr *sa; | |
467 | struct sockaddr **llsa; | |
468 | }; | |
469 | ||
b0d623f7 | 470 | #if !defined(KERNEL) || defined(KERNEL_PRIVATE) |
2d21ac55 A |
471 | #pragma pack(4) |
472 | ||
1c79356b A |
473 | struct ifmediareq { |
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 */ | |
481 | }; | |
9bccf70c | 482 | |
2d21ac55 | 483 | #pragma pack() |
b0d623f7 | 484 | #endif /* !KERNEL || KERNEL_PRIVATE */ |
2d21ac55 | 485 | |
91447636 | 486 | #ifdef KERNEL_PRIVATE |
b0d623f7 | 487 | #pragma pack(4) |
91447636 A |
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 */ | |
b0d623f7 | 495 | user64_addr_t ifmu_ulist __attribute__((aligned(8))); |
91447636 | 496 | }; |
b0d623f7 A |
497 | |
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 */ | |
506 | }; | |
507 | #pragma pack() | |
508 | #endif /* KERNEL_PRIVATE */ | |
91447636 | 509 | |
b7266188 A |
510 | |
511 | #pragma pack(4) | |
512 | struct ifdrv { | |
513 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
514 | unsigned long ifd_cmd; | |
515 | size_t ifd_len; | |
516 | void *ifd_data; | |
517 | }; | |
518 | #pragma pack() | |
519 | ||
520 | #ifdef KERNEL_PRIVATE | |
521 | #pragma pack(4) | |
522 | struct ifdrv32 { | |
523 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
524 | u_int32_t ifd_cmd; | |
525 | u_int32_t ifd_len; | |
526 | user32_addr_t ifd_data; | |
527 | }; | |
528 | ||
529 | struct ifdrv64 { | |
530 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
531 | u_int64_t ifd_cmd; | |
532 | u_int64_t ifd_len; | |
533 | user64_addr_t ifd_data; | |
534 | }; | |
535 | #pragma pack() | |
536 | #endif /* KERNEL_PRIVATE */ | |
537 | ||
9bccf70c A |
538 | /* |
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. | |
543 | */ | |
544 | ||
545 | #define IFSTATMAX 800 /* 10 lines of text */ | |
546 | struct ifstat { | |
547 | char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
548 | char ascii[IFSTATMAX + 1]; | |
549 | }; | |
550 | ||
b0d623f7 | 551 | #if !defined(KERNEL) || defined(KERNEL_PRIVATE) |
1c79356b A |
552 | /* |
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). | |
557 | */ | |
b0d623f7 | 558 | #pragma pack(4) |
1c79356b A |
559 | struct ifconf { |
560 | int ifc_len; /* size of associated buffer */ | |
561 | union { | |
562 | caddr_t ifcu_buf; | |
563 | struct ifreq *ifcu_req; | |
564 | } ifc_ifcu; | |
2d21ac55 | 565 | }; |
b0d623f7 | 566 | #pragma pack() |
1c79356b A |
567 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ |
568 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ | |
b0d623f7 | 569 | #endif /* !KERNEL || KERNEL_PRIVATE */ |
2d21ac55 | 570 | |
b0d623f7 A |
571 | #if defined(KERNEL_PRIVATE) |
572 | #pragma pack(4) | |
573 | struct ifconf32 { | |
574 | int ifc_len; /* size of associated buffer */ | |
575 | struct { | |
576 | user32_addr_t ifcu_req; | |
577 | } ifc_ifcu; | |
578 | }; | |
1c79356b | 579 | |
91447636 A |
580 | struct ifconf64 { |
581 | int ifc_len; /* size of associated buffer */ | |
b0d623f7 A |
582 | struct { |
583 | user64_addr_t ifcu_req __attribute__((aligned(8))); | |
91447636 A |
584 | } ifc_ifcu; |
585 | }; | |
b0d623f7 A |
586 | #pragma pack() |
587 | #endif /* KERNEL_PRIVATE */ | |
91447636 | 588 | |
0b4e3aa0 A |
589 | /* |
590 | * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure | |
591 | */ | |
592 | struct kev_dl_proto_data { | |
593 | struct net_event_data link_data; | |
2d21ac55 A |
594 | u_int32_t proto_family; |
595 | u_int32_t proto_remaining_count; | |
0b4e3aa0 | 596 | }; |
0b4e3aa0 | 597 | |
1c79356b A |
598 | /* |
599 | * Structure for SIOC[AGD]LIFADDR | |
600 | */ | |
601 | struct if_laddrreq { | |
91447636 A |
602 | char iflr_name[IFNAMSIZ]; |
603 | unsigned int flags; | |
9bccf70c | 604 | #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ |
91447636 A |
605 | unsigned int prefixlen; /* in/out */ |
606 | struct sockaddr_storage addr; /* in/out */ | |
607 | struct sockaddr_storage dstaddr; /* out */ | |
1c79356b A |
608 | }; |
609 | ||
316670eb A |
610 | #ifdef PRIVATE |
611 | /* | |
612 | * Link Quality Metrics | |
613 | * | |
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. | |
618 | */ | |
619 | enum { | |
620 | IFNET_LQM_THRESH_OFF = (-2), | |
621 | IFNET_LQM_THRESH_UNKNOWN = (-1), | |
622 | IFNET_LQM_THRESH_POOR = 50, | |
623 | IFNET_LQM_THRESH_GOOD = 100 | |
624 | }; | |
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 */ | |
629 | ||
630 | /* | |
631 | * DLIL KEV_DL_LINK_QUALITY_METRIC_CHANGED structure | |
632 | */ | |
633 | struct kev_dl_link_quality_metric_data { | |
634 | struct net_event_data link_data; | |
635 | int link_quality_metric; | |
636 | }; | |
637 | ||
638 | #define IF_DESCSIZE 128 | |
639 | ||
640 | /* | |
641 | * Structure for SIOC[SG]IFDESC | |
642 | */ | |
643 | struct if_descreq { | |
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 */ | |
647 | }; | |
648 | ||
649 | /* | |
650 | * Output packet scheduling models | |
651 | * | |
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 | |
656 | * shaping traffics. | |
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. | |
662 | */ | |
663 | enum { | |
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 */ | |
669 | }; | |
670 | ||
671 | /* | |
672 | * Values for iflpr_flags | |
673 | */ | |
674 | #define IFLPRF_ALTQ 0x1 /* configured via PF/ALTQ */ | |
675 | #define IFLPRF_DRVMANAGED 0x2 /* output queue scheduled by drv */ | |
676 | ||
677 | /* | |
678 | * Structure for SIOCGIFLINKPARAMS | |
679 | */ | |
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; | |
688 | }; | |
689 | ||
690 | /* | |
691 | * Structure for SIOCGIFQUEUESTATS | |
692 | */ | |
693 | struct if_qstatsreq { | |
694 | char ifqr_name[IFNAMSIZ]; /* interface name */ | |
695 | u_int32_t ifqr_slot; | |
696 | void *ifqr_buf __attribute__((aligned(8))); | |
697 | int ifqr_len __attribute__((aligned(8))); | |
698 | }; | |
699 | ||
700 | /* | |
701 | * Node Proximity Metrics | |
702 | */ | |
703 | enum { | |
704 | IFNET_NPM_THRESH_UNKNOWN = (-1), | |
705 | IFNET_NPM_THRESH_NEAR = 30, | |
706 | IFNET_NPM_THRESH_GENERAL = 70, | |
707 | IFNET_NPM_THRESH_FAR = 100, | |
708 | }; | |
709 | ||
710 | /* | |
711 | * Received Signal Strength Indication [special values] | |
712 | * | |
713 | * IFNET_RSSI_UNKNOWN Metric is not (yet) known. | |
714 | */ | |
715 | enum { | |
716 | IFNET_RSSI_UNKNOWN = ((-2147483647)-1), /* INT32_MIN */ | |
717 | }; | |
718 | ||
719 | ||
720 | /* | |
721 | * DLIL KEV_DL_NODE_PRESENCE/KEV_DL_NODE_ABSENCE event structures | |
722 | */ | |
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; | |
727 | int32_t rssi; | |
728 | int link_quality_metric; | |
729 | int node_proximity_metric; | |
730 | u_int8_t node_service_info[48]; | |
731 | }; | |
732 | ||
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; | |
737 | }; | |
738 | ||
739 | /* | |
740 | * Structure for SIOC[SG]IFTHROTTLE | |
741 | */ | |
742 | struct if_throttlereq { | |
743 | char ifthr_name[IFNAMSIZ]; /* interface name */ | |
744 | u_int32_t ifthr_level; | |
745 | }; | |
746 | ||
747 | /* | |
748 | * Interface throttling levels | |
749 | * | |
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. | |
760 | */ | |
761 | enum { | |
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 */ | |
767 | }; | |
768 | #endif /* PRIVATE */ | |
769 | ||
1c79356b A |
770 | #ifdef KERNEL |
771 | #ifdef MALLOC_DECLARE | |
772 | MALLOC_DECLARE(M_IFADDR); | |
773 | MALLOC_DECLARE(M_IFMADDR); | |
774 | #endif | |
775 | #endif | |
2d21ac55 | 776 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
1c79356b A |
777 | |
778 | #ifndef KERNEL | |
9bccf70c | 779 | struct if_nameindex { |
91447636 A |
780 | unsigned int if_index; /* 1, 2, ... */ |
781 | char *if_name; /* null terminated name: "le0", ... */ | |
9bccf70c A |
782 | }; |
783 | ||
1c79356b | 784 | __BEGIN_DECLS |
91447636 A |
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 *); | |
1c79356b A |
789 | __END_DECLS |
790 | #endif | |
791 | ||
1c79356b | 792 | #ifdef KERNEL |
91447636 | 793 | #include <net/kpi_interface.h> |
1c79356b A |
794 | #endif |
795 | ||
796 | #endif /* !_NET_IF_H_ */ |