]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
8ad349bb | 2 | * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb 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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * Copyright (c) 1982, 1986, 1989, 1993 | |
32 | * The Regents of the University of California. All rights reserved. | |
33 | * | |
34 | * Redistribution and use in source and binary forms, with or without | |
35 | * modification, are permitted provided that the following conditions | |
36 | * are met: | |
37 | * 1. Redistributions of source code must retain the above copyright | |
38 | * notice, this list of conditions and the following disclaimer. | |
39 | * 2. Redistributions in binary form must reproduce the above copyright | |
40 | * notice, this list of conditions and the following disclaimer in the | |
41 | * documentation and/or other materials provided with the distribution. | |
42 | * 3. All advertising materials mentioning features or use of this software | |
43 | * must display the following acknowledgement: | |
44 | * This product includes software developed by the University of | |
45 | * California, Berkeley and its contributors. | |
46 | * 4. Neither the name of the University nor the names of its contributors | |
47 | * may be used to endorse or promote products derived from this software | |
48 | * without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
51 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 | * SUCH DAMAGE. | |
61 | * | |
62 | * @(#)if.h 8.1 (Berkeley) 6/10/93 | |
9bccf70c | 63 | * $FreeBSD: src/sys/net/if.h,v 1.58.2.2 2001/07/24 19:10:18 brooks Exp $ |
1c79356b A |
64 | */ |
65 | ||
66 | #ifndef _NET_IF_H_ | |
67 | #define _NET_IF_H_ | |
68 | ||
91447636 A |
69 | #define IF_NAMESIZE 16 |
70 | ||
71 | #ifndef _POSIX_C_SOURCE | |
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 |
4a249263 | 97 | |
1c79356b | 98 | #include <net/if_var.h> |
91447636 | 99 | #include <sys/types.h> |
9bccf70c | 100 | #endif |
1c79356b | 101 | |
4a249263 A |
102 | #ifdef KERNEL_PRIVATE |
103 | struct if_clonereq { | |
104 | int ifcr_total; /* total cloners (out) */ | |
105 | int ifcr_count; /* room for this many in user buffer */ | |
106 | char *ifcr_buffer; /* buffer for cloner names */ | |
107 | }; | |
91447636 A |
108 | |
109 | /* in-kernel, LP64-aware version of if_clonereq. all pointers | |
110 | * grow when we're dealing with a 64-bit process. | |
111 | * WARNING - keep in sync with if_clonereq | |
112 | */ | |
113 | struct if_clonereq64 { | |
114 | int ifcr_total; /* total cloners (out) */ | |
115 | int ifcr_count; /* room for this many in user buffer */ | |
116 | union { | |
117 | u_int64_t ifcru_buffer64; | |
118 | char * ifcru_buffer32; | |
119 | } ifcr_ifcru; | |
120 | }; | |
4a249263 | 121 | #endif KERNEL_PRIVATE |
1c79356b A |
122 | |
123 | #define IFF_UP 0x1 /* interface is up */ | |
124 | #define IFF_BROADCAST 0x2 /* broadcast address valid */ | |
125 | #define IFF_DEBUG 0x4 /* turn on debugging */ | |
126 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ | |
127 | #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ | |
128 | #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */ | |
129 | #define IFF_RUNNING 0x40 /* resources allocated */ | |
130 | #define IFF_NOARP 0x80 /* no address resolution protocol */ | |
131 | #define IFF_PROMISC 0x100 /* receive all packets */ | |
132 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets */ | |
133 | #define IFF_OACTIVE 0x400 /* transmission in progress */ | |
134 | #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ | |
135 | #define IFF_LINK0 0x1000 /* per link layer defined bit */ | |
136 | #define IFF_LINK1 0x2000 /* per link layer defined bit */ | |
137 | #define IFF_LINK2 0x4000 /* per link layer defined bit */ | |
138 | #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ | |
139 | #define IFF_MULTICAST 0x8000 /* supports multicast */ | |
1c79356b | 140 | |
4a249263 | 141 | #ifdef KERNEL_PRIVATE |
0b4e3aa0 A |
142 | /* extended flags definitions: (all bits are reserved for internal/future use) */ |
143 | #define IFEF_AUTOCONFIGURING 0x1 | |
1c79356b | 144 | #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */ |
55e303ae | 145 | #define IFEF_ACCEPT_RTADVD 0x40 /* set to accept IPv6 router advertisement on the interface */ |
91447636 A |
146 | #define IFEF_DETACHING 0x80 /* Set when interface is detaching */ |
147 | #define IFEF_USEKPI 0x100 /* Set when interface is created through the KPIs */ | |
148 | #define IFEF_VLAN 0x200 /* interface has one or more vlans */ | |
149 | #define IFEF_BOND 0x400 /* interface is part of bond */ | |
150 | #define IFEF_ARPLL 0x800 /* ARP for IPv4LL addresses on this port */ | |
9bccf70c | 151 | #define IFEF_REUSE 0x20000000 /* DLIL ifnet recycler, ifnet is not new */ |
91447636 A |
152 | #define IFEF_INUSE 0x40000000 /* DLIL ifnet recycler, ifnet in use */ |
153 | #define IFEF_UPDOWNCHANGE 0x80000000 /* Interface's up/down state is changing */ | |
1c79356b A |
154 | |
155 | /* flags set internally only: */ | |
156 | #define IFF_CANTCHANGE \ | |
157 | (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ | |
158 | IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) | |
159 | ||
91447636 A |
160 | #endif /* KERNEL_PRIVATE */ |
161 | ||
1c79356b A |
162 | #define IFQ_MAXLEN 50 |
163 | #define IFNET_SLOWHZ 1 /* granularity is 1 second */ | |
164 | ||
165 | /* | |
166 | * Message format for use in obtaining information about interfaces | |
91447636 | 167 | * from sysctl and the routing socket |
1c79356b A |
168 | */ |
169 | struct if_msghdr { | |
91447636 A |
170 | unsigned short ifm_msglen; /* to skip over non-understood messages */ |
171 | unsigned char ifm_version; /* future binary compatability */ | |
172 | unsigned char ifm_type; /* message type */ | |
173 | int ifm_addrs; /* like rtm_addrs */ | |
174 | int ifm_flags; /* value of if_flags */ | |
175 | unsigned short ifm_index; /* index for associated ifp */ | |
176 | struct if_data ifm_data; /* statistics and other data about if */ | |
1c79356b A |
177 | }; |
178 | ||
179 | /* | |
180 | * Message format for use in obtaining information about interface addresses | |
91447636 | 181 | * from sysctl and the routing socket |
1c79356b A |
182 | */ |
183 | struct ifa_msghdr { | |
91447636 A |
184 | unsigned short ifam_msglen; /* to skip over non-understood messages */ |
185 | unsigned char ifam_version; /* future binary compatability */ | |
186 | unsigned char ifam_type; /* message type */ | |
187 | int ifam_addrs; /* like rtm_addrs */ | |
188 | int ifam_flags; /* value of ifa_flags */ | |
189 | unsigned short ifam_index; /* index for associated ifp */ | |
190 | int ifam_metric; /* value of ifa_metric */ | |
1c79356b A |
191 | }; |
192 | ||
193 | /* | |
194 | * Message format for use in obtaining information about multicast addresses | |
195 | * from the routing socket | |
196 | */ | |
197 | struct ifma_msghdr { | |
91447636 A |
198 | unsigned short ifmam_msglen; /* to skip over non-understood messages */ |
199 | unsigned char ifmam_version; /* future binary compatability */ | |
200 | unsigned char ifmam_type; /* message type */ | |
201 | int ifmam_addrs; /* like rtm_addrs */ | |
202 | int ifmam_flags; /* value of ifa_flags */ | |
203 | unsigned short ifmam_index; /* index for associated ifp */ | |
204 | }; | |
205 | ||
206 | /* | |
207 | * Message format for use in obtaining information about interfaces | |
208 | * from sysctl | |
209 | */ | |
210 | struct if_msghdr2 { | |
211 | u_short ifm_msglen; /* to skip over non-understood messages */ | |
212 | u_char ifm_version; /* future binary compatability */ | |
213 | u_char ifm_type; /* message type */ | |
214 | int ifm_addrs; /* like rtm_addrs */ | |
215 | int ifm_flags; /* value of if_flags */ | |
216 | u_short ifm_index; /* index for associated ifp */ | |
217 | int ifm_snd_len; /* instantaneous length of send queue */ | |
218 | int ifm_snd_maxlen; /* maximum length of send queue */ | |
219 | int ifm_snd_drops; /* number of drops in send queue */ | |
220 | int ifm_timer; /* time until if_watchdog called */ | |
221 | struct if_data64 ifm_data; /* statistics and other data about if */ | |
222 | }; | |
223 | ||
224 | /* | |
225 | * Message format for use in obtaining information about multicast addresses | |
226 | * from sysctl | |
227 | */ | |
228 | struct ifma_msghdr2 { | |
1c79356b A |
229 | u_short ifmam_msglen; /* to skip over non-understood messages */ |
230 | u_char ifmam_version; /* future binary compatability */ | |
231 | u_char ifmam_type; /* message type */ | |
232 | int ifmam_addrs; /* like rtm_addrs */ | |
233 | int ifmam_flags; /* value of ifa_flags */ | |
234 | u_short ifmam_index; /* index for associated ifp */ | |
91447636 A |
235 | int32_t ifmam_refcount; |
236 | }; | |
237 | ||
238 | /* | |
239 | * ifdevmtu: interface device mtu | |
240 | * Used with SIOCGIFDEVMTU to get the current mtu in use by the device, | |
241 | * as well as the minimum and maximum mtu allowed by the device. | |
242 | */ | |
243 | struct ifdevmtu { | |
244 | int ifdm_current; | |
245 | int ifdm_min; | |
246 | int ifdm_max; | |
1c79356b A |
247 | }; |
248 | ||
249 | /* | |
250 | * Interface request structure used for socket | |
251 | * ioctl's. All interface ioctl's must have parameter | |
252 | * definitions which begin with ifr_name. The | |
253 | * remainder may be interface specific. | |
254 | */ | |
1c79356b | 255 | struct ifreq { |
91447636 A |
256 | #ifndef IFNAMSIZ |
257 | #define IFNAMSIZ IF_NAMESIZE | |
258 | #endif | |
1c79356b A |
259 | char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
260 | union { | |
261 | struct sockaddr ifru_addr; | |
262 | struct sockaddr ifru_dstaddr; | |
263 | struct sockaddr ifru_broadaddr; | |
264 | short ifru_flags; | |
265 | int ifru_metric; | |
266 | int ifru_mtu; | |
267 | int ifru_phys; | |
268 | int ifru_media; | |
91447636 | 269 | int ifru_intval; |
1c79356b | 270 | caddr_t ifru_data; |
91447636 A |
271 | #ifdef KERNEL_PRIVATE |
272 | u_int64_t ifru_data64; /* 64-bit ifru_data */ | |
273 | #endif KERNEL_PRIVATE | |
274 | struct ifdevmtu ifru_devmtu; | |
1c79356b A |
275 | } ifr_ifru; |
276 | #define ifr_addr ifr_ifru.ifru_addr /* address */ | |
277 | #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ | |
278 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ | |
9bccf70c | 279 | #ifdef __APPLE__ |
1c79356b | 280 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
9bccf70c A |
281 | #else |
282 | #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ | |
283 | #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ | |
284 | #endif /* __APPLE__ */ | |
1c79356b A |
285 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ |
286 | #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ | |
287 | #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ | |
288 | #define ifr_media ifr_ifru.ifru_media /* physical media */ | |
289 | #define ifr_data ifr_ifru.ifru_data /* for use by interface */ | |
91447636 A |
290 | #define ifr_devmtu ifr_ifru.ifru_devmtu |
291 | #define ifr_intval ifr_ifru.ifru_intval /* integer value */ | |
292 | #ifdef KERNEL_PRIVATE | |
293 | #define ifr_data64 ifr_ifru.ifru_data64 /* 64-bit pointer */ | |
294 | #endif KERNEL_PRIVATE | |
1c79356b A |
295 | }; |
296 | ||
297 | #define _SIZEOF_ADDR_IFREQ(ifr) \ | |
298 | ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ | |
299 | (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ | |
300 | (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) | |
301 | ||
302 | struct ifaliasreq { | |
303 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
304 | struct sockaddr ifra_addr; | |
305 | struct sockaddr ifra_broadaddr; | |
306 | struct sockaddr ifra_mask; | |
307 | }; | |
308 | ||
309 | struct rslvmulti_req { | |
310 | struct sockaddr *sa; | |
311 | struct sockaddr **llsa; | |
312 | }; | |
313 | ||
314 | struct ifmediareq { | |
315 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
316 | int ifm_current; /* current media options */ | |
317 | int ifm_mask; /* don't care mask */ | |
318 | int ifm_status; /* media status */ | |
319 | int ifm_active; /* active options */ | |
320 | int ifm_count; /* # entries in ifm_ulist array */ | |
321 | int *ifm_ulist; /* media words */ | |
322 | }; | |
9bccf70c | 323 | |
91447636 A |
324 | #ifdef KERNEL_PRIVATE |
325 | /* LP64 version of ifmediareq. all pointers | |
326 | * grow when we're dealing with a 64-bit process. | |
327 | * WARNING - keep in sync with ifmediareq | |
328 | */ | |
329 | struct ifmediareq64 { | |
330 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
331 | int ifm_current; /* current media options */ | |
332 | int ifm_mask; /* don't care mask */ | |
333 | int ifm_status; /* media status */ | |
334 | int ifm_active; /* active options */ | |
335 | int ifm_count; /* # entries in ifm_ulist array */ | |
336 | union { /* media words */ | |
337 | int * ifmu_ulist32; /* 32-bit pointer */ | |
338 | u_int64_t ifmu_ulist64; /* 64-bit pointer */ | |
339 | } ifm_ifmu; | |
340 | }; | |
341 | #endif // KERNEL_PRIVATE | |
342 | ||
9bccf70c A |
343 | /* |
344 | * Structure used to retrieve aux status data from interfaces. | |
345 | * Kernel suppliers to this interface should respect the formatting | |
346 | * needed by ifconfig(8): each line starts with a TAB and ends with | |
347 | * a newline. The canonical example to copy and paste is in if_tun.c. | |
348 | */ | |
349 | ||
350 | #define IFSTATMAX 800 /* 10 lines of text */ | |
351 | struct ifstat { | |
352 | char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
353 | char ascii[IFSTATMAX + 1]; | |
354 | }; | |
355 | ||
1c79356b A |
356 | /* |
357 | * Structure used in SIOCGIFCONF request. | |
358 | * Used to retrieve interface configuration | |
359 | * for machine (useful for programs which | |
360 | * must know all networks accessible). | |
361 | */ | |
362 | struct ifconf { | |
363 | int ifc_len; /* size of associated buffer */ | |
364 | union { | |
365 | caddr_t ifcu_buf; | |
366 | struct ifreq *ifcu_req; | |
367 | } ifc_ifcu; | |
368 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ | |
369 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ | |
370 | }; | |
371 | ||
91447636 A |
372 | #ifdef KERNEL_PRIVATE |
373 | /* LP64 version of ifconf. all pointers | |
374 | * grow when we're dealing with a 64-bit process. | |
375 | * WARNING - keep in sync with ifconf | |
376 | */ | |
377 | struct ifconf64 { | |
378 | int ifc_len; /* size of associated buffer */ | |
379 | union { | |
380 | struct ifreq * ifcu_req; | |
381 | u_int64_t ifcu_req64; | |
382 | } ifc_ifcu; | |
383 | }; | |
384 | #define ifc_req64 ifc_ifcu.ifcu_req64 | |
385 | #endif // KERNEL_PRIVATE | |
386 | ||
0b4e3aa0 A |
387 | /* |
388 | * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure | |
389 | */ | |
390 | struct kev_dl_proto_data { | |
391 | struct net_event_data link_data; | |
91447636 A |
392 | unsigned long proto_family; |
393 | unsigned long proto_remaining_count; | |
0b4e3aa0 | 394 | }; |
0b4e3aa0 | 395 | |
1c79356b A |
396 | /* |
397 | * Structure for SIOC[AGD]LIFADDR | |
398 | */ | |
399 | struct if_laddrreq { | |
91447636 A |
400 | char iflr_name[IFNAMSIZ]; |
401 | unsigned int flags; | |
9bccf70c | 402 | #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ |
91447636 A |
403 | unsigned int prefixlen; /* in/out */ |
404 | struct sockaddr_storage addr; /* in/out */ | |
405 | struct sockaddr_storage dstaddr; /* out */ | |
1c79356b A |
406 | }; |
407 | ||
1c79356b A |
408 | #ifdef KERNEL |
409 | #ifdef MALLOC_DECLARE | |
410 | MALLOC_DECLARE(M_IFADDR); | |
411 | MALLOC_DECLARE(M_IFMADDR); | |
412 | #endif | |
413 | #endif | |
91447636 | 414 | #endif /* _POSIX_C_SOURCE */ |
1c79356b A |
415 | |
416 | #ifndef KERNEL | |
9bccf70c | 417 | struct if_nameindex { |
91447636 A |
418 | unsigned int if_index; /* 1, 2, ... */ |
419 | char *if_name; /* null terminated name: "le0", ... */ | |
9bccf70c A |
420 | }; |
421 | ||
1c79356b | 422 | __BEGIN_DECLS |
91447636 A |
423 | unsigned int if_nametoindex(const char *); |
424 | char *if_indextoname(unsigned int, char *); | |
425 | struct if_nameindex *if_nameindex(void); | |
426 | void if_freenameindex(struct if_nameindex *); | |
1c79356b A |
427 | __END_DECLS |
428 | #endif | |
429 | ||
1c79356b | 430 | #ifdef KERNEL |
91447636 | 431 | #include <net/kpi_interface.h> |
1c79356b A |
432 | #endif |
433 | ||
434 | #endif /* !_NET_IF_H_ */ |