]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
7ddcb079 | 2 | * Copyright (c) 2000-2012 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 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. | |
8f6c56a5 | 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. | |
17 | * | |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1982, 1986, 1989, 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 | * From: @(#)if.h 8.1 (Berkeley) 6/10/93 | |
9bccf70c | 61 | * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.7 2001/07/24 19:10:18 brooks Exp $ |
1c79356b A |
62 | */ |
63 | ||
64 | #ifndef _NET_IF_VAR_H_ | |
65 | #define _NET_IF_VAR_H_ | |
91447636 | 66 | |
9bccf70c | 67 | #include <sys/appleapiopts.h> |
b0d623f7 | 68 | #include <stdint.h> |
91447636 A |
69 | #include <sys/types.h> |
70 | #include <sys/time.h> | |
71 | #include <sys/queue.h> /* get TAILQ macros */ | |
72 | #ifdef KERNEL_PRIVATE | |
73 | #include <kern/locks.h> | |
74 | #endif /* KERNEL_PRIVATE */ | |
b0d623f7 A |
75 | #ifdef PRIVATE |
76 | #include <net/route.h> | |
77 | #endif | |
91447636 A |
78 | |
79 | #ifdef KERNEL | |
80 | #include <net/kpi_interface.h> | |
b0d623f7 | 81 | #endif /* KERNEL */ |
1c79356b | 82 | |
9bccf70c | 83 | #ifdef __APPLE__ |
1c79356b A |
84 | #define APPLE_IF_FAM_LOOPBACK 1 |
85 | #define APPLE_IF_FAM_ETHERNET 2 | |
86 | #define APPLE_IF_FAM_SLIP 3 | |
87 | #define APPLE_IF_FAM_TUN 4 | |
88 | #define APPLE_IF_FAM_VLAN 5 | |
89 | #define APPLE_IF_FAM_PPP 6 | |
90 | #define APPLE_IF_FAM_PVC 7 | |
91 | #define APPLE_IF_FAM_DISC 8 | |
92 | #define APPLE_IF_FAM_MDECAP 9 | |
93 | #define APPLE_IF_FAM_GIF 10 | |
94 | #define APPLE_IF_FAM_FAITH 11 | |
55e303ae A |
95 | #define APPLE_IF_FAM_STF 12 |
96 | #define APPLE_IF_FAM_FIREWIRE 13 | |
91447636 | 97 | #define APPLE_IF_FAM_BOND 14 |
0c530ab8 | 98 | #endif /* __APPLE__ */ |
91447636 A |
99 | |
100 | /* | |
101 | * 72 was chosen below because it is the size of a TCP/IP | |
102 | * header (40) + the minimum mss (32). | |
103 | */ | |
104 | #define IF_MINMTU 72 | |
105 | #define IF_MAXMTU 65535 | |
1c79356b A |
106 | |
107 | /* | |
108 | * Structures defining a network interface, providing a packet | |
109 | * transport mechanism (ala level 0 of the PUP protocols). | |
110 | * | |
111 | * Each interface accepts output datagrams of a specified maximum | |
112 | * length, and provides higher level routines with input datagrams | |
113 | * received from its medium. | |
114 | * | |
115 | * Output occurs when the routine if_output is called, with three parameters: | |
116 | * (*ifp->if_output)(ifp, m, dst, rt) | |
117 | * Here m is the mbuf chain to be sent and dst is the destination address. | |
118 | * The output routine encapsulates the supplied datagram if necessary, | |
119 | * and then transmits it on its medium. | |
120 | * | |
121 | * On input, each interface unwraps the data received by it, and either | |
122 | * places it on the input queue of a internetwork datagram routine | |
123 | * and posts the associated software interrupt, or passes the datagram to a raw | |
124 | * packet input routine. | |
125 | * | |
126 | * Routines exist for locating interfaces by their addresses | |
127 | * or for locating a interface on a certain network, as well as more general | |
128 | * routing and gateway routines maintaining information used to locate | |
129 | * interfaces. These routines live in the files if.c and route.c | |
130 | */ | |
131 | ||
1c79356b A |
132 | #define IFNAMSIZ 16 |
133 | ||
1c79356b A |
134 | /* This belongs up in socket.h or socketvar.h, depending on how far the |
135 | * event bubbles up. | |
136 | */ | |
137 | ||
138 | struct net_event_data { | |
2d21ac55 A |
139 | u_int32_t if_family; |
140 | u_int32_t if_unit; | |
141 | char if_name[IFNAMSIZ]; | |
1c79356b | 142 | }; |
1c79356b | 143 | |
2d21ac55 A |
144 | #if defined(__LP64__) |
145 | #define __need_struct_timeval32 | |
146 | #include <sys/_structs.h> | |
147 | #define IF_DATA_TIMEVAL timeval32 | |
148 | #else | |
149 | #define IF_DATA_TIMEVAL timeval | |
150 | #endif | |
151 | ||
152 | #pragma pack(4) | |
153 | ||
91447636 A |
154 | /* |
155 | * Structure describing information about an interface | |
156 | * which may be of interest to management entities. | |
157 | */ | |
158 | struct if_data { | |
159 | /* generic interface information */ | |
2d21ac55 A |
160 | u_char ifi_type; /* ethernet, tokenring, etc */ |
161 | u_char ifi_typelen; /* Length of frame type id */ | |
162 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ | |
163 | u_char ifi_addrlen; /* media address length */ | |
164 | u_char ifi_hdrlen; /* media header length */ | |
165 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
166 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
167 | u_char ifi_unused1; /* for future use */ | |
168 | u_int32_t ifi_mtu; /* maximum transmission unit */ | |
169 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
170 | u_int32_t ifi_baudrate; /* linespeed */ | |
91447636 | 171 | /* volatile statistics */ |
2d21ac55 A |
172 | u_int32_t ifi_ipackets; /* packets received on interface */ |
173 | u_int32_t ifi_ierrors; /* input errors on interface */ | |
174 | u_int32_t ifi_opackets; /* packets sent on interface */ | |
175 | u_int32_t ifi_oerrors; /* output errors on interface */ | |
176 | u_int32_t ifi_collisions; /* collisions on csma interfaces */ | |
177 | u_int32_t ifi_ibytes; /* total number of octets received */ | |
178 | u_int32_t ifi_obytes; /* total number of octets sent */ | |
179 | u_int32_t ifi_imcasts; /* packets received via multicast */ | |
180 | u_int32_t ifi_omcasts; /* packets sent via multicast */ | |
181 | u_int32_t ifi_iqdrops; /* dropped on input, this interface */ | |
182 | u_int32_t ifi_noproto; /* destined for unsupported protocol */ | |
183 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ | |
184 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
185 | struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ | |
186 | u_int32_t ifi_unused2; /* used to be the default_proto */ | |
187 | u_int32_t ifi_hwassist; /* HW offload capabilities */ | |
188 | u_int32_t ifi_reserved1; /* for future use */ | |
189 | u_int32_t ifi_reserved2; /* for future use */ | |
91447636 | 190 | }; |
4a249263 | 191 | |
1c79356b A |
192 | /* |
193 | * Structure describing information about an interface | |
194 | * which may be of interest to management entities. | |
195 | */ | |
91447636 | 196 | struct if_data64 { |
1c79356b | 197 | /* generic interface information */ |
2d21ac55 A |
198 | u_char ifi_type; /* ethernet, tokenring, etc */ |
199 | u_char ifi_typelen; /* Length of frame type id */ | |
91447636 A |
200 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ |
201 | u_char ifi_addrlen; /* media address length */ | |
202 | u_char ifi_hdrlen; /* media header length */ | |
203 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
204 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
205 | u_char ifi_unused1; /* for future use */ | |
2d21ac55 A |
206 | u_int32_t ifi_mtu; /* maximum transmission unit */ |
207 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
91447636 A |
208 | u_int64_t ifi_baudrate; /* linespeed */ |
209 | /* volatile statistics */ | |
210 | u_int64_t ifi_ipackets; /* packets received on interface */ | |
211 | u_int64_t ifi_ierrors; /* input errors on interface */ | |
212 | u_int64_t ifi_opackets; /* packets sent on interface */ | |
213 | u_int64_t ifi_oerrors; /* output errors on interface */ | |
214 | u_int64_t ifi_collisions; /* collisions on csma interfaces */ | |
215 | u_int64_t ifi_ibytes; /* total number of octets received */ | |
216 | u_int64_t ifi_obytes; /* total number of octets sent */ | |
217 | u_int64_t ifi_imcasts; /* packets received via multicast */ | |
218 | u_int64_t ifi_omcasts; /* packets sent via multicast */ | |
219 | u_int64_t ifi_iqdrops; /* dropped on input, this interface */ | |
220 | u_int64_t ifi_noproto; /* destined for unsupported protocol */ | |
2d21ac55 A |
221 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ |
222 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
223 | struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ | |
91447636 A |
224 | }; |
225 | ||
226 | #ifdef PRIVATE | |
d41d1dae A |
227 | struct if_traffic_class { |
228 | u_int64_t ifi_ibkpackets; /* TC_BK packets received on interface */ | |
229 | u_int64_t ifi_ibkbytes; /* TC_BK bytes received on interface */ | |
230 | u_int64_t ifi_obkpackets; /* TC_BK packet sent on interface */ | |
231 | u_int64_t ifi_obkbytes; /* TC_BK bytes sent on interface */ | |
232 | u_int64_t ifi_ivipackets; /* TC_VI packets received on interface */ | |
233 | u_int64_t ifi_ivibytes; /* TC_VI bytes received on interface */ | |
234 | u_int64_t ifi_ovipackets; /* TC_VI packets sent on interface */ | |
235 | u_int64_t ifi_ovibytes; /* TC_VI bytes sent on interface */ | |
236 | u_int64_t ifi_ivopackets; /* TC_VO packets received on interface */ | |
237 | u_int64_t ifi_ivobytes; /* TC_VO bytes received on interface */ | |
238 | u_int64_t ifi_ovopackets; /* TC_VO packets sent on interface */ | |
239 | u_int64_t ifi_ovobytes; /* TC_VO bytes sent on interface */ | |
240 | }; | |
6d2010ae A |
241 | #endif /* PRIVATE */ |
242 | ||
243 | #pragma pack() | |
d41d1dae | 244 | |
6d2010ae A |
245 | /* |
246 | * Structure defining a queue for a network interface. | |
247 | */ | |
248 | struct ifqueue { | |
249 | void *ifq_head; | |
250 | void *ifq_tail; | |
251 | int ifq_len; | |
252 | int ifq_maxlen; | |
253 | int ifq_drops; | |
254 | }; | |
255 | ||
256 | #ifdef XNU_KERNEL_PRIVATE | |
91447636 A |
257 | /* |
258 | * Internal storage of if_data. This is bound to change. Various places in the | |
259 | * stack will translate this data structure in to the externally visible | |
6d2010ae A |
260 | * if_data structure above. Note that during interface attach time, the |
261 | * embedded if_data structure in ifnet is cleared, with the exception of | |
262 | * some non-statistics related fields. | |
91447636 A |
263 | */ |
264 | struct if_data_internal { | |
265 | /* generic interface information */ | |
2d21ac55 A |
266 | u_char ifi_type; /* ethernet, tokenring, etc */ |
267 | u_char ifi_typelen; /* Length of frame type id */ | |
268 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ | |
269 | u_char ifi_addrlen; /* media address length */ | |
270 | u_char ifi_hdrlen; /* media header length */ | |
271 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
272 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
273 | u_char ifi_unused1; /* for future use */ | |
274 | u_int32_t ifi_mtu; /* maximum transmission unit */ | |
275 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
276 | u_int32_t ifi_baudrate; /* linespeed */ | |
6d2010ae | 277 | u_int32_t _pad; |
1c79356b | 278 | /* volatile statistics */ |
91447636 A |
279 | u_int64_t ifi_ipackets; /* packets received on interface */ |
280 | u_int64_t ifi_ierrors; /* input errors on interface */ | |
281 | u_int64_t ifi_opackets; /* packets sent on interface */ | |
282 | u_int64_t ifi_oerrors; /* output errors on interface */ | |
283 | u_int64_t ifi_collisions; /* collisions on csma interfaces */ | |
2d21ac55 A |
284 | u_int64_t ifi_ibytes; /* total number of octets received */ |
285 | u_int64_t ifi_obytes; /* total number of octets sent */ | |
91447636 A |
286 | u_int64_t ifi_imcasts; /* packets received via multicast */ |
287 | u_int64_t ifi_omcasts; /* packets sent via multicast */ | |
288 | u_int64_t ifi_iqdrops; /* dropped on input, this interface */ | |
289 | u_int64_t ifi_noproto; /* destined for unsupported protocol */ | |
2d21ac55 A |
290 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ |
291 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
91447636 | 292 | #define IF_LASTCHANGEUPTIME 1 /* lastchange: 1-uptime 0-calendar time */ |
1c79356b | 293 | struct timeval ifi_lastchange; /* time of last administrative change */ |
2d21ac55 | 294 | u_int32_t ifi_hwassist; /* HW offload capabilities */ |
b0d623f7 A |
295 | u_int32_t ifi_tso_v4_mtu; /* TCP Segment Offload IPv4 maximum segment size */ |
296 | u_int32_t ifi_tso_v6_mtu; /* TCP Segment Offload IPv6 maximum segment size */ | |
1c79356b | 297 | }; |
6d2010ae | 298 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 | 299 | |
6d2010ae | 300 | #ifdef PRIVATE |
91447636 A |
301 | #define if_mtu if_data.ifi_mtu |
302 | #define if_type if_data.ifi_type | |
303 | #define if_typelen if_data.ifi_typelen | |
304 | #define if_physical if_data.ifi_physical | |
305 | #define if_addrlen if_data.ifi_addrlen | |
306 | #define if_hdrlen if_data.ifi_hdrlen | |
307 | #define if_metric if_data.ifi_metric | |
308 | #define if_baudrate if_data.ifi_baudrate | |
309 | #define if_hwassist if_data.ifi_hwassist | |
310 | #define if_ipackets if_data.ifi_ipackets | |
311 | #define if_ierrors if_data.ifi_ierrors | |
312 | #define if_opackets if_data.ifi_opackets | |
313 | #define if_oerrors if_data.ifi_oerrors | |
314 | #define if_collisions if_data.ifi_collisions | |
315 | #define if_ibytes if_data.ifi_ibytes | |
316 | #define if_obytes if_data.ifi_obytes | |
317 | #define if_imcasts if_data.ifi_imcasts | |
318 | #define if_omcasts if_data.ifi_omcasts | |
319 | #define if_iqdrops if_data.ifi_iqdrops | |
320 | #define if_noproto if_data.ifi_noproto | |
321 | #define if_lastchange if_data.ifi_lastchange | |
322 | #define if_recvquota if_data.ifi_recvquota | |
323 | #define if_xmitquota if_data.ifi_xmitquota | |
6d2010ae A |
324 | #endif /* PRIVATE */ |
325 | #ifdef XNU_KERNEL_PRIVATE | |
b0d623f7 A |
326 | #define if_tso_v4_mtu if_data.ifi_tso_v4_mtu |
327 | #define if_tso_v6_mtu if_data.ifi_tso_v6_mtu | |
6d2010ae | 328 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 | 329 | |
6d2010ae | 330 | #ifdef XNU_KERNEL_PRIVATE |
91447636 A |
331 | /* |
332 | * Forward structure declarations for function prototypes [sic]. | |
333 | */ | |
6d2010ae A |
334 | struct proc; |
335 | struct rtentry; | |
336 | struct socket; | |
91447636 | 337 | struct ifnet_filter; |
6d2010ae A |
338 | struct mbuf; |
339 | struct ifaddr; | |
340 | struct tqdummy; | |
341 | struct proto_hash_entry; | |
342 | struct dlil_threading_info; | |
343 | #if PF | |
344 | struct pfi_kif; | |
345 | #endif /* PF */ | |
91447636 | 346 | |
6d2010ae A |
347 | /* we use TAILQs so that the order of instantiation is preserved in the list */ |
348 | TAILQ_HEAD(ifnethead, ifnet); | |
349 | TAILQ_HEAD(ifaddrhead, ifaddr); | |
350 | TAILQ_HEAD(ifprefixhead, ifprefix); | |
351 | LIST_HEAD(ifmultihead, ifmultiaddr); | |
352 | TAILQ_HEAD(tailq_head, tqdummy); | |
91447636 A |
353 | TAILQ_HEAD(ifnet_filter_head, ifnet_filter); |
354 | TAILQ_HEAD(ddesc_head_name, dlil_demux_desc); | |
6d2010ae | 355 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 | 356 | |
6d2010ae A |
357 | #ifdef PRIVATE |
358 | /* | |
359 | * All of the following IF_HWASSIST_* flags are defined in kpi_inteface.h as | |
360 | * IFNET_* flags. These are redefined here as constants to avoid failures to | |
361 | * build user level programs that can not include kpi_interface.h. It is | |
362 | * important to keep this in sync with the definitions in kpi_interface.h. | |
363 | * The corresponding constant for each definition is mentioned in the comment. | |
b0d623f7 | 364 | * |
6d2010ae | 365 | * Bottom 16 bits reserved for hardware checksum |
b0d623f7 A |
366 | */ |
367 | #define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP, IFNET_CSUM_IP */ | |
368 | #define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP, IFNET_CSUM_TCP */ | |
369 | #define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP, IFNET_CSUM_UDP */ | |
370 | #define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments, IFNET_CSUM_FRAGMENT */ | |
371 | #define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation, IFNET_IP_FRAGMENT */ | |
6d2010ae A |
372 | #define IF_HWASSIST_CSUM_TCPIPV6 0x0020 /* will csum TCPv6, IFNET_CSUM_TCPIPV6 */ |
373 | #define IF_HWASSIST_CSUM_UDPIPV6 0x0040 /* will csum UDPv6, IFNET_CSUM_UDP */ | |
374 | #define IF_HWASSIST_CSUM_FRAGMENT_IPV6 0x0080 /* will do IPv6 fragmentation, IFNET_IPV6_FRAGMENT */ | |
b0d623f7 | 375 | #define IF_HWASSIST_CSUM_TCP_SUM16 0x1000 /* simple TCP Sum16 computation, IFNET_CSUM_SUM16 */ |
91447636 A |
376 | #define IF_HWASSIST_CSUM_MASK 0xffff |
377 | #define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK) | |
378 | ||
379 | /* VLAN support */ | |
b0d623f7 A |
380 | #define IF_HWASSIST_VLAN_TAGGING 0x00010000 /* supports VLAN tagging, IFNET_VLAN_TAGGING */ |
381 | #define IF_HWASSIST_VLAN_MTU 0x00020000 /* supports VLAN MTU-sized packet (for software VLAN), IFNET_VLAN_MTU */ | |
382 | ||
383 | /* TCP Segment Offloading support */ | |
384 | ||
385 | #define IF_HWASSIST_TSO_V4 0x00200000 /* will do TCP Segment offload for IPv4, IFNET_TSO_IPV4 */ | |
386 | #define IF_HWASSIST_TSO_V6 0x00400000 /* will do TCP Segment offload for IPv6, IFNET_TSO_IPV6 */ | |
2d21ac55 | 387 | #endif /* PRIVATE */ |
1c79356b | 388 | |
6d2010ae A |
389 | #ifdef XNU_KERNEL_PRIVATE |
390 | #include <sys/tree.h> | |
391 | #include <netinet/in.h> | |
2d21ac55 | 392 | |
6d2010ae | 393 | RB_HEAD(ll_reach_tree, if_llreach); /* define struct ll_reach_tree */ |
91447636 | 394 | |
1c79356b A |
395 | /* |
396 | * Structure defining a network interface. | |
397 | * | |
398 | * (Would like to call this struct ``if'', but C isn't PL/1.) | |
399 | */ | |
400 | struct ifnet { | |
6d2010ae A |
401 | /* |
402 | * Lock (RW or mutex) to protect this data structure (static storage.) | |
403 | */ | |
404 | decl_lck_rw_data(, if_lock); | |
405 | void *if_softc; /* pointer to driver state */ | |
406 | const char *if_name; /* name, e.g. ``en'' or ``lo'' */ | |
407 | TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ | |
408 | TAILQ_ENTRY(ifnet) if_detaching_link; /* list of detaching ifnets */ | |
409 | ||
410 | decl_lck_mtx_data(, if_ref_lock) | |
411 | u_int32_t if_refflags; | |
412 | u_int32_t if_refio; /* number of io ops to the underlying driver */ | |
413 | ||
414 | #define if_list if_link | |
415 | struct ifaddrhead if_addrhead; /* linked list of addresses per if */ | |
416 | #define if_addrlist if_addrhead | |
417 | struct ifaddr *if_lladdr; /* link address (first/permanent) */ | |
418 | ||
419 | int if_pcount; /* number of promiscuous listeners */ | |
420 | struct bpf_if *if_bpf; /* packet filter structure */ | |
421 | u_short if_index; /* numeric abbreviation for this if */ | |
422 | short if_unit; /* sub-unit for lower level driver */ | |
423 | short if_timer; /* time 'til if_watchdog called */ | |
424 | short if_flags; /* up/down, broadcast, etc. */ | |
425 | u_int32_t if_eflags; /* see <net/if.h> */ | |
426 | ||
427 | int if_capabilities; /* interface features & capabilities */ | |
428 | int if_capenable; /* enabled features & capabilities */ | |
429 | ||
430 | void *if_linkmib; /* link-type-specific MIB data */ | |
431 | size_t if_linkmiblen; /* length of above data */ | |
432 | ||
433 | struct if_data_internal if_data __attribute__((aligned(8))); | |
434 | ||
435 | ifnet_family_t if_family; /* value assigned by Apple */ | |
436 | uintptr_t if_family_cookie; | |
91447636 A |
437 | ifnet_output_func if_output; |
438 | ifnet_ioctl_func if_ioctl; | |
439 | ifnet_set_bpf_tap if_set_bpf_tap; | |
440 | ifnet_detached_func if_free; | |
441 | ifnet_demux_func if_demux; | |
442 | ifnet_event_func if_event; | |
443 | ifnet_framer_func if_framer; | |
6d2010ae A |
444 | ifnet_add_proto_func if_add_proto; |
445 | ifnet_del_proto_func if_del_proto; | |
446 | ifnet_check_multi if_check_multi; | |
447 | struct proto_hash_entry *if_proto_hash; | |
448 | void *if_kpi_storage; | |
1c79356b | 449 | |
6d2010ae A |
450 | decl_lck_mtx_data(, if_flt_lock) |
451 | u_int32_t if_flt_busy; | |
452 | u_int32_t if_flt_waiters; | |
91447636 | 453 | struct ifnet_filter_head if_flt_head; |
1c79356b | 454 | |
6d2010ae A |
455 | struct ifmultihead if_multiaddrs; /* multicast addresses */ |
456 | u_int32_t if_updatemcasts; /* mcast addrs need updating */ | |
457 | int if_amcount; /* # of all-multicast reqs */ | |
458 | decl_lck_mtx_data(, if_addrconfig_lock); /* for serializing addr config */ | |
459 | struct in_multi *if_allhostsinm; /* store all-hosts inm for this ifp */ | |
1c79356b | 460 | |
2d21ac55 | 461 | struct dlil_threading_info *if_input_thread; |
91447636 | 462 | |
6d2010ae | 463 | struct ifqueue if_snd; |
91447636 | 464 | |
6d2010ae | 465 | struct ifprefixhead if_prefixhead; /* list of prefixes per if */ |
91447636 | 466 | struct { |
b0d623f7 | 467 | u_int32_t length; |
91447636 A |
468 | union { |
469 | u_char buffer[8]; | |
470 | u_char *ptr; | |
471 | } u; | |
472 | } if_broadcast; | |
2d21ac55 | 473 | #if CONFIG_MACF_NET |
6d2010ae | 474 | struct label *if_label; /* interface MAC label */ |
2d21ac55 | 475 | #endif |
b0d623f7 | 476 | |
6d2010ae | 477 | u_int32_t if_wake_properties; |
b0d623f7 | 478 | #if PF |
6d2010ae A |
479 | struct thread *if_pf_curthread; |
480 | struct pfi_kif *if_pf_kif; | |
b0d623f7 | 481 | #endif /* PF */ |
1c79356b | 482 | |
6d2010ae A |
483 | decl_lck_mtx_data(, if_cached_route_lock); |
484 | u_int32_t if_fwd_cacheok; | |
485 | struct route if_fwd_route; /* cached forwarding route */ | |
486 | struct route if_src_route; /* cached ipv4 source route */ | |
487 | struct route_in6 if_src_route6; /* cached ipv6 source route */ | |
91447636 | 488 | |
6d2010ae A |
489 | decl_lck_rw_data(, if_llreach_lock); |
490 | struct ll_reach_tree if_ll_srcs; /* source link-layer tree */ | |
91447636 | 491 | |
6d2010ae A |
492 | void *if_bridge; /* bridge glue */ |
493 | ||
494 | u_int32_t if_want_aggressive_drain; | |
495 | u_int32_t if_idle_flags; /* idle flags */ | |
496 | u_int32_t if_idle_new_flags; /* temporary idle flags */ | |
497 | u_int32_t if_idle_new_flags_mask; /* temporary mask */ | |
498 | u_int32_t if_route_refcnt; /* idle: route ref count */ | |
499 | ||
500 | struct if_traffic_class if_tc __attribute__((aligned(8))); | |
501 | #if INET | |
502 | struct igmp_ifinfo *if_igi; /* for IGMPv3 */ | |
503 | #endif /* INET */ | |
504 | #if INET6 | |
505 | struct mld_ifinfo *if_mli; /* for MLDv2 */ | |
506 | #endif /* INET6 */ | |
507 | }; | |
508 | ||
509 | /* | |
510 | * Valid values for if_useflags | |
511 | */ | |
512 | #define IFRF_ATTACHED 0x1 /* ifnet attach is completely done */ | |
513 | #define IFRF_DETACHING 0x2 /* detach has been requested */ | |
91447636 | 514 | |
4a249263 A |
515 | /* |
516 | * Structure describing a `cloning' interface. | |
517 | */ | |
518 | struct if_clone { | |
519 | LIST_ENTRY(if_clone) ifc_list; /* on list of cloners */ | |
6d2010ae A |
520 | const char *ifc_name; /* name of device, e.g. `vlan' */ |
521 | size_t ifc_namelen; /* length of name */ | |
522 | u_int32_t ifc_minifs; /* minimum number of interfaces */ | |
523 | u_int32_t ifc_maxunit; /* maximum unit number */ | |
524 | unsigned char *ifc_units; /* bitmap to handle units */ | |
525 | u_int32_t ifc_bmlen; /* bitmap length */ | |
526 | ||
527 | int (*ifc_create)(struct if_clone *, u_int32_t, void *); | |
528 | int (*ifc_destroy)(struct ifnet *); | |
4a249263 A |
529 | }; |
530 | ||
6d2010ae A |
531 | #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit) { \ |
532 | { NULL, NULL }, name, (sizeof (name) - 1), minifs, maxunit, NULL, 0, \ | |
533 | create, destroy \ | |
534 | } | |
9bccf70c | 535 | |
d1ecb069 A |
536 | #define M_CLONE M_IFADDR |
537 | ||
1c79356b | 538 | /* |
6d2010ae A |
539 | * Macros to manipulate ifqueue. Users of these macros are responsible |
540 | * for serialization, by holding whatever lock is appropriate for the | |
541 | * corresponding structure that is referring the ifqueue. | |
1c79356b A |
542 | */ |
543 | #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) | |
544 | #define IF_DROP(ifq) ((ifq)->ifq_drops++) | |
6d2010ae A |
545 | #define IF_ENQUEUE(ifq, m) { \ |
546 | (m)->m_nextpkt = NULL; \ | |
547 | if ((ifq)->ifq_tail == NULL) \ | |
548 | (ifq)->ifq_head = m; \ | |
549 | else \ | |
550 | ((struct mbuf*)(ifq)->ifq_tail)->m_nextpkt = m; \ | |
551 | (ifq)->ifq_tail = m; \ | |
552 | (ifq)->ifq_len++; \ | |
1c79356b | 553 | } |
6d2010ae A |
554 | #define IF_PREPEND(ifq, m) { \ |
555 | (m)->m_nextpkt = (ifq)->ifq_head; \ | |
556 | if ((ifq)->ifq_tail == NULL) \ | |
557 | (ifq)->ifq_tail = (m); \ | |
558 | (ifq)->ifq_head = (m); \ | |
559 | (ifq)->ifq_len++; \ | |
1c79356b | 560 | } |
6d2010ae A |
561 | #define IF_DEQUEUE(ifq, m) { \ |
562 | (m) = (ifq)->ifq_head; \ | |
563 | if (m != NULL) { \ | |
564 | if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \ | |
565 | (ifq)->ifq_tail = NULL; \ | |
566 | (m)->m_nextpkt = NULL; \ | |
567 | (ifq)->ifq_len--; \ | |
568 | } \ | |
1c79356b | 569 | } |
6d2010ae A |
570 | #define IF_REMQUEUE(ifq, m) { \ |
571 | struct mbuf *_p = (ifq)->ifq_head; \ | |
572 | struct mbuf *_n = (m)->m_nextpkt; \ | |
573 | if ((m) == _p) \ | |
574 | _p = NULL; \ | |
575 | while (_p != NULL) { \ | |
576 | if (_p->m_nextpkt == (m)) \ | |
577 | break; \ | |
578 | _p = _p->m_nextpkt; \ | |
579 | } \ | |
580 | VERIFY(_p != NULL || ((m) == (ifq)->ifq_head)); \ | |
581 | if ((m) == (ifq)->ifq_head) \ | |
582 | (ifq)->ifq_head = _n; \ | |
583 | if ((m) == (ifq)->ifq_tail) \ | |
584 | (ifq)->ifq_tail = _p; \ | |
585 | VERIFY((ifq)->ifq_tail != NULL || (ifq)->ifq_head == NULL); \ | |
586 | VERIFY((ifq)->ifq_len != 0); \ | |
587 | --(ifq)->ifq_len; \ | |
588 | if (_p != NULL) \ | |
589 | _p->m_nextpkt = _n; \ | |
590 | (m)->m_nextpkt = NULL; \ | |
1c79356b | 591 | } |
6d2010ae A |
592 | #define IF_DRAIN(ifq) do { \ |
593 | struct mbuf *m; \ | |
594 | for (;;) { \ | |
595 | IF_DEQUEUE(ifq, m); \ | |
596 | if (m == NULL) \ | |
597 | break; \ | |
598 | m_freem(m); \ | |
599 | } \ | |
600 | } while (0) | |
1c79356b | 601 | |
1c79356b A |
602 | /* |
603 | * The ifaddr structure contains information about one address | |
604 | * of an interface. They are maintained by the different address families, | |
605 | * are allocated and attached when an address is set, and are linked | |
606 | * together so all addresses for an interface can be located. | |
607 | */ | |
608 | struct ifaddr { | |
6d2010ae A |
609 | decl_lck_mtx_data(, ifa_lock); /* lock for ifaddr */ |
610 | uint32_t ifa_refcnt; /* ref count, use IFA_{ADD,REM}REF */ | |
611 | uint32_t ifa_debug; /* debug flags */ | |
612 | struct sockaddr *ifa_addr; /* address of interface */ | |
613 | struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ | |
1c79356b | 614 | #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ |
6d2010ae A |
615 | struct sockaddr *ifa_netmask; /* used to determine subnet */ |
616 | struct ifnet *ifa_ifp; /* back-pointer to interface */ | |
1c79356b | 617 | TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ |
b0d623f7 A |
618 | void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ |
619 | (int, struct rtentry *, struct sockaddr *); | |
6d2010ae A |
620 | uint32_t ifa_flags; /* mostly rt_flags for cloning */ |
621 | int32_t ifa_metric; /* cost of going out this interface */ | |
b0d623f7 A |
622 | void (*ifa_free)(struct ifaddr *); /* callback fn for freeing */ |
623 | void (*ifa_trace) /* callback fn for tracing refs */ | |
624 | (struct ifaddr *, int); | |
6d2010ae A |
625 | void (*ifa_attached)(struct ifaddr *); /* callback fn for attaching */ |
626 | void (*ifa_detached)(struct ifaddr *); /* callback fn for detaching */ | |
1c79356b | 627 | }; |
b0d623f7 A |
628 | |
629 | /* | |
630 | * Valid values for ifa_flags | |
631 | */ | |
91447636 A |
632 | #define IFA_ROUTE RTF_UP /* route installed (0x1) */ |
633 | #define IFA_CLONING RTF_CLONING /* (0x100) */ | |
b0d623f7 A |
634 | |
635 | /* | |
636 | * Valid values for ifa_debug | |
637 | */ | |
6d2010ae | 638 | #define IFD_ATTACHED 0x1 /* attached to list */ |
b0d623f7 A |
639 | #define IFD_ALLOC 0x2 /* dynamically allocated */ |
640 | #define IFD_DEBUG 0x4 /* has debugging info */ | |
6d2010ae A |
641 | #define IFD_LINK 0x8 /* link address */ |
642 | #define IFD_TRASHED 0x10 /* in trash list */ | |
643 | #define IFD_SKIP 0x20 /* skip this entry */ | |
644 | #define IFD_NOTREADY 0x40 /* embryonic; not yet ready */ | |
91447636 | 645 | |
6d2010ae A |
646 | #define IFA_LOCK_ASSERT_HELD(_ifa) \ |
647 | lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_OWNED) | |
648 | ||
649 | #define IFA_LOCK_ASSERT_NOTHELD(_ifa) \ | |
650 | lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_NOTOWNED) | |
651 | ||
652 | #define IFA_LOCK(_ifa) \ | |
653 | lck_mtx_lock(&(_ifa)->ifa_lock) | |
654 | ||
655 | #define IFA_LOCK_SPIN(_ifa) \ | |
656 | lck_mtx_lock_spin(&(_ifa)->ifa_lock) | |
657 | ||
658 | #define IFA_CONVERT_LOCK(_ifa) do { \ | |
659 | IFA_LOCK_ASSERT_HELD(_ifa); \ | |
660 | lck_mtx_convert_spin(&(_ifa)->ifa_lock); \ | |
661 | } while (0) | |
662 | ||
663 | #define IFA_UNLOCK(_ifa) \ | |
664 | lck_mtx_unlock(&(_ifa)->ifa_lock) | |
665 | ||
666 | #define IFA_ADDREF(_ifa) \ | |
667 | ifa_addref(_ifa, 0) | |
668 | ||
669 | #define IFA_ADDREF_LOCKED(_ifa) \ | |
670 | ifa_addref(_ifa, 1) | |
671 | ||
672 | #define IFA_REMREF(_ifa) do { \ | |
673 | (void) ifa_remref(_ifa, 0); \ | |
674 | } while (0) | |
675 | ||
676 | #define IFA_REMREF_LOCKED(_ifa) \ | |
677 | ifa_remref(_ifa, 1) | |
1c79356b A |
678 | |
679 | /* | |
680 | * The prefix structure contains information about one prefix | |
681 | * of an interface. They are maintained by the different address families, | |
682 | * are allocated and attached when an prefix or an address is set, | |
683 | * and are linked together so all prefixes for an interface can be located. | |
684 | */ | |
685 | struct ifprefix { | |
686 | struct sockaddr *ifpr_prefix; /* prefix of interface */ | |
687 | struct ifnet *ifpr_ifp; /* back-pointer to interface */ | |
9bccf70c | 688 | TAILQ_ENTRY(ifprefix) ifpr_list; /* queue macro glue */ |
1c79356b A |
689 | u_char ifpr_plen; /* prefix length in bits */ |
690 | u_char ifpr_type; /* protocol dependent prefix type */ | |
691 | }; | |
692 | ||
693 | /* | |
694 | * Multicast address structure. This is analogous to the ifaddr | |
695 | * structure except that it keeps track of multicast addresses. | |
6d2010ae A |
696 | * Also, the request count here is a count of requests for this |
697 | * address, not a count of pointers to this structure; anonymous | |
698 | * membership(s) holds one outstanding request count. | |
1c79356b A |
699 | */ |
700 | struct ifmultiaddr { | |
6d2010ae A |
701 | decl_lck_mtx_data(, ifma_lock); |
702 | u_int32_t ifma_refcount; /* reference count */ | |
703 | u_int32_t ifma_anoncnt; /* # of anonymous requests */ | |
704 | u_int32_t ifma_reqcnt; /* total requests for this address */ | |
705 | u_int32_t ifma_debug; /* see ifa_debug flags */ | |
706 | u_int32_t ifma_flags; /* see below */ | |
1c79356b | 707 | LIST_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ |
6d2010ae | 708 | struct sockaddr *ifma_addr; /* address this membership is for */ |
91447636 | 709 | struct ifmultiaddr *ifma_ll; /* link-layer translation, if any */ |
6d2010ae A |
710 | struct ifnet *ifma_ifp; /* back-pointer to interface */ |
711 | void *ifma_protospec; /* protocol-specific state, if any */ | |
712 | void (*ifma_trace) /* callback fn for tracing refs */ | |
713 | (struct ifmultiaddr *, int); | |
1c79356b | 714 | }; |
1c79356b | 715 | |
91447636 | 716 | /* |
6d2010ae | 717 | * Values for ifma_flags |
91447636 | 718 | */ |
6d2010ae A |
719 | #define IFMAF_ANONYMOUS 0x1 /* has anonymous request ref(s) held */ |
720 | ||
721 | #define IFMA_LOCK_ASSERT_HELD(_ifma) \ | |
722 | lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_OWNED) | |
723 | ||
724 | #define IFMA_LOCK_ASSERT_NOTHELD(_ifma) \ | |
725 | lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_NOTOWNED) | |
726 | ||
727 | #define IFMA_LOCK(_ifma) \ | |
728 | lck_mtx_lock(&(_ifma)->ifma_lock) | |
729 | ||
730 | #define IFMA_LOCK_SPIN(_ifma) \ | |
731 | lck_mtx_lock_spin(&(_ifma)->ifma_lock) | |
732 | ||
733 | #define IFMA_CONVERT_LOCK(_ifma) do { \ | |
734 | IFMA_LOCK_ASSERT_HELD(_ifma); \ | |
735 | lck_mtx_convert_spin(&(_ifma)->ifma_lock); \ | |
736 | } while (0) | |
737 | ||
738 | #define IFMA_UNLOCK(_ifma) \ | |
739 | lck_mtx_unlock(&(_ifma)->ifma_lock) | |
740 | ||
741 | #define IFMA_ADDREF(_ifma) \ | |
742 | ifma_addref(_ifma, 0) | |
743 | ||
744 | #define IFMA_ADDREF_LOCKED(_ifma) \ | |
745 | ifma_addref(_ifma, 1) | |
746 | ||
747 | #define IFMA_REMREF(_ifma) \ | |
748 | ifma_remref(_ifma) | |
749 | ||
750 | __private_extern__ struct ifnethead ifnet_head; | |
751 | __private_extern__ struct ifnet **ifindex2ifnet; | |
752 | __private_extern__ int ifqmaxlen; | |
753 | __private_extern__ int if_index; | |
754 | __private_extern__ struct ifaddr **ifnet_addrs; | |
755 | __private_extern__ lck_attr_t *ifa_mtx_attr; | |
756 | __private_extern__ lck_grp_t *ifa_mtx_grp; | |
757 | __private_extern__ lck_grp_t *ifnet_lock_group; | |
758 | __private_extern__ lck_attr_t *ifnet_lock_attr; | |
759 | extern ifnet_t lo_ifp; | |
760 | ||
761 | extern int if_addmulti(struct ifnet *, const struct sockaddr *, | |
762 | struct ifmultiaddr **); | |
763 | extern int if_addmulti_anon(struct ifnet *, const struct sockaddr *, | |
764 | struct ifmultiaddr **); | |
765 | extern int if_allmulti(struct ifnet *, int); | |
766 | extern int if_delmulti(struct ifnet *, const struct sockaddr *); | |
767 | extern int if_delmulti_ifma(struct ifmultiaddr *); | |
768 | extern int if_delmulti_anon(struct ifnet *, const struct sockaddr *); | |
769 | extern void if_down(struct ifnet *); | |
770 | extern int if_down_all(void); | |
771 | extern void if_up(struct ifnet *); | |
772 | __private_extern__ void if_updown(struct ifnet *ifp, int up); | |
773 | extern int ifioctl(struct socket *, u_long, caddr_t, struct proc *); | |
774 | extern int ifioctllocked(struct socket *, u_long, caddr_t, struct proc *); | |
775 | extern struct ifnet *ifunit(const char *); | |
776 | extern struct ifnet *if_withname(struct sockaddr *); | |
777 | ||
778 | extern struct if_clone *if_clone_lookup(const char *, u_int32_t *); | |
779 | extern int if_clone_attach(struct if_clone *); | |
780 | extern void if_clone_detach(struct if_clone *); | |
781 | ||
782 | extern errno_t if_mcasts_update(struct ifnet *); | |
783 | ||
784 | typedef enum { | |
785 | IFNET_LCK_ASSERT_EXCLUSIVE, /* RW: held as writer */ | |
786 | IFNET_LCK_ASSERT_SHARED, /* RW: held as reader */ | |
787 | IFNET_LCK_ASSERT_OWNED, /* RW: writer/reader, MTX: held */ | |
788 | IFNET_LCK_ASSERT_NOTOWNED /* not held */ | |
789 | } ifnet_lock_assert_t; | |
790 | ||
791 | __private_extern__ void ifnet_lock_assert(struct ifnet *, ifnet_lock_assert_t); | |
792 | __private_extern__ void ifnet_lock_shared(struct ifnet *ifp); | |
793 | __private_extern__ void ifnet_lock_exclusive(struct ifnet *ifp); | |
794 | __private_extern__ void ifnet_lock_done(struct ifnet *ifp); | |
795 | ||
796 | __private_extern__ void ifnet_head_lock_shared(void); | |
797 | __private_extern__ void ifnet_head_lock_exclusive(void); | |
798 | __private_extern__ void ifnet_head_done(void); | |
799 | ||
800 | __private_extern__ errno_t ifnet_set_idle_flags_locked(ifnet_t, u_int32_t, | |
801 | u_int32_t); | |
802 | __private_extern__ int ifnet_is_attached(struct ifnet *, int refio); | |
803 | __private_extern__ void ifnet_decr_iorefcnt(struct ifnet *); | |
804 | ||
805 | __private_extern__ void if_attach_ifa(struct ifnet *, struct ifaddr *); | |
806 | __private_extern__ void if_attach_link_ifa(struct ifnet *, struct ifaddr *); | |
807 | __private_extern__ void if_detach_ifa(struct ifnet *, struct ifaddr *); | |
808 | __private_extern__ void if_detach_link_ifa(struct ifnet *, struct ifaddr *); | |
809 | ||
7ddcb079 A |
810 | __private_extern__ void dlil_if_lock(void); |
811 | __private_extern__ void dlil_if_unlock(void); | |
812 | __private_extern__ void dlil_if_lock_assert(void); | |
813 | ||
6d2010ae A |
814 | extern struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); |
815 | extern struct ifaddr *ifa_ifwithaddr_scoped(const struct sockaddr *, unsigned int); | |
816 | extern struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); | |
817 | extern struct ifaddr *ifa_ifwithnet(const struct sockaddr *); | |
818 | extern struct ifaddr *ifa_ifwithnet_scoped(const struct sockaddr *, unsigned int); | |
819 | extern struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *, | |
820 | const struct sockaddr *); | |
821 | extern struct ifaddr *ifa_ifwithroute_locked(int, const struct sockaddr *, const struct sockaddr *); | |
822 | extern struct ifaddr *ifa_ifwithroute_scoped_locked(int, const struct sockaddr *, | |
c910b4d9 | 823 | const struct sockaddr *, unsigned int); |
6d2010ae A |
824 | extern struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); |
825 | __private_extern__ struct ifaddr *ifa_ifpgetprimary(struct ifnet *, int); | |
826 | extern void ifa_addref(struct ifaddr *, int); | |
827 | extern struct ifaddr *ifa_remref(struct ifaddr *, int); | |
828 | extern void ifa_lock_init(struct ifaddr *); | |
829 | extern void ifa_lock_destroy(struct ifaddr *); | |
830 | extern void ifma_addref(struct ifmultiaddr *, int); | |
831 | extern void ifma_remref(struct ifmultiaddr *); | |
832 | ||
833 | extern void ifa_init(void); | |
834 | ||
835 | __private_extern__ struct in_ifaddr *ifa_foraddr(unsigned int); | |
836 | __private_extern__ struct in_ifaddr *ifa_foraddr_scoped(unsigned int, | |
837 | unsigned int); | |
838 | ||
839 | #if INET6 | |
840 | struct in6_addr; | |
841 | __private_extern__ struct in6_ifaddr *ifa_foraddr6(struct in6_addr *); | |
842 | __private_extern__ struct in6_ifaddr *ifa_foraddr6_scoped(struct in6_addr *, | |
843 | unsigned int); | |
844 | #endif /* INET6 */ | |
845 | ||
846 | __private_extern__ void if_data_internal_to_if_data(struct ifnet *ifp, | |
847 | const struct if_data_internal *if_data_int, struct if_data *if_data); | |
848 | __private_extern__ void if_data_internal_to_if_data64(struct ifnet *ifp, | |
849 | const struct if_data_internal *if_data_int, struct if_data64 *if_data64); | |
850 | __private_extern__ void if_copy_traffic_class(struct ifnet *ifp, | |
851 | struct if_traffic_class *if_tc); | |
852 | ||
853 | __private_extern__ struct rtentry *ifnet_cached_rtlookup_inet(struct ifnet *, | |
854 | struct in_addr); | |
855 | #if INET6 | |
856 | __private_extern__ struct rtentry *ifnet_cached_rtlookup_inet6(struct ifnet *, | |
857 | struct in6_addr *); | |
858 | #endif /* INET6 */ | |
859 | ||
860 | #endif /* XNU_KERNEL_PRIVATE */ | |
1c79356b | 861 | #endif /* !_NET_IF_VAR_H_ */ |