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_ACCEPT_RTADVD 0x40 /* set to accept IPv6 router advertisement on the interface */
124 #define IFEF_INUSE 0x40000000 /* DLIL ifnet recycler, ifnet in use */
125 #define IFEF_REUSE 0x20000000 /* DLIL ifnet recycler, ifnet is not new */
126 #endif /* KERNEL_PRIVATE */
129 /* flags set internally only: */
130 #define IFF_CANTCHANGE \
131 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
132 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
134 #define IFQ_MAXLEN 50
135 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
138 * Message format for use in obtaining information about interfaces
139 * from getkerninfo and the routing socket
142 u_short ifm_msglen
; /* to skip over non-understood messages */
143 u_char ifm_version
; /* future binary compatability */
144 u_char ifm_type
; /* message type */
145 int ifm_addrs
; /* like rtm_addrs */
146 int ifm_flags
; /* value of if_flags */
147 u_short ifm_index
; /* index for associated ifp */
148 struct if_data ifm_data
;/* statistics and other data about if */
152 * Message format for use in obtaining information about interface addresses
153 * from getkerninfo and the routing socket
156 u_short ifam_msglen
; /* to skip over non-understood messages */
157 u_char ifam_version
; /* future binary compatability */
158 u_char ifam_type
; /* message type */
159 int ifam_addrs
; /* like rtm_addrs */
160 int ifam_flags
; /* value of ifa_flags */
161 u_short ifam_index
; /* index for associated ifp */
162 int ifam_metric
; /* value of ifa_metric */
166 * Message format for use in obtaining information about multicast addresses
167 * from the routing socket
170 u_short ifmam_msglen
; /* to skip over non-understood messages */
171 u_char ifmam_version
; /* future binary compatability */
172 u_char ifmam_type
; /* message type */
173 int ifmam_addrs
; /* like rtm_addrs */
174 int ifmam_flags
; /* value of ifa_flags */
175 u_short ifmam_index
; /* index for associated ifp */
179 * Interface request structure used for socket
180 * ioctl's. All interface ioctl's must have parameter
181 * definitions which begin with ifr_name. The
182 * remainder may be interface specific.
184 #define IF_NAMESIZE IFNAMSIZ
187 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
189 struct sockaddr ifru_addr
;
190 struct sockaddr ifru_dstaddr
;
191 struct sockaddr ifru_broadaddr
;
199 #define ifr_addr ifr_ifru.ifru_addr /* address */
200 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
201 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
203 #define ifr_flags ifr_ifru.ifru_flags /* flags */
205 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
206 #define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
207 #endif /* __APPLE__ */
208 #define ifr_metric ifr_ifru.ifru_metric /* metric */
209 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
210 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
211 #define ifr_media ifr_ifru.ifru_media /* physical media */
212 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
215 #define _SIZEOF_ADDR_IFREQ(ifr) \
216 ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
217 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
218 (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
221 char ifra_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
222 struct sockaddr ifra_addr
;
223 struct sockaddr ifra_broadaddr
;
224 struct sockaddr ifra_mask
;
227 struct rslvmulti_req
{
229 struct sockaddr
**llsa
;
233 char ifm_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
234 int ifm_current
; /* current media options */
235 int ifm_mask
; /* don't care mask */
236 int ifm_status
; /* media status */
237 int ifm_active
; /* active options */
238 int ifm_count
; /* # entries in ifm_ulist array */
239 int *ifm_ulist
; /* media words */
243 * Structure used to retrieve aux status data from interfaces.
244 * Kernel suppliers to this interface should respect the formatting
245 * needed by ifconfig(8): each line starts with a TAB and ends with
246 * a newline. The canonical example to copy and paste is in if_tun.c.
249 #define IFSTATMAX 800 /* 10 lines of text */
251 char ifs_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
252 char ascii
[IFSTATMAX
+ 1];
256 * Structure used in SIOCGIFCONF request.
257 * Used to retrieve interface configuration
258 * for machine (useful for programs which
259 * must know all networks accessible).
262 int ifc_len
; /* size of associated buffer */
265 struct ifreq
*ifcu_req
;
267 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
268 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
272 #ifdef __APPLE_API_UNSTABLE
274 * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure
276 struct kev_dl_proto_data
{
277 struct net_event_data link_data
;
279 u_long proto_remaining_count
;
281 #endif /* __APPLE_API_UNSTABLE */
286 * Structure for SIOC[AGD]LIFADDR
289 char iflr_name
[IFNAMSIZ
];
291 #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
292 u_int prefixlen
; /* in/out */
293 struct sockaddr_storage addr
; /* in/out */
294 struct sockaddr_storage dstaddr
; /* out */
298 #ifdef MALLOC_DECLARE
299 MALLOC_DECLARE(M_IFADDR
);
300 MALLOC_DECLARE(M_IFMADDR
);
305 struct if_nameindex
{
306 u_int if_index
; /* 1, 2, ... */
307 char *if_name
; /* null terminated name: "le0", ... */
311 u_int if_nametoindex
__P((const char *));
312 char *if_indextoname
__P((u_int
, char *));
313 struct if_nameindex
*if_nameindex
__P((void));
314 void if_freenameindex
__P((struct if_nameindex
*));
322 int prison_if
__P((struct proc
*p
, struct sockaddr
*sa
));
327 #endif /* !_NET_IF_H_ */