]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
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_ | |
9bccf70c | 60 | #include <sys/appleapiopts.h> |
1c79356b | 61 | |
9bccf70c | 62 | #ifdef __APPLE__ |
1c79356b A |
63 | /* |
64 | * Define Data-Link event subclass, and associated | |
65 | * events. | |
66 | */ | |
67 | ||
68 | #define KEV_DL_SUBCLASS 2 | |
69 | ||
70 | #define KEV_DL_SIFFLAGS 1 | |
71 | #define KEV_DL_SIFMETRICS 2 | |
72 | #define KEV_DL_SIFMTU 3 | |
73 | #define KEV_DL_SIFPHYS 4 | |
74 | #define KEV_DL_SIFMEDIA 5 | |
75 | #define KEV_DL_SIFGENERIC 6 | |
76 | #define KEV_DL_ADDMULTI 7 | |
77 | #define KEV_DL_DELMULTI 8 | |
78 | #define KEV_DL_IF_ATTACHED 9 | |
79 | #define KEV_DL_IF_DETACHING 10 | |
80 | #define KEV_DL_IF_DETACHED 11 | |
81 | #define KEV_DL_LINK_OFF 12 | |
82 | #define KEV_DL_LINK_ON 13 | |
0b4e3aa0 A |
83 | #define KEV_DL_PROTO_ATTACHED 14 |
84 | #define KEV_DL_PROTO_DETACHED 15 | |
9bccf70c | 85 | #endif |
1c79356b A |
86 | |
87 | /* | |
88 | * <net/if.h> does not depend on <sys/time.h> on most other systems. This | |
89 | * helps userland compatability. (struct timeval ifi_lastchange) | |
90 | */ | |
1c79356b | 91 | #include <sys/time.h> |
9bccf70c | 92 | |
4a249263 | 93 | |
9bccf70c | 94 | #ifdef __APPLE__ |
1c79356b | 95 | #include <net/if_var.h> |
9bccf70c | 96 | #endif |
1c79356b | 97 | |
4a249263 A |
98 | #ifdef KERNEL_PRIVATE |
99 | struct if_clonereq { | |
100 | int ifcr_total; /* total cloners (out) */ | |
101 | int ifcr_count; /* room for this many in user buffer */ | |
102 | char *ifcr_buffer; /* buffer for cloner names */ | |
103 | }; | |
104 | #endif KERNEL_PRIVATE | |
1c79356b A |
105 | |
106 | #define IFF_UP 0x1 /* interface is up */ | |
107 | #define IFF_BROADCAST 0x2 /* broadcast address valid */ | |
108 | #define IFF_DEBUG 0x4 /* turn on debugging */ | |
109 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ | |
110 | #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ | |
111 | #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */ | |
112 | #define IFF_RUNNING 0x40 /* resources allocated */ | |
113 | #define IFF_NOARP 0x80 /* no address resolution protocol */ | |
114 | #define IFF_PROMISC 0x100 /* receive all packets */ | |
115 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets */ | |
116 | #define IFF_OACTIVE 0x400 /* transmission in progress */ | |
117 | #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ | |
118 | #define IFF_LINK0 0x1000 /* per link layer defined bit */ | |
119 | #define IFF_LINK1 0x2000 /* per link layer defined bit */ | |
120 | #define IFF_LINK2 0x4000 /* per link layer defined bit */ | |
121 | #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ | |
122 | #define IFF_MULTICAST 0x8000 /* supports multicast */ | |
1c79356b | 123 | |
4a249263 | 124 | #ifdef KERNEL_PRIVATE |
0b4e3aa0 A |
125 | /* extended flags definitions: (all bits are reserved for internal/future use) */ |
126 | #define IFEF_AUTOCONFIGURING 0x1 | |
1c79356b | 127 | #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */ |
55e303ae | 128 | #define IFEF_ACCEPT_RTADVD 0x40 /* set to accept IPv6 router advertisement on the interface */ |
9bccf70c A |
129 | #define IFEF_INUSE 0x40000000 /* DLIL ifnet recycler, ifnet in use */ |
130 | #define IFEF_REUSE 0x20000000 /* DLIL ifnet recycler, ifnet is not new */ | |
d7e50217 | 131 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
132 | |
133 | ||
134 | /* flags set internally only: */ | |
135 | #define IFF_CANTCHANGE \ | |
136 | (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ | |
137 | IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) | |
138 | ||
139 | #define IFQ_MAXLEN 50 | |
140 | #define IFNET_SLOWHZ 1 /* granularity is 1 second */ | |
141 | ||
142 | /* | |
143 | * Message format for use in obtaining information about interfaces | |
144 | * from getkerninfo and the routing socket | |
145 | */ | |
146 | struct if_msghdr { | |
147 | u_short ifm_msglen; /* to skip over non-understood messages */ | |
148 | u_char ifm_version; /* future binary compatability */ | |
149 | u_char ifm_type; /* message type */ | |
150 | int ifm_addrs; /* like rtm_addrs */ | |
151 | int ifm_flags; /* value of if_flags */ | |
152 | u_short ifm_index; /* index for associated ifp */ | |
153 | struct if_data ifm_data;/* statistics and other data about if */ | |
154 | }; | |
155 | ||
156 | /* | |
157 | * Message format for use in obtaining information about interface addresses | |
158 | * from getkerninfo and the routing socket | |
159 | */ | |
160 | struct ifa_msghdr { | |
161 | u_short ifam_msglen; /* to skip over non-understood messages */ | |
162 | u_char ifam_version; /* future binary compatability */ | |
163 | u_char ifam_type; /* message type */ | |
164 | int ifam_addrs; /* like rtm_addrs */ | |
165 | int ifam_flags; /* value of ifa_flags */ | |
166 | u_short ifam_index; /* index for associated ifp */ | |
167 | int ifam_metric; /* value of ifa_metric */ | |
168 | }; | |
169 | ||
170 | /* | |
171 | * Message format for use in obtaining information about multicast addresses | |
172 | * from the routing socket | |
173 | */ | |
174 | struct ifma_msghdr { | |
175 | u_short ifmam_msglen; /* to skip over non-understood messages */ | |
176 | u_char ifmam_version; /* future binary compatability */ | |
177 | u_char ifmam_type; /* message type */ | |
178 | int ifmam_addrs; /* like rtm_addrs */ | |
179 | int ifmam_flags; /* value of ifa_flags */ | |
180 | u_short ifmam_index; /* index for associated ifp */ | |
181 | }; | |
182 | ||
183 | /* | |
184 | * Interface request structure used for socket | |
185 | * ioctl's. All interface ioctl's must have parameter | |
186 | * definitions which begin with ifr_name. The | |
187 | * remainder may be interface specific. | |
188 | */ | |
189 | #define IF_NAMESIZE IFNAMSIZ | |
190 | struct ifreq { | |
191 | #define IFNAMSIZ 16 | |
192 | char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
193 | union { | |
194 | struct sockaddr ifru_addr; | |
195 | struct sockaddr ifru_dstaddr; | |
196 | struct sockaddr ifru_broadaddr; | |
197 | short ifru_flags; | |
198 | int ifru_metric; | |
199 | int ifru_mtu; | |
200 | int ifru_phys; | |
201 | int ifru_media; | |
202 | caddr_t ifru_data; | |
203 | } ifr_ifru; | |
204 | #define ifr_addr ifr_ifru.ifru_addr /* address */ | |
205 | #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ | |
206 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ | |
9bccf70c | 207 | #ifdef __APPLE__ |
1c79356b | 208 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
9bccf70c A |
209 | #else |
210 | #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ | |
211 | #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ | |
212 | #endif /* __APPLE__ */ | |
1c79356b A |
213 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ |
214 | #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ | |
215 | #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ | |
216 | #define ifr_media ifr_ifru.ifru_media /* physical media */ | |
217 | #define ifr_data ifr_ifru.ifru_data /* for use by interface */ | |
218 | }; | |
219 | ||
220 | #define _SIZEOF_ADDR_IFREQ(ifr) \ | |
221 | ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ | |
222 | (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ | |
223 | (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) | |
224 | ||
225 | struct ifaliasreq { | |
226 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
227 | struct sockaddr ifra_addr; | |
228 | struct sockaddr ifra_broadaddr; | |
229 | struct sockaddr ifra_mask; | |
230 | }; | |
231 | ||
232 | struct rslvmulti_req { | |
233 | struct sockaddr *sa; | |
234 | struct sockaddr **llsa; | |
235 | }; | |
236 | ||
237 | struct ifmediareq { | |
238 | char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
239 | int ifm_current; /* current media options */ | |
240 | int ifm_mask; /* don't care mask */ | |
241 | int ifm_status; /* media status */ | |
242 | int ifm_active; /* active options */ | |
243 | int ifm_count; /* # entries in ifm_ulist array */ | |
244 | int *ifm_ulist; /* media words */ | |
245 | }; | |
9bccf70c A |
246 | |
247 | /* | |
248 | * Structure used to retrieve aux status data from interfaces. | |
249 | * Kernel suppliers to this interface should respect the formatting | |
250 | * needed by ifconfig(8): each line starts with a TAB and ends with | |
251 | * a newline. The canonical example to copy and paste is in if_tun.c. | |
252 | */ | |
253 | ||
254 | #define IFSTATMAX 800 /* 10 lines of text */ | |
255 | struct ifstat { | |
256 | char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
257 | char ascii[IFSTATMAX + 1]; | |
258 | }; | |
259 | ||
1c79356b A |
260 | /* |
261 | * Structure used in SIOCGIFCONF request. | |
262 | * Used to retrieve interface configuration | |
263 | * for machine (useful for programs which | |
264 | * must know all networks accessible). | |
265 | */ | |
266 | struct ifconf { | |
267 | int ifc_len; /* size of associated buffer */ | |
268 | union { | |
269 | caddr_t ifcu_buf; | |
270 | struct ifreq *ifcu_req; | |
271 | } ifc_ifcu; | |
272 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ | |
273 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ | |
274 | }; | |
275 | ||
9bccf70c A |
276 | #ifdef __APPLE__ |
277 | #ifdef __APPLE_API_UNSTABLE | |
0b4e3aa0 A |
278 | /* |
279 | * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure | |
280 | */ | |
281 | struct kev_dl_proto_data { | |
282 | struct net_event_data link_data; | |
283 | u_long proto_family; | |
284 | u_long proto_remaining_count; | |
285 | }; | |
9bccf70c A |
286 | #endif /* __APPLE_API_UNSTABLE */ |
287 | #endif | |
0b4e3aa0 A |
288 | |
289 | ||
1c79356b A |
290 | /* |
291 | * Structure for SIOC[AGD]LIFADDR | |
292 | */ | |
293 | struct if_laddrreq { | |
9bccf70c A |
294 | char iflr_name[IFNAMSIZ]; |
295 | u_int flags; | |
296 | #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ | |
297 | u_int prefixlen; /* in/out */ | |
298 | struct sockaddr_storage addr; /* in/out */ | |
299 | struct sockaddr_storage dstaddr; /* out */ | |
1c79356b A |
300 | }; |
301 | ||
1c79356b A |
302 | #ifdef KERNEL |
303 | #ifdef MALLOC_DECLARE | |
304 | MALLOC_DECLARE(M_IFADDR); | |
305 | MALLOC_DECLARE(M_IFMADDR); | |
306 | #endif | |
307 | #endif | |
308 | ||
309 | #ifndef KERNEL | |
9bccf70c A |
310 | struct if_nameindex { |
311 | u_int if_index; /* 1, 2, ... */ | |
312 | char *if_name; /* null terminated name: "le0", ... */ | |
313 | }; | |
314 | ||
1c79356b | 315 | __BEGIN_DECLS |
9bccf70c A |
316 | u_int if_nametoindex __P((const char *)); |
317 | char *if_indextoname __P((u_int, char *)); | |
318 | struct if_nameindex *if_nameindex __P((void)); | |
319 | void if_freenameindex __P((struct if_nameindex *)); | |
1c79356b A |
320 | __END_DECLS |
321 | #endif | |
322 | ||
1c79356b | 323 | #ifdef KERNEL |
9bccf70c A |
324 | #ifndef __APPLE__ |
325 | struct proc; | |
326 | ||
327 | int prison_if __P((struct proc *p, struct sockaddr *sa)); | |
328 | #endif | |
329 | ||
1c79356b A |
330 | #endif |
331 | ||
332 | #endif /* !_NET_IF_H_ */ |