]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
39037602 | 2 | * Copyright (c) 2000-2016 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
39236c6e | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
39236c6e | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
39236c6e | 17 | * |
2d21ac55 A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
39236c6e | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1985, 1986, 1993 | |
30 | * The Regents of the University of California. All rights reserved. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * 3. All advertising materials mentioning features or use of this software | |
41 | * must display the following acknowledgement: | |
42 | * This product includes software developed by the University of | |
43 | * California, Berkeley and its contributors. | |
44 | * 4. Neither the name of the University nor the names of its contributors | |
45 | * may be used to endorse or promote products derived from this software | |
46 | * without specific prior written permission. | |
47 | * | |
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
58 | * SUCH DAMAGE. | |
59 | * | |
60 | * @(#)in_var.h 8.2 (Berkeley) 1/9/95 | |
61 | */ | |
62 | ||
63 | #ifndef _NETINET_IN_VAR_H_ | |
39236c6e | 64 | #define _NETINET_IN_VAR_H_ |
9bccf70c | 65 | #include <sys/appleapiopts.h> |
1c79356b A |
66 | |
67 | #include <sys/queue.h> | |
68 | #include <sys/kern_event.h> | |
39037602 | 69 | #include <net/net_kev.h> |
9bccf70c | 70 | |
39236c6e | 71 | #ifdef BSD_KERNEL_PRIVATE |
2d21ac55 | 72 | #include <net/route.h> |
1c79356b A |
73 | |
74 | /* | |
75 | * Interface address, Internet version. One of these structures | |
76 | * is allocated for each Internet address on an interface. | |
77 | * The ifaddr structure contains the protocol-independent part | |
78 | * of the structure and is assumed to be first. | |
79 | */ | |
80 | struct in_ifaddr { | |
39236c6e A |
81 | struct ifaddr ia_ifa; /* protocol-independent info */ |
82 | #define ia_ifp ia_ifa.ifa_ifp | |
83 | #define ia_flags ia_ifa.ifa_flags | |
84 | /* ia_{,sub}net{,mask} in host order */ | |
85 | u_int32_t ia_net; /* network number of interface */ | |
86 | u_int32_t ia_netmask; /* mask of net part */ | |
87 | u_int32_t ia_subnet; /* subnet number, including net */ | |
88 | u_int32_t ia_subnetmask; /* mask of subnet part */ | |
89 | struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ | |
90 | TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */ | |
91 | struct sockaddr_in ia_addr; /* reserve space for interface name */ | |
92 | struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */ | |
93 | #define ia_broadaddr ia_dstaddr | |
94 | struct sockaddr_in ia_sockmask; /* reserve space for general netmask */ | |
95 | TAILQ_ENTRY(in_ifaddr) ia_hash; /* hash bucket entry */ | |
1c79356b | 96 | }; |
316670eb A |
97 | |
98 | #define ifatoia(ifa) ((struct in_ifaddr *)(void *)(ifa)) | |
39236c6e A |
99 | #endif /* BSD_KERNEL_PRIVATE */ |
100 | ||
101 | struct in_aliasreq { | |
102 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
103 | struct sockaddr_in ifra_addr; | |
104 | struct sockaddr_in ifra_broadaddr; | |
105 | #define ifra_dstaddr ifra_broadaddr | |
106 | struct sockaddr_in ifra_mask; | |
1c79356b A |
107 | }; |
108 | ||
1c79356b | 109 | /* |
39236c6e | 110 | * Event data, inet style. |
1c79356b | 111 | */ |
1c79356b | 112 | struct kev_in_data { |
39236c6e A |
113 | struct net_event_data link_data; |
114 | struct in_addr ia_addr; /* interface address */ | |
115 | u_int32_t ia_net; /* network number of interface */ | |
116 | u_int32_t ia_netmask; /* mask of net part */ | |
117 | u_int32_t ia_subnet; /* subnet number, including net */ | |
118 | u_int32_t ia_subnetmask; /* mask of subnet part */ | |
119 | struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ | |
120 | struct in_addr ia_dstaddr; | |
1c79356b A |
121 | }; |
122 | ||
90556fb8 | 123 | struct kev_in_collision { |
39236c6e A |
124 | struct net_event_data link_data; /* link where ARP was received on */ |
125 | struct in_addr ia_ipaddr; /* conflicting IP address */ | |
126 | u_char hw_len; /* length of hardware address */ | |
127 | u_char hw_addr[0]; /* variable length hardware address */ | |
2d21ac55 A |
128 | }; |
129 | ||
fe8ab488 A |
130 | struct kev_in_arpfailure { |
131 | struct net_event_data link_data; /* link where ARP is being sent */ | |
132 | }; | |
133 | ||
134 | struct kev_in_arpalive { | |
135 | struct net_event_data link_data; /* link where ARP was received */ | |
136 | }; | |
137 | ||
138 | ||
2d21ac55 A |
139 | #ifdef __APPLE_API_PRIVATE |
140 | struct kev_in_portinuse { | |
39236c6e A |
141 | u_int16_t port; /* conflicting port number in host order */ |
142 | u_int32_t req_pid; /* PID port requestor */ | |
143 | u_int32_t reserved[2]; | |
90556fb8 | 144 | }; |
39236c6e | 145 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b | 146 | |
39236c6e | 147 | #ifdef BSD_KERNEL_PRIVATE |
3e170ce0 | 148 | #include <net/if.h> |
b0d623f7 | 149 | #include <net/if_var.h> |
5ba3f43e | 150 | #include <net/if_llatbl.h> |
b0d623f7 | 151 | #include <kern/locks.h> |
6d2010ae | 152 | #include <sys/tree.h> |
1c79356b A |
153 | /* |
154 | * Given a pointer to an in_ifaddr (ifaddr), | |
155 | * return a pointer to the addr as a sockaddr_in. | |
156 | */ | |
39236c6e A |
157 | #define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr)) |
158 | #define IA_DSTSIN(ia) (&(((struct in_ifaddr *)(ia))->ia_dstaddr)) | |
1c79356b | 159 | |
39236c6e | 160 | #define IN_LNAOF(in, ifa) \ |
1c79356b A |
161 | ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask)) |
162 | ||
b0d623f7 A |
163 | /* |
164 | * Hash table for IPv4 addresses. | |
165 | */ | |
39236c6e A |
166 | extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead; |
167 | extern TAILQ_HEAD(in_ifaddrhashhead, in_ifaddr) *in_ifaddrhashtbl; | |
168 | extern lck_rw_t *in_ifaddr_rwlock; | |
b0d623f7 A |
169 | |
170 | #define INADDR_HASH(x) (&in_ifaddrhashtbl[inaddr_hashval(x)]) | |
171 | ||
1c79356b A |
172 | extern u_char inetctlerrmap[]; |
173 | ||
174 | /* | |
175 | * Macro for finding the interface (ifnet structure) corresponding to one | |
176 | * of our IP addresses. | |
177 | */ | |
39236c6e | 178 | #define INADDR_TO_IFP(addr, ifp) \ |
b0d623f7 A |
179 | /* struct in_addr addr; */ \ |
180 | /* struct ifnet *ifp; */ \ | |
181 | { \ | |
182 | struct in_ifaddr *ia; \ | |
183 | \ | |
184 | lck_rw_lock_shared(in_ifaddr_rwlock); \ | |
6d2010ae A |
185 | TAILQ_FOREACH(ia, INADDR_HASH((addr).s_addr), ia_hash) { \ |
186 | IFA_LOCK_SPIN(&ia->ia_ifa); \ | |
187 | if (IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) { \ | |
188 | IFA_UNLOCK(&ia->ia_ifa); \ | |
b0d623f7 | 189 | break; \ |
6d2010ae A |
190 | } \ |
191 | IFA_UNLOCK(&ia->ia_ifa); \ | |
192 | } \ | |
b0d623f7 A |
193 | (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ |
194 | lck_rw_done(in_ifaddr_rwlock); \ | |
1c79356b A |
195 | } |
196 | ||
197 | /* | |
198 | * Macro for finding the internet address structure (in_ifaddr) corresponding | |
b0d623f7 A |
199 | * to a given interface (ifnet structure). Caller is responsible for freeing |
200 | * the reference. | |
1c79356b | 201 | */ |
39236c6e | 202 | #define IFP_TO_IA(ifp, ia) \ |
b0d623f7 A |
203 | /* struct ifnet *ifp; */ \ |
204 | /* struct in_ifaddr *ia; */ \ | |
205 | { \ | |
206 | lck_rw_lock_shared(in_ifaddr_rwlock); \ | |
207 | for ((ia) = TAILQ_FIRST(&in_ifaddrhead); \ | |
208 | (ia) != NULL && (ia)->ia_ifp != (ifp); \ | |
209 | (ia) = TAILQ_NEXT((ia), ia_link)) \ | |
210 | continue; \ | |
211 | if ((ia) != NULL) \ | |
6d2010ae | 212 | IFA_ADDREF(&(ia)->ia_ifa); \ |
b0d623f7 | 213 | lck_rw_done(in_ifaddr_rwlock); \ |
1c79356b | 214 | } |
1c79356b A |
215 | |
216 | /* | |
217 | * This information should be part of the ifnet structure but we don't wish | |
218 | * to change that - as it might break a number of things | |
219 | */ | |
220 | ||
6d2010ae A |
221 | /* |
222 | * Legacy IPv4 IGMP per-link structure. | |
223 | */ | |
1c79356b A |
224 | struct router_info { |
225 | struct ifnet *rti_ifp; | |
226 | int rti_type; /* type of router which is querier on this interface */ | |
227 | int rti_time; /* # of slow timeouts since last old query */ | |
6d2010ae A |
228 | SLIST_ENTRY(router_info) rti_list; |
229 | }; | |
230 | ||
231 | /* | |
232 | * IPv4 multicast IGMP-layer source entry. | |
233 | */ | |
234 | struct ip_msource { | |
235 | RB_ENTRY(ip_msource) ims_link; /* RB tree links */ | |
236 | in_addr_t ims_haddr; /* host byte order */ | |
237 | struct ims_st { | |
238 | uint16_t ex; /* # of exclusive members */ | |
239 | uint16_t in; /* # of inclusive members */ | |
240 | } ims_st[2]; /* state at t0, t1 */ | |
241 | uint8_t ims_stp; /* pending query */ | |
242 | }; | |
243 | ||
244 | /* | |
245 | * IPv4 multicast PCB-layer source entry. | |
246 | */ | |
247 | struct in_msource { | |
248 | RB_ENTRY(ip_msource) ims_link; /* RB tree links */ | |
249 | in_addr_t ims_haddr; /* host byte order */ | |
250 | uint8_t imsl_st[2]; /* state before/at commit */ | |
1c79356b A |
251 | }; |
252 | ||
6d2010ae A |
253 | RB_HEAD(ip_msource_tree, ip_msource); /* define struct ip_msource_tree */ |
254 | ||
255 | RB_PROTOTYPE_SC_PREV(__private_extern__, ip_msource_tree, ip_msource, | |
256 | ims_link, ip_msource_cmp); | |
257 | ||
258 | /* | |
259 | * IPv4 multicast PCB-layer group filter descriptor. | |
260 | */ | |
261 | struct in_mfilter { | |
262 | struct ip_msource_tree imf_sources; /* source list for (S,G) */ | |
263 | u_long imf_nsrc; /* # of source entries */ | |
264 | uint8_t imf_st[2]; /* state before/at commit */ | |
265 | }; | |
266 | ||
267 | struct igmp_ifinfo; | |
268 | ||
1c79356b | 269 | /* |
6d2010ae A |
270 | * IPv4 group descriptor. |
271 | * | |
272 | * For every entry on an ifnet's if_multiaddrs list which represents | |
273 | * an IP multicast group, there is one of these structures. | |
274 | * | |
275 | * If any source filters are present, then a node will exist in the RB-tree | |
276 | * to permit fast lookup by source whenever an operation takes place. | |
277 | * This permits pre-order traversal when we issue reports. | |
278 | * Source filter trees are kept separately from the socket layer to | |
279 | * greatly simplify locking. | |
280 | * | |
281 | * When IGMPv3 is active, inm_timer is the response to group query timer. | |
282 | * The state-change timer inm_sctimer is separate; whenever state changes | |
283 | * for the group the state change record is generated and transmitted, | |
284 | * and kept if retransmissions are necessary. | |
285 | * | |
39236c6e A |
286 | * The request count here is a count of requests for this address, not a |
287 | * count of pointers to this structure. | |
288 | * | |
6d2010ae | 289 | * FUTURE: inm_link is now only used when groups are being purged |
39236c6e | 290 | * on a detaching ifnet. It could be demoted to a SLIST_ENTRY. |
1c79356b A |
291 | */ |
292 | struct in_multi { | |
6d2010ae A |
293 | decl_lck_mtx_data(, inm_lock); |
294 | u_int32_t inm_refcount; /* reference count */ | |
295 | u_int32_t inm_reqcnt; /* request count for this address */ | |
296 | u_int32_t inm_debug; /* see ifa_debug flags */ | |
1c79356b A |
297 | LIST_ENTRY(in_multi) inm_link; /* queue macro glue */ |
298 | struct in_addr inm_addr; /* IP multicast address, convenience */ | |
299 | struct ifnet *inm_ifp; /* back pointer to ifnet */ | |
300 | struct ifmultiaddr *inm_ifma; /* back pointer to ifmultiaddr */ | |
6d2010ae | 301 | u_int inm_timer; /* IGMPv1/v2 group / v3 query timer */ |
1c79356b | 302 | u_int inm_state; /* state of the membership */ |
6d2010ae A |
303 | void *inm_rti; /* unused, legacy field */ |
304 | ||
305 | /* New fields for IGMPv3 follow. */ | |
306 | struct igmp_ifinfo *inm_igi; /* IGMP info */ | |
13f56ec4 | 307 | SLIST_ENTRY(in_multi) inm_dtle; /* detached waiting for rele */ |
6d2010ae A |
308 | SLIST_ENTRY(in_multi) inm_nrele; /* to-be-released by IGMP */ |
309 | u_int32_t inm_nrelecnt; /* deferred release count */ | |
310 | struct ip_msource_tree inm_srcs; /* tree of sources */ | |
311 | u_long inm_nsrc; /* # of tree entries */ | |
312 | ||
313 | struct ifqueue inm_scq; /* queue of pending | |
314 | * state-change packets */ | |
315 | struct timeval inm_lastgsrtv; /* Time of last G-S-R query */ | |
316 | uint16_t inm_sctimer; /* state-change timer */ | |
317 | uint16_t inm_scrv; /* state-change rexmit count */ | |
318 | ||
319 | /* | |
320 | * SSM state counters which track state at T0 (the time the last | |
321 | * state-change report's RV timer went to zero) and T1 | |
322 | * (time of pending report, i.e. now). | |
323 | * Used for computing IGMPv3 state-change reports. Several refcounts | |
324 | * are maintained here to optimize for common use-cases. | |
325 | */ | |
326 | struct inm_st { | |
327 | uint16_t iss_fmode; /* IGMP filter mode */ | |
328 | uint16_t iss_asm; /* # of ASM listeners */ | |
329 | uint16_t iss_ex; /* # of exclusive members */ | |
330 | uint16_t iss_in; /* # of inclusive members */ | |
331 | uint16_t iss_rec; /* # of recorded sources */ | |
332 | } inm_st[2]; /* state at t0, t1 */ | |
333 | ||
334 | void (*inm_trace) /* callback fn for tracing refs */ | |
335 | (struct in_multi *, int); | |
1c79356b | 336 | }; |
1c79356b | 337 | |
6d2010ae | 338 | #define INM_LOCK_ASSERT_HELD(_inm) \ |
5ba3f43e | 339 | LCK_MTX_ASSERT(&(_inm)->inm_lock, LCK_MTX_ASSERT_OWNED) |
6d2010ae A |
340 | |
341 | #define INM_LOCK_ASSERT_NOTHELD(_inm) \ | |
5ba3f43e | 342 | LCK_MTX_ASSERT(&(_inm)->inm_lock, LCK_MTX_ASSERT_NOTOWNED) |
6d2010ae A |
343 | |
344 | #define INM_LOCK(_inm) \ | |
345 | lck_mtx_lock(&(_inm)->inm_lock) | |
346 | ||
347 | #define INM_LOCK_SPIN(_inm) \ | |
348 | lck_mtx_lock_spin(&(_inm)->inm_lock) | |
349 | ||
350 | #define INM_CONVERT_LOCK(_inm) do { \ | |
351 | INM_LOCK_ASSERT_HELD(_inm); \ | |
352 | lck_mtx_convert_spin(&(_inm)->inm_lock); \ | |
353 | } while (0) | |
354 | ||
355 | #define INM_UNLOCK(_inm) \ | |
356 | lck_mtx_unlock(&(_inm)->inm_lock) | |
357 | ||
358 | #define INM_ADDREF(_inm) \ | |
359 | inm_addref(_inm, 0) | |
360 | ||
361 | #define INM_ADDREF_LOCKED(_inm) \ | |
362 | inm_addref(_inm, 1) | |
363 | ||
364 | #define INM_REMREF(_inm) \ | |
365 | inm_remref(_inm, 0) | |
366 | ||
367 | #define INM_REMREF_LOCKED(_inm) \ | |
368 | inm_remref(_inm, 1) | |
369 | ||
1c79356b A |
370 | #ifdef SYSCTL_DECL |
371 | SYSCTL_DECL(_net_inet_ip); | |
372 | SYSCTL_DECL(_net_inet_raw); | |
373 | #endif | |
374 | ||
375 | extern LIST_HEAD(in_multihead, in_multi) in_multihead; | |
376 | ||
377 | /* | |
378 | * Structure used by macros below to remember position when stepping through | |
379 | * all of the in_multi records. | |
380 | */ | |
381 | struct in_multistep { | |
382 | struct in_multi *i_inm; | |
383 | }; | |
384 | ||
385 | /* | |
386 | * Macro for looking up the in_multi record for a given IP multicast address | |
387 | * on a given interface. If no matching record is found, "inm" is set null. | |
6d2010ae A |
388 | * |
389 | * We do this differently compared other BSD implementations; instead of | |
390 | * walking the if_multiaddrs list at the interface and returning the | |
391 | * ifma_protospec value of a matching entry, we search the global list | |
392 | * of in_multi records and find it that way. Otherwise either the two | |
393 | * structures (in_multi, ifmultiaddr) need to be ref counted both ways, | |
394 | * which will make things too complicated, or they need to reside in the | |
395 | * same protected domain, which they aren't. | |
396 | * | |
397 | * Must be called with in_multihead_lock held. | |
1c79356b | 398 | */ |
39236c6e | 399 | #define IN_LOOKUP_MULTI(addr, ifp, inm) \ |
6d2010ae A |
400 | /* struct in_addr *addr; */ \ |
401 | /* struct ifnet *ifp; */ \ | |
402 | /* struct in_multi *inm; */ \ | |
403 | do { \ | |
404 | struct in_multistep _step; \ | |
405 | IN_FIRST_MULTI(_step, inm); \ | |
406 | while ((inm) != NULL) { \ | |
407 | INM_LOCK_SPIN(inm); \ | |
408 | if ((inm)->inm_ifp == (ifp) && \ | |
409 | (inm)->inm_addr.s_addr == (addr)->s_addr) { \ | |
410 | INM_ADDREF_LOCKED(inm); \ | |
411 | INM_UNLOCK(inm); \ | |
412 | break; \ | |
413 | } \ | |
414 | INM_UNLOCK(inm); \ | |
415 | IN_NEXT_MULTI(_step, inm); \ | |
416 | } \ | |
417 | } while (0) | |
1c79356b A |
418 | |
419 | /* | |
420 | * Macro to step through all of the in_multi records, one at a time. | |
421 | * The current position is remembered in "step", which the caller must | |
422 | * provide. IN_FIRST_MULTI(), below, must be called to initialize "step" | |
423 | * and get the first record. Both macros return a NULL "inm" when there | |
424 | * are no remaining records. | |
6d2010ae A |
425 | * |
426 | * Must be called with in_multihead_lock held. | |
1c79356b | 427 | */ |
39236c6e | 428 | #define IN_NEXT_MULTI(step, inm) \ |
6d2010ae A |
429 | /* struct in_multistep step; */ \ |
430 | /* struct in_multi *inm; */ \ | |
431 | do { \ | |
432 | in_multihead_lock_assert(LCK_RW_ASSERT_HELD); \ | |
433 | if (((inm) = (step).i_inm) != NULL) \ | |
434 | (step).i_inm = LIST_NEXT((step).i_inm, inm_link); \ | |
435 | } while (0) | |
436 | ||
39236c6e | 437 | #define IN_FIRST_MULTI(step, inm) \ |
6d2010ae A |
438 | /* struct in_multistep step; */ \ |
439 | /* struct in_multi *inm; */ \ | |
440 | do { \ | |
441 | in_multihead_lock_assert(LCK_RW_ASSERT_HELD); \ | |
442 | (step).i_inm = LIST_FIRST(&in_multihead); \ | |
443 | IN_NEXT_MULTI((step), (inm)); \ | |
444 | } while (0) | |
1c79356b | 445 | |
39236c6e A |
446 | extern lck_mtx_t *inet_domain_mutex; |
447 | extern struct domain *inetdomain; | |
448 | ||
449 | struct ip_moptions; | |
316670eb | 450 | struct inpcb; |
6d2010ae A |
451 | |
452 | /* | |
453 | * Return values for imo_multi_filter(). | |
454 | */ | |
39236c6e A |
455 | #define MCAST_PASS 0 /* Pass */ |
456 | #define MCAST_NOTGMEMBER 1 /* This host not a member of group */ | |
457 | #define MCAST_NOTSMEMBER 2 /* This host excluded source */ | |
458 | #define MCAST_MUTED 3 /* [deprecated] */ | |
459 | ||
3e170ce0 A |
460 | /* |
461 | * Per-interface IPv4 structures. | |
462 | */ | |
463 | struct in_ifextra { | |
464 | uint32_t netsig_len; | |
465 | u_int8_t netsig[IFNET_SIGNATURELEN]; | |
5ba3f43e | 466 | struct lltable *ii_llt; /* ARP state */ |
3e170ce0 A |
467 | }; |
468 | #define IN_IFEXTRA(_ifp) ((struct in_ifextra *)(_ifp->if_inetdata)) | |
5ba3f43e | 469 | #define LLTABLE(ifp) ((IN_IFEXTRA(ifp) == NULL) ? NULL : IN_IFEXTRA(ifp)->ii_llt) |
3e170ce0 | 470 | |
39236c6e | 471 | extern u_int32_t ipv4_ll_arp_aware; |
b0d623f7 A |
472 | |
473 | extern void in_ifaddr_init(void); | |
5ba3f43e A |
474 | extern int imo_multi_filter(const struct ip_moptions *, |
475 | const struct ifnet *, const struct sockaddr_in *, | |
476 | const struct sockaddr_in *); | |
316670eb | 477 | extern int imo_clone(struct inpcb *, struct inpcb *); |
6d2010ae A |
478 | extern void inm_commit(struct in_multi *); |
479 | extern void inm_clear_recorded(struct in_multi *); | |
480 | extern void inm_print(const struct in_multi *); | |
481 | extern int inm_record_source(struct in_multi *inm, const in_addr_t); | |
482 | extern void inm_release(struct in_multi *); | |
483 | extern void in_multi_init(void); | |
b0d623f7 | 484 | extern struct in_multi *in_addmulti(struct in_addr *, struct ifnet *); |
6d2010ae | 485 | extern void in_delmulti(struct in_multi *); |
39236c6e | 486 | extern int in_leavegroup(struct in_multi *, struct in_mfilter *); |
6d2010ae A |
487 | extern int in_multi_detach(struct in_multi *); |
488 | extern void inm_addref(struct in_multi *, int); | |
489 | extern void inm_remref(struct in_multi *, int); | |
490 | extern void inm_purge(struct in_multi *); | |
491 | extern uint8_t ims_get_mode(const struct in_multi *, | |
492 | const struct ip_msource *, uint8_t); | |
b0d623f7 A |
493 | extern int in_control(struct socket *, u_long, caddr_t, struct ifnet *, |
494 | struct proc *); | |
39236c6e | 495 | extern int in_inithead(void **, int); |
b0d623f7 | 496 | extern void in_rtqdrain(void); |
c910b4d9 | 497 | extern struct radix_node *in_validate(struct radix_node *); |
b0d623f7 | 498 | extern void ip_input(struct mbuf *); |
3e170ce0 | 499 | extern void ip_input_process_list(struct mbuf *); |
b0d623f7 A |
500 | extern int in_ifadown(struct ifaddr *ifa, int); |
501 | extern void in_ifscrub(struct ifnet *, struct in_ifaddr *, int); | |
b0d623f7 | 502 | extern u_int32_t inaddr_hashval(u_int32_t); |
6d2010ae | 503 | extern void in_purgeaddrs(struct ifnet *); |
39236c6e A |
504 | extern void gre_input(struct mbuf *, int); |
505 | extern void imf_leave(struct in_mfilter *); | |
506 | extern void imf_purge(struct in_mfilter *); | |
507 | extern int inp_join_group(struct inpcb *, struct sockopt *); | |
508 | extern int inp_leave_group(struct inpcb *, struct sockopt *); | |
509 | extern void in_multihead_lock_exclusive(void); | |
510 | extern void in_multihead_lock_shared(void); | |
511 | extern void in_multihead_lock_assert(int); | |
512 | extern void in_multihead_lock_done(void); | |
513 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b A |
514 | /* INET6 stuff */ |
515 | #include <netinet6/in6_var.h> | |
1c79356b | 516 | #endif /* _NETINET_IN_VAR_H_ */ |