|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
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.
11: *
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
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
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
55: */
56:
57: #ifndef _NET_IF_H_
58: #define _NET_IF_H_
59:
60: /*
61: * <net/if.h> does not depend on <sys/time.h> on most other systems. This
62: * helps userland compatability. (struct timeval ifi_lastchange)
63: */
64:
65: #include <sys/time.h>
66: #include <net/if_var.h>
67:
68:
69: #define IFF_UP 0x1 /* interface is up */
70: #define IFF_BROADCAST 0x2 /* broadcast address valid */
71: #define IFF_DEBUG 0x4 /* turn on debugging */
72: #define IFF_LOOPBACK 0x8 /* is a loopback net */
73: #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
74: #define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */
75: #define IFF_RUNNING 0x40 /* resources allocated */
76: #define IFF_NOARP 0x80 /* no address resolution protocol */
77: #define IFF_PROMISC 0x100 /* receive all packets */
78: #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
79: #define IFF_OACTIVE 0x400 /* transmission in progress */
80: #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
81: #define IFF_LINK0 0x1000 /* per link layer defined bit */
82: #define IFF_LINK1 0x2000 /* per link layer defined bit */
83: #define IFF_LINK2 0x4000 /* per link layer defined bit */
84: #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
85: #define IFF_MULTICAST 0x8000 /* supports multicast */
86: #define IFF_SPLITTER IFF_LINK2 /* Y splitter in force */
87:
88:
89:
90: #define IFEF_DVR_REENTRY_OK 0x20 /* When set, driver may be reentered from its own thread */
91:
92:
93: /* flags set internally only: */
94: #define IFF_CANTCHANGE \
95: (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
96: IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
97:
98: #define IFQ_MAXLEN 50
99: #define IFNET_SLOWHZ 1 /* granularity is 1 second */
100:
101: /*
102: * Message format for use in obtaining information about interfaces
103: * from getkerninfo and the routing socket
104: */
105: struct if_msghdr {
106: u_short ifm_msglen; /* to skip over non-understood messages */
107: u_char ifm_version; /* future binary compatability */
108: u_char ifm_type; /* message type */
109: int ifm_addrs; /* like rtm_addrs */
110: int ifm_flags; /* value of if_flags */
111: u_short ifm_index; /* index for associated ifp */
112: struct if_data ifm_data;/* statistics and other data about if */
113: };
114:
115: /*
116: * Message format for use in obtaining information about interface addresses
117: * from getkerninfo and the routing socket
118: */
119: struct ifa_msghdr {
120: u_short ifam_msglen; /* to skip over non-understood messages */
121: u_char ifam_version; /* future binary compatability */
122: u_char ifam_type; /* message type */
123: int ifam_addrs; /* like rtm_addrs */
124: int ifam_flags; /* value of ifa_flags */
125: u_short ifam_index; /* index for associated ifp */
126: int ifam_metric; /* value of ifa_metric */
127: };
128:
129: /*
130: * Message format for use in obtaining information about multicast addresses
131: * from the routing socket
132: */
133: struct ifma_msghdr {
134: u_short ifmam_msglen; /* to skip over non-understood messages */
135: u_char ifmam_version; /* future binary compatability */
136: u_char ifmam_type; /* message type */
137: int ifmam_addrs; /* like rtm_addrs */
138: int ifmam_flags; /* value of ifa_flags */
139: u_short ifmam_index; /* index for associated ifp */
140: };
141:
142: /*
143: * Interface request structure used for socket
144: * ioctl's. All interface ioctl's must have parameter
145: * definitions which begin with ifr_name. The
146: * remainder may be interface specific.
147: */
148: struct ifreq {
149: #define IFNAMSIZ 16
150: char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
151: union {
152: struct sockaddr ifru_addr;
153: struct sockaddr ifru_dstaddr;
154: struct sockaddr ifru_broadaddr;
155: short ifru_flags;
156: int ifru_metric;
157: int ifru_mtu;
158: int ifru_phys;
159: int ifru_media;
160: caddr_t ifru_data;
161: } ifr_ifru;
162: #define ifr_addr ifr_ifru.ifru_addr /* address */
163: #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
164: #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
165: #define ifr_flags ifr_ifru.ifru_flags /* flags */
166: #define ifr_metric ifr_ifru.ifru_metric /* metric */
167: #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
168: #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
169: #define ifr_media ifr_ifru.ifru_media /* physical media */
170: #define ifr_data ifr_ifru.ifru_data /* for use by interface */
171: };
172:
173: #define _SIZEOF_ADDR_IFREQ(ifr) \
174: ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
175: (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
176: (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
177:
178: struct ifaliasreq {
179: char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
180: struct sockaddr ifra_addr;
181: struct sockaddr ifra_broadaddr;
182: struct sockaddr ifra_mask;
183: };
184:
185: struct ifmediareq {
186: char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
187: int ifm_current; /* current media options */
188: int ifm_mask; /* don't care mask */
189: int ifm_status; /* media status */
190: int ifm_active; /* active options */
191: int ifm_count; /* # entries in ifm_ulist array */
192: int *ifm_ulist; /* media words */
193: };
194: /*
195: * Structure used in SIOCGIFCONF request.
196: * Used to retrieve interface configuration
197: * for machine (useful for programs which
198: * must know all networks accessible).
199: */
200: struct ifconf {
201: int ifc_len; /* size of associated buffer */
202: union {
203: caddr_t ifcu_buf;
204: struct ifreq *ifcu_req;
205: } ifc_ifcu;
206: #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
207: #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
208: };
209:
210: #ifdef KERNEL
211: #ifdef MALLOC_DECLARE
212: MALLOC_DECLARE(M_IFADDR);
213: MALLOC_DECLARE(M_IFMADDR);
214: #endif
215: #endif
216:
217: /* XXX - this should go away soon */
218: #ifdef KERNEL
219: #include <net/if_var.h>
220: #endif
221:
222: #endif /* !_NET_IF_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.