]>
Commit | Line | Data |
---|---|---|
6d2010ae | 1 | /* |
39037602 | 2 | * Copyright (c) 2010-2016 Apple Inc. All rights reserved. |
6d2010ae A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
39037602 | 5 | * |
6d2010ae 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. | |
39037602 | 14 | * |
6d2010ae A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
39037602 | 17 | * |
6d2010ae 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 | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
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. | |
39037602 | 25 | * |
6d2010ae A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | #ifndef __NTSTAT_H__ | |
29 | #define __NTSTAT_H__ | |
30 | #include <netinet/in.h> | |
39236c6e A |
31 | #include <net/if.h> |
32 | #include <net/if_var.h> | |
3e170ce0 | 33 | #include <netinet/tcp.h> |
6d2010ae A |
34 | |
35 | #ifdef PRIVATE | |
36 | #pragma pack(push, 4) | |
37 | #pragma mark -- Common Data Structures -- | |
38 | ||
39037602 | 39 | #define __NSTAT_REVISION__ 8 |
6d2010ae A |
40 | |
41 | typedef u_int32_t nstat_provider_id_t; | |
39037602 A |
42 | typedef u_int64_t nstat_src_ref_t; |
43 | typedef u_int64_t nstat_event_flags_t; | |
44 | ||
45 | // The following event definitions are very provisional.. | |
46 | enum | |
47 | { | |
48 | NSTAT_EVENT_SRC_ADDED = 0x00000001 | |
49 | ,NSTAT_EVENT_SRC_REMOVED = 0x00000002 | |
50 | ,NSTAT_EVENT_SRC_QUERIED = 0x00000004 | |
51 | ,NSTAT_EVENT_SRC_QUERIED_ALL = 0x00000008 | |
52 | ,NSTAT_EVENT_SRC_WILL_CHANGE_STATE = 0x00000010 | |
53 | ,NSTAT_EVENT_SRC_DID_CHANGE_STATE = 0x00000020 | |
54 | ,NSTAT_EVENT_SRC_WILL_CHANGE_OWNER = 0x00000040 | |
55 | ,NSTAT_EVENT_SRC_DID_CHANGE_OWNER = 0x00000080 | |
56 | ,NSTAT_EVENT_SRC_WILL_CHANGE_PROPERTY = 0x00000100 | |
57 | ,NSTAT_EVENT_SRC_DID_CHANGE_PROPERTY = 0x00000200 | |
58 | }; | |
6d2010ae A |
59 | |
60 | typedef struct nstat_counts | |
61 | { | |
62 | /* Counters */ | |
63 | u_int64_t nstat_rxpackets __attribute__((aligned(8))); | |
64 | u_int64_t nstat_rxbytes __attribute__((aligned(8))); | |
65 | u_int64_t nstat_txpackets __attribute__((aligned(8))); | |
66 | u_int64_t nstat_txbytes __attribute__((aligned(8))); | |
67 | ||
68 | u_int32_t nstat_rxduplicatebytes; | |
69 | u_int32_t nstat_rxoutoforderbytes; | |
70 | u_int32_t nstat_txretransmit; | |
39037602 | 71 | |
6d2010ae A |
72 | u_int32_t nstat_connectattempts; |
73 | u_int32_t nstat_connectsuccesses; | |
39037602 | 74 | |
6d2010ae A |
75 | u_int32_t nstat_min_rtt; |
76 | u_int32_t nstat_avg_rtt; | |
77 | u_int32_t nstat_var_rtt; | |
39236c6e A |
78 | |
79 | u_int64_t nstat_cell_rxbytes __attribute__((aligned(8))); | |
80 | u_int64_t nstat_cell_txbytes __attribute__((aligned(8))); | |
81 | u_int64_t nstat_wifi_rxbytes __attribute__((aligned(8))); | |
82 | u_int64_t nstat_wifi_txbytes __attribute__((aligned(8))); | |
fe8ab488 A |
83 | u_int64_t nstat_wired_rxbytes __attribute__((aligned(8))); |
84 | u_int64_t nstat_wired_txbytes __attribute__((aligned(8))); | |
6d2010ae A |
85 | } nstat_counts; |
86 | ||
fe8ab488 A |
87 | typedef struct nstat_sysinfo_keyval |
88 | { | |
89 | u_int32_t nstat_sysinfo_key; | |
90 | u_int32_t nstat_sysinfo_flags; | |
91 | union { | |
92 | int64_t nstat_sysinfo_scalar; | |
93 | double nstat_sysinfo_distribution; | |
94 | } u; | |
3e170ce0 | 95 | } __attribute__((packed)) nstat_sysinfo_keyval; |
fe8ab488 A |
96 | |
97 | #define NSTAT_SYSINFO_FLAG_SCALAR 0x0001 | |
98 | #define NSTAT_SYSINFO_FLAG_DISTRIBUTION 0x0002 | |
99 | ||
3e170ce0 A |
100 | #define NSTAT_MAX_MSG_SIZE 4096 |
101 | ||
fe8ab488 A |
102 | typedef struct nstat_sysinfo_counts |
103 | { | |
104 | /* Counters */ | |
105 | u_int32_t nstat_sysinfo_len; | |
106 | u_int32_t pad; | |
107 | u_int8_t nstat_sysinfo_keyvals[]; | |
3e170ce0 | 108 | } __attribute__((packed)) nstat_sysinfo_counts; |
fe8ab488 A |
109 | |
110 | enum | |
111 | { | |
112 | NSTAT_SYSINFO_KEY_MBUF_256B_TOTAL = 1 | |
113 | ,NSTAT_SYSINFO_KEY_MBUF_2KB_TOTAL = 2 | |
114 | ,NSTAT_SYSINFO_KEY_MBUF_4KB_TOTAL = 3 | |
115 | ,NSTAT_SYSINFO_KEY_SOCK_MBCNT = 4 | |
116 | ,NSTAT_SYSINFO_KEY_SOCK_ATMBLIMIT = 5 | |
117 | ,NSTAT_SYSINFO_KEY_IPV4_AVGRTT = 6 | |
118 | ,NSTAT_SYSINFO_KEY_IPV6_AVGRTT = 7 | |
119 | ,NSTAT_SYSINFO_KEY_SEND_PLR = 8 | |
120 | ,NSTAT_SYSINFO_KEY_RECV_PLR = 9 | |
121 | ,NSTAT_SYSINFO_KEY_SEND_TLRTO = 10 | |
122 | ,NSTAT_SYSINFO_KEY_SEND_REORDERRATE = 11 | |
3e170ce0 A |
123 | ,NSTAT_SYSINFO_CONNECTION_ATTEMPTS = 12 |
124 | ,NSTAT_SYSINFO_CONNECTION_ACCEPTS = 13 | |
125 | ,NSTAT_SYSINFO_ECN_CLIENT_SETUP = 14 | |
126 | ,NSTAT_SYSINFO_ECN_SERVER_SETUP = 15 | |
127 | ,NSTAT_SYSINFO_ECN_CLIENT_SUCCESS = 16 | |
128 | ,NSTAT_SYSINFO_ECN_SERVER_SUCCESS = 17 | |
129 | ,NSTAT_SYSINFO_ECN_NOT_SUPPORTED = 18 | |
130 | ,NSTAT_SYSINFO_ECN_LOST_SYN = 19 | |
131 | ,NSTAT_SYSINFO_ECN_LOST_SYNACK = 20 | |
132 | ,NSTAT_SYSINFO_ECN_RECV_CE = 21 | |
133 | ,NSTAT_SYSINFO_ECN_RECV_ECE = 22 | |
134 | ,NSTAT_SYSINFO_ECN_SENT_ECE = 23 | |
135 | ,NSTAT_SYSINFO_ECN_CONN_RECV_CE = 24 | |
136 | ,NSTAT_SYSINFO_ECN_CONN_PLNOCE = 25 | |
137 | ,NSTAT_SYSINFO_ECN_CONN_PL_CE = 26 | |
138 | ,NSTAT_SYSINFO_ECN_CONN_NOPL_CE = 27 | |
139 | ,NSTAT_SYSINFO_MBUF_16KB_TOTAL = 28 | |
140 | ,NSTAT_SYSINFO_ECN_CLIENT_ENABLED = 29 | |
141 | ,NSTAT_SYSINFO_ECN_SERVER_ENABLED = 30 | |
142 | ,NSTAT_SYSINFO_ECN_CONN_RECV_ECE = 31 | |
143 | ,NSTAT_SYSINFO_MBUF_MEM_RELEASED = 32 | |
144 | ,NSTAT_SYSINFO_MBUF_DRAIN_CNT = 33 | |
145 | ,NSTAT_SYSINFO_TFO_SYN_DATA_RCV = 34 | |
146 | ,NSTAT_SYSINFO_TFO_COOKIE_REQ_RCV = 35 | |
147 | ,NSTAT_SYSINFO_TFO_COOKIE_SENT = 36 | |
148 | ,NSTAT_SYSINFO_TFO_COOKIE_INVALID = 37 | |
149 | ,NSTAT_SYSINFO_TFO_COOKIE_REQ = 38 | |
150 | ,NSTAT_SYSINFO_TFO_COOKIE_RCV = 39 | |
151 | ,NSTAT_SYSINFO_TFO_SYN_DATA_SENT = 40 | |
152 | ,NSTAT_SYSINFO_TFO_SYN_DATA_ACKED = 41 | |
153 | ,NSTAT_SYSINFO_TFO_SYN_LOSS = 42 | |
154 | ,NSTAT_SYSINFO_TFO_BLACKHOLE = 43 | |
4bd07ac2 A |
155 | ,NSTAT_SYSINFO_ECN_FALLBACK_SYNLOSS = 44 |
156 | ,NSTAT_SYSINFO_ECN_FALLBACK_REORDER = 45 | |
157 | ,NSTAT_SYSINFO_ECN_FALLBACK_CE = 46 | |
158 | ,NSTAT_SYSINFO_ECN_IFNET_TYPE = 47 | |
159 | ,NSTAT_SYSINFO_ECN_IFNET_PROTO = 48 | |
160 | ,NSTAT_SYSINFO_ECN_IFNET_CLIENT_SETUP = 49 | |
161 | ,NSTAT_SYSINFO_ECN_IFNET_SERVER_SETUP = 50 | |
162 | ,NSTAT_SYSINFO_ECN_IFNET_CLIENT_SUCCESS = 51 | |
163 | ,NSTAT_SYSINFO_ECN_IFNET_SERVER_SUCCESS = 52 | |
164 | ,NSTAT_SYSINFO_ECN_IFNET_PEER_NOSUPPORT = 53 | |
165 | ,NSTAT_SYSINFO_ECN_IFNET_SYN_LOST = 54 | |
166 | ,NSTAT_SYSINFO_ECN_IFNET_SYNACK_LOST = 55 | |
167 | ,NSTAT_SYSINFO_ECN_IFNET_RECV_CE = 56 | |
168 | ,NSTAT_SYSINFO_ECN_IFNET_RECV_ECE = 57 | |
169 | ,NSTAT_SYSINFO_ECN_IFNET_SENT_ECE = 58 | |
170 | ,NSTAT_SYSINFO_ECN_IFNET_CONN_RECV_CE = 59 | |
171 | ,NSTAT_SYSINFO_ECN_IFNET_CONN_RECV_ECE = 60 | |
172 | ,NSTAT_SYSINFO_ECN_IFNET_CONN_PLNOCE = 61 | |
173 | ,NSTAT_SYSINFO_ECN_IFNET_CONN_PLCE = 62 | |
174 | ,NSTAT_SYSINFO_ECN_IFNET_CONN_NOPLCE = 63 | |
175 | ,NSTAT_SYSINFO_ECN_IFNET_FALLBACK_SYNLOSS = 64 | |
176 | ,NSTAT_SYSINFO_ECN_IFNET_FALLBACK_REORDER = 65 | |
177 | ,NSTAT_SYSINFO_ECN_IFNET_FALLBACK_CE = 66 | |
178 | ,NSTAT_SYSINFO_ECN_IFNET_ON_RTT_AVG = 67 | |
179 | ,NSTAT_SYSINFO_ECN_IFNET_ON_RTT_VAR = 68 | |
180 | ,NSTAT_SYSINFO_ECN_IFNET_ON_OOPERCENT = 69 | |
181 | ,NSTAT_SYSINFO_ECN_IFNET_ON_SACK_EPISODE = 70 | |
182 | ,NSTAT_SYSINFO_ECN_IFNET_ON_REORDER_PERCENT = 71 | |
183 | ,NSTAT_SYSINFO_ECN_IFNET_ON_RXMIT_PERCENT = 72 | |
184 | ,NSTAT_SYSINFO_ECN_IFNET_ON_RXMIT_DROP = 73 | |
185 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_RTT_AVG = 74 | |
186 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_RTT_VAR = 75 | |
187 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_OOPERCENT = 76 | |
188 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_SACK_EPISODE = 77 | |
189 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_REORDER_PERCENT = 78 | |
190 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_RXMIT_PERCENT = 79 | |
191 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_RXMIT_DROP = 80 | |
490019cf A |
192 | ,NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_TXPKTS = 81 |
193 | ,NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_RXMTPKTS = 82 | |
194 | ,NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_RXPKTS = 83 | |
195 | ,NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_OOPKTS = 84 | |
196 | ,NSTAT_SYSINFO_ECN_IFNET_ON_DROP_RST = 85 | |
197 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_TXPKTS = 86 | |
198 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_RXMTPKTS = 87 | |
199 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_RXPKTS = 88 | |
200 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_OOPKTS = 89 | |
201 | ,NSTAT_SYSINFO_ECN_IFNET_OFF_DROP_RST = 90 | |
202 | ,NSTAT_SYSINFO_ECN_IFNET_TOTAL_CONN = 91 | |
39037602 A |
203 | ,NSTAT_SYSINFO_TFO_COOKIE_WRONG = 92 |
204 | ,NSTAT_SYSINFO_TFO_NO_COOKIE_RCV = 93 | |
205 | ,NSTAT_SYSINFO_TFO_HEURISTICS_DISABLE = 94 | |
206 | ,NSTAT_SYSINFO_TFO_SEND_BLACKHOLE = 95 | |
207 | ,NSTAT_SYSINFO_KEY_SOCK_MBFLOOR = 96 | |
208 | ,NSTAT_SYSINFO_IFNET_UNSENT_DATA = 97 | |
209 | ,NSTAT_SYSINFO_ECN_IFNET_FALLBACK_DROPRST = 98 | |
210 | ,NSTAT_SYSINFO_ECN_IFNET_FALLBACK_DROPRXMT = 99 | |
490019cf | 211 | // NSTAT_SYSINFO_ENUM_VERSION must be updated any time a value is added |
39037602 | 212 | #define NSTAT_SYSINFO_ENUM_VERSION 20160715 |
fe8ab488 A |
213 | }; |
214 | ||
6d2010ae A |
215 | #pragma mark -- Network Statistics Providers -- |
216 | ||
3e170ce0 A |
217 | |
218 | // Interface properties | |
219 | ||
220 | #define NSTAT_IFNET_IS_UNKNOWN_TYPE 0x01 | |
221 | #define NSTAT_IFNET_IS_LOOPBACK 0x02 | |
222 | #define NSTAT_IFNET_IS_CELLULAR 0x04 | |
223 | #define NSTAT_IFNET_IS_WIFI 0x08 | |
224 | #define NSTAT_IFNET_IS_WIRED 0x10 | |
225 | #define NSTAT_IFNET_IS_AWDL 0x20 | |
226 | #define NSTAT_IFNET_IS_EXPENSIVE 0x40 | |
227 | #define NSTAT_IFNET_IS_VPN 0x80 | |
490019cf | 228 | #define NSTAT_IFNET_VIA_CELLFALLBACK 0x100 |
3e170ce0 A |
229 | |
230 | ||
6d2010ae A |
231 | enum |
232 | { | |
3e170ce0 A |
233 | NSTAT_PROVIDER_NONE = 0 |
234 | ,NSTAT_PROVIDER_ROUTE = 1 | |
39037602 A |
235 | ,NSTAT_PROVIDER_TCP_KERNEL = 2 |
236 | ,NSTAT_PROVIDER_TCP_USERLAND = 3 | |
237 | ,NSTAT_PROVIDER_UDP_KERNEL = 4 | |
238 | ,NSTAT_PROVIDER_UDP_USERLAND = 5 | |
239 | ,NSTAT_PROVIDER_IFNET = 6 | |
240 | ,NSTAT_PROVIDER_SYSINFO = 7 | |
6d2010ae | 241 | }; |
3e170ce0 A |
242 | #define NSTAT_PROVIDER_LAST NSTAT_PROVIDER_SYSINFO |
243 | #define NSTAT_PROVIDER_COUNT (NSTAT_PROVIDER_LAST+1) | |
6d2010ae A |
244 | |
245 | typedef struct nstat_route_add_param | |
246 | { | |
247 | union | |
248 | { | |
249 | struct sockaddr_in v4; | |
250 | struct sockaddr_in6 v6; | |
251 | } dst; | |
252 | union | |
253 | { | |
254 | struct sockaddr_in v4; | |
255 | struct sockaddr_in6 v6; | |
256 | } mask; | |
257 | u_int32_t ifindex; | |
258 | } nstat_route_add_param; | |
259 | ||
260 | typedef struct nstat_tcp_add_param | |
261 | { | |
262 | union | |
263 | { | |
264 | struct sockaddr_in v4; | |
265 | struct sockaddr_in6 v6; | |
266 | } local; | |
267 | union | |
268 | { | |
269 | struct sockaddr_in v4; | |
270 | struct sockaddr_in6 v6; | |
271 | } remote; | |
272 | } nstat_tcp_add_param; | |
273 | ||
274 | typedef struct nstat_tcp_descriptor | |
275 | { | |
276 | union | |
277 | { | |
278 | struct sockaddr_in v4; | |
279 | struct sockaddr_in6 v6; | |
280 | } local; | |
39037602 | 281 | |
6d2010ae A |
282 | union |
283 | { | |
284 | struct sockaddr_in v4; | |
285 | struct sockaddr_in6 v6; | |
286 | } remote; | |
39037602 | 287 | |
6d2010ae | 288 | u_int32_t ifindex; |
39037602 | 289 | |
6d2010ae | 290 | u_int32_t state; |
39037602 | 291 | |
6d2010ae A |
292 | u_int32_t sndbufsize; |
293 | u_int32_t sndbufused; | |
294 | u_int32_t rcvbufsize; | |
295 | u_int32_t rcvbufused; | |
296 | u_int32_t txunacked; | |
297 | u_int32_t txwindow; | |
298 | u_int32_t txcwindow; | |
316670eb | 299 | u_int32_t traffic_class; |
fe8ab488 A |
300 | u_int32_t traffic_mgt_flags; |
301 | char cc_algo[16]; | |
39037602 | 302 | |
6d2010ae A |
303 | u_int64_t upid; |
304 | u_int32_t pid; | |
305 | char pname[64]; | |
39236c6e A |
306 | u_int64_t eupid; |
307 | u_int32_t epid; | |
308 | ||
39037602 A |
309 | uuid_t uuid; |
310 | uuid_t euuid; | |
311 | uuid_t vuuid; | |
3e170ce0 A |
312 | struct tcp_conn_status connstatus; |
313 | uint16_t ifnet_properties __attribute__((aligned(4))); | |
6d2010ae A |
314 | } nstat_tcp_descriptor; |
315 | ||
316 | typedef struct nstat_tcp_add_param nstat_udp_add_param; | |
317 | ||
318 | typedef struct nstat_udp_descriptor | |
319 | { | |
320 | union | |
321 | { | |
322 | struct sockaddr_in v4; | |
323 | struct sockaddr_in6 v6; | |
324 | } local; | |
39037602 | 325 | |
6d2010ae A |
326 | union |
327 | { | |
328 | struct sockaddr_in v4; | |
329 | struct sockaddr_in6 v6; | |
330 | } remote; | |
39037602 | 331 | |
6d2010ae | 332 | u_int32_t ifindex; |
39037602 | 333 | |
6d2010ae A |
334 | u_int32_t rcvbufsize; |
335 | u_int32_t rcvbufused; | |
316670eb | 336 | u_int32_t traffic_class; |
39037602 | 337 | |
6d2010ae A |
338 | u_int64_t upid; |
339 | u_int32_t pid; | |
340 | char pname[64]; | |
39236c6e A |
341 | u_int64_t eupid; |
342 | u_int32_t epid; | |
343 | ||
39037602 A |
344 | uuid_t uuid; |
345 | uuid_t euuid; | |
346 | uuid_t vuuid; | |
3e170ce0 | 347 | uint16_t ifnet_properties; |
6d2010ae A |
348 | } nstat_udp_descriptor; |
349 | ||
350 | typedef struct nstat_route_descriptor | |
351 | { | |
352 | u_int64_t id; | |
353 | u_int64_t parent_id; | |
354 | u_int64_t gateway_id; | |
39037602 | 355 | |
6d2010ae A |
356 | union |
357 | { | |
358 | struct sockaddr_in v4; | |
359 | struct sockaddr_in6 v6; | |
360 | struct sockaddr sa; | |
361 | } dst; | |
39037602 | 362 | |
6d2010ae A |
363 | union |
364 | { | |
365 | struct sockaddr_in v4; | |
366 | struct sockaddr_in6 v6; | |
367 | struct sockaddr sa; | |
368 | } mask; | |
39037602 | 369 | |
6d2010ae A |
370 | union |
371 | { | |
372 | struct sockaddr_in v4; | |
373 | struct sockaddr_in6 v6; | |
374 | struct sockaddr sa; | |
375 | } gateway; | |
39037602 | 376 | |
6d2010ae A |
377 | u_int32_t ifindex; |
378 | u_int32_t flags; | |
39037602 | 379 | |
6d2010ae A |
380 | } nstat_route_descriptor; |
381 | ||
39236c6e A |
382 | typedef struct nstat_ifnet_add_param |
383 | { | |
384 | u_int32_t ifindex; | |
385 | u_int64_t threshold; | |
386 | } nstat_ifnet_add_param; | |
387 | ||
3e170ce0 A |
388 | typedef struct nstat_ifnet_desc_cellular_status |
389 | { | |
390 | u_int32_t valid_bitmask; /* indicates which fields are valid */ | |
391 | #define NSTAT_IFNET_DESC_CELL_LINK_QUALITY_METRIC_VALID 0x1 | |
392 | #define NSTAT_IFNET_DESC_CELL_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
393 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_BANDWIDTH_VALID 0x4 | |
394 | #define NSTAT_IFNET_DESC_CELL_UL_MIN_LATENCY_VALID 0x8 | |
395 | #define NSTAT_IFNET_DESC_CELL_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
396 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_LATENCY_VALID 0x20 | |
397 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_VALID 0x40 | |
398 | #define NSTAT_IFNET_DESC_CELL_UL_BYTES_LOST_VALID 0x80 | |
399 | #define NSTAT_IFNET_DESC_CELL_UL_MIN_QUEUE_SIZE_VALID 0x100 | |
400 | #define NSTAT_IFNET_DESC_CELL_UL_AVG_QUEUE_SIZE_VALID 0x200 | |
401 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_QUEUE_SIZE_VALID 0x400 | |
402 | #define NSTAT_IFNET_DESC_CELL_DL_EFFECTIVE_BANDWIDTH_VALID 0x800 | |
403 | #define NSTAT_IFNET_DESC_CELL_DL_MAX_BANDWIDTH_VALID 0x1000 | |
404 | #define NSTAT_IFNET_DESC_CELL_CONFIG_INACTIVITY_TIME_VALID 0x2000 | |
405 | #define NSTAT_IFNET_DESC_CELL_CONFIG_BACKOFF_TIME_VALID 0x4000 | |
39037602 | 406 | #define NSTAT_IFNET_DESC_CELL_MSS_RECOMMENDED_VALID 0x8000 |
3e170ce0 A |
407 | u_int32_t link_quality_metric; |
408 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on | |
409 | current activity (bps) */ | |
410 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth | |
411 | (bps) */ | |
412 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop | |
413 | (ms) */ | |
414 | u_int32_t ul_effective_latency; /* current expected uplink latency for | |
415 | first hop (ms) */ | |
416 | u_int32_t ul_max_latency; /* max expected uplink latency first hop | |
417 | (ms) */ | |
418 | u_int32_t ul_retxt_level; /* Retransmission metric */ | |
419 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_NONE 1 | |
420 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_LOW 2 | |
421 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_MEDIUM 3 | |
422 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_HIGH 4 | |
423 | ||
424 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 | |
425 | format */ | |
426 | u_int32_t ul_min_queue_size; /* minimum bytes in queue */ | |
427 | u_int32_t ul_avg_queue_size; /* average bytes in queue */ | |
428 | u_int32_t ul_max_queue_size; /* maximum bytes in queue */ | |
429 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based | |
430 | on current activity (bps) */ | |
431 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth | |
432 | (bps) */ | |
433 | u_int32_t config_inactivity_time; /* ms */ | |
434 | u_int32_t config_backoff_time; /* new connections backoff time in ms */ | |
39037602 A |
435 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_NONE 0x0 |
436 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_MEDIUM 0x1 | |
437 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_LOW 0x2 | |
438 | u_int16_t mss_recommended; /* recommended MSS */ | |
3e170ce0 A |
439 | } nstat_ifnet_desc_cellular_status; |
440 | ||
441 | typedef struct nstat_ifnet_desc_wifi_status { | |
442 | u_int32_t valid_bitmask; | |
443 | #define NSTAT_IFNET_DESC_WIFI_LINK_QUALITY_METRIC_VALID 0x1 | |
444 | #define NSTAT_IFNET_DESC_WIFI_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
445 | #define NSTAT_IFNET_DESC_WIFI_UL_MAX_BANDWIDTH_VALID 0x4 | |
446 | #define NSTAT_IFNET_DESC_WIFI_UL_MIN_LATENCY_VALID 0x8 | |
447 | #define NSTAT_IFNET_DESC_WIFI_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
448 | #define NSTAT_IFNET_DESC_WIFI_UL_MAX_LATENCY_VALID 0x20 | |
449 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_VALID 0x40 | |
450 | #define NSTAT_IFNET_DESC_WIFI_UL_ERROR_RATE_VALID 0x80 | |
451 | #define NSTAT_IFNET_DESC_WIFI_UL_BYTES_LOST_VALID 0x100 | |
452 | #define NSTAT_IFNET_DESC_WIFI_DL_EFFECTIVE_BANDWIDTH_VALID 0x200 | |
453 | #define NSTAT_IFNET_DESC_WIFI_DL_MAX_BANDWIDTH_VALID 0x400 | |
454 | #define NSTAT_IFNET_DESC_WIFI_DL_MIN_LATENCY_VALID 0x800 | |
455 | #define NSTAT_IFNET_DESC_WIFI_DL_EFFECTIVE_LATENCY_VALID 0x1000 | |
456 | #define NSTAT_IFNET_DESC_WIFI_DL_MAX_LATENCY_VALID 0x2000 | |
457 | #define NSTAT_IFNET_DESC_WIFI_DL_ERROR_RATE_VALID 0x4000 | |
458 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_VALID 0x8000 | |
459 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_MULTICAST_RATE_VALID 0x10000 | |
460 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_SCAN_COUNT_VALID 0x20000 | |
461 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_SCAN_DURATION_VALID 0x40000 | |
462 | u_int32_t link_quality_metric; /* link quality metric */ | |
463 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on | |
464 | current activity (bps) */ | |
465 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth | |
466 | (bps) */ | |
467 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop | |
468 | (ms) */ | |
469 | u_int32_t ul_effective_latency; /* current expected uplink latency for | |
470 | first hop (ms) */ | |
471 | u_int32_t ul_max_latency; /* max expected uplink latency for first hop | |
472 | (ms) */ | |
473 | u_int32_t ul_retxt_level; /* Retransmission metric */ | |
474 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_NONE 1 | |
475 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_LOW 2 | |
476 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_MEDIUM 3 | |
477 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_HIGH 4 | |
478 | ||
479 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 | |
480 | format */ | |
481 | u_int32_t ul_error_rate; /* % of bytes dropped on uplink after many | |
482 | retransmissions in Q10 format */ | |
483 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based | |
484 | on current activity (bps) */ | |
485 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth | |
486 | (bps) */ | |
487 | /* | |
488 | * The download latency values indicate the time AP may have to wait | |
489 | * for the driver to receive the packet. These values give the range | |
490 | * of expected latency mainly due to co-existence events and channel | |
491 | * hopping where the interface becomes unavailable. | |
492 | */ | |
493 | u_int32_t dl_min_latency; /* min expected latency for first hop in ms */ | |
494 | u_int32_t dl_effective_latency; /* current expected latency for first | |
495 | hop in ms */ | |
496 | u_int32_t dl_max_latency; /* max expected latency for first hop in ms */ | |
497 | u_int32_t dl_error_rate; /* % of CRC or other errors in Q10 format */ | |
498 | u_int32_t config_frequency; /* 2.4 or 5 GHz */ | |
499 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_2_4_GHZ 1 | |
500 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_5_0_GHZ 2 | |
501 | u_int32_t config_multicast_rate; /* bps */ | |
502 | u_int32_t scan_count; /* scan count during the previous period */ | |
503 | u_int32_t scan_duration; /* scan duration in ms */ | |
504 | } nstat_ifnet_desc_wifi_status; | |
505 | ||
506 | enum | |
507 | { | |
508 | NSTAT_IFNET_DESC_LINK_STATUS_TYPE_NONE = 0 | |
509 | ,NSTAT_IFNET_DESC_LINK_STATUS_TYPE_CELLULAR = 1 | |
510 | ,NSTAT_IFNET_DESC_LINK_STATUS_TYPE_WIFI = 2 | |
511 | }; | |
512 | ||
513 | typedef struct nstat_ifnet_desc_link_status | |
514 | { | |
515 | u_int32_t link_status_type; | |
516 | union { | |
517 | nstat_ifnet_desc_cellular_status cellular; | |
518 | nstat_ifnet_desc_wifi_status wifi; | |
519 | } u; | |
520 | } nstat_ifnet_desc_link_status; | |
521 | ||
39236c6e A |
522 | #ifndef IF_DESCSIZE |
523 | #define IF_DESCSIZE 128 | |
524 | #endif | |
525 | typedef struct nstat_ifnet_descriptor | |
526 | { | |
3e170ce0 A |
527 | char name[IFNAMSIZ+1]; |
528 | u_int32_t ifindex; | |
529 | u_int64_t threshold; | |
530 | unsigned int type; | |
531 | char description[IF_DESCSIZE]; | |
532 | nstat_ifnet_desc_link_status link_status; | |
39236c6e A |
533 | } nstat_ifnet_descriptor; |
534 | ||
fe8ab488 A |
535 | typedef struct nstat_sysinfo_descriptor |
536 | { | |
537 | u_int32_t flags; | |
538 | } nstat_sysinfo_descriptor; | |
539 | ||
540 | typedef struct nstat_sysinfo_add_param | |
541 | { | |
542 | /* To indicate which system level information should be collected */ | |
543 | u_int32_t flags; | |
544 | } nstat_sysinfo_add_param; | |
545 | ||
546 | #define NSTAT_SYSINFO_MBUF_STATS 0x0001 | |
39037602 | 547 | #define NSTAT_SYSINFO_TCP_STATS 0x0002 |
4bd07ac2 | 548 | #define NSTAT_SYSINFO_IFNET_ECN_STATS 0x0003 |
fe8ab488 | 549 | |
6d2010ae A |
550 | #pragma mark -- Network Statistics User Client -- |
551 | ||
552 | #define NET_STAT_CONTROL_NAME "com.apple.network.statistics" | |
553 | ||
554 | enum | |
555 | { | |
316670eb | 556 | // generic response messages |
6d2010ae A |
557 | NSTAT_MSG_TYPE_SUCCESS = 0 |
558 | ,NSTAT_MSG_TYPE_ERROR = 1 | |
39037602 | 559 | |
6d2010ae | 560 | // Requests |
3e170ce0 | 561 | ,NSTAT_MSG_TYPE_ADD_SRC = 1001 |
39236c6e | 562 | ,NSTAT_MSG_TYPE_ADD_ALL_SRCS = 1002 |
3e170ce0 A |
563 | ,NSTAT_MSG_TYPE_REM_SRC = 1003 |
564 | ,NSTAT_MSG_TYPE_QUERY_SRC = 1004 | |
39236c6e | 565 | ,NSTAT_MSG_TYPE_GET_SRC_DESC = 1005 |
3e170ce0 A |
566 | ,NSTAT_MSG_TYPE_SET_FILTER = 1006 |
567 | ,NSTAT_MSG_TYPE_GET_UPDATE = 1007 | |
568 | ,NSTAT_MSG_TYPE_SUBSCRIBE_SYSINFO = 1008 | |
39037602 | 569 | |
6d2010ae | 570 | // Responses/Notfications |
3e170ce0 A |
571 | ,NSTAT_MSG_TYPE_SRC_ADDED = 10001 |
572 | ,NSTAT_MSG_TYPE_SRC_REMOVED = 10002 | |
573 | ,NSTAT_MSG_TYPE_SRC_DESC = 10003 | |
574 | ,NSTAT_MSG_TYPE_SRC_COUNTS = 10004 | |
575 | ,NSTAT_MSG_TYPE_SYSINFO_COUNTS = 10005 | |
576 | ,NSTAT_MSG_TYPE_SRC_UPDATE = 10006 | |
6d2010ae A |
577 | }; |
578 | ||
579 | enum | |
580 | { | |
39037602 | 581 | NSTAT_SRC_REF_ALL = 0xffffffffffffffffULL |
6d2010ae A |
582 | ,NSTAT_SRC_REF_INVALID = 0 |
583 | }; | |
584 | ||
3e170ce0 | 585 | /* Source-level filters */ |
39236c6e A |
586 | enum |
587 | { | |
3e170ce0 A |
588 | NSTAT_FILTER_NOZEROBYTES = 0x00000001 |
589 | }; | |
590 | ||
591 | /* Provider-level filters */ | |
592 | enum | |
593 | { | |
594 | NSTAT_FILTER_ACCEPT_UNKNOWN = 0x00000001 | |
595 | ,NSTAT_FILTER_ACCEPT_LOOPBACK = 0x00000002 | |
596 | ,NSTAT_FILTER_ACCEPT_CELLULAR = 0x00000004 | |
597 | ,NSTAT_FILTER_ACCEPT_WIFI = 0x00000008 | |
598 | ,NSTAT_FILTER_ACCEPT_WIRED = 0x00000010 | |
39037602 A |
599 | ,NSTAT_FILTER_ACCEPT_AWDL = 0x00000020 |
600 | ,NSTAT_FILTER_ACCEPT_EXPENSIVE = 0x00000040 | |
601 | ,NSTAT_FILTER_ACCEPT_CELLFALLBACK = 0x00000100 | |
602 | ,NSTAT_FILTER_IFNET_FLAGS = 0x00000FFF | |
3e170ce0 A |
603 | |
604 | ,NSTAT_FILTER_TCP_NO_LISTENER = 0x00001000 | |
605 | ,NSTAT_FILTER_TCP_ONLY_LISTENER = 0x00002000 | |
606 | ,NSTAT_FILTER_TCP_INTERFACE_ATTACH = 0x00004000 | |
607 | ,NSTAT_FILTER_TCP_FLAGS = 0x0000F000 | |
608 | ||
609 | ,NSTAT_FILTER_UDP_INTERFACE_ATTACH = 0x00010000 | |
610 | ,NSTAT_FILTER_UDP_FLAGS = 0x000F0000 | |
611 | ||
612 | ,NSTAT_FILTER_SUPPRESS_SRC_ADDED = 0x00100000 | |
613 | ,NSTAT_FILTER_REQUIRE_SRC_ADDED = 0x00200000 | |
39037602 A |
614 | ,NSTAT_FILTER_PROVIDER_NOZEROBYTES = 0x00400000 |
615 | ||
616 | ,NSTAT_FILTER_SPECIFIC_USER_BY_PID = 0x01000000 | |
617 | ,NSTAT_FILTER_SPECIFIC_USER_BY_EPID = 0x02000000 | |
618 | ,NSTAT_FILTER_SPECIFIC_USER_BY_UUID = 0x04000000 | |
619 | ,NSTAT_FILTER_SPECIFIC_USER_BY_EUUID = 0x08000000 | |
620 | ,NSTAT_FILTER_SPECIFIC_USER = 0x0F000000 | |
3e170ce0 A |
621 | }; |
622 | ||
623 | enum | |
624 | { | |
625 | NSTAT_MSG_HDR_FLAG_SUPPORTS_AGGREGATE = 1 << 0, | |
626 | NSTAT_MSG_HDR_FLAG_CONTINUATION = 1 << 1, | |
627 | NSTAT_MSG_HDR_FLAG_CLOSING = 1 << 2, | |
39236c6e A |
628 | }; |
629 | ||
6d2010ae A |
630 | typedef struct nstat_msg_hdr |
631 | { | |
632 | u_int64_t context; | |
633 | u_int32_t type; | |
3e170ce0 A |
634 | u_int16_t length; |
635 | u_int16_t flags; | |
6d2010ae A |
636 | } nstat_msg_hdr; |
637 | ||
638 | typedef struct nstat_msg_error | |
639 | { | |
640 | nstat_msg_hdr hdr; | |
641 | u_int32_t error; // errno error | |
642 | } nstat_msg_error; | |
643 | ||
644 | typedef struct nstat_msg_add_src | |
645 | { | |
646 | nstat_msg_hdr hdr; | |
647 | nstat_provider_id_t provider; | |
648 | u_int8_t param[]; | |
649 | } nstat_msg_add_src_req; | |
650 | ||
651 | typedef struct nstat_msg_add_all_srcs | |
652 | { | |
653 | nstat_msg_hdr hdr; | |
654 | nstat_provider_id_t provider; | |
39037602 A |
655 | u_int64_t filter; |
656 | nstat_event_flags_t events; | |
657 | pid_t target_pid; | |
658 | uuid_t target_uuid; | |
6d2010ae A |
659 | } nstat_msg_add_all_srcs; |
660 | ||
661 | typedef struct nstat_msg_src_added | |
662 | { | |
663 | nstat_msg_hdr hdr; | |
664 | nstat_provider_id_t provider; | |
665 | nstat_src_ref_t srcref; | |
666 | } nstat_msg_src_added; | |
667 | ||
668 | typedef struct nstat_msg_rem_src | |
669 | { | |
670 | nstat_msg_hdr hdr; | |
671 | nstat_src_ref_t srcref; | |
672 | } nstat_msg_rem_src_req; | |
673 | ||
674 | typedef struct nstat_msg_get_src_description | |
675 | { | |
676 | nstat_msg_hdr hdr; | |
677 | nstat_src_ref_t srcref; | |
678 | } nstat_msg_get_src_description; | |
679 | ||
39236c6e A |
680 | typedef struct nstat_msg_set_filter |
681 | { | |
682 | nstat_msg_hdr hdr; | |
683 | nstat_src_ref_t srcref; | |
684 | u_int32_t filter; | |
685 | } nstat_msg_set_filter; | |
686 | ||
6d2010ae A |
687 | typedef struct nstat_msg_src_description |
688 | { | |
689 | nstat_msg_hdr hdr; | |
690 | nstat_src_ref_t srcref; | |
39037602 | 691 | nstat_event_flags_t event_flags; |
6d2010ae A |
692 | nstat_provider_id_t provider; |
693 | u_int8_t data[]; | |
694 | } nstat_msg_src_description; | |
695 | ||
696 | typedef struct nstat_msg_query_src | |
697 | { | |
698 | nstat_msg_hdr hdr; | |
699 | nstat_src_ref_t srcref; | |
700 | } nstat_msg_query_src_req; | |
701 | ||
702 | typedef struct nstat_msg_src_counts | |
703 | { | |
704 | nstat_msg_hdr hdr; | |
705 | nstat_src_ref_t srcref; | |
39037602 | 706 | nstat_event_flags_t event_flags; |
6d2010ae A |
707 | nstat_counts counts; |
708 | } nstat_msg_src_counts; | |
709 | ||
3e170ce0 A |
710 | typedef struct nstat_msg_src_update |
711 | { | |
712 | nstat_msg_hdr hdr; | |
713 | nstat_src_ref_t srcref; | |
39037602 | 714 | nstat_event_flags_t event_flags; |
3e170ce0 A |
715 | nstat_counts counts; |
716 | nstat_provider_id_t provider; | |
717 | u_int8_t data[]; | |
718 | } nstat_msg_src_update; | |
719 | ||
6d2010ae A |
720 | typedef struct nstat_msg_src_removed |
721 | { | |
722 | nstat_msg_hdr hdr; | |
723 | nstat_src_ref_t srcref; | |
724 | } nstat_msg_src_removed; | |
725 | ||
fe8ab488 A |
726 | typedef struct nstat_msg_sysinfo_counts |
727 | { | |
728 | nstat_msg_hdr hdr; | |
729 | nstat_src_ref_t srcref; | |
730 | nstat_sysinfo_counts counts; | |
3e170ce0 A |
731 | } __attribute__((packed)) nstat_msg_sysinfo_counts; |
732 | ||
733 | #pragma pack(pop) | |
734 | ||
735 | #pragma mark -- Statitiscs about Network Statistics -- | |
736 | ||
737 | struct nstat_stats { | |
738 | u_int32_t nstat_successmsgfailures; | |
739 | u_int32_t nstat_sendcountfailures; | |
740 | u_int32_t nstat_sysinfofailures; | |
741 | u_int32_t nstat_srcupatefailures; | |
742 | u_int32_t nstat_descriptionfailures; | |
743 | u_int32_t nstat_msgremovedfailures; | |
744 | u_int32_t nstat_srcaddedfailures; | |
745 | u_int32_t nstat_msgerrorfailures; | |
746 | u_int32_t nstat_copy_descriptor_failures; | |
747 | u_int32_t nstat_provider_counts_failures; | |
748 | u_int32_t nstat_control_send_description_failures; | |
749 | u_int32_t nstat_control_send_goodbye_failures; | |
750 | u_int32_t nstat_flush_accumulated_msgs_failures; | |
751 | u_int32_t nstat_accumulate_msg_failures; | |
752 | u_int32_t nstat_control_cleanup_source_failures; | |
753 | u_int32_t nstat_handle_msg_failures; | |
754 | }; | |
755 | ||
756 | #endif /* PRIVATE */ | |
757 | ||
758 | #ifdef XNU_KERNEL_PRIVATE | |
759 | #include <sys/mcache.h> | |
760 | ||
761 | #pragma mark -- System Information Internal Support -- | |
fe8ab488 A |
762 | |
763 | typedef struct nstat_sysinfo_mbuf_stats | |
764 | { | |
3e170ce0 A |
765 | u_int32_t total_256b; /* Peak usage, 256B pool */ |
766 | u_int32_t total_2kb; /* Peak usage, 2KB pool */ | |
767 | u_int32_t total_4kb; /* Peak usage, 4KB pool */ | |
768 | u_int32_t total_16kb; /* Peak usage, 16KB pool */ | |
769 | u_int32_t sbmb_total; /* Total mbufs in sock buffer pool */ | |
770 | u_int32_t sb_atmbuflimit; /* Memory limit reached for socket buffer autoscaling */ | |
771 | u_int32_t draincnt; /* Number of times mbuf pool has been drained under memory pressure */ | |
772 | u_int32_t memreleased; /* Memory (bytes) released from mbuf pool to VM */ | |
39037602 | 773 | u_int32_t sbmb_floor; /* Lowest mbufs in sock buffer pool */ |
fe8ab488 A |
774 | } nstat_sysinfo_mbuf_stats; |
775 | ||
776 | typedef struct nstat_sysinfo_tcp_stats | |
777 | { | |
39037602 | 778 | u_int32_t ipv4_avgrtt; /* Average RTT for IPv4 */ |
3e170ce0 A |
779 | u_int32_t ipv6_avgrtt; /* Average RTT for IPv6 */ |
780 | u_int32_t send_plr; /* Average uplink packet loss rate */ | |
781 | u_int32_t recv_plr; /* Average downlink packet loss rate */ | |
782 | u_int32_t send_tlrto_rate; /* Average rxt timeout after tail loss */ | |
783 | u_int32_t send_reorder_rate; /* Average packet reordering rate */ | |
784 | u_int32_t connection_attempts; /* TCP client connection attempts */ | |
785 | u_int32_t connection_accepts; /* TCP server connection accepts */ | |
786 | u_int32_t ecn_client_enabled; /* Global setting for ECN client side */ | |
787 | u_int32_t ecn_server_enabled; /* Global setting for ECN server side */ | |
788 | u_int32_t ecn_client_setup; /* Attempts to setup TCP client connection with ECN */ | |
789 | u_int32_t ecn_server_setup; /* Attempts to setup TCP server connection with ECN */ | |
790 | u_int32_t ecn_client_success; /* Number of successful negotiations of ECN for a client connection */ | |
791 | u_int32_t ecn_server_success; /* Number of successful negotiations of ECN for a server connection */ | |
792 | u_int32_t ecn_not_supported; /* Number of falbacks to Non-ECN, no support from peer */ | |
793 | u_int32_t ecn_lost_syn; /* Number of SYNs lost with ECN bits */ | |
794 | u_int32_t ecn_lost_synack; /* Number of SYN-ACKs lost with ECN bits */ | |
795 | u_int32_t ecn_recv_ce; /* Number of CEs received from network */ | |
796 | u_int32_t ecn_recv_ece; /* Number of ECEs received from receiver */ | |
797 | u_int32_t ecn_sent_ece; /* Number of ECEs sent in response to CE */ | |
798 | u_int32_t ecn_conn_recv_ce; /* Number of connections using ECN received CE at least once */ | |
799 | u_int32_t ecn_conn_recv_ece; /* Number of connections using ECN received ECE at least once */ | |
800 | u_int32_t ecn_conn_plnoce; /* Number of connections using ECN seen packet loss but never received CE */ | |
801 | u_int32_t ecn_conn_pl_ce; /* Number of connections using ECN seen packet loss and CE */ | |
802 | u_int32_t ecn_conn_nopl_ce; /* Number of connections using ECN with no packet loss but received CE */ | |
4bd07ac2 A |
803 | u_int32_t ecn_fallback_synloss; /* Number of times we did fall back due to SYN-Loss */ |
804 | u_int32_t ecn_fallback_reorder; /* Number of times we fallback because we detected the PAWS-issue */ | |
805 | u_int32_t ecn_fallback_ce; /* Number of times we fallback because we received too many CEs */ | |
3e170ce0 A |
806 | u_int32_t tfo_syn_data_rcv; /* Number of SYN+data received with valid cookie */ |
807 | u_int32_t tfo_cookie_req_rcv;/* Number of TFO cookie-requests received */ | |
808 | u_int32_t tfo_cookie_sent; /* Number of TFO-cookies offered to the client */ | |
809 | u_int32_t tfo_cookie_invalid;/* Number of invalid TFO-cookies received */ | |
810 | u_int32_t tfo_cookie_req; /* Number of SYNs with cookie request received*/ | |
811 | u_int32_t tfo_cookie_rcv; /* Number of SYN/ACKs with Cookie received */ | |
812 | u_int32_t tfo_syn_data_sent; /* Number of SYNs+data+cookie sent */ | |
813 | u_int32_t tfo_syn_data_acked;/* Number of times our SYN+data has been acknowledged */ | |
814 | u_int32_t tfo_syn_loss; /* Number of times SYN+TFO has been lost and we fallback */ | |
815 | u_int32_t tfo_blackhole; /* Number of times SYN+TFO has been lost and we fallback */ | |
39037602 A |
816 | u_int32_t tfo_cookie_wrong; /* TFO-cookie we sent was wrong */ |
817 | u_int32_t tfo_no_cookie_rcv; /* We asked for a cookie but didn't get one */ | |
818 | u_int32_t tfo_heuristics_disable; /* TFO got disabled due to heuristics */ | |
819 | u_int32_t tfo_sndblackhole; /* TFO got blackholed in the sending direction */ | |
fe8ab488 A |
820 | } nstat_sysinfo_tcp_stats; |
821 | ||
4bd07ac2 A |
822 | enum { |
823 | NSTAT_IFNET_ECN_PROTO_IPV4 = 1 | |
824 | ,NSTAT_IFNET_ECN_PROTO_IPV6 | |
825 | }; | |
826 | ||
827 | enum { | |
828 | NSTAT_IFNET_ECN_TYPE_CELLULAR = 1 | |
829 | ,NSTAT_IFNET_ECN_TYPE_WIFI | |
830 | ,NSTAT_IFNET_ECN_TYPE_ETHERNET | |
831 | }; | |
832 | ||
833 | typedef struct nstat_sysinfo_ifnet_ecn_stats { | |
834 | u_int32_t ifnet_proto; | |
835 | u_int32_t ifnet_type; | |
836 | struct if_tcp_ecn_stat ecn_stat; | |
837 | } nstat_sysinfo_ifnet_ecn_stats; | |
838 | ||
fe8ab488 A |
839 | typedef struct nstat_sysinfo_data |
840 | { | |
841 | u_int32_t flags; | |
842 | union { | |
843 | nstat_sysinfo_mbuf_stats mb_stats; | |
844 | nstat_sysinfo_tcp_stats tcp_stats; | |
4bd07ac2 | 845 | nstat_sysinfo_ifnet_ecn_stats ifnet_ecn_stats; |
fe8ab488 | 846 | } u; |
39037602 | 847 | uint32_t unsent_data_cnt; /* Before sleeping */ |
fe8ab488 A |
848 | } nstat_sysinfo_data; |
849 | ||
6d2010ae A |
850 | #pragma mark -- Generic Network Statistics Provider -- |
851 | ||
852 | typedef void * nstat_provider_cookie_t; | |
853 | ||
854 | #pragma mark -- Route Statistics Gathering Functions -- | |
855 | struct rtentry; | |
856 | ||
857 | enum | |
858 | { | |
859 | NSTAT_TX_FLAG_RETRANSMIT = 1 | |
860 | }; | |
861 | ||
862 | enum | |
863 | { | |
864 | NSTAT_RX_FLAG_DUPLICATE = 1, | |
865 | NSTAT_RX_FLAG_OUT_OF_ORDER = 2 | |
866 | }; | |
867 | ||
868 | // indicates whether or not collection of statistics is enabled | |
869 | extern int nstat_collect; | |
870 | ||
316670eb A |
871 | void nstat_init(void); |
872 | ||
6d2010ae A |
873 | // Route collection routines |
874 | void nstat_route_connect_attempt(struct rtentry *rte); | |
875 | void nstat_route_connect_success(struct rtentry *rte); | |
876 | void nstat_route_tx(struct rtentry *rte, u_int32_t packets, u_int32_t bytes, u_int32_t flags); | |
877 | void nstat_route_rx(struct rtentry *rte, u_int32_t packets, u_int32_t bytes, u_int32_t flags); | |
878 | void nstat_route_rtt(struct rtentry *rte, u_int32_t rtt, u_int32_t rtt_var); | |
879 | void nstat_route_detach(struct rtentry *rte); | |
880 | ||
881 | // watcher support | |
882 | struct inpcb; | |
883 | void nstat_tcp_new_pcb(struct inpcb *inp); | |
884 | void nstat_udp_new_pcb(struct inpcb *inp); | |
885 | void nstat_route_new_entry(struct rtentry *rt); | |
316670eb | 886 | void nstat_pcb_detach(struct inpcb *inp); |
fe8ab488 A |
887 | void nstat_pcb_cache(struct inpcb *inp); |
888 | void nstat_pcb_invalidate_cache(struct inpcb *inp); | |
6d2010ae | 889 | |
39236c6e A |
890 | |
891 | void nstat_ifnet_threshold_reached(unsigned int ifindex); | |
892 | ||
fe8ab488 A |
893 | void nstat_sysinfo_send_data(struct nstat_sysinfo_data *); |
894 | ||
39037602 A |
895 | // Userland stats reporting |
896 | ||
897 | // Each side, NetworkStatistics and the kernel provider for userland, | |
898 | // pass opaque references. | |
899 | typedef void *userland_stats_provider_context; | |
900 | typedef void *nstat_userland_context; | |
901 | ||
902 | // When things have been set up, Netstats can request a refresh of its data. | |
903 | typedef bool (userland_stats_request_vals_fn)(userland_stats_provider_context *ctx, | |
904 | nstat_counts *countsp, | |
905 | void *metadatap); | |
906 | ||
907 | // Things get started with a call to netstats to say that there’s a new connection: | |
908 | nstat_userland_context ntstat_userland_stats_open(userland_stats_provider_context *ctx, | |
909 | int provider_id, | |
910 | u_int64_t properties, | |
911 | userland_stats_request_vals_fn req_fn); | |
912 | ||
913 | void ntstat_userland_stats_close(nstat_userland_context nstat_ctx); | |
914 | ||
915 | ||
916 | // There may be other occasions where the stats have changed and NECP should push the new values. | |
917 | // This is provisional, ahead of full implementation. | |
918 | ||
919 | typedef enum { | |
920 | USERLAND_STATS_WILL_UPDATE, | |
921 | USERLAND_STATS_DID_UPDATE | |
922 | } userland_stats_event_t; | |
923 | ||
924 | void ntstat_userland_stats_event(nstat_userland_context nstat_ctx, userland_stats_event_t event); | |
925 | ||
926 | ||
6d2010ae A |
927 | // locked_add_64 uses atomic operations on 32bit so the 64bit |
928 | // value can be properly read. The values are only ever incremented | |
929 | // while under the socket lock, so on 64bit we don't actually need | |
930 | // atomic operations to increment. | |
931 | #if defined(__LP64__) | |
932 | #define locked_add_64(__addr, __count) do { \ | |
933 | *(__addr) += (__count); \ | |
934 | } while (0) | |
935 | #else | |
936 | #define locked_add_64(__addr, __count) do { \ | |
937 | atomic_add_64((__addr), (__count)); \ | |
938 | } while (0) | |
939 | #endif | |
940 | ||
941 | #endif /* XNU_KERNEL_PRIVATE */ | |
942 | ||
943 | #endif /* __NTSTAT_H__ */ |