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