]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
6d2010ae | 2 | * Copyright (c) 2000-2011 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 | ||
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 | |
0b4e3aa0 A |
94 | #define KEV_DL_PROTO_ATTACHED 14 |
95 | #define KEV_DL_PROTO_DETACHED 15 | |
91447636 | 96 | #define KEV_DL_LINK_ADDRESS_CHANGED 16 |
b0d623f7 | 97 | #define KEV_DL_WAKEFLAGS_CHANGED 17 |
d1ecb069 | 98 | #define KEV_DL_IF_IDLE_ROUTE_REFCNT 18 |
6d2010ae | 99 | #define KEV_DL_IFCAP_CHANGED 19 |
4a249263 | 100 | |
1c79356b | 101 | #include <net/if_var.h> |
91447636 | 102 | #include <sys/types.h> |
9bccf70c | 103 | #endif |
1c79356b | 104 | |
4a249263 | 105 | #ifdef KERNEL_PRIVATE |
b7266188 A |
106 | #define IF_MAXUNIT 0x7fff /* historical value */ |
107 | ||
4a249263 A |
108 | struct if_clonereq { |
109 | int ifcr_total; /* total cloners (out) */ | |
110 | int ifcr_count; /* room for this many in user buffer */ | |
111 | char *ifcr_buffer; /* buffer for cloner names */ | |
112 | }; | |
91447636 | 113 | |
91447636 A |
114 | struct if_clonereq64 { |
115 | int ifcr_total; /* total cloners (out) */ | |
116 | int ifcr_count; /* room for this many in user buffer */ | |
b0d623f7 A |
117 | user64_addr_t ifcru_buffer __attribute__((aligned(8))); |
118 | }; | |
119 | ||
120 | struct if_clonereq32 { | |
121 | int ifcr_total; /* total cloners (out) */ | |
122 | int ifcr_count; /* room for this many in user buffer */ | |
123 | user32_addr_t ifcru_buffer; | |
91447636 | 124 | }; |
b0d623f7 | 125 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
126 | |
127 | #define IFF_UP 0x1 /* interface is up */ | |
128 | #define IFF_BROADCAST 0x2 /* broadcast address valid */ | |
129 | #define IFF_DEBUG 0x4 /* turn on debugging */ | |
130 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ | |
131 | #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ | |
132 | #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */ | |
133 | #define IFF_RUNNING 0x40 /* resources allocated */ | |
134 | #define IFF_NOARP 0x80 /* no address resolution protocol */ | |
135 | #define IFF_PROMISC 0x100 /* receive all packets */ | |
136 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets */ | |
137 | #define IFF_OACTIVE 0x400 /* transmission in progress */ | |
138 | #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ | |
139 | #define IFF_LINK0 0x1000 /* per link layer defined bit */ | |
140 | #define IFF_LINK1 0x2000 /* per link layer defined bit */ | |
141 | #define IFF_LINK2 0x4000 /* per link layer defined bit */ | |
142 | #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ | |
143 | #define IFF_MULTICAST 0x8000 /* supports multicast */ | |
1c79356b | 144 | |
4a249263 | 145 | #ifdef KERNEL_PRIVATE |
0b4e3aa0 A |
146 | /* extended flags definitions: (all bits are reserved for internal/future use) */ |
147 | #define IFEF_AUTOCONFIGURING 0x1 | |
1c79356b | 148 | #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */ |
55e303ae | 149 | #define IFEF_ACCEPT_RTADVD 0x40 /* set to accept IPv6 router advertisement on the interface */ |
6d2010ae A |
150 | #define _IFEF_DETACHING 0x80 /* deprecated */ |
151 | #define IFEF_USEKPI 0x100 /* Set when interface is created through the KPIs */ | |
91447636 A |
152 | #define IFEF_VLAN 0x200 /* interface has one or more vlans */ |
153 | #define IFEF_BOND 0x400 /* interface is part of bond */ | |
154 | #define IFEF_ARPLL 0x800 /* ARP for IPv4LL addresses on this port */ | |
b0d623f7 A |
155 | #define IFEF_NOWINDOWSCALE 0x1000 /* Don't scale TCP window on iface */ |
156 | #define IFEF_NOAUTOIPV6LL 0x2000 /* Interface IPv6 LinkLocal address not provided by kernel */ | |
6d2010ae A |
157 | #define IFEF_SERVICE_TRIGGERED 0x20000 /* interface is on-demand dynamically created/destroyed */ |
158 | #define IFEF_SENDLIST 0x10000000 /* Interface supports sending a list of packets */ | |
159 | #define _IFEF_REUSE 0x20000000 /* deprecated */ | |
160 | #define _IFEF_INUSE 0x40000000 /* deprecated */ | |
91447636 | 161 | #define IFEF_UPDOWNCHANGE 0x80000000 /* Interface's up/down state is changing */ |
1c79356b | 162 | |
d1ecb069 A |
163 | /* |
164 | * !!! NOTE !!! | |
165 | * | |
166 | * if_idle_flags definitions: (all bits are reserved for internal/future | |
167 | * use). Setting these flags MUST be done via the ifnet_set_idle_flags() | |
168 | * KPI due to the associated reference counting. Clearing them may be done by | |
169 | * calling the KPI, otherwise implicitly at interface detach time. Setting | |
170 | * the if_idle_flags field to a non-zero value will cause the networking | |
171 | * stack to aggressively purge expired objects (routes, etc.) | |
172 | */ | |
173 | #define IFRF_IDLE_NOTIFY 0x1 /* Generate notifications on idle */ | |
174 | ||
1c79356b A |
175 | /* flags set internally only: */ |
176 | #define IFF_CANTCHANGE \ | |
177 | (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ | |
178 | IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) | |
179 | ||
91447636 A |
180 | #endif /* KERNEL_PRIVATE */ |
181 | ||
6d2010ae A |
182 | /* |
183 | * Capabilities that interfaces can advertise. | |
184 | * | |
185 | * struct ifnet.if_capabilities | |
186 | * contains the optional features & capabilities a particular interface | |
187 | * supports (not only the driver but also the detected hw revision). | |
188 | * Capabilities are defined by IFCAP_* below. | |
189 | * struct ifnet.if_capenable | |
190 | * contains the enabled (either by default or through ifconfig) optional | |
191 | * features & capabilities on this interface. | |
192 | * Capabilities are defined by IFCAP_* below. | |
193 | * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h, | |
194 | * contains the enabled optional features & capabilites that can be used | |
195 | * individually per packet and are specified in the mbuf pkthdr.csum_flags | |
196 | * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be | |
197 | * more detailed or differenciated than IFCAP_*. | |
198 | * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h | |
199 | */ | |
200 | #define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ | |
201 | #define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ | |
202 | #define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */ | |
203 | #define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */ | |
204 | #define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */ | |
205 | #define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */ | |
206 | #define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */ | |
207 | #define IFCAP_LRO 0x00080 /* can do Large Receive Offload */ | |
208 | #define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */ | |
209 | ||
210 | #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) | |
211 | #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) | |
212 | ||
213 | #define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \ | |
214 | IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV) | |
215 | ||
1c79356b A |
216 | #define IFQ_MAXLEN 50 |
217 | #define IFNET_SLOWHZ 1 /* granularity is 1 second */ | |
218 | ||
219 | /* | |
220 | * Message format for use in obtaining information about interfaces | |
91447636 | 221 | * from sysctl and the routing socket |
1c79356b A |
222 | */ |
223 | struct if_msghdr { | |
91447636 A |
224 | unsigned short ifm_msglen; /* to skip over non-understood messages */ |
225 | unsigned char ifm_version; /* future binary compatability */ | |
226 | unsigned char ifm_type; /* message type */ | |
227 | int ifm_addrs; /* like rtm_addrs */ | |
228 | int ifm_flags; /* value of if_flags */ | |
229 | unsigned short ifm_index; /* index for associated ifp */ | |
230 | struct if_data ifm_data; /* statistics and other data about if */ | |
1c79356b A |
231 | }; |
232 | ||
233 | /* | |
234 | * Message format for use in obtaining information about interface addresses | |
91447636 | 235 | * from sysctl and the routing socket |
1c79356b A |
236 | */ |
237 | struct ifa_msghdr { | |
91447636 A |
238 | unsigned short ifam_msglen; /* to skip over non-understood messages */ |
239 | unsigned char ifam_version; /* future binary compatability */ | |
240 | unsigned char ifam_type; /* message type */ | |
241 | int ifam_addrs; /* like rtm_addrs */ | |
242 | int ifam_flags; /* value of ifa_flags */ | |
243 | unsigned short ifam_index; /* index for associated ifp */ | |
244 | int ifam_metric; /* value of ifa_metric */ | |
1c79356b A |
245 | }; |
246 | ||
247 | /* | |
248 | * Message format for use in obtaining information about multicast addresses | |
249 | * from the routing socket | |
250 | */ | |
251 | struct ifma_msghdr { | |
91447636 A |
252 | unsigned short ifmam_msglen; /* to skip over non-understood messages */ |
253 | unsigned char ifmam_version; /* future binary compatability */ | |
254 | unsigned char ifmam_type; /* message type */ | |
255 | int ifmam_addrs; /* like rtm_addrs */ | |
256 | int ifmam_flags; /* value of ifa_flags */ | |
257 | unsigned short ifmam_index; /* index for associated ifp */ | |
258 | }; | |
259 | ||
260 | /* | |
261 | * Message format for use in obtaining information about interfaces | |
262 | * from sysctl | |
263 | */ | |
264 | struct if_msghdr2 { | |
265 | u_short ifm_msglen; /* to skip over non-understood messages */ | |
266 | u_char ifm_version; /* future binary compatability */ | |
267 | u_char ifm_type; /* message type */ | |
268 | int ifm_addrs; /* like rtm_addrs */ | |
269 | int ifm_flags; /* value of if_flags */ | |
270 | u_short ifm_index; /* index for associated ifp */ | |
271 | int ifm_snd_len; /* instantaneous length of send queue */ | |
272 | int ifm_snd_maxlen; /* maximum length of send queue */ | |
273 | int ifm_snd_drops; /* number of drops in send queue */ | |
274 | int ifm_timer; /* time until if_watchdog called */ | |
275 | struct if_data64 ifm_data; /* statistics and other data about if */ | |
276 | }; | |
277 | ||
278 | /* | |
279 | * Message format for use in obtaining information about multicast addresses | |
280 | * from sysctl | |
281 | */ | |
282 | struct ifma_msghdr2 { | |
1c79356b A |
283 | u_short ifmam_msglen; /* to skip over non-understood messages */ |
284 | u_char ifmam_version; /* future binary compatability */ | |
285 | u_char ifmam_type; /* message type */ | |
286 | int ifmam_addrs; /* like rtm_addrs */ | |
287 | int ifmam_flags; /* value of ifa_flags */ | |
288 | u_short ifmam_index; /* index for associated ifp */ | |
91447636 A |
289 | int32_t ifmam_refcount; |
290 | }; | |
291 | ||
292 | /* | |
293 | * ifdevmtu: interface device mtu | |
294 | * Used with SIOCGIFDEVMTU to get the current mtu in use by the device, | |
295 | * as well as the minimum and maximum mtu allowed by the device. | |
296 | */ | |
297 | struct ifdevmtu { | |
298 | int ifdm_current; | |
299 | int ifdm_min; | |
300 | int ifdm_max; | |
1c79356b A |
301 | }; |
302 | ||
2d21ac55 A |
303 | #pragma pack(4) |
304 | ||
305 | /* | |
306 | ifkpi: interface kpi ioctl | |
307 | Used with SIOCSIFKPI and SIOCGIFKPI. | |
308 | ||
309 | ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From | |
310 | user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket. | |
311 | ifk_type - The type. Types are specific to each module id. | |
312 | ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes. | |
313 | ||
314 | Copying data between user space and kernel space is done using copyin | |
315 | and copyout. A process may be running in 64bit mode. In such a case, | |
316 | the pointer will be a 64bit pointer, not a 32bit pointer. The following | |
317 | sample is a safe way to copy the data in to the kernel from either a | |
318 | 32bit or 64bit process: | |
319 | ||
320 | user_addr_t tmp_ptr; | |
321 | if (IS_64BIT_PROCESS(current_proc())) { | |
322 | tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64); | |
323 | } | |
324 | else { | |
325 | tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr); | |
326 | } | |
327 | error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer); | |
328 | */ | |
329 | ||
330 | struct ifkpi { | |
331 | unsigned int ifk_module_id; | |
332 | unsigned int ifk_type; | |
333 | union { | |
334 | void *ifk_ptr; | |
335 | int ifk_value; | |
336 | #ifdef KERNEL | |
337 | u_int64_t ifk_ptr64; | |
338 | #endif /* KERNEL */ | |
339 | } ifk_data; | |
340 | }; | |
341 | ||
b0d623f7 A |
342 | /* Wake capabilities of a interface */ |
343 | #define IF_WAKE_ON_MAGIC_PACKET 0x01 | |
344 | #ifdef KERNEL_PRIVATE | |
345 | #define IF_WAKE_VALID_FLAGS IF_WAKE_ON_MAGIC_PACKET | |
346 | #endif /* KERNEL_PRIVATE */ | |
347 | ||
348 | ||
2d21ac55 A |
349 | #pragma pack() |
350 | ||
1c79356b A |
351 | /* |
352 | * Interface request structure used for socket | |
353 | * ioctl's. All interface ioctl's must have parameter | |
354 | * definitions which begin with ifr_name. The | |
355 | * remainder may be interface specific. | |
356 | */ | |
1c79356b | 357 | struct ifreq { |
91447636 A |
358 | #ifndef IFNAMSIZ |
359 | #define IFNAMSIZ IF_NAMESIZE | |
360 | #endif | |
1c79356b A |
361 | char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
362 | union { | |
363 | struct sockaddr ifru_addr; | |
364 | struct sockaddr ifru_dstaddr; | |
365 | struct sockaddr ifru_broadaddr; | |
366 | short ifru_flags; | |
367 | int ifru_metric; | |
368 | int ifru_mtu; | |
369 | int ifru_phys; | |
370 | int ifru_media; | |
91447636 | 371 | int ifru_intval; |
1c79356b | 372 | caddr_t ifru_data; |
91447636 A |
373 | #ifdef KERNEL_PRIVATE |
374 | u_int64_t ifru_data64; /* 64-bit ifru_data */ | |
b0d623f7 | 375 | #endif /* KERNEL_PRIVATE */ |
91447636 | 376 | struct ifdevmtu ifru_devmtu; |
2d21ac55 | 377 | struct ifkpi ifru_kpi; |
b0d623f7 | 378 | u_int32_t ifru_wake_flags; |
d1ecb069 | 379 | u_int32_t ifru_route_refcnt; |
6d2010ae | 380 | int ifru_cap[2]; |
1c79356b A |
381 | } ifr_ifru; |
382 | #define ifr_addr ifr_ifru.ifru_addr /* address */ | |
383 | #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ | |
384 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ | |
9bccf70c | 385 | #ifdef __APPLE__ |
1c79356b | 386 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
9bccf70c A |
387 | #else |
388 | #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ | |
389 | #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ | |
390 | #endif /* __APPLE__ */ | |
1c79356b A |
391 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ |
392 | #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ | |
393 | #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ | |
394 | #define ifr_media ifr_ifru.ifru_media /* physical media */ | |
395 | #define ifr_data ifr_ifru.ifru_data /* for use by interface */ | |
91447636 A |
396 | #define ifr_devmtu ifr_ifru.ifru_devmtu |
397 | #define ifr_intval ifr_ifru.ifru_intval /* integer value */ | |
398 | #ifdef KERNEL_PRIVATE | |
399 | #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */ | |
b0d623f7 | 400 | #endif /* KERNEL_PRIVATE */ |
2d21ac55 | 401 | #define ifr_kpi ifr_ifru.ifru_kpi |
b0d623f7 | 402 | #define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities of devive */ |
d1ecb069 | 403 | #define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references on interface */ |
6d2010ae A |
404 | #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ |
405 | #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ | |
1c79356b A |
406 | }; |
407 | ||
408 | #define _SIZEOF_ADDR_IFREQ(ifr) \ | |
409 | ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ | |
410 | (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ | |
411 | (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) | |
412 | ||
413 | struct ifaliasreq { | |
414 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
415 | struct sockaddr ifra_addr; | |
416 | struct sockaddr ifra_broadaddr; | |
417 | struct sockaddr ifra_mask; | |
418 | }; | |
419 | ||
420 | struct rslvmulti_req { | |
421 | struct sockaddr *sa; | |
422 | struct sockaddr **llsa; | |
423 | }; | |
424 | ||
b0d623f7 | 425 | #if !defined(KERNEL) || defined(KERNEL_PRIVATE) |
2d21ac55 A |
426 | #pragma pack(4) |
427 | ||
1c79356b A |
428 | struct ifmediareq { |
429 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
430 | int ifm_current; /* current media options */ | |
431 | int ifm_mask; /* don't care mask */ | |
432 | int ifm_status; /* media status */ | |
433 | int ifm_active; /* active options */ | |
434 | int ifm_count; /* # entries in ifm_ulist array */ | |
435 | int *ifm_ulist; /* media words */ | |
436 | }; | |
9bccf70c | 437 | |
2d21ac55 | 438 | #pragma pack() |
b0d623f7 | 439 | #endif /* !KERNEL || KERNEL_PRIVATE */ |
2d21ac55 | 440 | |
91447636 | 441 | #ifdef KERNEL_PRIVATE |
b0d623f7 | 442 | #pragma pack(4) |
91447636 A |
443 | struct ifmediareq64 { |
444 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
445 | int ifm_current; /* current media options */ | |
446 | int ifm_mask; /* don't care mask */ | |
447 | int ifm_status; /* media status */ | |
448 | int ifm_active; /* active options */ | |
449 | int ifm_count; /* # entries in ifm_ulist array */ | |
b0d623f7 | 450 | user64_addr_t ifmu_ulist __attribute__((aligned(8))); |
91447636 | 451 | }; |
b0d623f7 A |
452 | |
453 | struct ifmediareq32 { | |
454 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
455 | int ifm_current; /* current media options */ | |
456 | int ifm_mask; /* don't care mask */ | |
457 | int ifm_status; /* media status */ | |
458 | int ifm_active; /* active options */ | |
459 | int ifm_count; /* # entries in ifm_ulist array */ | |
460 | user32_addr_t ifmu_ulist; /* 32-bit pointer */ | |
461 | }; | |
462 | #pragma pack() | |
463 | #endif /* KERNEL_PRIVATE */ | |
91447636 | 464 | |
b7266188 A |
465 | |
466 | #pragma pack(4) | |
467 | struct ifdrv { | |
468 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
469 | unsigned long ifd_cmd; | |
470 | size_t ifd_len; | |
471 | void *ifd_data; | |
472 | }; | |
473 | #pragma pack() | |
474 | ||
475 | #ifdef KERNEL_PRIVATE | |
476 | #pragma pack(4) | |
477 | struct ifdrv32 { | |
478 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
479 | u_int32_t ifd_cmd; | |
480 | u_int32_t ifd_len; | |
481 | user32_addr_t ifd_data; | |
482 | }; | |
483 | ||
484 | struct ifdrv64 { | |
485 | char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
486 | u_int64_t ifd_cmd; | |
487 | u_int64_t ifd_len; | |
488 | user64_addr_t ifd_data; | |
489 | }; | |
490 | #pragma pack() | |
491 | #endif /* KERNEL_PRIVATE */ | |
492 | ||
9bccf70c A |
493 | /* |
494 | * Structure used to retrieve aux status data from interfaces. | |
495 | * Kernel suppliers to this interface should respect the formatting | |
496 | * needed by ifconfig(8): each line starts with a TAB and ends with | |
497 | * a newline. The canonical example to copy and paste is in if_tun.c. | |
498 | */ | |
499 | ||
500 | #define IFSTATMAX 800 /* 10 lines of text */ | |
501 | struct ifstat { | |
502 | char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
503 | char ascii[IFSTATMAX + 1]; | |
504 | }; | |
505 | ||
b0d623f7 | 506 | #if !defined(KERNEL) || defined(KERNEL_PRIVATE) |
1c79356b A |
507 | /* |
508 | * Structure used in SIOCGIFCONF request. | |
509 | * Used to retrieve interface configuration | |
510 | * for machine (useful for programs which | |
511 | * must know all networks accessible). | |
512 | */ | |
b0d623f7 | 513 | #pragma pack(4) |
1c79356b A |
514 | struct ifconf { |
515 | int ifc_len; /* size of associated buffer */ | |
516 | union { | |
517 | caddr_t ifcu_buf; | |
518 | struct ifreq *ifcu_req; | |
519 | } ifc_ifcu; | |
2d21ac55 | 520 | }; |
b0d623f7 | 521 | #pragma pack() |
1c79356b A |
522 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ |
523 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ | |
b0d623f7 | 524 | #endif /* !KERNEL || KERNEL_PRIVATE */ |
2d21ac55 | 525 | |
b0d623f7 A |
526 | #if defined(KERNEL_PRIVATE) |
527 | #pragma pack(4) | |
528 | struct ifconf32 { | |
529 | int ifc_len; /* size of associated buffer */ | |
530 | struct { | |
531 | user32_addr_t ifcu_req; | |
532 | } ifc_ifcu; | |
533 | }; | |
1c79356b | 534 | |
91447636 A |
535 | struct ifconf64 { |
536 | int ifc_len; /* size of associated buffer */ | |
b0d623f7 A |
537 | struct { |
538 | user64_addr_t ifcu_req __attribute__((aligned(8))); | |
91447636 A |
539 | } ifc_ifcu; |
540 | }; | |
b0d623f7 A |
541 | #pragma pack() |
542 | #endif /* KERNEL_PRIVATE */ | |
91447636 | 543 | |
0b4e3aa0 A |
544 | /* |
545 | * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure | |
546 | */ | |
547 | struct kev_dl_proto_data { | |
548 | struct net_event_data link_data; | |
2d21ac55 A |
549 | u_int32_t proto_family; |
550 | u_int32_t proto_remaining_count; | |
0b4e3aa0 | 551 | }; |
0b4e3aa0 | 552 | |
1c79356b A |
553 | /* |
554 | * Structure for SIOC[AGD]LIFADDR | |
555 | */ | |
556 | struct if_laddrreq { | |
91447636 A |
557 | char iflr_name[IFNAMSIZ]; |
558 | unsigned int flags; | |
9bccf70c | 559 | #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ |
91447636 A |
560 | unsigned int prefixlen; /* in/out */ |
561 | struct sockaddr_storage addr; /* in/out */ | |
562 | struct sockaddr_storage dstaddr; /* out */ | |
1c79356b A |
563 | }; |
564 | ||
1c79356b A |
565 | #ifdef KERNEL |
566 | #ifdef MALLOC_DECLARE | |
567 | MALLOC_DECLARE(M_IFADDR); | |
568 | MALLOC_DECLARE(M_IFMADDR); | |
569 | #endif | |
570 | #endif | |
2d21ac55 | 571 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
1c79356b A |
572 | |
573 | #ifndef KERNEL | |
9bccf70c | 574 | struct if_nameindex { |
91447636 A |
575 | unsigned int if_index; /* 1, 2, ... */ |
576 | char *if_name; /* null terminated name: "le0", ... */ | |
9bccf70c A |
577 | }; |
578 | ||
1c79356b | 579 | __BEGIN_DECLS |
91447636 A |
580 | unsigned int if_nametoindex(const char *); |
581 | char *if_indextoname(unsigned int, char *); | |
582 | struct if_nameindex *if_nameindex(void); | |
583 | void if_freenameindex(struct if_nameindex *); | |
1c79356b A |
584 | __END_DECLS |
585 | #endif | |
586 | ||
1c79356b | 587 | #ifdef KERNEL |
91447636 | 588 | #include <net/kpi_interface.h> |
1c79356b A |
589 | #endif |
590 | ||
591 | #endif /* !_NET_IF_H_ */ |