2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1982, 1986, 1989, 1993
27 * The Regents of the University of California. All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * This product includes software developed by the University of
40 * California, Berkeley and its contributors.
41 * 4. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * @(#)if.h 8.1 (Berkeley) 6/10/93
58 * $FreeBSD: src/sys/net/if.h,v 1.58.2.2 2001/07/24 19:10:18 brooks Exp $
63 #include <sys/appleapiopts.h>
67 * Define Data-Link event subclass, and associated
71 #define KEV_DL_SUBCLASS 2
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
86 #define KEV_DL_PROTO_ATTACHED 14
87 #define KEV_DL_PROTO_DETACHED 15
91 * <net/if.h> does not depend on <sys/time.h> on most other systems. This
92 * helps userland compatability. (struct timeval ifi_lastchange)
97 #include <net/if_var.h>
101 #define IFF_UP 0x1 /* interface is up */
102 #define IFF_BROADCAST 0x2 /* broadcast address valid */
103 #define IFF_DEBUG 0x4 /* turn on debugging */
104 #define IFF_LOOPBACK 0x8 /* is a loopback net */
105 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
106 #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
107 #define IFF_RUNNING 0x40 /* resources allocated */
108 #define IFF_NOARP 0x80 /* no address resolution protocol */
109 #define IFF_PROMISC 0x100 /* receive all packets */
110 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
111 #define IFF_OACTIVE 0x400 /* transmission in progress */
112 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
113 #define IFF_LINK0 0x1000 /* per link layer defined bit */
114 #define IFF_LINK1 0x2000 /* per link layer defined bit */
115 #define IFF_LINK2 0x4000 /* per link layer defined bit */
116 #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
117 #define IFF_MULTICAST 0x8000 /* supports multicast */
120 /* extended flags definitions: (all bits are reserved for internal/future use) */
121 #define IFEF_AUTOCONFIGURING 0x1
122 #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */
123 #define IFEF_INUSE 0x40000000 /* DLIL ifnet recycler, ifnet in use */
124 #define IFEF_REUSE 0x20000000 /* DLIL ifnet recycler, ifnet is not new */
125 #endif /* KERNEL_PRIVATE */
128 /* flags set internally only: */
129 #define IFF_CANTCHANGE \
130 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
131 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
133 #define IFQ_MAXLEN 50
134 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
137 * Message format for use in obtaining information about interfaces
138 * from getkerninfo and the routing socket
141 u_short ifm_msglen
; /* to skip over non-understood messages */
142 u_char ifm_version
; /* future binary compatability */
143 u_char ifm_type
; /* message type */
144 int ifm_addrs
; /* like rtm_addrs */
145 int ifm_flags
; /* value of if_flags */
146 u_short ifm_index
; /* index for associated ifp */
147 struct if_data ifm_data
;/* statistics and other data about if */
151 * Message format for use in obtaining information about interface addresses
152 * from getkerninfo and the routing socket
155 u_short ifam_msglen
; /* to skip over non-understood messages */
156 u_char ifam_version
; /* future binary compatability */
157 u_char ifam_type
; /* message type */
158 int ifam_addrs
; /* like rtm_addrs */
159 int ifam_flags
; /* value of ifa_flags */
160 u_short ifam_index
; /* index for associated ifp */
161 int ifam_metric
; /* value of ifa_metric */
165 * Message format for use in obtaining information about multicast addresses
166 * from the routing socket
169 u_short ifmam_msglen
; /* to skip over non-understood messages */
170 u_char ifmam_version
; /* future binary compatability */
171 u_char ifmam_type
; /* message type */
172 int ifmam_addrs
; /* like rtm_addrs */
173 int ifmam_flags
; /* value of ifa_flags */
174 u_short ifmam_index
; /* index for associated ifp */
178 * Interface request structure used for socket
179 * ioctl's. All interface ioctl's must have parameter
180 * definitions which begin with ifr_name. The
181 * remainder may be interface specific.
183 #define IF_NAMESIZE IFNAMSIZ
186 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
188 struct sockaddr ifru_addr
;
189 struct sockaddr ifru_dstaddr
;
190 struct sockaddr ifru_broadaddr
;
198 #define ifr_addr ifr_ifru.ifru_addr /* address */
199 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
200 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
202 #define ifr_flags ifr_ifru.ifru_flags /* flags */
204 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
205 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
206 #endif /* __APPLE__ */
207 #define ifr_metric ifr_ifru.ifru_metric /* metric */
208 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
209 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
210 #define ifr_media ifr_ifru.ifru_media /* physical media */
211 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
214 #define _SIZEOF_ADDR_IFREQ(ifr) \
215 ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
216 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
217 (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
220 char ifra_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
221 struct sockaddr ifra_addr
;
222 struct sockaddr ifra_broadaddr
;
223 struct sockaddr ifra_mask
;
226 struct rslvmulti_req
{
228 struct sockaddr
**llsa
;
232 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
233 int ifm_current
; /* current media options */
234 int ifm_mask
; /* don't care mask */
235 int ifm_status
; /* media status */
236 int ifm_active
; /* active options */
237 int ifm_count
; /* # entries in ifm_ulist array */
238 int *ifm_ulist
; /* media words */
242 * Structure used to retrieve aux status data from interfaces.
243 * Kernel suppliers to this interface should respect the formatting
244 * needed by ifconfig(8): each line starts with a TAB and ends with
245 * a newline. The canonical example to copy and paste is in if_tun.c.
248 #define IFSTATMAX 800 /* 10 lines of text */
250 char ifs_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
251 char ascii
[IFSTATMAX
+ 1];
255 * Structure used in SIOCGIFCONF request.
256 * Used to retrieve interface configuration
257 * for machine (useful for programs which
258 * must know all networks accessible).
261 int ifc_len
; /* size of associated buffer */
264 struct ifreq
*ifcu_req
;
266 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
267 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
271 #ifdef __APPLE_API_UNSTABLE
273 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
275 struct kev_dl_proto_data
{
276 struct net_event_data link_data
;
278 u_long proto_remaining_count
;
280 #endif /* __APPLE_API_UNSTABLE */
285 * Structure for SIOC[AGD]LIFADDR
288 char iflr_name
[IFNAMSIZ
];
290 #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
291 u_int prefixlen
; /* in/out */
292 struct sockaddr_storage addr
; /* in/out */
293 struct sockaddr_storage dstaddr
; /* out */
297 #ifdef MALLOC_DECLARE
298 MALLOC_DECLARE(M_IFADDR
);
299 MALLOC_DECLARE(M_IFMADDR
);
304 struct if_nameindex
{
305 u_int if_index
; /* 1, 2, ... */
306 char *if_name
; /* null terminated name: "le0", ... */
310 u_int if_nametoindex
__P((const char *));
311 char *if_indextoname
__P((u_int
, char *));
312 struct if_nameindex
*if_nameindex
__P((void));
313 void if_freenameindex
__P((struct if_nameindex
*));
321 int prison_if
__P((struct proc
*p
, struct sockaddr
*sa
));
326 #endif /* !_NET_IF_H_ */