]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
f427ee49 | 2 | * Copyright (c) 2000-2020 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) 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 | ||
0a7de745 A |
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> | |
0a7de745 | 71 | #include <sys/queue.h> /* get TAILQ macros */ |
91447636 A |
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 | |
cb323159 | 78 | #ifdef BSD_KERN_PRIVATE |
f427ee49 | 79 | #include <net/pktsched/pktsched.h> |
5ba3f43e A |
80 | #include <sys/eventhandler.h> |
81 | #endif | |
91447636 A |
82 | |
83 | #ifdef KERNEL | |
84 | #include <net/kpi_interface.h> | |
b0d623f7 | 85 | #endif /* KERNEL */ |
1c79356b | 86 | |
9bccf70c | 87 | #ifdef __APPLE__ |
1c79356b A |
88 | #define APPLE_IF_FAM_LOOPBACK 1 |
89 | #define APPLE_IF_FAM_ETHERNET 2 | |
90 | #define APPLE_IF_FAM_SLIP 3 | |
91 | #define APPLE_IF_FAM_TUN 4 | |
92 | #define APPLE_IF_FAM_VLAN 5 | |
93 | #define APPLE_IF_FAM_PPP 6 | |
94 | #define APPLE_IF_FAM_PVC 7 | |
95 | #define APPLE_IF_FAM_DISC 8 | |
96 | #define APPLE_IF_FAM_MDECAP 9 | |
97 | #define APPLE_IF_FAM_GIF 10 | |
0a7de745 | 98 | #define APPLE_IF_FAM_FAITH 11 /* deprecated */ |
55e303ae A |
99 | #define APPLE_IF_FAM_STF 12 |
100 | #define APPLE_IF_FAM_FIREWIRE 13 | |
91447636 | 101 | #define APPLE_IF_FAM_BOND 14 |
cb323159 A |
102 | #define APPLE_IF_FAM_CELLULAR 15 |
103 | #define APPLE_IF_FAM_6LOWPAN 16 | |
104 | #define APPLE_IF_FAM_UTUN 17 | |
105 | #define APPLE_IF_FAM_IPSEC 18 | |
0c530ab8 | 106 | #endif /* __APPLE__ */ |
91447636 A |
107 | |
108 | /* | |
109 | * 72 was chosen below because it is the size of a TCP/IP | |
110 | * header (40) + the minimum mss (32). | |
111 | */ | |
0a7de745 A |
112 | #define IF_MINMTU 72 |
113 | #define IF_MAXMTU 65535 | |
1c79356b A |
114 | |
115 | /* | |
116 | * Structures defining a network interface, providing a packet | |
117 | * transport mechanism (ala level 0 of the PUP protocols). | |
118 | * | |
119 | * Each interface accepts output datagrams of a specified maximum | |
120 | * length, and provides higher level routines with input datagrams | |
121 | * received from its medium. | |
122 | * | |
123 | * Output occurs when the routine if_output is called, with three parameters: | |
124 | * (*ifp->if_output)(ifp, m, dst, rt) | |
125 | * Here m is the mbuf chain to be sent and dst is the destination address. | |
126 | * The output routine encapsulates the supplied datagram if necessary, | |
127 | * and then transmits it on its medium. | |
128 | * | |
129 | * On input, each interface unwraps the data received by it, and either | |
130 | * places it on the input queue of a internetwork datagram routine | |
131 | * and posts the associated software interrupt, or passes the datagram to a raw | |
132 | * packet input routine. | |
133 | * | |
134 | * Routines exist for locating interfaces by their addresses | |
135 | * or for locating a interface on a certain network, as well as more general | |
136 | * routing and gateway routines maintaining information used to locate | |
137 | * interfaces. These routines live in the files if.c and route.c | |
138 | */ | |
139 | ||
0a7de745 | 140 | #define IFNAMSIZ 16 |
1c79356b | 141 | |
1c79356b A |
142 | /* This belongs up in socket.h or socketvar.h, depending on how far the |
143 | * event bubbles up. | |
144 | */ | |
145 | ||
146 | struct net_event_data { | |
0a7de745 A |
147 | u_int32_t if_family; |
148 | u_int32_t if_unit; | |
149 | char if_name[IFNAMSIZ]; | |
1c79356b | 150 | }; |
1c79356b | 151 | |
2d21ac55 | 152 | #if defined(__LP64__) |
39236c6e | 153 | #include <sys/_types/_timeval32.h> |
2d21ac55 A |
154 | #define IF_DATA_TIMEVAL timeval32 |
155 | #else | |
156 | #define IF_DATA_TIMEVAL timeval | |
157 | #endif | |
158 | ||
159 | #pragma pack(4) | |
160 | ||
91447636 A |
161 | /* |
162 | * Structure describing information about an interface | |
163 | * which may be of interest to management entities. | |
164 | */ | |
165 | struct if_data { | |
166 | /* generic interface information */ | |
0a7de745 A |
167 | u_char ifi_type; /* ethernet, tokenring, etc */ |
168 | u_char ifi_typelen; /* Length of frame type id */ | |
169 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ | |
170 | u_char ifi_addrlen; /* media address length */ | |
171 | u_char ifi_hdrlen; /* media header length */ | |
172 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
173 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
174 | u_char ifi_unused1; /* for future use */ | |
175 | u_int32_t ifi_mtu; /* maximum transmission unit */ | |
176 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
177 | u_int32_t ifi_baudrate; /* linespeed */ | |
91447636 | 178 | /* volatile statistics */ |
0a7de745 A |
179 | u_int32_t ifi_ipackets; /* packets received on interface */ |
180 | u_int32_t ifi_ierrors; /* input errors on interface */ | |
181 | u_int32_t ifi_opackets; /* packets sent on interface */ | |
182 | u_int32_t ifi_oerrors; /* output errors on interface */ | |
183 | u_int32_t ifi_collisions; /* collisions on csma interfaces */ | |
184 | u_int32_t ifi_ibytes; /* total number of octets received */ | |
185 | u_int32_t ifi_obytes; /* total number of octets sent */ | |
186 | u_int32_t ifi_imcasts; /* packets received via multicast */ | |
187 | u_int32_t ifi_omcasts; /* packets sent via multicast */ | |
188 | u_int32_t ifi_iqdrops; /* dropped on input, this interface */ | |
189 | u_int32_t ifi_noproto; /* destined for unsupported protocol */ | |
190 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ | |
191 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
192 | struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ | |
193 | u_int32_t ifi_unused2; /* used to be the default_proto */ | |
194 | u_int32_t ifi_hwassist; /* HW offload capabilities */ | |
195 | u_int32_t ifi_reserved1; /* for future use */ | |
196 | u_int32_t ifi_reserved2; /* for future use */ | |
91447636 | 197 | }; |
4a249263 | 198 | |
1c79356b A |
199 | /* |
200 | * Structure describing information about an interface | |
201 | * which may be of interest to management entities. | |
202 | */ | |
91447636 | 203 | struct if_data64 { |
1c79356b | 204 | /* generic interface information */ |
0a7de745 A |
205 | u_char ifi_type; /* ethernet, tokenring, etc */ |
206 | u_char ifi_typelen; /* Length of frame type id */ | |
207 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ | |
208 | u_char ifi_addrlen; /* media address length */ | |
209 | u_char ifi_hdrlen; /* media header length */ | |
210 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
211 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
212 | u_char ifi_unused1; /* for future use */ | |
213 | u_int32_t ifi_mtu; /* maximum transmission unit */ | |
214 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
215 | u_int64_t ifi_baudrate; /* linespeed */ | |
91447636 | 216 | /* volatile statistics */ |
0a7de745 A |
217 | u_int64_t ifi_ipackets; /* packets received on interface */ |
218 | u_int64_t ifi_ierrors; /* input errors on interface */ | |
219 | u_int64_t ifi_opackets; /* packets sent on interface */ | |
220 | u_int64_t ifi_oerrors; /* output errors on interface */ | |
221 | u_int64_t ifi_collisions; /* collisions on csma interfaces */ | |
222 | u_int64_t ifi_ibytes; /* total number of octets received */ | |
223 | u_int64_t ifi_obytes; /* total number of octets sent */ | |
224 | u_int64_t ifi_imcasts; /* packets received via multicast */ | |
225 | u_int64_t ifi_omcasts; /* packets sent via multicast */ | |
226 | u_int64_t ifi_iqdrops; /* dropped on input, this interface */ | |
227 | u_int64_t ifi_noproto; /* destined for unsupported protocol */ | |
228 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ | |
229 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
230 | struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ | |
91447636 A |
231 | }; |
232 | ||
233 | #ifdef PRIVATE | |
d41d1dae | 234 | struct if_traffic_class { |
0a7de745 A |
235 | u_int64_t ifi_ibepackets; /* TC_BE packets received on interface */ |
236 | u_int64_t ifi_ibebytes; /* TC_BE bytes received on interface */ | |
237 | u_int64_t ifi_obepackets; /* TC_BE packet sent on interface */ | |
238 | u_int64_t ifi_obebytes; /* TC_BE bytes sent on interface */ | |
239 | u_int64_t ifi_ibkpackets; /* TC_BK packets received on interface */ | |
240 | u_int64_t ifi_ibkbytes; /* TC_BK bytes received on interface */ | |
241 | u_int64_t ifi_obkpackets; /* TC_BK packet sent on interface */ | |
242 | u_int64_t ifi_obkbytes; /* TC_BK bytes sent on interface */ | |
243 | u_int64_t ifi_ivipackets; /* TC_VI packets received on interface */ | |
244 | u_int64_t ifi_ivibytes; /* TC_VI bytes received on interface */ | |
245 | u_int64_t ifi_ovipackets; /* TC_VI packets sent on interface */ | |
246 | u_int64_t ifi_ovibytes; /* TC_VI bytes sent on interface */ | |
247 | u_int64_t ifi_ivopackets; /* TC_VO packets received on interface */ | |
248 | u_int64_t ifi_ivobytes; /* TC_VO bytes received on interface */ | |
249 | u_int64_t ifi_ovopackets; /* TC_VO packets sent on interface */ | |
250 | u_int64_t ifi_ovobytes; /* TC_VO bytes sent on interface */ | |
251 | u_int64_t ifi_ipvpackets; /* TC priv packets received on interface */ | |
252 | u_int64_t ifi_ipvbytes; /* TC priv bytes received on interface */ | |
253 | u_int64_t ifi_opvpackets; /* TC priv packets sent on interface */ | |
254 | u_int64_t ifi_opvbytes; /* TC priv bytes sent on interface */ | |
316670eb A |
255 | }; |
256 | ||
257 | struct if_data_extended { | |
0a7de745 A |
258 | u_int64_t ifi_alignerrs; /* unaligned (32-bit) input pkts */ |
259 | u_int64_t ifi_dt_bytes; /* Data threshold counter */ | |
260 | u_int64_t ifi_fpackets; /* forwarded packets on interface */ | |
261 | u_int64_t ifi_fbytes; /* forwarded bytes on interface */ | |
262 | u_int64_t reserved[12]; /* for future */ | |
316670eb A |
263 | }; |
264 | ||
265 | struct if_packet_stats { | |
266 | /* TCP */ | |
0a7de745 A |
267 | u_int64_t ifi_tcp_badformat; |
268 | u_int64_t ifi_tcp_unspecv6; | |
269 | u_int64_t ifi_tcp_synfin; | |
270 | u_int64_t ifi_tcp_badformatipsec; | |
271 | u_int64_t ifi_tcp_noconnnolist; | |
272 | u_int64_t ifi_tcp_noconnlist; | |
273 | u_int64_t ifi_tcp_listbadsyn; | |
274 | u_int64_t ifi_tcp_icmp6unreach; | |
275 | u_int64_t ifi_tcp_deprecate6; | |
276 | u_int64_t ifi_tcp_rstinsynrcv; | |
277 | u_int64_t ifi_tcp_ooopacket; | |
278 | u_int64_t ifi_tcp_dospacket; | |
279 | u_int64_t ifi_tcp_cleanup; | |
280 | u_int64_t ifi_tcp_synwindow; | |
281 | u_int64_t reserved[6]; | |
316670eb | 282 | /* UDP */ |
0a7de745 A |
283 | u_int64_t ifi_udp_port_unreach; |
284 | u_int64_t ifi_udp_faithprefix; | |
285 | u_int64_t ifi_udp_port0; | |
286 | u_int64_t ifi_udp_badlength; | |
287 | u_int64_t ifi_udp_badchksum; | |
288 | u_int64_t ifi_udp_badmcast; | |
289 | u_int64_t ifi_udp_cleanup; | |
290 | u_int64_t ifi_udp_badipsec; | |
291 | u_int64_t _reserved[4]; | |
316670eb A |
292 | }; |
293 | ||
294 | struct if_description { | |
0a7de745 A |
295 | u_int32_t ifd_maxlen; /* must be IF_DESCSIZE */ |
296 | u_int32_t ifd_len; /* actual ifd_desc length */ | |
297 | u_int8_t *ifd_desc; /* ptr to desc buffer */ | |
316670eb A |
298 | }; |
299 | ||
300 | struct if_bandwidths { | |
f427ee49 A |
301 | uint64_t eff_bw; /* effective bandwidth */ |
302 | uint64_t max_bw; /* maximum theoretical bandwidth */ | |
316670eb A |
303 | }; |
304 | ||
39236c6e | 305 | struct if_latencies { |
0a7de745 A |
306 | u_int64_t eff_lt; /* effective latency */ |
307 | u_int64_t max_lt; /* maximum theoretical latency */ | |
39236c6e A |
308 | }; |
309 | ||
cb323159 A |
310 | #define IF_NETEM_PARAMS_PSCALE 100000 |
311 | struct if_netem_params { | |
312 | /* bandwidth limit */ | |
313 | uint64_t ifnetem_bandwidth_bps; | |
314 | ||
315 | /* latency (normal distribution with jitter as stdev) */ | |
316 | uint32_t ifnetem_latency_ms; | |
317 | uint32_t ifnetem_jitter_ms; | |
318 | ||
319 | /* | |
320 | * NetEm probabilistic model parameters has a scaling factor of 100,000 | |
321 | * for 5 digits precision. For instance, probability 12.345% is | |
322 | * expressed as uint32_t fixed point 12345 in ifnet_*_p variable below. | |
323 | */ | |
324 | /* random packet corruption */ | |
325 | uint32_t ifnetem_corruption_p; | |
326 | ||
327 | /* random packet duplication */ | |
328 | uint32_t ifnetem_duplication_p; | |
329 | ||
330 | /* 4 state Markov loss model */ | |
331 | uint32_t ifnetem_loss_p_gr_gl; /* P( gap_loss | gap_rx ) */ | |
332 | uint32_t ifnetem_loss_p_gr_bl; /* P( burst_loss | gap_rx ) */ | |
333 | uint32_t ifnetem_loss_p_bl_br; /* P( burst_rx | burst_loss ) */ | |
334 | uint32_t ifnetem_loss_p_bl_gr; /* P( gap_rx | burst_loss ) */ | |
335 | uint32_t ifnetem_loss_p_br_bl; /* P( burst_loss | burst_rx ) */ | |
336 | ||
337 | /* random packet reordering */ | |
338 | uint32_t ifnetem_reordering_p; | |
339 | }; | |
340 | ||
316670eb | 341 | struct if_rxpoll_stats { |
0a7de745 A |
342 | u_int32_t ifi_poll_off_req; /* total # of POLL_OFF reqs */ |
343 | u_int32_t ifi_poll_off_err; /* total # of POLL_OFF errors */ | |
344 | u_int32_t ifi_poll_on_req; /* total # of POLL_ON reqs */ | |
345 | u_int32_t ifi_poll_on_err; /* total # of POLL_ON errors */ | |
346 | ||
347 | u_int32_t ifi_poll_wakeups_avg; /* avg # of wakeup reqs */ | |
348 | u_int32_t ifi_poll_wakeups_lowat; /* wakeups low watermark */ | |
349 | u_int32_t ifi_poll_wakeups_hiwat; /* wakeups high watermark */ | |
350 | ||
351 | u_int64_t ifi_poll_packets; /* total # of polled packets */ | |
352 | u_int32_t ifi_poll_packets_avg; /* average polled packets */ | |
353 | u_int32_t ifi_poll_packets_min; /* smallest polled packets */ | |
354 | u_int32_t ifi_poll_packets_max; /* largest polled packets */ | |
355 | u_int32_t ifi_poll_packets_lowat; /* packets low watermark */ | |
356 | u_int32_t ifi_poll_packets_hiwat; /* packets high watermark */ | |
357 | ||
358 | u_int64_t ifi_poll_bytes; /* total # of polled bytes */ | |
359 | u_int32_t ifi_poll_bytes_avg; /* average polled bytes */ | |
360 | u_int32_t ifi_poll_bytes_min; /* smallest polled bytes */ | |
361 | u_int32_t ifi_poll_bytes_max; /* largest polled bytes */ | |
362 | u_int32_t ifi_poll_bytes_lowat; /* bytes low watermark */ | |
363 | u_int32_t ifi_poll_bytes_hiwat; /* bytes high watermark */ | |
364 | ||
365 | u_int32_t ifi_poll_packets_limit; /* max packets per poll call */ | |
366 | u_int64_t ifi_poll_interval_time; /* poll interval (nsec) */ | |
d41d1dae | 367 | }; |
3e170ce0 | 368 | |
cb323159 A |
369 | struct if_netif_stats { |
370 | u_int64_t ifn_rx_mit_interval; /* rx mitigation ival (nsec) */ | |
371 | u_int32_t ifn_rx_mit_mode; /* 0: static, 1: dynamic */ | |
372 | u_int32_t ifn_rx_mit_packets_avg; /* average # of packets */ | |
373 | u_int32_t ifn_rx_mit_packets_min; /* smallest # of packets */ | |
374 | u_int32_t ifn_rx_mit_packets_max; /* largest # of packets */ | |
375 | u_int32_t ifn_rx_mit_bytes_avg; /* average # of bytes */ | |
376 | u_int32_t ifn_rx_mit_bytes_min; /* smallest # of bytes */ | |
377 | u_int32_t ifn_rx_mit_bytes_max; /* largest # of bytes */ | |
378 | u_int32_t ifn_rx_mit_cfg_idx; /* current config selector */ | |
379 | u_int32_t ifn_rx_mit_cfg_packets_lowat; /* pkts low watermark */ | |
380 | u_int32_t ifn_rx_mit_cfg_packets_hiwat; /* pkts high watermark */ | |
381 | u_int32_t ifn_rx_mit_cfg_bytes_lowat; /* bytes low watermark */ | |
382 | u_int32_t ifn_rx_mit_cfg_bytes_hiwat; /* bytes high watermark */ | |
383 | u_int32_t ifn_rx_mit_cfg_interval; /* delay interval (nsec) */ | |
384 | }; | |
385 | ||
4bd07ac2 | 386 | struct if_tcp_ecn_perf_stat { |
490019cf A |
387 | u_int64_t total_txpkts; |
388 | u_int64_t total_rxmitpkts; | |
389 | u_int64_t total_rxpkts; | |
390 | u_int64_t total_oopkts; | |
391 | u_int64_t total_reorderpkts; | |
4bd07ac2 A |
392 | u_int64_t rtt_avg; |
393 | u_int64_t rtt_var; | |
4bd07ac2 | 394 | u_int64_t sack_episodes; |
490019cf A |
395 | u_int64_t rxmit_drop; |
396 | u_int64_t rst_drop; | |
397 | u_int64_t oo_percent; | |
4bd07ac2 A |
398 | u_int64_t reorder_percent; |
399 | u_int64_t rxmit_percent; | |
4bd07ac2 A |
400 | }; |
401 | ||
402 | struct if_tcp_ecn_stat { | |
403 | u_int64_t timestamp; | |
404 | u_int64_t ecn_client_setup; | |
405 | u_int64_t ecn_server_setup; | |
406 | u_int64_t ecn_client_success; | |
407 | u_int64_t ecn_server_success; | |
408 | u_int64_t ecn_peer_nosupport; | |
409 | u_int64_t ecn_syn_lost; | |
410 | u_int64_t ecn_synack_lost; | |
411 | u_int64_t ecn_recv_ce; | |
412 | u_int64_t ecn_recv_ece; | |
413 | u_int64_t ecn_conn_recv_ce; | |
414 | u_int64_t ecn_conn_recv_ece; | |
415 | u_int64_t ecn_conn_plnoce; | |
416 | u_int64_t ecn_conn_plce; | |
417 | u_int64_t ecn_conn_noplce; | |
418 | u_int64_t ecn_fallback_synloss; | |
419 | u_int64_t ecn_fallback_reorder; | |
420 | u_int64_t ecn_fallback_ce; | |
490019cf A |
421 | u_int64_t ecn_off_conn; |
422 | u_int64_t ecn_total_conn; | |
39037602 A |
423 | u_int64_t ecn_fallback_droprst; |
424 | u_int64_t ecn_fallback_droprxmt; | |
5ba3f43e | 425 | u_int64_t ecn_fallback_synrst; |
4bd07ac2 A |
426 | struct if_tcp_ecn_perf_stat ecn_on; |
427 | struct if_tcp_ecn_perf_stat ecn_off; | |
428 | }; | |
429 | ||
5ba3f43e | 430 | struct if_lim_perf_stat { |
0a7de745 A |
431 | u_int64_t lim_dl_max_bandwidth; /* bits per second */ |
432 | u_int64_t lim_ul_max_bandwidth; /* bits per second */ | |
433 | u_int64_t lim_total_txpkts; /* Total transmit packets, count */ | |
434 | u_int64_t lim_total_rxpkts; /* Total receive packets, count */ | |
435 | u_int64_t lim_total_retxpkts; /* Total retransmit packets */ | |
5ba3f43e | 436 | u_int64_t lim_packet_loss_percent; /* Packet loss rate */ |
0a7de745 | 437 | u_int64_t lim_total_oopkts; /* Total out-of-order packets */ |
5ba3f43e | 438 | u_int64_t lim_packet_ooo_percent; /* Out-of-order packet rate */ |
0a7de745 A |
439 | u_int64_t lim_rtt_variance; /* RTT variance, milliseconds */ |
440 | u_int64_t lim_rtt_average; /* RTT average, milliseconds */ | |
441 | u_int64_t lim_rtt_min; /* RTT minimum, milliseconds */ | |
442 | u_int64_t lim_conn_timeouts; /* connection timeouts */ | |
443 | u_int64_t lim_conn_attempts; /* connection attempts */ | |
5ba3f43e | 444 | u_int64_t lim_conn_timeout_percent; /* Rate of connection timeouts */ |
0a7de745 A |
445 | u_int64_t lim_bk_txpkts; /* Transmit packets with BK service class, that use delay based algorithms */ |
446 | u_int64_t lim_dl_detected:1, /* Low internet */ | |
447 | lim_ul_detected:1; | |
5ba3f43e A |
448 | }; |
449 | ||
450 | #define IF_VAR_H_HAS_IFNET_STATS_PER_FLOW 1 | |
451 | struct ifnet_stats_per_flow { | |
452 | u_int64_t bk_txpackets; | |
453 | u_int64_t txpackets; | |
454 | u_int64_t rxpackets; | |
455 | u_int32_t txretransmitbytes; | |
456 | u_int32_t rxoutoforderbytes; | |
457 | u_int32_t rxmitpkts; | |
458 | u_int32_t rcvoopack; | |
459 | u_int32_t pawsdrop; | |
460 | u_int32_t sack_recovery_episodes; | |
461 | u_int32_t reordered_pkts; | |
462 | u_int32_t dsack_sent; | |
463 | u_int32_t dsack_recvd; | |
464 | u_int32_t srtt; | |
465 | u_int32_t rttupdated; | |
466 | u_int32_t rttvar; | |
467 | u_int32_t rttmin; | |
468 | u_int32_t bw_sndbw_max; | |
469 | u_int32_t bw_rcvbw_max; | |
470 | u_int32_t ecn_recv_ece; | |
471 | u_int32_t ecn_recv_ce; | |
472 | u_int16_t ecn_flags; | |
473 | u_int16_t ipv4:1, | |
474 | local:1, | |
475 | connreset:1, | |
476 | conntimeout:1, | |
477 | rxmit_drop:1, | |
478 | ecn_fallback_synloss:1, | |
479 | ecn_fallback_droprst:1, | |
480 | ecn_fallback_droprxmt:1, | |
481 | ecn_fallback_ce:1, | |
482 | ecn_fallback_reorder:1; | |
483 | }; | |
484 | ||
3e170ce0 A |
485 | /* |
486 | * Interface link status report -- includes statistics related to | |
487 | * the link layer technology sent by the driver. The driver will monitor | |
488 | * these statistics over an interval (3-4 secs) and will generate a report | |
489 | * to the network stack. This will give first-hand information about the | |
490 | * status of the first hop of the network path. The version and | |
491 | * length values should be correct for the data to be processed correctly. | |
492 | * The definitions are different for different kind of interfaces like | |
493 | * Wifi, Cellular etc,. | |
494 | */ | |
0a7de745 A |
495 | #define IF_CELLULAR_STATUS_REPORT_VERSION_1 1 |
496 | #define IF_WIFI_STATUS_REPORT_VERSION_1 1 | |
497 | #define IF_CELLULAR_STATUS_REPORT_CURRENT_VERSION \ | |
498 | IF_CELLULAR_STATUS_REPORT_VERSION_1 | |
499 | #define IF_WIFI_STATUS_REPORT_CURRENT_VERSION IF_WIFI_STATUS_REPORT_VERSION_1 | |
3e170ce0 A |
500 | /* |
501 | * For cellular interface -- | |
502 | * There is no way to share common headers between the Baseband and | |
503 | * the kernel. Any changes to this structure will need to be communicated | |
504 | * to the Baseband team. It is better to use reserved space instead of | |
505 | * changing the size or existing fields in the structure. | |
506 | */ | |
507 | struct if_cellular_status_v1 { | |
508 | u_int32_t valid_bitmask; /* indicates which fields are valid */ | |
0a7de745 A |
509 | #define IF_CELL_LINK_QUALITY_METRIC_VALID 0x1 |
510 | #define IF_CELL_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
511 | #define IF_CELL_UL_MAX_BANDWIDTH_VALID 0x4 | |
512 | #define IF_CELL_UL_MIN_LATENCY_VALID 0x8 | |
513 | #define IF_CELL_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
514 | #define IF_CELL_UL_MAX_LATENCY_VALID 0x20 | |
515 | #define IF_CELL_UL_RETXT_LEVEL_VALID 0x40 | |
516 | #define IF_CELL_UL_BYTES_LOST_VALID 0x80 | |
517 | #define IF_CELL_UL_MIN_QUEUE_SIZE_VALID 0x100 | |
518 | #define IF_CELL_UL_AVG_QUEUE_SIZE_VALID 0x200 | |
519 | #define IF_CELL_UL_MAX_QUEUE_SIZE_VALID 0x400 | |
520 | #define IF_CELL_DL_EFFECTIVE_BANDWIDTH_VALID 0x800 | |
521 | #define IF_CELL_DL_MAX_BANDWIDTH_VALID 0x1000 | |
522 | #define IF_CELL_CONFIG_INACTIVITY_TIME_VALID 0x2000 | |
523 | #define IF_CELL_CONFIG_BACKOFF_TIME_VALID 0x4000 | |
524 | #define IF_CELL_UL_MSS_RECOMMENDED_VALID 0x8000 | |
39037602 | 525 | |
3e170ce0 A |
526 | u_int32_t link_quality_metric; |
527 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */ | |
528 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */ | |
529 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */ | |
530 | u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */ | |
531 | u_int32_t ul_max_latency; /* max expected uplink latency first hop (ms) */ | |
532 | u_int32_t ul_retxt_level; /* Retransmission metric */ | |
0a7de745 A |
533 | #define IF_CELL_UL_RETXT_LEVEL_NONE 1 |
534 | #define IF_CELL_UL_RETXT_LEVEL_LOW 2 | |
535 | #define IF_CELL_UL_RETXT_LEVEL_MEDIUM 3 | |
536 | #define IF_CELL_UL_RETXT_LEVEL_HIGH 4 | |
3e170ce0 A |
537 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */ |
538 | u_int32_t ul_min_queue_size; /* minimum bytes in queue */ | |
539 | u_int32_t ul_avg_queue_size; /* average bytes in queue */ | |
540 | u_int32_t ul_max_queue_size; /* maximum bytes in queue */ | |
541 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */ | |
542 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */ | |
543 | u_int32_t config_inactivity_time; /* ms */ | |
544 | u_int32_t config_backoff_time; /* new connections backoff time in ms */ | |
0a7de745 A |
545 | #define IF_CELL_UL_MSS_RECOMMENDED_NONE 0x0 /* Use default */ |
546 | #define IF_CELL_UL_MSS_RECOMMENDED_MEDIUM 0x1 /* 1200 byte MSS */ | |
547 | #define IF_CELL_UL_MSS_RECOMMENDED_LOW 0x2 /* 512 byte MSS */ | |
39037602 A |
548 | u_int16_t mss_recommended; |
549 | u_int16_t reserved_1; | |
550 | u_int32_t reserved_2; | |
3e170ce0 A |
551 | u_int64_t reserved_3; |
552 | u_int64_t reserved_4; | |
553 | u_int64_t reserved_5; | |
39037602 | 554 | u_int64_t reserved_6; |
3e170ce0 A |
555 | } __attribute__((packed)); |
556 | ||
557 | struct if_cellular_status { | |
558 | union { | |
559 | struct if_cellular_status_v1 if_status_v1; | |
560 | } if_cell_u; | |
561 | }; | |
562 | ||
563 | /* | |
564 | * These statistics will be provided by the Wifi driver periodically. | |
565 | * After sending each report, the driver should start computing again | |
566 | * for the next report duration so that the values represent the link | |
567 | * status for one report duration. | |
568 | */ | |
569 | ||
570 | struct if_wifi_status_v1 { | |
571 | u_int32_t valid_bitmask; | |
0a7de745 A |
572 | #define IF_WIFI_LINK_QUALITY_METRIC_VALID 0x1 |
573 | #define IF_WIFI_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
574 | #define IF_WIFI_UL_MAX_BANDWIDTH_VALID 0x4 | |
575 | #define IF_WIFI_UL_MIN_LATENCY_VALID 0x8 | |
576 | #define IF_WIFI_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
577 | #define IF_WIFI_UL_MAX_LATENCY_VALID 0x20 | |
578 | #define IF_WIFI_UL_RETXT_LEVEL_VALID 0x40 | |
579 | #define IF_WIFI_UL_ERROR_RATE_VALID 0x80 | |
580 | #define IF_WIFI_UL_BYTES_LOST_VALID 0x100 | |
581 | #define IF_WIFI_DL_EFFECTIVE_BANDWIDTH_VALID 0x200 | |
582 | #define IF_WIFI_DL_MAX_BANDWIDTH_VALID 0x400 | |
583 | #define IF_WIFI_DL_MIN_LATENCY_VALID 0x800 | |
584 | #define IF_WIFI_DL_EFFECTIVE_LATENCY_VALID 0x1000 | |
585 | #define IF_WIFI_DL_MAX_LATENCY_VALID 0x2000 | |
586 | #define IF_WIFI_DL_ERROR_RATE_VALID 0x4000 | |
587 | #define IF_WIFI_CONFIG_FREQUENCY_VALID 0x8000 | |
588 | #define IF_WIFI_CONFIG_MULTICAST_RATE_VALID 0x10000 | |
589 | #define IF_WIFI_CONFIG_SCAN_COUNT_VALID 0x20000 | |
590 | #define IF_WIFI_CONFIG_SCAN_DURATION_VALID 0x40000 | |
3e170ce0 A |
591 | u_int32_t link_quality_metric; /* link quality metric */ |
592 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */ | |
593 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */ | |
594 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */ | |
595 | u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */ | |
596 | u_int32_t ul_max_latency; /* max expected uplink latency for first hop (ms) */ | |
597 | u_int32_t ul_retxt_level; /* Retransmission metric */ | |
0a7de745 A |
598 | #define IF_WIFI_UL_RETXT_LEVEL_NONE 1 |
599 | #define IF_WIFI_UL_RETXT_LEVEL_LOW 2 | |
600 | #define IF_WIFI_UL_RETXT_LEVEL_MEDIUM 3 | |
601 | #define IF_WIFI_UL_RETXT_LEVEL_HIGH 4 | |
3e170ce0 A |
602 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */ |
603 | u_int32_t ul_error_rate; /* % of bytes dropped on uplink after many retransmissions in Q10 format */ | |
604 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */ | |
605 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */ | |
606 | /* | |
607 | * The download latency values indicate the time AP may have to wait for the | |
608 | * driver to receive the packet. These values give the range of expected latency | |
609 | * mainly due to co-existence events and channel hopping where the interface | |
610 | * becomes unavailable. | |
611 | */ | |
612 | u_int32_t dl_min_latency; /* min expected latency for first hop in ms */ | |
613 | u_int32_t dl_effective_latency; /* current expected latency for first hop in ms */ | |
614 | u_int32_t dl_max_latency; /* max expected latency for first hop in ms */ | |
615 | u_int32_t dl_error_rate; /* % of CRC or other errors in Q10 format */ | |
616 | u_int32_t config_frequency; /* 2.4 or 5 GHz */ | |
0a7de745 A |
617 | #define IF_WIFI_CONFIG_FREQUENCY_2_4_GHZ 1 |
618 | #define IF_WIFI_CONFIG_FREQUENCY_5_0_GHZ 2 | |
3e170ce0 A |
619 | u_int32_t config_multicast_rate; /* bps */ |
620 | u_int32_t scan_count; /* scan count during the previous period */ | |
621 | u_int32_t scan_duration; /* scan duration in ms */ | |
622 | u_int64_t reserved_1; | |
623 | u_int64_t reserved_2; | |
624 | u_int64_t reserved_3; | |
625 | u_int64_t reserved_4; | |
626 | } __attribute__((packed)); | |
627 | ||
628 | struct if_wifi_status { | |
629 | union { | |
630 | struct if_wifi_status_v1 if_status_v1; | |
631 | } if_wifi_u; | |
632 | }; | |
633 | ||
634 | struct if_link_status { | |
0a7de745 A |
635 | u_int32_t ifsr_version; /* version of this report */ |
636 | u_int32_t ifsr_len; /* length of the following struct */ | |
3e170ce0 A |
637 | union { |
638 | struct if_cellular_status ifsr_cell; | |
639 | struct if_wifi_status ifsr_wifi; | |
640 | } ifsr_u; | |
641 | }; | |
642 | ||
643 | struct if_interface_state { | |
644 | /* | |
645 | * The bitmask tells which of the fields | |
646 | * to consider: | |
647 | * - When setting, to control which fields | |
648 | * are being modified; | |
649 | * - When getting, it tells which fields are set. | |
650 | */ | |
651 | u_int8_t valid_bitmask; | |
0a7de745 A |
652 | #define IF_INTERFACE_STATE_RRC_STATE_VALID 0x1 |
653 | #define IF_INTERFACE_STATE_LQM_STATE_VALID 0x2 | |
654 | #define IF_INTERFACE_STATE_INTERFACE_AVAILABILITY_VALID 0x4 | |
3e170ce0 A |
655 | |
656 | /* | |
657 | * Valid only for cellular interface | |
658 | */ | |
659 | u_int8_t rrc_state; | |
0a7de745 A |
660 | #define IF_INTERFACE_STATE_RRC_STATE_IDLE 0x0 |
661 | #define IF_INTERFACE_STATE_RRC_STATE_CONNECTED 0x1 | |
3e170ce0 A |
662 | |
663 | /* | |
664 | * Values normalized to the edge of the following values | |
665 | * that are defined on <net/if.h>: | |
666 | * IFNET_LQM_THRESH_BAD | |
667 | * IFNET_LQM_THRESH_POOR | |
668 | * IFNET_LQM_THRESH_GOOD | |
669 | */ | |
670 | int8_t lqm_state; | |
671 | ||
672 | /* | |
673 | * Indicate if the underlying link is currently | |
39037602 | 674 | * available |
3e170ce0 A |
675 | */ |
676 | u_int8_t interface_availability; | |
0a7de745 A |
677 | #define IF_INTERFACE_STATE_INTERFACE_AVAILABLE 0x0 |
678 | #define IF_INTERFACE_STATE_INTERFACE_UNAVAILABLE 0x1 | |
3e170ce0 A |
679 | }; |
680 | ||
681 | struct chain_len_stats { | |
0a7de745 A |
682 | uint64_t cls_one; |
683 | uint64_t cls_two; | |
684 | uint64_t cls_three; | |
685 | uint64_t cls_four; | |
686 | uint64_t cls_five_or_more; | |
687 | } __attribute__((__aligned__(sizeof(uint64_t)))); | |
3e170ce0 | 688 | |
cb323159 A |
689 | /* |
690 | * This structure is used to define the parameters for advisory notifications | |
691 | * on an interface. | |
692 | */ | |
693 | #pragma pack(push, 1) | |
694 | struct ifnet_interface_advisory { | |
695 | /* The current structure version */ | |
696 | uint8_t version; | |
697 | #define IF_INTERFACE_ADVISORY_VERSION_1 0x1 | |
698 | #define IF_INTERFACE_ADVISORY_VERSION_CURRENT IF_INTERFACE_ADVISORY_VERSION_1 | |
699 | /* Specifies if the advisory is for transmit or receive path */ | |
700 | uint8_t direction; | |
701 | #define IF_INTERFACE_ADVISORY_DIRECTION_TX 0x1 | |
702 | #define IF_INTERFACE_ADVISORY_DIRECTION_RX 0x2 | |
703 | /* reserved for future use */ | |
704 | uint16_t _reserved; | |
705 | /* | |
706 | * suggestion for data rate change to keep the latency low. | |
707 | * unit: bits per second (bps) | |
708 | * NOTE: if the interface cannot provide suggestions in terms of bps, | |
709 | * it should use the following values: | |
710 | * INT32_MAX : ramp up | |
711 | * INT32_MIN : ramp down | |
712 | * 0 : neutral | |
713 | */ | |
714 | #define IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_UP INT32_MAX | |
715 | #define IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_DOWN INT32_MIN | |
716 | #define IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_NEUTRAL 0 | |
717 | int32_t rate_trend_suggestion; | |
718 | /* | |
719 | * Time of the issue of advisory. | |
720 | * Timestamp should be in the host domain. | |
721 | * unit: mach absolute time | |
722 | */ | |
723 | uint64_t timestamp; | |
724 | /* | |
725 | * Maximum theoretical bandwidth of the interface. | |
726 | * unit: bits per second (bps) | |
727 | */ | |
728 | uint64_t max_bandwidth; | |
729 | /* | |
730 | * Total bytes sent or received on the interface. | |
731 | * wrap around possible and the application should account for that. | |
732 | * unit: byte | |
733 | */ | |
734 | uint64_t total_byte_count; | |
735 | /* | |
736 | * average throughput observed at the driver stack. | |
737 | * unit: bits per second (bps) | |
738 | */ | |
739 | uint64_t average_throughput; | |
740 | /* | |
741 | * flushable queue size at the driver. | |
742 | * should be set to UINT32_MAX if not available. | |
743 | * unit: byte | |
744 | */ | |
745 | uint32_t flushable_queue_size; | |
746 | /* | |
747 | * non flushable queue size at the driver. | |
748 | * should be set to UINT32_MAX if not available. | |
749 | * unit: byte | |
750 | */ | |
751 | uint32_t non_flushable_queue_size; | |
752 | /* | |
753 | * average delay observed at the interface. | |
754 | * unit: milliseconds (ms) | |
755 | */ | |
756 | uint32_t average_delay; | |
757 | } __attribute__((aligned(sizeof(uint64_t)))); | |
758 | #pragma pack(pop) | |
759 | ||
6d2010ae A |
760 | #endif /* PRIVATE */ |
761 | ||
762 | #pragma pack() | |
d41d1dae | 763 | |
6d2010ae A |
764 | /* |
765 | * Structure defining a queue for a network interface. | |
766 | */ | |
0a7de745 A |
767 | struct ifqueue { |
768 | void *ifq_head; | |
769 | void *ifq_tail; | |
770 | int ifq_len; | |
771 | int ifq_maxlen; | |
772 | int ifq_drops; | |
6d2010ae A |
773 | }; |
774 | ||
316670eb | 775 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 | 776 | #define IFNETS_MAX 64 |
d9a64523 | 777 | |
91447636 A |
778 | /* |
779 | * Internal storage of if_data. This is bound to change. Various places in the | |
780 | * stack will translate this data structure in to the externally visible | |
6d2010ae A |
781 | * if_data structure above. Note that during interface attach time, the |
782 | * embedded if_data structure in ifnet is cleared, with the exception of | |
783 | * some non-statistics related fields. | |
91447636 A |
784 | */ |
785 | struct if_data_internal { | |
786 | /* generic interface information */ | |
0a7de745 A |
787 | u_char ifi_type; /* ethernet, tokenring, etc */ |
788 | u_char ifi_typelen; /* Length of frame type id */ | |
789 | u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ | |
790 | u_char ifi_addrlen; /* media address length */ | |
791 | u_char ifi_hdrlen; /* media header length */ | |
792 | u_char ifi_recvquota; /* polling quota for receive intrs */ | |
793 | u_char ifi_xmitquota; /* polling quota for xmit intrs */ | |
794 | u_char ifi_unused1; /* for future use */ | |
795 | u_int32_t ifi_mtu; /* maximum transmission unit */ | |
796 | u_int32_t ifi_metric; /* routing metric (external only) */ | |
797 | u_int32_t ifi_baudrate; /* linespeed */ | |
1c79356b | 798 | /* volatile statistics */ |
0a7de745 A |
799 | u_int64_t ifi_ipackets; /* packets received on interface */ |
800 | u_int64_t ifi_ierrors; /* input errors on interface */ | |
801 | u_int64_t ifi_opackets; /* packets sent on interface */ | |
802 | u_int64_t ifi_oerrors; /* output errors on interface */ | |
803 | u_int64_t ifi_collisions; /* collisions on csma interfaces */ | |
804 | u_int64_t ifi_ibytes; /* total number of octets received */ | |
805 | u_int64_t ifi_obytes; /* total number of octets sent */ | |
806 | u_int64_t ifi_imcasts; /* packets received via multicast */ | |
807 | u_int64_t ifi_omcasts; /* packets sent via multicast */ | |
808 | u_int64_t ifi_iqdrops; /* dropped on input, this interface */ | |
809 | u_int64_t ifi_noproto; /* destined for unsupported protocol */ | |
810 | u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ | |
811 | u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ | |
812 | u_int64_t ifi_alignerrs; /* unaligned (32-bit) input pkts */ | |
813 | u_int64_t ifi_dt_bytes; /* Data threshold counter */ | |
814 | u_int64_t ifi_fpackets; /* forwarded packets on interface */ | |
815 | u_int64_t ifi_fbytes; /* forwarded bytes on interface */ | |
816 | struct timeval ifi_lastchange; /* time of last administrative change */ | |
817 | struct timeval ifi_lastupdown; /* time of last up/down event */ | |
818 | u_int32_t ifi_hwassist; /* HW offload capabilities */ | |
819 | u_int32_t ifi_tso_v4_mtu; /* TCP Segment Offload IPv4 maximum segment size */ | |
820 | u_int32_t ifi_tso_v6_mtu; /* TCP Segment Offload IPv6 maximum segment size */ | |
1c79356b | 821 | }; |
316670eb | 822 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 823 | |
6d2010ae | 824 | #ifdef PRIVATE |
0a7de745 A |
825 | #define if_mtu if_data.ifi_mtu |
826 | #define if_type if_data.ifi_type | |
827 | #define if_typelen if_data.ifi_typelen | |
828 | #define if_physical if_data.ifi_physical | |
829 | #define if_addrlen if_data.ifi_addrlen | |
830 | #define if_hdrlen if_data.ifi_hdrlen | |
831 | #define if_metric if_data.ifi_metric | |
832 | #define if_baudrate if_data.ifi_baudrate | |
833 | #define if_hwassist if_data.ifi_hwassist | |
834 | #define if_ipackets if_data.ifi_ipackets | |
835 | #define if_ierrors if_data.ifi_ierrors | |
836 | #define if_opackets if_data.ifi_opackets | |
837 | #define if_oerrors if_data.ifi_oerrors | |
838 | #define if_collisions if_data.ifi_collisions | |
839 | #define if_ibytes if_data.ifi_ibytes | |
840 | #define if_obytes if_data.ifi_obytes | |
841 | #define if_imcasts if_data.ifi_imcasts | |
842 | #define if_omcasts if_data.ifi_omcasts | |
843 | #define if_iqdrops if_data.ifi_iqdrops | |
844 | #define if_noproto if_data.ifi_noproto | |
845 | #define if_lastchange if_data.ifi_lastchange | |
846 | #define if_recvquota if_data.ifi_recvquota | |
847 | #define if_xmitquota if_data.ifi_xmitquota | |
6d2010ae | 848 | #endif /* PRIVATE */ |
316670eb | 849 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 A |
850 | #define if_tso_v4_mtu if_data.ifi_tso_v4_mtu |
851 | #define if_tso_v6_mtu if_data.ifi_tso_v6_mtu | |
852 | #define if_alignerrs if_data.ifi_alignerrs | |
853 | #define if_dt_bytes if_data.ifi_dt_bytes | |
854 | #define if_fpackets if_data.ifi_fpackets | |
855 | #define if_fbytes if_data.ifi_fbytes | |
856 | #define if_lastupdown if_data.ifi_lastupdown | |
316670eb | 857 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 858 | |
316670eb | 859 | #ifdef BSD_KERNEL_PRIVATE |
91447636 A |
860 | /* |
861 | * Forward structure declarations for function prototypes [sic]. | |
862 | */ | |
6d2010ae A |
863 | struct proc; |
864 | struct rtentry; | |
865 | struct socket; | |
91447636 | 866 | struct ifnet_filter; |
6d2010ae A |
867 | struct mbuf; |
868 | struct ifaddr; | |
869 | struct tqdummy; | |
870 | struct proto_hash_entry; | |
871 | struct dlil_threading_info; | |
316670eb A |
872 | struct tcpstat_local; |
873 | struct udpstat_local; | |
6d2010ae A |
874 | #if PF |
875 | struct pfi_kif; | |
876 | #endif /* PF */ | |
91447636 | 877 | |
6d2010ae A |
878 | /* we use TAILQs so that the order of instantiation is preserved in the list */ |
879 | TAILQ_HEAD(ifnethead, ifnet); | |
880 | TAILQ_HEAD(ifaddrhead, ifaddr); | |
6d2010ae A |
881 | LIST_HEAD(ifmultihead, ifmultiaddr); |
882 | TAILQ_HEAD(tailq_head, tqdummy); | |
91447636 A |
883 | TAILQ_HEAD(ifnet_filter_head, ifnet_filter); |
884 | TAILQ_HEAD(ddesc_head_name, dlil_demux_desc); | |
5c9f4661 A |
885 | |
886 | extern boolean_t intcoproc_unrestricted; | |
316670eb | 887 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 888 | |
6d2010ae A |
889 | #ifdef PRIVATE |
890 | /* | |
5ba3f43e | 891 | * All of the following IF_HWASSIST_* flags are defined in kpi_interface.h as |
6d2010ae A |
892 | * IFNET_* flags. These are redefined here as constants to avoid failures to |
893 | * build user level programs that can not include kpi_interface.h. It is | |
894 | * important to keep this in sync with the definitions in kpi_interface.h. | |
895 | * The corresponding constant for each definition is mentioned in the comment. | |
b0d623f7 | 896 | * |
6d2010ae | 897 | * Bottom 16 bits reserved for hardware checksum |
b0d623f7 | 898 | */ |
0a7de745 A |
899 | #define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP, IFNET_CSUM_IP */ |
900 | #define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP, IFNET_CSUM_TCP */ | |
901 | #define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP, IFNET_CSUM_UDP */ | |
902 | #define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments, IFNET_CSUM_FRAGMENT */ | |
903 | #define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation, IFNET_IP_FRAGMENT */ | |
904 | #define IF_HWASSIST_CSUM_TCPIPV6 0x0020 /* will csum TCPv6, IFNET_CSUM_TCPIPV6 */ | |
905 | #define IF_HWASSIST_CSUM_UDPIPV6 0x0040 /* will csum UDPv6, IFNET_CSUM_UDP */ | |
906 | #define IF_HWASSIST_CSUM_FRAGMENT_IPV6 0x0080 /* will do IPv6 fragmentation, IFNET_IPV6_FRAGMENT */ | |
907 | #define IF_HWASSIST_CSUM_PARTIAL 0x1000 /* simple Sum16 computation, IFNET_CSUM_PARTIAL */ | |
908 | #define IF_HWASSIST_CSUM_ZERO_INVERT 0x2000 /* capable of inverting csum of 0 to -0 (0xffff) */ | |
909 | #define IF_HWASSIST_CSUM_MASK 0xffff | |
910 | #define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK) | |
91447636 A |
911 | |
912 | /* VLAN support */ | |
0a7de745 A |
913 | #define IF_HWASSIST_VLAN_TAGGING 0x00010000 /* supports VLAN tagging, IFNET_VLAN_TAGGING */ |
914 | #define IF_HWASSIST_VLAN_MTU 0x00020000 /* supports VLAN MTU-sized packet (for software VLAN), IFNET_VLAN_MTU */ | |
b0d623f7 A |
915 | |
916 | /* TCP Segment Offloading support */ | |
917 | ||
0a7de745 A |
918 | #define IF_HWASSIST_TSO_V4 0x00200000 /* will do TCP Segment offload for IPv4, IFNET_TSO_IPV4 */ |
919 | #define IF_HWASSIST_TSO_V6 0x00400000 /* will do TCP Segment offload for IPv6, IFNET_TSO_IPV6 */ | |
2d21ac55 | 920 | #endif /* PRIVATE */ |
1c79356b | 921 | |
39236c6e | 922 | #ifdef PRIVATE |
0a7de745 | 923 | #define IFXNAMSIZ (IFNAMSIZ + 8) /* external name (name + unit) */ |
f427ee49 | 924 | #define IFNET_NETWORK_ID_LEN 32 |
39236c6e A |
925 | #endif |
926 | ||
316670eb A |
927 | #ifdef BSD_KERNEL_PRIVATE |
928 | /* | |
929 | * ifnet is private to BSD portion of kernel | |
930 | */ | |
39236c6e | 931 | #include <sys/mcache.h> |
6d2010ae A |
932 | #include <sys/tree.h> |
933 | #include <netinet/in.h> | |
39236c6e | 934 | #include <net/if_dl.h> |
316670eb | 935 | #include <net/classq/if_classq.h> |
39236c6e | 936 | #include <net/if_types.h> |
2d21ac55 | 937 | |
0a7de745 | 938 | RB_HEAD(ll_reach_tree, if_llreach); /* define struct ll_reach_tree */ |
91447636 | 939 | |
5ba3f43e A |
940 | |
941 | typedef errno_t (*dlil_input_func)(ifnet_t ifp, mbuf_t m_head, | |
942 | mbuf_t m_tail, const struct ifnet_stat_increment_param *s, | |
943 | boolean_t poll, struct thread *tp); | |
944 | typedef errno_t (*dlil_output_func)(ifnet_t interface, mbuf_t data); | |
945 | ||
f427ee49 A |
946 | typedef u_int8_t ipv6_router_mode_t; |
947 | ||
0a7de745 | 948 | #define if_name(ifp) ifp->if_xname |
1c79356b A |
949 | /* |
950 | * Structure defining a network interface. | |
951 | * | |
952 | * (Would like to call this struct ``if'', but C isn't PL/1.) | |
953 | */ | |
954 | struct ifnet { | |
6d2010ae A |
955 | /* |
956 | * Lock (RW or mutex) to protect this data structure (static storage.) | |
957 | */ | |
958 | decl_lck_rw_data(, if_lock); | |
0a7de745 A |
959 | void *if_softc; /* pointer to driver state */ |
960 | const char *if_name; /* name, e.g. ``en'' or ``lo'' */ | |
961 | const char *if_xname; /* external name (name + unit) */ | |
962 | struct if_description if_desc; /* extended description */ | |
963 | TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ | |
6d2010ae | 964 | TAILQ_ENTRY(ifnet) if_detaching_link; /* list of detaching ifnets */ |
0a7de745 | 965 | TAILQ_ENTRY(ifnet) if_ordered_link; /* list of ordered ifnets */ |
6d2010ae | 966 | |
cb323159 | 967 | decl_lck_mtx_data(, if_ref_lock); |
0a7de745 A |
968 | u_int32_t if_refflags; /* see IFRF flags below */ |
969 | u_int32_t if_refio; /* number of io ops to the underlying driver */ | |
cb323159 A |
970 | u_int32_t if_threads_pending; /* Threads created but waiting for first run */ |
971 | u_int32_t if_datamov; /* number of threads moving data */ | |
972 | u_int32_t if_drainers; /* number of draining threads */ | |
973 | u_int32_t if_suspend; /* number of suspend requests */ | |
6d2010ae | 974 | |
0a7de745 A |
975 | #define if_list if_link |
976 | struct ifaddrhead if_addrhead; /* linked list of addresses per if */ | |
977 | #define if_addrlist if_addrhead | |
978 | struct ifaddr *if_lladdr; /* link address (first/permanent) */ | |
6d2010ae | 979 | |
0a7de745 | 980 | u_int32_t if_qosmarking_mode; /* generation to use with NECP clients */ |
39037602 | 981 | |
0a7de745 A |
982 | int if_pcount; /* number of promiscuous listeners */ |
983 | struct bpf_if *if_bpf; /* packet filter structure */ | |
984 | u_short if_index; /* numeric abbreviation for this if */ | |
985 | short if_unit; /* sub-unit for lower level driver */ | |
986 | short if_timer; /* time 'til if_watchdog called */ | |
987 | short if_flags; /* up/down, broadcast, etc. */ | |
988 | u_int32_t if_eflags; /* see <net/if.h> */ | |
989 | u_int32_t if_xflags; /* see <net/if.h> */ | |
6d2010ae | 990 | |
0a7de745 A |
991 | int if_capabilities; /* interface features & capabilities */ |
992 | int if_capenable; /* enabled features & capabilities */ | |
6d2010ae | 993 | |
0a7de745 | 994 | void *if_linkmib; /* link-type-specific MIB data */ |
f427ee49 | 995 | uint32_t if_linkmiblen; /* length of above data */ |
6d2010ae A |
996 | |
997 | struct if_data_internal if_data __attribute__((aligned(8))); | |
998 | ||
0a7de745 A |
999 | ifnet_family_t if_family; /* value assigned by Apple */ |
1000 | ifnet_subfamily_t if_subfamily; /* value assigned by Apple */ | |
1001 | uintptr_t if_family_cookie; | |
5ba3f43e A |
1002 | volatile dlil_input_func if_input_dlil; |
1003 | volatile dlil_output_func if_output_dlil; | |
1004 | volatile ifnet_start_func if_start; | |
0a7de745 A |
1005 | ifnet_output_func if_output; |
1006 | ifnet_pre_enqueue_func if_pre_enqueue; | |
1007 | ifnet_ctl_func if_output_ctl; | |
1008 | ifnet_input_poll_func if_input_poll; | |
1009 | ifnet_ctl_func if_input_ctl; | |
1010 | ifnet_ioctl_func if_ioctl; | |
1011 | ifnet_set_bpf_tap if_set_bpf_tap; | |
1012 | ifnet_detached_func if_free; | |
1013 | ifnet_demux_func if_demux; | |
1014 | ifnet_event_func if_event; | |
1015 | ifnet_framer_func if_framer_legacy; | |
39236c6e | 1016 | ifnet_framer_extended_func if_framer; |
0a7de745 A |
1017 | ifnet_add_proto_func if_add_proto; |
1018 | ifnet_del_proto_func if_del_proto; | |
1019 | ifnet_check_multi if_check_multi; | |
1020 | struct proto_hash_entry *if_proto_hash; | |
1021 | void *if_kpi_storage; | |
1c79356b | 1022 | |
0a7de745 | 1023 | u_int32_t if_flowhash; /* interface flow control ID */ |
39236c6e | 1024 | |
316670eb | 1025 | decl_lck_mtx_data(, if_start_lock); |
0a7de745 A |
1026 | u_int32_t if_start_flags; /* see IFSF flags below */ |
1027 | u_int32_t if_start_req; | |
f427ee49 A |
1028 | u_int8_t if_start_embryonic; |
1029 | u_int8_t if_start_active; /* output is active */ | |
0a7de745 A |
1030 | u_int16_t if_start_delayed; |
1031 | u_int16_t if_start_delay_qlen; | |
1032 | u_int16_t if_start_delay_idle; | |
1033 | u_int64_t if_start_delay_swin; | |
1034 | u_int32_t if_start_delay_cnt; | |
1035 | u_int32_t if_start_delay_timeout; /* nanoseconds */ | |
1036 | struct timespec if_start_cycle; /* restart interval */ | |
1037 | struct thread *if_start_thread; | |
1038 | ||
1039 | struct ifclassq if_snd; /* transmit queue */ | |
1040 | u_int32_t if_output_sched_model; /* tx sched model */ | |
1041 | ||
1042 | struct if_bandwidths if_output_bw; | |
1043 | struct if_bandwidths if_input_bw; | |
1044 | ||
1045 | struct if_latencies if_output_lt; | |
1046 | struct if_latencies if_input_lt; | |
39236c6e | 1047 | |
cb323159 | 1048 | decl_lck_mtx_data(, if_flt_lock); |
0a7de745 A |
1049 | u_int32_t if_flt_busy; |
1050 | u_int32_t if_flt_waiters; | |
91447636 | 1051 | struct ifnet_filter_head if_flt_head; |
1c79356b | 1052 | |
0a7de745 A |
1053 | struct ifmultihead if_multiaddrs; /* multicast addresses */ |
1054 | u_int32_t if_updatemcasts; /* mcast addrs need updating */ | |
1055 | int if_amcount; /* # of all-multicast reqs */ | |
6d2010ae | 1056 | decl_lck_mtx_data(, if_addrconfig_lock); /* for serializing addr config */ |
0a7de745 | 1057 | struct in_multi *if_allhostsinm; /* store all-hosts inm for this ifp */ |
1c79356b | 1058 | |
cb323159 A |
1059 | /* |
1060 | * Opportunistic polling parameters. | |
1061 | */ | |
316670eb | 1062 | decl_lck_mtx_data(, if_poll_lock); |
cb323159 A |
1063 | struct if_poll_params { |
1064 | u_int16_t poll_req; | |
1065 | u_int16_t poll_update; /* link update */ | |
1066 | u_int32_t poll_flags; | |
1067 | #define IF_POLLF_READY 0x1 /* poll thread is ready */ | |
1068 | #define IF_POLLF_RUNNING 0x2 /* poll thread is running/active */ | |
f427ee49 | 1069 | #define IF_POLLF_EMBRYONIC 0x8000 /* poll thread is being setup */ |
cb323159 A |
1070 | struct timespec poll_cycle; /* poll interval */ |
1071 | struct thread *poll_thread; | |
1072 | ||
1073 | ifnet_model_t poll_mode; /* current mode */ | |
1074 | struct pktcntr poll_tstats; /* incremental polling statistics */ | |
1075 | struct if_rxpoll_stats poll_pstats; /* polling statistics */ | |
1076 | struct pktcntr poll_sstats; /* packets and bytes per sampling */ | |
1077 | struct timespec poll_mode_holdtime; /* mode holdtime in nsec */ | |
1078 | struct timespec poll_mode_lasttime; /* last mode change time in nsec */ | |
1079 | struct timespec poll_sample_holdtime; /* sampling holdtime in nsec */ | |
1080 | struct timespec poll_sample_lasttime; /* last sampling time in nsec */ | |
1081 | struct timespec poll_dbg_lasttime; /* last debug message time in nsec */ | |
1082 | } rxpoll_params; | |
1083 | #define if_poll_req rxpoll_params.poll_req | |
1084 | #define if_poll_update rxpoll_params.poll_update | |
1085 | #define if_poll_flags rxpoll_params.poll_flags | |
1086 | #define if_poll_cycle rxpoll_params.poll_cycle | |
1087 | #define if_poll_thread rxpoll_params.poll_thread | |
1088 | #define if_poll_mode rxpoll_params.poll_mode | |
1089 | #define if_poll_tstats rxpoll_params.poll_tstats | |
1090 | #define if_poll_sstats rxpoll_params.poll_sstats | |
1091 | #define if_poll_pstats rxpoll_params.poll_pstats | |
1092 | ||
1093 | #define if_poll_mode_holdtime rxpoll_params.poll_mode_holdtime | |
1094 | #define if_poll_mode_lasttime rxpoll_params.poll_mode_lasttime | |
1095 | #define if_poll_sample_holdtime rxpoll_params.poll_sample_holdtime | |
1096 | #define if_poll_sample_lasttime rxpoll_params.poll_sample_lasttime | |
1097 | #define if_poll_dbg_lasttime rxpoll_params.poll_dbg_lasttime | |
1098 | ||
1099 | #define if_rxpoll_offreq rxpoll_params.poll_pstats.ifi_poll_off_req | |
1100 | #define if_rxpoll_offerr rxpoll_params.poll_pstats.ifi_poll_off_err | |
1101 | #define if_rxpoll_onreq rxpoll_params.poll_pstats.ifi_poll_on_req | |
1102 | #define if_rxpoll_onerr rxpoll_params.poll_pstats.ifi_poll_on_err | |
1103 | #define if_rxpoll_wavg rxpoll_params.poll_pstats.ifi_poll_wakeups_avg | |
1104 | #define if_rxpoll_wlowat rxpoll_params.poll_pstats.ifi_poll_wakeups_lowat | |
1105 | #define if_rxpoll_whiwat rxpoll_params.poll_pstats.ifi_poll_wakeups_hiwat | |
1106 | #define if_rxpoll_pavg rxpoll_params.poll_pstats.ifi_poll_packets_avg | |
1107 | #define if_rxpoll_pmin rxpoll_params.poll_pstats.ifi_poll_packets_min | |
1108 | #define if_rxpoll_pmax rxpoll_params.poll_pstats.ifi_poll_packets_max | |
1109 | #define if_rxpoll_plowat rxpoll_params.poll_pstats.ifi_poll_packets_lowat | |
1110 | #define if_rxpoll_phiwat rxpoll_params.poll_pstats.ifi_poll_packets_hiwat | |
1111 | #define if_rxpoll_bavg rxpoll_params.poll_pstats.ifi_poll_bytes_avg | |
1112 | #define if_rxpoll_bmin rxpoll_params.poll_pstats.ifi_poll_bytes_min | |
1113 | #define if_rxpoll_bmax rxpoll_params.poll_pstats.ifi_poll_bytes_max | |
1114 | #define if_rxpoll_blowat rxpoll_params.poll_pstats.ifi_poll_bytes_lowat | |
1115 | #define if_rxpoll_bhiwat rxpoll_params.poll_pstats.ifi_poll_bytes_hiwat | |
1116 | #define if_rxpoll_plim rxpoll_params.poll_pstats.ifi_poll_packets_limit | |
1117 | #define if_rxpoll_ival rxpoll_params.poll_pstats.ifi_poll_interval_time | |
91447636 | 1118 | |
316670eb | 1119 | struct dlil_threading_info *if_inp; |
91447636 | 1120 | |
5ba3f43e | 1121 | /* allocated once along with dlil_ifnet and is never freed */ |
0a7de745 | 1122 | thread_call_t if_dt_tcall; |
5ba3f43e | 1123 | |
91447636 | 1124 | struct { |
0a7de745 | 1125 | u_int32_t length; |
91447636 | 1126 | union { |
0a7de745 A |
1127 | u_char buffer[8]; |
1128 | u_char *ptr; | |
91447636 A |
1129 | } u; |
1130 | } if_broadcast; | |
b0d623f7 | 1131 | |
b0d623f7 | 1132 | #if PF |
0a7de745 | 1133 | struct pfi_kif *if_pf_kif; |
b0d623f7 | 1134 | #endif /* PF */ |
1c79356b | 1135 | |
6d2010ae | 1136 | decl_lck_mtx_data(, if_cached_route_lock); |
0a7de745 A |
1137 | u_int32_t if_fwd_cacheok; |
1138 | struct route if_fwd_route; /* cached forwarding route */ | |
1139 | struct route if_src_route; /* cached ipv4 source route */ | |
1140 | struct route_in6 if_src_route6; /* cached ipv6 source route */ | |
91447636 | 1141 | |
6d2010ae | 1142 | decl_lck_rw_data(, if_llreach_lock); |
0a7de745 | 1143 | struct ll_reach_tree if_ll_srcs; /* source link-layer tree */ |
91447636 | 1144 | |
0a7de745 | 1145 | void *if_bridge; /* bridge glue */ |
6d2010ae | 1146 | |
0a7de745 A |
1147 | u_int32_t if_want_aggressive_drain; |
1148 | u_int32_t if_idle_flags; /* idle flags */ | |
1149 | u_int32_t if_idle_new_flags; /* temporary idle flags */ | |
1150 | u_int32_t if_idle_new_flags_mask; /* temporary mask */ | |
1151 | u_int32_t if_route_refcnt; /* idle: route ref count */ | |
1152 | u_int32_t if_rt_sendts; /* last of a real time packet */ | |
6d2010ae A |
1153 | |
1154 | struct if_traffic_class if_tc __attribute__((aligned(8))); | |
1155 | #if INET | |
0a7de745 | 1156 | struct igmp_ifinfo *if_igi; /* for IGMPv3 */ |
6d2010ae | 1157 | #endif /* INET */ |
0a7de745 | 1158 | struct mld_ifinfo *if_mli; /* for MLDv2 */ |
316670eb | 1159 | |
0a7de745 A |
1160 | struct tcpstat_local *if_tcp_stat; /* TCP specific stats */ |
1161 | struct udpstat_local *if_udp_stat; /* UDP specific stats */ | |
39236c6e A |
1162 | |
1163 | struct { | |
0a7de745 A |
1164 | int32_t level; /* cached logging level */ |
1165 | u_int32_t flags; /* cached logging flags */ | |
1166 | int32_t category; /* cached category */ | |
1167 | int32_t subcategory; /* cached subcategory */ | |
39236c6e A |
1168 | } if_log; |
1169 | ||
1170 | struct { | |
0a7de745 A |
1171 | struct ifnet *ifp; /* delegated ifp */ |
1172 | u_int32_t type; /* delegated i/f type */ | |
1173 | u_int32_t family; /* delegated i/f family */ | |
1174 | u_int32_t subfamily; /* delegated i/f sub-family */ | |
cb323159 A |
1175 | uint32_t expensive:1, /* delegated i/f expensive? */ |
1176 | constrained:1; /* delegated i/f constrained? */ | |
39236c6e A |
1177 | } if_delegated; |
1178 | ||
0a7de745 A |
1179 | uuid_t *if_agentids; /* network agents attached to interface */ |
1180 | u_int32_t if_agentcount; | |
3e170ce0 | 1181 | |
0a7de745 | 1182 | volatile uint32_t if_low_power_gencnt; |
d9a64523 | 1183 | |
0a7de745 A |
1184 | u_int32_t if_generation; /* generation to use with NECP clients */ |
1185 | u_int32_t if_fg_sendts; /* last send on a fg socket in seconds */ | |
39037602 | 1186 | |
0a7de745 | 1187 | u_int64_t if_data_threshold; |
39037602 A |
1188 | |
1189 | /* Total bytes in send socket buffer */ | |
0a7de745 | 1190 | int64_t if_sndbyte_total __attribute__ ((aligned(8))); |
39037602 | 1191 | /* Total unsent bytes in send socket buffer */ |
0a7de745 | 1192 | int64_t if_sndbyte_unsent __attribute__ ((aligned(8))); |
39037602 | 1193 | /* count of times, when there was data to send when sleep is impending */ |
0a7de745 | 1194 | uint32_t if_unsent_data_cnt; |
39236c6e | 1195 | |
3e170ce0 A |
1196 | #if INET |
1197 | decl_lck_rw_data(, if_inetdata_lock); | |
0a7de745 | 1198 | void *if_inetdata; |
3e170ce0 | 1199 | #endif /* INET */ |
39236c6e | 1200 | decl_lck_rw_data(, if_inet6data_lock); |
0a7de745 | 1201 | void *if_inet6data; |
3e170ce0 | 1202 | decl_lck_rw_data(, if_link_status_lock); |
0a7de745 A |
1203 | struct if_link_status *if_link_status; |
1204 | struct if_interface_state if_interface_state; | |
4bd07ac2 A |
1205 | struct if_tcp_ecn_stat *if_ipv4_stat; |
1206 | struct if_tcp_ecn_stat *if_ipv6_stat; | |
5ba3f43e A |
1207 | |
1208 | struct if_lim_perf_stat if_lim_stat; | |
cb323159 A |
1209 | |
1210 | uint32_t if_tcp_kao_max; | |
1211 | uint32_t if_tcp_kao_cnt; | |
1212 | ||
1213 | struct netem *if_output_netem; | |
f427ee49 A |
1214 | |
1215 | ipv6_router_mode_t if_ipv6_router_mode; /* see <netinet6/in6_var.h> */ | |
1216 | ||
1217 | uint8_t network_id[IFNET_NETWORK_ID_LEN]; | |
1218 | uint8_t network_id_len; | |
6d2010ae A |
1219 | }; |
1220 | ||
5ba3f43e A |
1221 | /* Interface event handling declarations */ |
1222 | extern struct eventhandler_lists_ctxt ifnet_evhdlr_ctxt; | |
1223 | ||
1224 | typedef enum { | |
1225 | INTF_EVENT_CODE_CREATED, | |
1226 | INTF_EVENT_CODE_REMOVED, | |
1227 | INTF_EVENT_CODE_STATUS_UPDATE, | |
1228 | INTF_EVENT_CODE_IPADDR_ATTACHED, | |
1229 | INTF_EVENT_CODE_IPADDR_DETACHED, | |
1230 | INTF_EVENT_CODE_LLADDR_UPDATE, | |
1231 | INTF_EVENT_CODE_MTU_CHANGED, | |
d9a64523 | 1232 | INTF_EVENT_CODE_LOW_POWER_UPDATE, |
5ba3f43e A |
1233 | } intf_event_code_t; |
1234 | ||
1235 | typedef void (*ifnet_event_fn)(struct eventhandler_entry_arg, struct ifnet *, struct sockaddr *, intf_event_code_t); | |
1236 | EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn); | |
1237 | ||
0a7de745 A |
1238 | #define IF_TCP_STATINC(_ifp, _s) do { \ |
1239 | if ((_ifp)->if_tcp_stat != NULL) \ | |
1240 | atomic_add_64(&(_ifp)->if_tcp_stat->_s, 1); \ | |
39236c6e A |
1241 | } while (0); |
1242 | ||
0a7de745 A |
1243 | #define IF_UDP_STATINC(_ifp, _s) do { \ |
1244 | if ((_ifp)->if_udp_stat != NULL) \ | |
1245 | atomic_add_64(&(_ifp)->if_udp_stat->_s, 1); \ | |
39236c6e A |
1246 | } while (0); |
1247 | ||
6d2010ae | 1248 | /* |
39236c6e | 1249 | * Valid values for if_refflags |
6d2010ae | 1250 | */ |
0a7de745 A |
1251 | #define IFRF_EMBRYONIC 0x1 /* ifnet is allocated; awaiting attach */ |
1252 | #define IFRF_ATTACHED 0x2 /* ifnet attach is completely done */ | |
1253 | #define IFRF_DETACHING 0x4 /* detach has been requested */ | |
cb323159 A |
1254 | #define IFRF_READY 0x8 /* data path is ready */ |
1255 | ||
0a7de745 | 1256 | #define IFRF_ATTACH_MASK \ |
5ba3f43e A |
1257 | (IFRF_EMBRYONIC|IFRF_ATTACHED|IFRF_DETACHING) |
1258 | ||
0a7de745 | 1259 | #define IF_FULLY_ATTACHED(_ifp) \ |
5ba3f43e | 1260 | (((_ifp)->if_refflags & IFRF_ATTACH_MASK) == IFRF_ATTACHED) |
cb323159 A |
1261 | |
1262 | #define IF_FULLY_ATTACHED_AND_READY(_ifp) \ | |
1263 | (IF_FULLY_ATTACHED(_ifp) && ((_ifp)->if_refflags & IFRF_READY)) | |
39236c6e A |
1264 | /* |
1265 | * Valid values for if_start_flags | |
1266 | */ | |
0a7de745 | 1267 | #define IFSF_FLOW_CONTROLLED 0x1 /* flow controlled */ |
39236c6e | 1268 | |
4a249263 A |
1269 | /* |
1270 | * Structure describing a `cloning' interface. | |
1271 | */ | |
1272 | struct if_clone { | |
0a7de745 A |
1273 | LIST_ENTRY(if_clone) ifc_list; /* on list of cloners */ |
1274 | decl_lck_mtx_data(, ifc_mutex); /* To serialize clone create/delete */ | |
1275 | const char *ifc_name; /* name of device, e.g. `vlan' */ | |
1276 | size_t ifc_namelen; /* length of name */ | |
1277 | u_int32_t ifc_minifs; /* minimum number of interfaces */ | |
1278 | u_int32_t ifc_maxunit; /* maximum unit number */ | |
1279 | unsigned char *ifc_units; /* bitmap to handle units */ | |
1280 | u_int32_t ifc_bmlen; /* bitmap length */ | |
1281 | u_int32_t ifc_zone_max_elem; /* Max elements for this zone type */ | |
1282 | u_int32_t ifc_softc_size; /* size of softc for the device */ | |
1283 | struct zone *ifc_zone; /* if_clone allocation zone */ | |
1284 | int (*ifc_create)(struct if_clone *, u_int32_t, void *); | |
1285 | int (*ifc_destroy)(struct ifnet *); | |
4a249263 A |
1286 | }; |
1287 | ||
0a7de745 A |
1288 | #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit, zone_max_elem, softc_size) { \ |
1289 | .ifc_list = { NULL, NULL }, \ | |
1290 | .ifc_mutex = {}, \ | |
1291 | .ifc_name = name, \ | |
1292 | .ifc_namelen = (sizeof (name) - 1), \ | |
1293 | .ifc_minifs = minifs, \ | |
1294 | .ifc_maxunit = maxunit, \ | |
1295 | .ifc_units = NULL, \ | |
1296 | .ifc_bmlen = 0, \ | |
1297 | .ifc_zone_max_elem = zone_max_elem, \ | |
1298 | .ifc_softc_size = softc_size, \ | |
1299 | .ifc_zone = NULL, \ | |
1300 | .ifc_create = create, \ | |
1301 | .ifc_destroy = destroy \ | |
6d2010ae | 1302 | } |
9bccf70c | 1303 | |
d1ecb069 A |
1304 | #define M_CLONE M_IFADDR |
1305 | ||
1c79356b | 1306 | /* |
6d2010ae A |
1307 | * Macros to manipulate ifqueue. Users of these macros are responsible |
1308 | * for serialization, by holding whatever lock is appropriate for the | |
1309 | * corresponding structure that is referring the ifqueue. | |
1c79356b | 1310 | */ |
0a7de745 A |
1311 | #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) |
1312 | #define IF_DROP(ifq) ((ifq)->ifq_drops++) | |
1313 | ||
1314 | #define IF_ENQUEUE(ifq, m) do { \ | |
1315 | (m)->m_nextpkt = NULL; \ | |
1316 | if ((ifq)->ifq_tail == NULL) \ | |
1317 | (ifq)->ifq_head = m; \ | |
1318 | else \ | |
1319 | ((struct mbuf*)(ifq)->ifq_tail)->m_nextpkt = m; \ | |
1320 | (ifq)->ifq_tail = m; \ | |
1321 | (ifq)->ifq_len++; \ | |
316670eb A |
1322 | } while (0) |
1323 | ||
0a7de745 A |
1324 | #define IF_PREPEND(ifq, m) do { \ |
1325 | (m)->m_nextpkt = (ifq)->ifq_head; \ | |
1326 | if ((ifq)->ifq_tail == NULL) \ | |
1327 | (ifq)->ifq_tail = (m); \ | |
1328 | (ifq)->ifq_head = (m); \ | |
1329 | (ifq)->ifq_len++; \ | |
316670eb A |
1330 | } while (0) |
1331 | ||
0a7de745 A |
1332 | #define IF_DEQUEUE(ifq, m) do { \ |
1333 | (m) = (ifq)->ifq_head; \ | |
1334 | if (m != NULL) { \ | |
1335 | if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \ | |
1336 | (ifq)->ifq_tail = NULL; \ | |
1337 | (m)->m_nextpkt = NULL; \ | |
1338 | (ifq)->ifq_len--; \ | |
1339 | } \ | |
316670eb A |
1340 | } while (0) |
1341 | ||
0a7de745 A |
1342 | #define IF_REMQUEUE(ifq, m) do { \ |
1343 | struct mbuf *_p = (ifq)->ifq_head; \ | |
1344 | struct mbuf *_n = (m)->m_nextpkt; \ | |
1345 | if ((m) == _p) \ | |
1346 | _p = NULL; \ | |
1347 | while (_p != NULL) { \ | |
1348 | if (_p->m_nextpkt == (m)) \ | |
1349 | break; \ | |
1350 | _p = _p->m_nextpkt; \ | |
1351 | } \ | |
1352 | VERIFY(_p != NULL || ((m) == (ifq)->ifq_head)); \ | |
1353 | if ((m) == (ifq)->ifq_head) \ | |
1354 | (ifq)->ifq_head = _n; \ | |
1355 | if ((m) == (ifq)->ifq_tail) \ | |
1356 | (ifq)->ifq_tail = _p; \ | |
1357 | VERIFY((ifq)->ifq_tail != NULL || (ifq)->ifq_head == NULL); \ | |
1358 | VERIFY((ifq)->ifq_len != 0); \ | |
1359 | --(ifq)->ifq_len; \ | |
1360 | if (_p != NULL) \ | |
1361 | _p->m_nextpkt = _n; \ | |
1362 | (m)->m_nextpkt = NULL; \ | |
316670eb A |
1363 | } while (0) |
1364 | ||
0a7de745 A |
1365 | #define IF_DRAIN(ifq) do { \ |
1366 | struct mbuf *_m; \ | |
1367 | for (;;) { \ | |
1368 | IF_DEQUEUE(ifq, _m); \ | |
1369 | if (_m == NULL) \ | |
1370 | break; \ | |
1371 | m_freem(_m); \ | |
1372 | } \ | |
6d2010ae | 1373 | } while (0) |
1c79356b | 1374 | |
1c79356b A |
1375 | /* |
1376 | * The ifaddr structure contains information about one address | |
1377 | * of an interface. They are maintained by the different address families, | |
1378 | * are allocated and attached when an address is set, and are linked | |
1379 | * together so all addresses for an interface can be located. | |
1380 | */ | |
1381 | struct ifaddr { | |
0a7de745 A |
1382 | decl_lck_mtx_data(, ifa_lock); /* lock for ifaddr */ |
1383 | uint32_t ifa_refcnt; /* ref count, use IFA_{ADD,REM}REF */ | |
1384 | uint32_t ifa_debug; /* debug flags */ | |
1385 | struct sockaddr *ifa_addr; /* address of interface */ | |
1386 | struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ | |
1387 | #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ | |
1388 | struct sockaddr *ifa_netmask; /* used to determine subnet */ | |
1389 | struct ifnet *ifa_ifp; /* back-pointer to interface */ | |
1390 | TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ | |
1391 | void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ | |
1392 | (int, struct rtentry *, struct sockaddr *); | |
1393 | uint32_t ifa_flags; /* mostly rt_flags for cloning */ | |
1394 | int32_t ifa_metric; /* cost of going out this interface */ | |
b0d623f7 | 1395 | void (*ifa_free)(struct ifaddr *); /* callback fn for freeing */ |
0a7de745 A |
1396 | void (*ifa_trace) /* callback fn for tracing refs */ |
1397 | (struct ifaddr *, int); | |
6d2010ae A |
1398 | void (*ifa_attached)(struct ifaddr *); /* callback fn for attaching */ |
1399 | void (*ifa_detached)(struct ifaddr *); /* callback fn for detaching */ | |
cb323159 A |
1400 | void *ifa_del_wc; /* Wait channel to avoid address deletion races */ |
1401 | int ifa_del_waiters; /* Threads in wait to delete the address */ | |
5ba3f43e A |
1402 | #if __arm__ && (__BIGGEST_ALIGNMENT__ > 4) |
1403 | /* For the newer ARMv7k ABI where 64-bit types are 64-bit aligned, but pointers | |
1404 | * are 32-bit: | |
1405 | * Align to 64-bit since we cast to this to struct in6_ifaddr, which is | |
1406 | * 64-bit aligned | |
1407 | */ | |
1408 | } __attribute__ ((aligned(8))); | |
1409 | #else | |
1c79356b | 1410 | }; |
5ba3f43e | 1411 | #endif |
b0d623f7 | 1412 | |
3e170ce0 | 1413 | |
b0d623f7 A |
1414 | /* |
1415 | * Valid values for ifa_flags | |
1416 | */ | |
0a7de745 A |
1417 | #define IFA_ROUTE RTF_UP /* route installed (0x1) */ |
1418 | #define IFA_CLONING RTF_CLONING /* (0x100) */ | |
b0d623f7 A |
1419 | |
1420 | /* | |
1421 | * Valid values for ifa_debug | |
1422 | */ | |
0a7de745 A |
1423 | #define IFD_ATTACHED 0x1 /* attached to list */ |
1424 | #define IFD_ALLOC 0x2 /* dynamically allocated */ | |
1425 | #define IFD_DEBUG 0x4 /* has debugging info */ | |
1426 | #define IFD_LINK 0x8 /* link address */ | |
1427 | #define IFD_TRASHED 0x10 /* in trash list */ | |
1428 | #define IFD_DETACHING 0x20 /* detach is in progress */ | |
1429 | #define IFD_NOTREADY 0x40 /* embryonic; not yet ready */ | |
1430 | ||
1431 | #define IFA_LOCK_ASSERT_HELD(_ifa) \ | |
5ba3f43e | 1432 | LCK_MTX_ASSERT(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_OWNED) |
6d2010ae | 1433 | |
0a7de745 | 1434 | #define IFA_LOCK_ASSERT_NOTHELD(_ifa) \ |
5ba3f43e | 1435 | LCK_MTX_ASSERT(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_NOTOWNED) |
6d2010ae | 1436 | |
0a7de745 | 1437 | #define IFA_LOCK(_ifa) \ |
6d2010ae A |
1438 | lck_mtx_lock(&(_ifa)->ifa_lock) |
1439 | ||
0a7de745 | 1440 | #define IFA_LOCK_SPIN(_ifa) \ |
6d2010ae A |
1441 | lck_mtx_lock_spin(&(_ifa)->ifa_lock) |
1442 | ||
0a7de745 A |
1443 | #define IFA_CONVERT_LOCK(_ifa) do { \ |
1444 | IFA_LOCK_ASSERT_HELD(_ifa); \ | |
1445 | lck_mtx_convert_spin(&(_ifa)->ifa_lock); \ | |
6d2010ae A |
1446 | } while (0) |
1447 | ||
0a7de745 | 1448 | #define IFA_UNLOCK(_ifa) \ |
6d2010ae A |
1449 | lck_mtx_unlock(&(_ifa)->ifa_lock) |
1450 | ||
0a7de745 | 1451 | #define IFA_ADDREF(_ifa) \ |
6d2010ae A |
1452 | ifa_addref(_ifa, 0) |
1453 | ||
0a7de745 | 1454 | #define IFA_ADDREF_LOCKED(_ifa) \ |
6d2010ae A |
1455 | ifa_addref(_ifa, 1) |
1456 | ||
0a7de745 A |
1457 | #define IFA_REMREF(_ifa) do { \ |
1458 | (void) ifa_remref(_ifa, 0); \ | |
6d2010ae A |
1459 | } while (0) |
1460 | ||
0a7de745 | 1461 | #define IFA_REMREF_LOCKED(_ifa) \ |
6d2010ae | 1462 | ifa_remref(_ifa, 1) |
1c79356b | 1463 | |
1c79356b A |
1464 | /* |
1465 | * Multicast address structure. This is analogous to the ifaddr | |
1466 | * structure except that it keeps track of multicast addresses. | |
6d2010ae A |
1467 | * Also, the request count here is a count of requests for this |
1468 | * address, not a count of pointers to this structure; anonymous | |
1469 | * membership(s) holds one outstanding request count. | |
1c79356b A |
1470 | */ |
1471 | struct ifmultiaddr { | |
6d2010ae | 1472 | decl_lck_mtx_data(, ifma_lock); |
0a7de745 A |
1473 | u_int32_t ifma_refcount; /* reference count */ |
1474 | u_int32_t ifma_anoncnt; /* # of anonymous requests */ | |
1475 | u_int32_t ifma_reqcnt; /* total requests for this address */ | |
1476 | u_int32_t ifma_debug; /* see ifa_debug flags */ | |
1477 | u_int32_t ifma_flags; /* see below */ | |
1c79356b | 1478 | LIST_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ |
0a7de745 A |
1479 | struct sockaddr *ifma_addr; /* address this membership is for */ |
1480 | struct ifmultiaddr *ifma_ll; /* link-layer translation, if any */ | |
1481 | struct ifnet *ifma_ifp; /* back-pointer to interface */ | |
1482 | void *ifma_protospec; /* protocol-specific state, if any */ | |
1483 | void (*ifma_trace) /* callback fn for tracing refs */ | |
1484 | (struct ifmultiaddr *, int); | |
1c79356b | 1485 | }; |
1c79356b | 1486 | |
91447636 | 1487 | /* |
6d2010ae | 1488 | * Values for ifma_flags |
91447636 | 1489 | */ |
0a7de745 | 1490 | #define IFMAF_ANONYMOUS 0x1 /* has anonymous request ref(s) held */ |
6d2010ae | 1491 | |
0a7de745 | 1492 | #define IFMA_LOCK_ASSERT_HELD(_ifma) \ |
5ba3f43e | 1493 | LCK_MTX_ASSERT(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_OWNED) |
6d2010ae | 1494 | |
0a7de745 | 1495 | #define IFMA_LOCK_ASSERT_NOTHELD(_ifma) \ |
5ba3f43e | 1496 | LCK_MTX_ASSERT(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_NOTOWNED) |
6d2010ae | 1497 | |
0a7de745 | 1498 | #define IFMA_LOCK(_ifma) \ |
6d2010ae A |
1499 | lck_mtx_lock(&(_ifma)->ifma_lock) |
1500 | ||
0a7de745 | 1501 | #define IFMA_LOCK_SPIN(_ifma) \ |
6d2010ae A |
1502 | lck_mtx_lock_spin(&(_ifma)->ifma_lock) |
1503 | ||
0a7de745 A |
1504 | #define IFMA_CONVERT_LOCK(_ifma) do { \ |
1505 | IFMA_LOCK_ASSERT_HELD(_ifma); \ | |
1506 | lck_mtx_convert_spin(&(_ifma)->ifma_lock); \ | |
6d2010ae A |
1507 | } while (0) |
1508 | ||
0a7de745 | 1509 | #define IFMA_UNLOCK(_ifma) \ |
6d2010ae A |
1510 | lck_mtx_unlock(&(_ifma)->ifma_lock) |
1511 | ||
0a7de745 | 1512 | #define IFMA_ADDREF(_ifma) \ |
6d2010ae A |
1513 | ifma_addref(_ifma, 0) |
1514 | ||
0a7de745 | 1515 | #define IFMA_ADDREF_LOCKED(_ifma) \ |
6d2010ae A |
1516 | ifma_addref(_ifma, 1) |
1517 | ||
0a7de745 | 1518 | #define IFMA_REMREF(_ifma) \ |
6d2010ae A |
1519 | ifma_remref(_ifma) |
1520 | ||
39236c6e A |
1521 | /* |
1522 | * Indicate whether or not the immediate interface, or the interface delegated | |
1523 | * by it, is a cellular interface (IFT_CELLULAR). Delegated interface type is | |
1524 | * set/cleared along with the delegated ifp; we cache the type for performance | |
1525 | * to avoid dereferencing delegated ifp each time. | |
1526 | * | |
1527 | * Note that this is meant to be used only for accounting and policy purposes; | |
1528 | * certain places need to explicitly know the immediate interface type, and | |
1529 | * this macro should not be used there. | |
1530 | * | |
1531 | * The test is done against IFT_CELLULAR instead of IFNET_FAMILY_CELLULAR to | |
1532 | * handle certain cases where the family isn't set to the latter. | |
1533 | */ | |
0a7de745 A |
1534 | #define IFNET_IS_CELLULAR(_ifp) \ |
1535 | ((_ifp)->if_type == IFT_CELLULAR || \ | |
39236c6e A |
1536 | (_ifp)->if_delegated.type == IFT_CELLULAR) |
1537 | ||
4bd07ac2 A |
1538 | /* |
1539 | * Indicate whether or not the immediate interface, or the interface delegated | |
1540 | * by it, is an ETHERNET interface. | |
1541 | */ | |
0a7de745 A |
1542 | #define IFNET_IS_ETHERNET(_ifp) \ |
1543 | ((_ifp)->if_family == IFNET_FAMILY_ETHERNET || \ | |
4bd07ac2 | 1544 | (_ifp)->if_delegated.family == IFNET_FAMILY_ETHERNET) |
39236c6e A |
1545 | /* |
1546 | * Indicate whether or not the immediate interface, or the interface delegated | |
1547 | * by it, is a Wi-Fi interface (IFNET_SUBFAMILY_WIFI). Delegated interface | |
1548 | * subfamily is set/cleared along with the delegated ifp; we cache the subfamily | |
1549 | * for performance to avoid dereferencing delegated ifp each time. | |
1550 | * | |
1551 | * Note that this is meant to be used only for accounting and policy purposes; | |
1552 | * certain places need to explicitly know the immediate interface type, and | |
1553 | * this macro should not be used there. | |
1554 | * | |
1555 | * The test is done against IFNET_SUBFAMILY_WIFI as the family may be set to | |
1556 | * IFNET_FAMILY_ETHERNET (as well as type to IFT_ETHER) which is too generic. | |
1557 | */ | |
0a7de745 | 1558 | #define IFNET_IS_WIFI(_ifp) \ |
cb323159 A |
1559 | (((_ifp)->if_family == IFNET_FAMILY_ETHERNET && \ |
1560 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_WIFI) || \ | |
1561 | ((_ifp)->if_delegated.family == IFNET_FAMILY_ETHERNET && \ | |
1562 | (_ifp)->if_delegated.subfamily == IFNET_SUBFAMILY_WIFI)) | |
39236c6e | 1563 | |
fe8ab488 A |
1564 | /* |
1565 | * Indicate whether or not the immediate interface, or the interface delegated | |
1566 | * by it, is a Wired interface (several families). Delegated interface | |
1567 | * family is set/cleared along with the delegated ifp; we cache the family | |
1568 | * for performance to avoid dereferencing delegated ifp each time. | |
1569 | * | |
1570 | * Note that this is meant to be used only for accounting and policy purposes; | |
1571 | * certain places need to explicitly know the immediate interface type, and | |
1572 | * this macro should not be used there. | |
1573 | */ | |
0a7de745 A |
1574 | #define IFNET_IS_WIRED(_ifp) \ |
1575 | ((_ifp)->if_family == IFNET_FAMILY_ETHERNET || \ | |
1576 | (_ifp)->if_delegated.family == IFNET_FAMILY_ETHERNET || \ | |
1577 | (_ifp)->if_family == IFNET_FAMILY_FIREWIRE || \ | |
fe8ab488 A |
1578 | (_ifp)->if_delegated.family == IFNET_FAMILY_FIREWIRE) |
1579 | ||
39037602 A |
1580 | /* |
1581 | * Indicate whether or not the immediate WiFi interface is on an infrastructure | |
1582 | * network | |
1583 | */ | |
0a7de745 A |
1584 | #define IFNET_IS_WIFI_INFRA(_ifp) \ |
1585 | ((_ifp)->if_family == IFNET_FAMILY_ETHERNET && \ | |
1586 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_WIFI && \ | |
39037602 A |
1587 | !((_ifp)->if_eflags & IFEF_AWDL)) |
1588 | ||
cb323159 A |
1589 | /* |
1590 | * Indicate whether or not the immediate interface is a companion link | |
1591 | * interface. | |
1592 | */ | |
1593 | #define IFNET_IS_COMPANION_LINK(_ifp) \ | |
1594 | ((_ifp)->if_family == IFNET_FAMILY_IPSEC && \ | |
1595 | ((_ifp)->if_subfamily == IFNET_SUBFAMILY_BLUETOOTH || \ | |
1596 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_WIFI || \ | |
1597 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_QUICKRELAY || \ | |
1598 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_DEFAULT)) | |
1599 | ||
fe8ab488 A |
1600 | /* |
1601 | * Indicate whether or not the immediate interface, or the interface delegated | |
39037602 A |
1602 | * by it, is marked as expensive. The delegated interface is set/cleared |
1603 | * along with the delegated ifp; we cache the flag for performance to avoid | |
fe8ab488 A |
1604 | * dereferencing delegated ifp each time. |
1605 | * | |
1606 | * Note that this is meant to be used only for policy purposes. | |
1607 | */ | |
0a7de745 | 1608 | #define IFNET_IS_EXPENSIVE(_ifp) \ |
cb323159 | 1609 | ((_ifp)->if_eflags & IFEF_EXPENSIVE || \ |
fe8ab488 A |
1610 | (_ifp)->if_delegated.expensive) |
1611 | ||
0a7de745 A |
1612 | #define IFNET_IS_LOW_POWER(_ifp) \ |
1613 | (if_low_power_restricted != 0 && \ | |
1614 | ((_ifp)->if_xflags & IFXF_LOW_POWER) || \ | |
1615 | ((_ifp)->if_delegated.ifp != NULL && \ | |
d9a64523 A |
1616 | ((_ifp)->if_delegated.ifp->if_xflags & IFXF_LOW_POWER))) |
1617 | ||
cb323159 A |
1618 | #define IFNET_IS_CONSTRAINED(_ifp) \ |
1619 | ((_ifp)->if_xflags & IFXF_CONSTRAINED || \ | |
1620 | (_ifp)->if_delegated.constrained) | |
1621 | ||
fe8ab488 A |
1622 | /* |
1623 | * We don't support AWDL interface delegation. | |
1624 | */ | |
0a7de745 A |
1625 | #define IFNET_IS_AWDL_RESTRICTED(_ifp) \ |
1626 | (((_ifp)->if_eflags & (IFEF_AWDL|IFEF_AWDL_RESTRICTED)) == \ | |
fe8ab488 A |
1627 | (IFEF_AWDL|IFEF_AWDL_RESTRICTED)) |
1628 | ||
0a7de745 A |
1629 | #define IFNET_IS_INTCOPROC(_ifp) \ |
1630 | ((_ifp)->if_family == IFNET_FAMILY_ETHERNET && \ | |
39037602 | 1631 | (_ifp)->if_subfamily == IFNET_SUBFAMILY_INTCOPROC) |
fe8ab488 | 1632 | |
39236c6e | 1633 | extern struct ifnethead ifnet_head; |
39037602 | 1634 | extern struct ifnethead ifnet_ordered_head; |
39236c6e A |
1635 | extern struct ifnet **ifindex2ifnet; |
1636 | extern u_int32_t if_sndq_maxlen; | |
1637 | extern u_int32_t if_rcvq_maxlen; | |
1638 | extern int if_index; | |
1639 | extern struct ifaddr **ifnet_addrs; | |
1640 | extern lck_attr_t *ifa_mtx_attr; | |
1641 | extern lck_grp_t *ifa_mtx_grp; | |
1642 | extern lck_grp_t *ifnet_lock_group; | |
1643 | extern lck_attr_t *ifnet_lock_attr; | |
6d2010ae A |
1644 | extern ifnet_t lo_ifp; |
1645 | ||
1646 | extern int if_addmulti(struct ifnet *, const struct sockaddr *, | |
1647 | struct ifmultiaddr **); | |
1648 | extern int if_addmulti_anon(struct ifnet *, const struct sockaddr *, | |
1649 | struct ifmultiaddr **); | |
1650 | extern int if_allmulti(struct ifnet *, int); | |
1651 | extern int if_delmulti(struct ifnet *, const struct sockaddr *); | |
1652 | extern int if_delmulti_ifma(struct ifmultiaddr *); | |
1653 | extern int if_delmulti_anon(struct ifnet *, const struct sockaddr *); | |
1654 | extern void if_down(struct ifnet *); | |
1655 | extern int if_down_all(void); | |
1656 | extern void if_up(struct ifnet *); | |
1657 | __private_extern__ void if_updown(struct ifnet *ifp, int up); | |
1658 | extern int ifioctl(struct socket *, u_long, caddr_t, struct proc *); | |
1659 | extern int ifioctllocked(struct socket *, u_long, caddr_t, struct proc *); | |
1660 | extern struct ifnet *ifunit(const char *); | |
39037602 A |
1661 | extern struct ifnet *ifunit_ref(const char *); |
1662 | extern int ifunit_extract(const char *src, char *dst, size_t dstlen, int *unit); | |
6d2010ae | 1663 | extern struct ifnet *if_withname(struct sockaddr *); |
316670eb A |
1664 | extern void if_qflush(struct ifnet *, int); |
1665 | extern void if_qflush_sc(struct ifnet *, mbuf_svc_class_t, u_int32_t, | |
1666 | u_int32_t *, u_int32_t *, int); | |
6d2010ae A |
1667 | |
1668 | extern struct if_clone *if_clone_lookup(const char *, u_int32_t *); | |
1669 | extern int if_clone_attach(struct if_clone *); | |
1670 | extern void if_clone_detach(struct if_clone *); | |
d9a64523 A |
1671 | extern void *if_clone_softc_allocate(const struct if_clone *); |
1672 | extern void if_clone_softc_deallocate(const struct if_clone *, void *); | |
39037602 | 1673 | extern u_int32_t if_functional_type(struct ifnet *, bool); |
3e170ce0 | 1674 | |
6d2010ae A |
1675 | extern errno_t if_mcasts_update(struct ifnet *); |
1676 | ||
1677 | typedef enum { | |
0a7de745 A |
1678 | IFNET_LCK_ASSERT_EXCLUSIVE, /* RW: held as writer */ |
1679 | IFNET_LCK_ASSERT_SHARED, /* RW: held as reader */ | |
1680 | IFNET_LCK_ASSERT_OWNED, /* RW: writer/reader, MTX: held */ | |
1681 | IFNET_LCK_ASSERT_NOTOWNED /* not held */ | |
6d2010ae A |
1682 | } ifnet_lock_assert_t; |
1683 | ||
0a7de745 | 1684 | #define IF_LLADDR(_ifp) \ |
39236c6e A |
1685 | (LLADDR(SDL(((_ifp)->if_lladdr)->ifa_addr))) |
1686 | ||
0a7de745 | 1687 | #define IF_INDEX_IN_RANGE(_ind_) ((_ind_) > 0 && \ |
4d15aeb1 A |
1688 | (unsigned int)(_ind_) <= (unsigned int)if_index) |
1689 | ||
6d2010ae A |
1690 | __private_extern__ void ifnet_lock_assert(struct ifnet *, ifnet_lock_assert_t); |
1691 | __private_extern__ void ifnet_lock_shared(struct ifnet *ifp); | |
1692 | __private_extern__ void ifnet_lock_exclusive(struct ifnet *ifp); | |
1693 | __private_extern__ void ifnet_lock_done(struct ifnet *ifp); | |
1694 | ||
3e170ce0 A |
1695 | #if INET |
1696 | __private_extern__ void if_inetdata_lock_shared(struct ifnet *ifp); | |
1697 | __private_extern__ void if_inetdata_lock_exclusive(struct ifnet *ifp); | |
1698 | __private_extern__ void if_inetdata_lock_done(struct ifnet *ifp); | |
1699 | #endif | |
1700 | ||
39236c6e A |
1701 | __private_extern__ void if_inet6data_lock_shared(struct ifnet *ifp); |
1702 | __private_extern__ void if_inet6data_lock_exclusive(struct ifnet *ifp); | |
1703 | __private_extern__ void if_inet6data_lock_done(struct ifnet *ifp); | |
39236c6e | 1704 | |
0a7de745 A |
1705 | __private_extern__ void ifnet_head_lock_shared(void); |
1706 | __private_extern__ void ifnet_head_lock_exclusive(void); | |
1707 | __private_extern__ void ifnet_head_done(void); | |
1708 | __private_extern__ void ifnet_head_assert_exclusive(void); | |
6d2010ae A |
1709 | |
1710 | __private_extern__ errno_t ifnet_set_idle_flags_locked(ifnet_t, u_int32_t, | |
1711 | u_int32_t); | |
1712 | __private_extern__ int ifnet_is_attached(struct ifnet *, int refio); | |
cb323159 A |
1713 | __private_extern__ void ifnet_incr_pending_thread_count(struct ifnet *); |
1714 | __private_extern__ void ifnet_decr_pending_thread_count(struct ifnet *); | |
39037602 | 1715 | __private_extern__ void ifnet_incr_iorefcnt(struct ifnet *); |
6d2010ae | 1716 | __private_extern__ void ifnet_decr_iorefcnt(struct ifnet *); |
cb323159 A |
1717 | __private_extern__ boolean_t ifnet_datamov_begin(struct ifnet *); |
1718 | __private_extern__ void ifnet_datamov_end(struct ifnet *); | |
1719 | __private_extern__ void ifnet_datamov_suspend(struct ifnet *); | |
1720 | __private_extern__ void ifnet_datamov_drain(struct ifnet *); | |
1721 | __private_extern__ void ifnet_datamov_resume(struct ifnet *); | |
316670eb A |
1722 | __private_extern__ void ifnet_set_start_cycle(struct ifnet *, |
1723 | struct timespec *); | |
1724 | __private_extern__ void ifnet_set_poll_cycle(struct ifnet *, | |
1725 | struct timespec *); | |
6d2010ae A |
1726 | |
1727 | __private_extern__ void if_attach_ifa(struct ifnet *, struct ifaddr *); | |
1728 | __private_extern__ void if_attach_link_ifa(struct ifnet *, struct ifaddr *); | |
1729 | __private_extern__ void if_detach_ifa(struct ifnet *, struct ifaddr *); | |
1730 | __private_extern__ void if_detach_link_ifa(struct ifnet *, struct ifaddr *); | |
1731 | ||
7ddcb079 A |
1732 | __private_extern__ void dlil_if_lock(void); |
1733 | __private_extern__ void dlil_if_unlock(void); | |
1734 | __private_extern__ void dlil_if_lock_assert(void); | |
1735 | ||
6d2010ae | 1736 | extern struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); |
39037602 | 1737 | extern struct ifaddr *ifa_ifwithaddr_locked(const struct sockaddr *); |
316670eb A |
1738 | extern struct ifaddr *ifa_ifwithaddr_scoped(const struct sockaddr *, |
1739 | unsigned int); | |
39037602 A |
1740 | extern struct ifaddr *ifa_ifwithaddr_scoped_locked(const struct sockaddr *, |
1741 | unsigned int); | |
6d2010ae A |
1742 | extern struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); |
1743 | extern struct ifaddr *ifa_ifwithnet(const struct sockaddr *); | |
316670eb A |
1744 | extern struct ifaddr *ifa_ifwithnet_scoped(const struct sockaddr *, |
1745 | unsigned int); | |
6d2010ae A |
1746 | extern struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *, |
1747 | const struct sockaddr *); | |
0a7de745 | 1748 | extern struct ifaddr *ifa_ifwithroute_locked(int, const struct sockaddr *, |
316670eb A |
1749 | const struct sockaddr *); |
1750 | extern struct ifaddr *ifa_ifwithroute_scoped_locked(int, | |
1751 | const struct sockaddr *, const struct sockaddr *, unsigned int); | |
9d749ea3 | 1752 | extern struct ifaddr *ifaof_ifpforaddr_select(const struct sockaddr *, struct ifnet *); |
6d2010ae A |
1753 | extern struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); |
1754 | __private_extern__ struct ifaddr *ifa_ifpgetprimary(struct ifnet *, int); | |
1755 | extern void ifa_addref(struct ifaddr *, int); | |
1756 | extern struct ifaddr *ifa_remref(struct ifaddr *, int); | |
1757 | extern void ifa_lock_init(struct ifaddr *); | |
1758 | extern void ifa_lock_destroy(struct ifaddr *); | |
1759 | extern void ifma_addref(struct ifmultiaddr *, int); | |
1760 | extern void ifma_remref(struct ifmultiaddr *); | |
1761 | ||
1762 | extern void ifa_init(void); | |
1763 | ||
1764 | __private_extern__ struct in_ifaddr *ifa_foraddr(unsigned int); | |
1765 | __private_extern__ struct in_ifaddr *ifa_foraddr_scoped(unsigned int, | |
1766 | unsigned int); | |
1767 | ||
316670eb A |
1768 | struct ifreq; |
1769 | extern errno_t ifnet_getset_opportunistic(struct ifnet *, u_long, | |
1770 | struct ifreq *, struct proc *); | |
1771 | extern int ifnet_get_throttle(struct ifnet *, u_int32_t *); | |
1772 | extern int ifnet_set_throttle(struct ifnet *, u_int32_t); | |
39236c6e A |
1773 | extern errno_t ifnet_getset_log(struct ifnet *, u_long, |
1774 | struct ifreq *, struct proc *); | |
1775 | extern int ifnet_set_log(struct ifnet *, int32_t, uint32_t, int32_t, int32_t); | |
1776 | extern int ifnet_get_log(struct ifnet *, int32_t *, uint32_t *, int32_t *, | |
1777 | int32_t *); | |
1778 | extern int ifnet_notify_address(struct ifnet *, int); | |
5ba3f43e A |
1779 | extern void ifnet_notify_data_threshold(struct ifnet *); |
1780 | ||
1781 | #define IF_AFDATA_RLOCK if_afdata_rlock | |
1782 | #define IF_AFDATA_RUNLOCK if_afdata_unlock | |
1783 | #define IF_AFDATA_WLOCK if_afdata_wlock | |
1784 | #define IF_AFDATA_WUNLOCK if_afdata_unlock | |
1785 | #define IF_AFDATA_WLOCK_ASSERT if_afdata_wlock_assert | |
1786 | #define IF_AFDATA_LOCK_ASSERT if_afdata_lock_assert | |
1787 | #define IF_AFDATA_UNLOCK_ASSERT if_afdata_unlock_assert | |
1788 | ||
1789 | static inline void | |
0a7de745 | 1790 | if_afdata_rlock(struct ifnet *ifp, int af) |
5ba3f43e A |
1791 | { |
1792 | switch (af) { | |
1793 | #if INET | |
1794 | case AF_INET: | |
1795 | lck_rw_lock_shared(&ifp->if_inetdata_lock); | |
1796 | break; | |
1797 | #endif | |
5ba3f43e A |
1798 | case AF_INET6: |
1799 | lck_rw_lock_shared(&ifp->if_inet6data_lock); | |
1800 | break; | |
5ba3f43e A |
1801 | default: |
1802 | VERIFY(0); | |
1803 | /* NOTREACHED */ | |
1804 | } | |
1805 | return; | |
1806 | } | |
1807 | ||
1808 | static inline void | |
0a7de745 | 1809 | if_afdata_runlock(struct ifnet *ifp, int af) |
5ba3f43e A |
1810 | { |
1811 | switch (af) { | |
1812 | #if INET | |
1813 | case AF_INET: | |
1814 | lck_rw_done(&ifp->if_inetdata_lock); | |
1815 | break; | |
1816 | #endif | |
5ba3f43e A |
1817 | case AF_INET6: |
1818 | lck_rw_done(&ifp->if_inet6data_lock); | |
1819 | break; | |
5ba3f43e A |
1820 | default: |
1821 | VERIFY(0); | |
1822 | /* NOTREACHED */ | |
1823 | } | |
1824 | return; | |
1825 | } | |
1826 | ||
1827 | static inline void | |
0a7de745 | 1828 | if_afdata_wlock(struct ifnet *ifp, int af) |
5ba3f43e A |
1829 | { |
1830 | switch (af) { | |
1831 | #if INET | |
1832 | case AF_INET: | |
1833 | lck_rw_lock_exclusive(&ifp->if_inetdata_lock); | |
1834 | break; | |
1835 | #endif | |
5ba3f43e A |
1836 | case AF_INET6: |
1837 | lck_rw_lock_exclusive(&ifp->if_inet6data_lock); | |
1838 | break; | |
5ba3f43e A |
1839 | default: |
1840 | VERIFY(0); | |
1841 | /* NOTREACHED */ | |
1842 | } | |
1843 | return; | |
1844 | } | |
1845 | ||
1846 | static inline void | |
0a7de745 | 1847 | if_afdata_unlock(struct ifnet *ifp, int af) |
5ba3f43e A |
1848 | { |
1849 | switch (af) { | |
1850 | #if INET | |
1851 | case AF_INET: | |
1852 | lck_rw_done(&ifp->if_inetdata_lock); | |
1853 | break; | |
1854 | #endif | |
5ba3f43e A |
1855 | case AF_INET6: |
1856 | lck_rw_done(&ifp->if_inet6data_lock); | |
1857 | break; | |
5ba3f43e A |
1858 | default: |
1859 | VERIFY(0); | |
1860 | /* NOTREACHED */ | |
1861 | } | |
1862 | return; | |
1863 | } | |
1864 | ||
1865 | static inline void | |
0a7de745 | 1866 | if_afdata_wlock_assert(struct ifnet *ifp, int af) |
5ba3f43e A |
1867 | { |
1868 | #if !MACH_ASSERT | |
1869 | #pragma unused(ifp) | |
1870 | #endif | |
1871 | switch (af) { | |
1872 | #if INET | |
1873 | case AF_INET: | |
1874 | LCK_RW_ASSERT(&ifp->if_inetdata_lock, LCK_RW_ASSERT_EXCLUSIVE); | |
1875 | break; | |
1876 | #endif | |
5ba3f43e A |
1877 | case AF_INET6: |
1878 | LCK_RW_ASSERT(&ifp->if_inet6data_lock, LCK_RW_ASSERT_EXCLUSIVE); | |
1879 | break; | |
5ba3f43e A |
1880 | default: |
1881 | VERIFY(0); | |
1882 | /* NOTREACHED */ | |
1883 | } | |
1884 | return; | |
1885 | } | |
1886 | ||
1887 | static inline void | |
0a7de745 | 1888 | if_afdata_unlock_assert(struct ifnet *ifp, int af) |
5ba3f43e A |
1889 | { |
1890 | #if !MACH_ASSERT | |
1891 | #pragma unused(ifp) | |
1892 | #endif | |
1893 | switch (af) { | |
1894 | #if INET | |
1895 | case AF_INET: | |
1896 | LCK_RW_ASSERT(&ifp->if_inetdata_lock, LCK_RW_ASSERT_NOTHELD); | |
1897 | break; | |
1898 | #endif | |
5ba3f43e A |
1899 | case AF_INET6: |
1900 | LCK_RW_ASSERT(&ifp->if_inet6data_lock, LCK_RW_ASSERT_NOTHELD); | |
1901 | break; | |
5ba3f43e A |
1902 | default: |
1903 | VERIFY(0); | |
1904 | /* NOTREACHED */ | |
1905 | } | |
1906 | return; | |
1907 | } | |
1908 | ||
1909 | static inline void | |
0a7de745 | 1910 | if_afdata_lock_assert(struct ifnet *ifp, int af) |
5ba3f43e A |
1911 | { |
1912 | #if !MACH_ASSERT | |
1913 | #pragma unused(ifp) | |
1914 | #endif | |
1915 | switch (af) { | |
1916 | #if INET | |
1917 | case AF_INET: | |
1918 | LCK_RW_ASSERT(&ifp->if_inetdata_lock, LCK_RW_ASSERT_HELD); | |
1919 | break; | |
1920 | #endif | |
5ba3f43e A |
1921 | case AF_INET6: |
1922 | LCK_RW_ASSERT(&ifp->if_inet6data_lock, LCK_RW_ASSERT_HELD); | |
1923 | break; | |
5ba3f43e A |
1924 | default: |
1925 | VERIFY(0); | |
1926 | /* NOTREACHED */ | |
1927 | } | |
1928 | return; | |
1929 | } | |
316670eb | 1930 | |
6d2010ae A |
1931 | struct in6_addr; |
1932 | __private_extern__ struct in6_ifaddr *ifa_foraddr6(struct in6_addr *); | |
1933 | __private_extern__ struct in6_ifaddr *ifa_foraddr6_scoped(struct in6_addr *, | |
1934 | unsigned int); | |
6d2010ae A |
1935 | |
1936 | __private_extern__ void if_data_internal_to_if_data(struct ifnet *ifp, | |
1937 | const struct if_data_internal *if_data_int, struct if_data *if_data); | |
0a7de745 | 1938 | __private_extern__ void if_data_internal_to_if_data64(struct ifnet *ifp, |
6d2010ae | 1939 | const struct if_data_internal *if_data_int, struct if_data64 *if_data64); |
0a7de745 | 1940 | __private_extern__ void if_copy_traffic_class(struct ifnet *ifp, |
6d2010ae | 1941 | struct if_traffic_class *if_tc); |
0a7de745 | 1942 | __private_extern__ void if_copy_data_extended(struct ifnet *ifp, |
316670eb A |
1943 | struct if_data_extended *if_de); |
1944 | __private_extern__ void if_copy_packet_stats(struct ifnet *ifp, | |
1945 | struct if_packet_stats *if_ps); | |
1946 | __private_extern__ void if_copy_rxpoll_stats(struct ifnet *ifp, | |
1947 | struct if_rxpoll_stats *if_rs); | |
cb323159 A |
1948 | __private_extern__ void if_copy_netif_stats(struct ifnet *ifp, |
1949 | struct if_netif_stats *if_ns); | |
6d2010ae A |
1950 | |
1951 | __private_extern__ struct rtentry *ifnet_cached_rtlookup_inet(struct ifnet *, | |
1952 | struct in_addr); | |
6d2010ae A |
1953 | __private_extern__ struct rtentry *ifnet_cached_rtlookup_inet6(struct ifnet *, |
1954 | struct in6_addr *); | |
6d2010ae | 1955 | |
a39ff7e2 A |
1956 | __private_extern__ u_int32_t if_get_protolist(struct ifnet * ifp, |
1957 | u_int32_t *protolist, u_int32_t count); | |
1958 | __private_extern__ void if_free_protolist(u_int32_t *list); | |
3e170ce0 A |
1959 | __private_extern__ errno_t if_state_update(struct ifnet *, |
1960 | struct if_interface_state *); | |
1961 | __private_extern__ void if_get_state(struct ifnet *, | |
1962 | struct if_interface_state *); | |
1963 | __private_extern__ errno_t if_probe_connectivity(struct ifnet *ifp, | |
1964 | u_int32_t conn_probe); | |
1965 | __private_extern__ void if_lqm_update(struct ifnet *, int32_t, int); | |
316670eb A |
1966 | __private_extern__ void ifnet_update_sndq(struct ifclassq *, cqev_t); |
1967 | __private_extern__ void ifnet_update_rcv(struct ifnet *, cqev_t); | |
1968 | ||
39236c6e A |
1969 | __private_extern__ void ifnet_flowadv(uint32_t); |
1970 | ||
316670eb A |
1971 | __private_extern__ errno_t ifnet_set_input_bandwidths(struct ifnet *, |
1972 | struct if_bandwidths *); | |
1973 | __private_extern__ errno_t ifnet_set_output_bandwidths(struct ifnet *, | |
1974 | struct if_bandwidths *, boolean_t); | |
1975 | __private_extern__ u_int64_t ifnet_output_linkrate(struct ifnet *); | |
1976 | __private_extern__ u_int64_t ifnet_input_linkrate(struct ifnet *); | |
39236c6e A |
1977 | |
1978 | __private_extern__ errno_t ifnet_set_input_latencies(struct ifnet *, | |
1979 | struct if_latencies *); | |
1980 | __private_extern__ errno_t ifnet_set_output_latencies(struct ifnet *, | |
1981 | struct if_latencies *, boolean_t); | |
1982 | ||
3e170ce0 A |
1983 | __private_extern__ void ifnet_clear_netagent(uuid_t); |
1984 | ||
1985 | __private_extern__ int ifnet_set_netsignature(struct ifnet *, uint8_t, | |
1986 | uint8_t, uint16_t, uint8_t *); | |
1987 | __private_extern__ int ifnet_get_netsignature(struct ifnet *, uint8_t, | |
1988 | uint8_t *, uint16_t *, uint8_t *); | |
1989 | ||
5ba3f43e A |
1990 | struct ipv6_prefix; |
1991 | __private_extern__ int ifnet_set_nat64prefix(struct ifnet *, | |
1992 | struct ipv6_prefix *); | |
1993 | __private_extern__ int ifnet_get_nat64prefix(struct ifnet *, | |
1994 | struct ipv6_prefix *); | |
5ba3f43e | 1995 | |
39037602 A |
1996 | /* Required exclusive ifnet_head lock */ |
1997 | __private_extern__ void ifnet_remove_from_ordered_list(struct ifnet *); | |
1998 | ||
1999 | __private_extern__ void ifnet_increment_generation(struct ifnet *); | |
2000 | __private_extern__ u_int32_t ifnet_get_generation(struct ifnet *); | |
2001 | ||
5ba3f43e A |
2002 | /* Adding and deleting netagents will take ifnet lock */ |
2003 | __private_extern__ int if_add_netagent(struct ifnet *, uuid_t); | |
cb323159 | 2004 | __private_extern__ int if_add_netagent_locked(struct ifnet *, uuid_t); |
5ba3f43e | 2005 | __private_extern__ int if_delete_netagent(struct ifnet *, uuid_t); |
a39ff7e2 A |
2006 | __private_extern__ boolean_t if_check_netagent(struct ifnet *, uuid_t); |
2007 | ||
39037602 | 2008 | |
5ba3f43e A |
2009 | extern int if_set_qosmarking_mode(struct ifnet *, u_int32_t); |
2010 | __private_extern__ uint32_t ifnet_mbuf_packetpreamblelen(struct ifnet *); | |
2011 | __private_extern__ void intf_event_enqueue_nwk_wq_entry(struct ifnet *ifp, | |
2012 | struct sockaddr *addrp, uint32_t intf_event_code); | |
2013 | __private_extern__ void ifnet_update_stats_per_flow(struct ifnet_stats_per_flow *, | |
2014 | struct ifnet *); | |
cb323159 | 2015 | __private_extern__ int if_get_tcp_kao_max(struct ifnet *); |
f427ee49 | 2016 | #if XNU_TARGET_OS_OSX |
39236c6e A |
2017 | __private_extern__ errno_t ifnet_framer_stub(struct ifnet *, struct mbuf **, |
2018 | const struct sockaddr *, const char *, const char *, u_int32_t *, | |
2019 | u_int32_t *); | |
f427ee49 | 2020 | #endif /* XNU_TARGET_OS_OSX */ |
5ba3f43e A |
2021 | __private_extern__ void ifnet_enqueue_multi_setup(struct ifnet *, uint16_t, |
2022 | uint16_t); | |
2023 | __private_extern__ errno_t ifnet_enqueue_mbuf(struct ifnet *, struct mbuf *, | |
2024 | boolean_t, boolean_t *); | |
f427ee49 A |
2025 | __private_extern__ errno_t ifnet_enqueue_mbuf_chain(struct ifnet *, |
2026 | struct mbuf *, struct mbuf *, uint32_t, uint32_t, boolean_t, boolean_t *); | |
cb323159 A |
2027 | __private_extern__ int ifnet_enqueue_netem(void *handle, pktsched_pkt_t *pkts, |
2028 | uint32_t n_pkts); | |
d9a64523 A |
2029 | |
2030 | extern int if_low_power_verbose; | |
2031 | extern int if_low_power_restricted; | |
2032 | extern void if_low_power_evhdlr_init(void); | |
2033 | extern int if_set_low_power(struct ifnet *, bool); | |
f427ee49 A |
2034 | extern u_int32_t if_set_eflags(ifnet_t, u_int32_t); |
2035 | extern void if_clear_eflags(ifnet_t, u_int32_t); | |
2036 | extern u_int32_t if_set_xflags(ifnet_t, u_int32_t); | |
2037 | extern void if_clear_xflags(ifnet_t, u_int32_t); | |
d9a64523 | 2038 | |
316670eb A |
2039 | #endif /* BSD_KERNEL_PRIVATE */ |
2040 | #ifdef XNU_KERNEL_PRIVATE | |
2041 | /* for uuid.c */ | |
2042 | __private_extern__ int uuid_get_ethernet(u_int8_t *); | |
6d2010ae | 2043 | #endif /* XNU_KERNEL_PRIVATE */ |
1c79356b | 2044 | #endif /* !_NET_IF_VAR_H_ */ |