]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 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 | * |
de355530 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, | |
de355530 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) 1985, 1986, 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 | * @(#)in_var.h 8.2 (Berkeley) 1/9/95 | |
9bccf70c | 55 | * $FreeBSD: src/sys/netinet/in_var.h,v 1.33.2.2 2001/07/17 10:50:01 ru Exp $ |
1c79356b A |
56 | */ |
57 | ||
58 | #ifndef _NETINET_IN_VAR_H_ | |
59 | #define _NETINET_IN_VAR_H_ | |
9bccf70c | 60 | #include <sys/appleapiopts.h> |
1c79356b A |
61 | |
62 | #include <sys/queue.h> | |
9bccf70c | 63 | #ifdef __APPLE__ |
1c79356b | 64 | #include <sys/kern_event.h> |
9bccf70c A |
65 | #endif |
66 | ||
67 | #ifdef __APPLE_API_UNSTABLE | |
1c79356b A |
68 | |
69 | /* | |
70 | * Interface address, Internet version. One of these structures | |
71 | * is allocated for each Internet address on an interface. | |
72 | * The ifaddr structure contains the protocol-independent part | |
73 | * of the structure and is assumed to be first. | |
74 | */ | |
75 | struct in_ifaddr { | |
76 | struct ifaddr ia_ifa; /* protocol-independent info */ | |
77 | #define ia_ifp ia_ifa.ifa_ifp | |
78 | #define ia_flags ia_ifa.ifa_flags | |
79 | /* ia_{,sub}net{,mask} in host order */ | |
80 | u_long ia_net; /* network number of interface */ | |
81 | u_long ia_netmask; /* mask of net part */ | |
82 | u_long ia_subnet; /* subnet number, including net */ | |
83 | u_long ia_subnetmask; /* mask of subnet part */ | |
84 | struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ | |
85 | TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */ | |
86 | struct sockaddr_in ia_addr; /* reserve space for interface name */ | |
87 | struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */ | |
88 | #define ia_broadaddr ia_dstaddr | |
89 | struct sockaddr_in ia_sockmask; /* reserve space for general netmask */ | |
90 | }; | |
91 | ||
92 | struct in_aliasreq { | |
93 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
94 | struct sockaddr_in ifra_addr; | |
95 | struct sockaddr_in ifra_broadaddr; | |
96 | #define ifra_dstaddr ifra_broadaddr | |
97 | struct sockaddr_in ifra_mask; | |
9bccf70c | 98 | #ifdef __APPLE__ |
1c79356b | 99 | u_long dlt; |
9bccf70c | 100 | #endif |
1c79356b A |
101 | }; |
102 | ||
9bccf70c | 103 | #ifdef __APPLE__ |
1c79356b A |
104 | /* |
105 | * Event data, internet style. | |
106 | */ | |
1c79356b A |
107 | struct kev_in_data { |
108 | struct net_event_data link_data; | |
109 | struct in_addr ia_addr; | |
110 | u_long ia_net; /* network number of interface */ | |
111 | u_long ia_netmask; /* mask of net part */ | |
112 | u_long ia_subnet; /* subnet number, including net */ | |
113 | u_long ia_subnetmask; /* mask of subnet part */ | |
114 | struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ | |
115 | struct in_addr ia_dstaddr; | |
116 | }; | |
117 | ||
90556fb8 A |
118 | struct kev_in_collision { |
119 | struct net_event_data link_data; /* link colliding arp was received on */ | |
120 | struct in_addr ia_ipaddr; /* IP address we and another node are using */ | |
121 | u_char hw_len; /* length of hardware address */ | |
122 | u_char hw_addr[0]; /* variable length hardware address */ | |
123 | }; | |
124 | ||
1c79356b | 125 | |
1c79356b A |
126 | /* |
127 | * Define inet event subclass and specific inet events. | |
128 | */ | |
129 | ||
130 | #define KEV_INET_SUBCLASS 1 | |
131 | ||
132 | #define KEV_INET_NEW_ADDR 1 | |
133 | #define KEV_INET_CHANGED_ADDR 2 | |
134 | #define KEV_INET_ADDR_DELETED 3 | |
135 | #define KEV_INET_SIFDSTADDR 4 | |
136 | #define KEV_INET_SIFBRDADDR 5 | |
137 | #define KEV_INET_SIFNETMASK 6 | |
90556fb8 | 138 | #define KEV_INET_ARPCOLLISION 7 /* use kev_in_collision */ |
9bccf70c | 139 | #endif /* __APPLE__ */ |
1c79356b A |
140 | |
141 | /* | |
142 | * Given a pointer to an in_ifaddr (ifaddr), | |
143 | * return a pointer to the addr as a sockaddr_in. | |
144 | */ | |
145 | #define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr)) | |
146 | #define IA_DSTSIN(ia) (&(((struct in_ifaddr *)(ia))->ia_dstaddr)) | |
147 | ||
148 | #define IN_LNAOF(in, ifa) \ | |
149 | ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask)) | |
150 | ||
9bccf70c | 151 | #endif /* __APPLE_API_UNSTABLE */ |
1c79356b A |
152 | |
153 | #ifdef KERNEL | |
9bccf70c | 154 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
155 | extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead; |
156 | extern struct ifqueue ipintrq; /* ip packet input queue */ | |
157 | extern struct in_addr zeroin_addr; | |
158 | extern u_char inetctlerrmap[]; | |
159 | ||
160 | /* | |
161 | * Macro for finding the interface (ifnet structure) corresponding to one | |
162 | * of our IP addresses. | |
163 | */ | |
164 | #define INADDR_TO_IFP(addr, ifp) \ | |
165 | /* struct in_addr addr; */ \ | |
166 | /* struct ifnet *ifp; */ \ | |
167 | { \ | |
9bccf70c | 168 | struct in_ifaddr *ia; \ |
1c79356b | 169 | \ |
9bccf70c A |
170 | TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) \ |
171 | if (IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \ | |
172 | break; \ | |
1c79356b A |
173 | (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ |
174 | } | |
175 | ||
176 | /* | |
177 | * Macro for finding the internet address structure (in_ifaddr) corresponding | |
178 | * to a given interface (ifnet structure). | |
179 | */ | |
180 | #define IFP_TO_IA(ifp, ia) \ | |
181 | /* struct ifnet *ifp; */ \ | |
182 | /* struct in_ifaddr *ia; */ \ | |
183 | { \ | |
9bccf70c | 184 | for ((ia) = TAILQ_FIRST(&in_ifaddrhead); \ |
1c79356b | 185 | (ia) != NULL && (ia)->ia_ifp != (ifp); \ |
9bccf70c | 186 | (ia) = TAILQ_NEXT((ia), ia_link)) \ |
1c79356b A |
187 | continue; \ |
188 | } | |
9bccf70c | 189 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
190 | #endif |
191 | ||
9bccf70c | 192 | #ifdef __APPLE_API_UNSTABLE |
1c79356b A |
193 | /* |
194 | * This information should be part of the ifnet structure but we don't wish | |
195 | * to change that - as it might break a number of things | |
196 | */ | |
197 | ||
198 | struct router_info { | |
199 | struct ifnet *rti_ifp; | |
200 | int rti_type; /* type of router which is querier on this interface */ | |
201 | int rti_time; /* # of slow timeouts since last old query */ | |
202 | struct router_info *rti_next; | |
203 | }; | |
204 | ||
205 | /* | |
206 | * Internet multicast address structure. There is one of these for each IP | |
207 | * multicast group to which this host belongs on a given network interface. | |
208 | * For every entry on the interface's if_multiaddrs list which represents | |
209 | * an IP multicast group, there is one of these structures. They are also | |
210 | * kept on a system-wide list to make it easier to keep our legacy IGMP code | |
211 | * compatible with the rest of the world (see IN_FIRST_MULTI et al, below). | |
212 | */ | |
213 | struct in_multi { | |
214 | LIST_ENTRY(in_multi) inm_link; /* queue macro glue */ | |
215 | struct in_addr inm_addr; /* IP multicast address, convenience */ | |
216 | struct ifnet *inm_ifp; /* back pointer to ifnet */ | |
217 | struct ifmultiaddr *inm_ifma; /* back pointer to ifmultiaddr */ | |
218 | u_int inm_timer; /* IGMP membership report timer */ | |
219 | u_int inm_state; /* state of the membership */ | |
220 | struct router_info *inm_rti; /* router info*/ | |
221 | }; | |
9bccf70c | 222 | #endif /* __APPLE_API_UNSTABLE */ |
1c79356b A |
223 | |
224 | #ifdef KERNEL | |
9bccf70c | 225 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
226 | |
227 | #ifdef SYSCTL_DECL | |
228 | SYSCTL_DECL(_net_inet_ip); | |
229 | SYSCTL_DECL(_net_inet_raw); | |
230 | #endif | |
231 | ||
232 | extern LIST_HEAD(in_multihead, in_multi) in_multihead; | |
233 | ||
234 | /* | |
235 | * Structure used by macros below to remember position when stepping through | |
236 | * all of the in_multi records. | |
237 | */ | |
238 | struct in_multistep { | |
239 | struct in_multi *i_inm; | |
240 | }; | |
241 | ||
242 | /* | |
243 | * Macro for looking up the in_multi record for a given IP multicast address | |
244 | * on a given interface. If no matching record is found, "inm" is set null. | |
245 | */ | |
246 | #define IN_LOOKUP_MULTI(addr, ifp, inm) \ | |
247 | /* struct in_addr addr; */ \ | |
248 | /* struct ifnet *ifp; */ \ | |
249 | /* struct in_multi *inm; */ \ | |
250 | do { \ | |
9bccf70c | 251 | struct ifmultiaddr *ifma; \ |
1c79356b | 252 | \ |
9bccf70c | 253 | LIST_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) { \ |
1c79356b A |
254 | if (ifma->ifma_addr->sa_family == AF_INET \ |
255 | && ((struct sockaddr_in *)ifma->ifma_addr)->sin_addr.s_addr == \ | |
256 | (addr).s_addr) \ | |
257 | break; \ | |
258 | } \ | |
259 | (inm) = ifma ? ifma->ifma_protospec : 0; \ | |
260 | } while(0) | |
261 | ||
262 | /* | |
263 | * Macro to step through all of the in_multi records, one at a time. | |
264 | * The current position is remembered in "step", which the caller must | |
265 | * provide. IN_FIRST_MULTI(), below, must be called to initialize "step" | |
266 | * and get the first record. Both macros return a NULL "inm" when there | |
267 | * are no remaining records. | |
268 | */ | |
269 | #define IN_NEXT_MULTI(step, inm) \ | |
270 | /* struct in_multistep step; */ \ | |
271 | /* struct in_multi *inm; */ \ | |
272 | do { \ | |
273 | if (((inm) = (step).i_inm) != NULL) \ | |
9bccf70c | 274 | (step).i_inm = LIST_NEXT((step).i_inm, inm_link); \ |
1c79356b A |
275 | } while(0) |
276 | ||
277 | #define IN_FIRST_MULTI(step, inm) \ | |
278 | /* struct in_multistep step; */ \ | |
279 | /* struct in_multi *inm; */ \ | |
280 | do { \ | |
9bccf70c | 281 | (step).i_inm = LIST_FIRST(&in_multihead); \ |
1c79356b A |
282 | IN_NEXT_MULTI((step), (inm)); \ |
283 | } while(0) | |
284 | ||
285 | struct route; | |
286 | struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *)); | |
287 | void in_delmulti __P((struct in_multi *)); | |
288 | int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *, | |
289 | struct proc *)); | |
290 | void in_rtqdrain __P((void)); | |
291 | void ip_input __P((struct mbuf *)); | |
9bccf70c | 292 | int in_ifadown __P((struct ifaddr *ifa, int)); |
1c79356b A |
293 | void in_ifscrub __P((struct ifnet *, struct in_ifaddr *)); |
294 | int ipflow_fastforward __P((struct mbuf *)); | |
295 | void ipflow_create __P((const struct route *, struct mbuf *)); | |
296 | void ipflow_slowtimo __P((void)); | |
297 | ||
9bccf70c A |
298 | #endif /* __APPLE_API_PRIVATE */ |
299 | #endif /* _KERNEL */ | |
300 | ||
1c79356b A |
301 | /* INET6 stuff */ |
302 | #include <netinet6/in6_var.h> | |
1c79356b A |
303 | |
304 | #endif /* _NETINET_IN_VAR_H_ */ |