]>
Commit | Line | Data |
---|---|---|
6d2010ae | 1 | /* |
5ba3f43e | 2 | * Copyright (c) 2010-2017 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> | |
5ba3f43e A |
33 | #include <net/net_api_stats.h> |
34 | #include <netinet/in_stat.h> | |
3e170ce0 | 35 | #include <netinet/tcp.h> |
6d2010ae A |
36 | |
37 | #ifdef PRIVATE | |
6d2010ae A |
38 | #pragma mark -- Common Data Structures -- |
39 | ||
0a7de745 | 40 | #define __NSTAT_REVISION__ 9 |
6d2010ae | 41 | |
0a7de745 A |
42 | typedef u_int32_t nstat_provider_id_t; |
43 | typedef u_int64_t nstat_src_ref_t; | |
44 | typedef u_int64_t nstat_event_flags_t; | |
39037602 A |
45 | |
46 | // The following event definitions are very provisional.. | |
0a7de745 | 47 | enum{ |
cb323159 A |
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 | |
0a7de745 A |
56 | , NSTAT_EVENT_SRC_WILL_CHANGE_PROPERTY = 0x00000100 |
57 | , NSTAT_EVENT_SRC_DID_CHANGE_PROPERTY = 0x00000200 | |
cb323159 A |
58 | , NSTAT_EVENT_SRC_ENTER_CELLFALLBACK = 0x00000400 |
59 | , NSTAT_EVENT_SRC_EXIT_CELLFALLBACK = 0x00000800 | |
60 | #if (DEBUG || DEVELOPMENT) | |
61 | , NSTAT_EVENT_SRC_RESERVED_1 = 0x00001000 | |
62 | , NSTAT_EVENT_SRC_RESERVED_2 = 0x00002000 | |
63 | #endif /* (DEBUG || DEVELOPMENT) */ | |
39037602 | 64 | }; |
6d2010ae | 65 | |
0a7de745 | 66 | typedef struct nstat_counts { |
6d2010ae | 67 | /* Counters */ |
0a7de745 A |
68 | u_int64_t nstat_rxpackets __attribute__((aligned(sizeof(u_int64_t)))); |
69 | u_int64_t nstat_rxbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
70 | u_int64_t nstat_txpackets __attribute__((aligned(sizeof(u_int64_t)))); | |
71 | u_int64_t nstat_txbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
72 | ||
73 | u_int64_t nstat_cell_rxbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
74 | u_int64_t nstat_cell_txbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
75 | u_int64_t nstat_wifi_rxbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
76 | u_int64_t nstat_wifi_txbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
77 | u_int64_t nstat_wired_rxbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
78 | u_int64_t nstat_wired_txbytes __attribute__((aligned(sizeof(u_int64_t)))); | |
79 | ||
80 | u_int32_t nstat_rxduplicatebytes; | |
81 | u_int32_t nstat_rxoutoforderbytes; | |
82 | u_int32_t nstat_txretransmit; | |
83 | ||
84 | u_int32_t nstat_connectattempts; | |
85 | u_int32_t nstat_connectsuccesses; | |
86 | ||
87 | u_int32_t nstat_min_rtt; | |
88 | u_int32_t nstat_avg_rtt; | |
89 | u_int32_t nstat_var_rtt; | |
6d2010ae A |
90 | } nstat_counts; |
91 | ||
0a7de745 A |
92 | #define NSTAT_SYSINFO_KEYVAL_STRING_MAXSIZE 24 |
93 | typedef struct nstat_sysinfo_keyval { | |
94 | u_int32_t nstat_sysinfo_key; | |
95 | u_int32_t nstat_sysinfo_flags; | |
fe8ab488 | 96 | union { |
0a7de745 A |
97 | int64_t nstat_sysinfo_scalar; |
98 | double nstat_sysinfo_distribution; | |
99 | u_int8_t nstat_sysinfo_string[NSTAT_SYSINFO_KEYVAL_STRING_MAXSIZE]; | |
fe8ab488 | 100 | } u; |
0a7de745 A |
101 | u_int32_t nstat_sysinfo_valsize; |
102 | u_int8_t reserved[4]; | |
5ba3f43e | 103 | } nstat_sysinfo_keyval; |
fe8ab488 | 104 | |
0a7de745 A |
105 | #define NSTAT_SYSINFO_FLAG_SCALAR 0x0001 |
106 | #define NSTAT_SYSINFO_FLAG_DISTRIBUTION 0x0002 | |
107 | #define NSTAT_SYSINFO_FLAG_STRING 0x0004 | |
fe8ab488 | 108 | |
0a7de745 | 109 | #define NSTAT_MAX_MSG_SIZE 4096 |
3e170ce0 | 110 | |
0a7de745 | 111 | typedef struct nstat_sysinfo_counts { |
fe8ab488 | 112 | /* Counters */ |
0a7de745 A |
113 | u_int32_t nstat_sysinfo_len; |
114 | u_int32_t pad; | |
115 | u_int8_t nstat_sysinfo_keyvals[]; | |
5ba3f43e | 116 | } nstat_sysinfo_counts; |
fe8ab488 | 117 | |
0a7de745 | 118 | enum{ |
cb323159 | 119 | NSTAT_SYSINFO_KEY_MBUF_256B_TOTAL = 1 |
0a7de745 A |
120 | , NSTAT_SYSINFO_KEY_MBUF_2KB_TOTAL = 2 |
121 | , NSTAT_SYSINFO_KEY_MBUF_4KB_TOTAL = 3 | |
122 | , NSTAT_SYSINFO_KEY_SOCK_MBCNT = 4 | |
123 | , NSTAT_SYSINFO_KEY_SOCK_ATMBLIMIT = 5 | |
124 | , NSTAT_SYSINFO_KEY_IPV4_AVGRTT = 6 | |
125 | , NSTAT_SYSINFO_KEY_IPV6_AVGRTT = 7 | |
126 | , NSTAT_SYSINFO_KEY_SEND_PLR = 8 | |
127 | , NSTAT_SYSINFO_KEY_RECV_PLR = 9 | |
128 | , NSTAT_SYSINFO_KEY_SEND_TLRTO = 10 | |
129 | , NSTAT_SYSINFO_KEY_SEND_REORDERRATE = 11 | |
130 | , NSTAT_SYSINFO_CONNECTION_ATTEMPTS = 12 | |
131 | , NSTAT_SYSINFO_CONNECTION_ACCEPTS = 13 | |
132 | , NSTAT_SYSINFO_ECN_CLIENT_SETUP = 14 | |
133 | , NSTAT_SYSINFO_ECN_SERVER_SETUP = 15 | |
134 | , NSTAT_SYSINFO_ECN_CLIENT_SUCCESS = 16 | |
135 | , NSTAT_SYSINFO_ECN_SERVER_SUCCESS = 17 | |
136 | , NSTAT_SYSINFO_ECN_NOT_SUPPORTED = 18 | |
137 | , NSTAT_SYSINFO_ECN_LOST_SYN = 19 | |
138 | , NSTAT_SYSINFO_ECN_LOST_SYNACK = 20 | |
139 | , NSTAT_SYSINFO_ECN_RECV_CE = 21 | |
140 | , NSTAT_SYSINFO_ECN_RECV_ECE = 22 | |
141 | , NSTAT_SYSINFO_ECN_SENT_ECE = 23 | |
142 | , NSTAT_SYSINFO_ECN_CONN_RECV_CE = 24 | |
143 | , NSTAT_SYSINFO_ECN_CONN_PLNOCE = 25 | |
144 | , NSTAT_SYSINFO_ECN_CONN_PL_CE = 26 | |
145 | , NSTAT_SYSINFO_ECN_CONN_NOPL_CE = 27 | |
146 | , NSTAT_SYSINFO_MBUF_16KB_TOTAL = 28 | |
147 | , NSTAT_SYSINFO_ECN_CLIENT_ENABLED = 29 | |
148 | , NSTAT_SYSINFO_ECN_SERVER_ENABLED = 30 | |
149 | , NSTAT_SYSINFO_ECN_CONN_RECV_ECE = 31 | |
150 | , NSTAT_SYSINFO_MBUF_MEM_RELEASED = 32 | |
151 | , NSTAT_SYSINFO_MBUF_DRAIN_CNT = 33 | |
152 | , NSTAT_SYSINFO_TFO_SYN_DATA_RCV = 34 | |
153 | , NSTAT_SYSINFO_TFO_COOKIE_REQ_RCV = 35 | |
154 | , NSTAT_SYSINFO_TFO_COOKIE_SENT = 36 | |
155 | , NSTAT_SYSINFO_TFO_COOKIE_INVALID = 37 | |
156 | , NSTAT_SYSINFO_TFO_COOKIE_REQ = 38 | |
157 | , NSTAT_SYSINFO_TFO_COOKIE_RCV = 39 | |
158 | , NSTAT_SYSINFO_TFO_SYN_DATA_SENT = 40 | |
159 | , NSTAT_SYSINFO_TFO_SYN_DATA_ACKED = 41 | |
160 | , NSTAT_SYSINFO_TFO_SYN_LOSS = 42 | |
161 | , NSTAT_SYSINFO_TFO_BLACKHOLE = 43 | |
162 | , NSTAT_SYSINFO_ECN_FALLBACK_SYNLOSS = 44 | |
163 | , NSTAT_SYSINFO_ECN_FALLBACK_REORDER = 45 | |
164 | , NSTAT_SYSINFO_ECN_FALLBACK_CE = 46 | |
165 | , NSTAT_SYSINFO_ECN_IFNET_TYPE = 47 | |
166 | , NSTAT_SYSINFO_ECN_IFNET_PROTO = 48 | |
167 | , NSTAT_SYSINFO_ECN_IFNET_CLIENT_SETUP = 49 | |
168 | , NSTAT_SYSINFO_ECN_IFNET_SERVER_SETUP = 50 | |
169 | , NSTAT_SYSINFO_ECN_IFNET_CLIENT_SUCCESS = 51 | |
170 | , NSTAT_SYSINFO_ECN_IFNET_SERVER_SUCCESS = 52 | |
171 | , NSTAT_SYSINFO_ECN_IFNET_PEER_NOSUPPORT = 53 | |
172 | , NSTAT_SYSINFO_ECN_IFNET_SYN_LOST = 54 | |
173 | , NSTAT_SYSINFO_ECN_IFNET_SYNACK_LOST = 55 | |
174 | , NSTAT_SYSINFO_ECN_IFNET_RECV_CE = 56 | |
175 | , NSTAT_SYSINFO_ECN_IFNET_RECV_ECE = 57 | |
176 | , NSTAT_SYSINFO_ECN_IFNET_SENT_ECE = 58 | |
177 | , NSTAT_SYSINFO_ECN_IFNET_CONN_RECV_CE = 59 | |
178 | , NSTAT_SYSINFO_ECN_IFNET_CONN_RECV_ECE = 60 | |
179 | , NSTAT_SYSINFO_ECN_IFNET_CONN_PLNOCE = 61 | |
180 | , NSTAT_SYSINFO_ECN_IFNET_CONN_PLCE = 62 | |
181 | , NSTAT_SYSINFO_ECN_IFNET_CONN_NOPLCE = 63 | |
182 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_SYNLOSS = 64 | |
183 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_REORDER = 65 | |
184 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_CE = 66 | |
185 | , NSTAT_SYSINFO_ECN_IFNET_ON_RTT_AVG = 67 | |
186 | , NSTAT_SYSINFO_ECN_IFNET_ON_RTT_VAR = 68 | |
187 | , NSTAT_SYSINFO_ECN_IFNET_ON_OOPERCENT = 69 | |
188 | , NSTAT_SYSINFO_ECN_IFNET_ON_SACK_EPISODE = 70 | |
189 | , NSTAT_SYSINFO_ECN_IFNET_ON_REORDER_PERCENT = 71 | |
190 | , NSTAT_SYSINFO_ECN_IFNET_ON_RXMIT_PERCENT = 72 | |
191 | , NSTAT_SYSINFO_ECN_IFNET_ON_RXMIT_DROP = 73 | |
192 | , NSTAT_SYSINFO_ECN_IFNET_OFF_RTT_AVG = 74 | |
193 | , NSTAT_SYSINFO_ECN_IFNET_OFF_RTT_VAR = 75 | |
194 | , NSTAT_SYSINFO_ECN_IFNET_OFF_OOPERCENT = 76 | |
195 | , NSTAT_SYSINFO_ECN_IFNET_OFF_SACK_EPISODE = 77 | |
196 | , NSTAT_SYSINFO_ECN_IFNET_OFF_REORDER_PERCENT = 78 | |
197 | , NSTAT_SYSINFO_ECN_IFNET_OFF_RXMIT_PERCENT = 79 | |
198 | , NSTAT_SYSINFO_ECN_IFNET_OFF_RXMIT_DROP = 80 | |
199 | , NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_TXPKTS = 81 | |
200 | , NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_RXMTPKTS = 82 | |
201 | , NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_RXPKTS = 83 | |
202 | , NSTAT_SYSINFO_ECN_IFNET_ON_TOTAL_OOPKTS = 84 | |
203 | , NSTAT_SYSINFO_ECN_IFNET_ON_DROP_RST = 85 | |
204 | , NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_TXPKTS = 86 | |
205 | , NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_RXMTPKTS = 87 | |
206 | , NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_RXPKTS = 88 | |
207 | , NSTAT_SYSINFO_ECN_IFNET_OFF_TOTAL_OOPKTS = 89 | |
208 | , NSTAT_SYSINFO_ECN_IFNET_OFF_DROP_RST = 90 | |
209 | , NSTAT_SYSINFO_ECN_IFNET_TOTAL_CONN = 91 | |
210 | , NSTAT_SYSINFO_TFO_COOKIE_WRONG = 92 | |
211 | , NSTAT_SYSINFO_TFO_NO_COOKIE_RCV = 93 | |
212 | , NSTAT_SYSINFO_TFO_HEURISTICS_DISABLE = 94 | |
213 | , NSTAT_SYSINFO_TFO_SEND_BLACKHOLE = 95 | |
214 | , NSTAT_SYSINFO_KEY_SOCK_MBFLOOR = 96 | |
215 | , NSTAT_SYSINFO_IFNET_UNSENT_DATA = 97 | |
216 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_DROPRST = 98 | |
217 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_DROPRXMT = 99 | |
218 | , NSTAT_SYSINFO_LIM_IFNET_SIGNATURE = 100 | |
219 | , NSTAT_SYSINFO_LIM_IFNET_DL_MAX_BANDWIDTH = 101 | |
220 | , NSTAT_SYSINFO_LIM_IFNET_UL_MAX_BANDWIDTH = 102 | |
221 | , NSTAT_SYSINFO_LIM_IFNET_PACKET_LOSS_PERCENT = 103 | |
222 | , NSTAT_SYSINFO_LIM_IFNET_PACKET_OOO_PERCENT = 104 | |
223 | , NSTAT_SYSINFO_LIM_IFNET_RTT_VARIANCE = 105 | |
224 | , NSTAT_SYSINFO_LIM_IFNET_RTT_MIN = 106 | |
225 | , NSTAT_SYSINFO_LIM_IFNET_RTT_AVG = 107 | |
226 | , NSTAT_SYSINFO_LIM_IFNET_CONN_TIMEOUT_PERCENT = 108 | |
227 | , NSTAT_SYSINFO_LIM_IFNET_DL_DETECTED = 109 | |
228 | , NSTAT_SYSINFO_LIM_IFNET_UL_DETECTED = 110 | |
229 | , NSTAT_SYSINFO_LIM_IFNET_TYPE = 111 | |
230 | ||
231 | , NSTAT_SYSINFO_API_IF_FLTR_ATTACH = 112 | |
232 | , NSTAT_SYSINFO_API_IF_FLTR_ATTACH_OS = 113 | |
233 | , NSTAT_SYSINFO_API_IP_FLTR_ADD = 114 | |
234 | , NSTAT_SYSINFO_API_IP_FLTR_ADD_OS = 115 | |
235 | , NSTAT_SYSINFO_API_SOCK_FLTR_ATTACH = 116 | |
236 | , NSTAT_SYSINFO_API_SOCK_FLTR_ATTACH_OS = 117 | |
237 | ||
238 | , NSTAT_SYSINFO_API_SOCK_ALLOC_TOTAL = 118 | |
239 | , NSTAT_SYSINFO_API_SOCK_ALLOC_KERNEL = 119 | |
240 | , NSTAT_SYSINFO_API_SOCK_ALLOC_KERNEL_OS = 120 | |
241 | , NSTAT_SYSINFO_API_SOCK_NECP_CLIENTUUID = 121 | |
242 | ||
243 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_LOCAL = 122 | |
244 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_ROUTE = 123 | |
245 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_INET = 124 | |
246 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_INET6 = 125 | |
247 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_SYSTEM = 126 | |
248 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_MULTIPATH = 127 | |
249 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_KEY = 128 | |
250 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_NDRV = 129 | |
251 | , NSTAT_SYSINFO_API_SOCK_DOMAIN_OTHER = 130 | |
252 | ||
253 | , NSTAT_SYSINFO_API_SOCK_INET_STREAM= 131 | |
254 | , NSTAT_SYSINFO_API_SOCK_INET_DGRAM = 132 | |
255 | , NSTAT_SYSINFO_API_SOCK_INET_DGRAM_CONNECTED = 133 | |
256 | , NSTAT_SYSINFO_API_SOCK_INET_DGRAM_DNS = 134 | |
257 | , NSTAT_SYSINFO_API_SOCK_INET_DGRAM_NO_DATA = 135 | |
258 | ||
259 | , NSTAT_SYSINFO_API_SOCK_INET6_STREAM= 136 | |
260 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM = 137 | |
261 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM_CONNECTED = 138 | |
262 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM_DNS = 139 | |
263 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM_NO_DATA = 140 | |
264 | ||
265 | , NSTAT_SYSINFO_API_SOCK_INET_MCAST_JOIN = 141 | |
266 | , NSTAT_SYSINFO_API_SOCK_INET_MCAST_JOIN_OS = 142 | |
267 | ||
268 | , NSTAT_SYSINFO_API_SOCK_INET6_STREAM_EXTHDR_IN = 143 | |
269 | , NSTAT_SYSINFO_API_SOCK_INET6_STREAM_EXTHDR_OUT = 144 | |
270 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM_EXTHDR_IN = 145 | |
271 | , NSTAT_SYSINFO_API_SOCK_INET6_DGRAM_EXTHDR_OUT = 146 | |
272 | ||
273 | , NSTAT_SYSINFO_API_NEXUS_FLOW_INET_STREAM = 147 | |
274 | , NSTAT_SYSINFO_API_NEXUS_FLOW_INET_DATAGRAM = 148 | |
275 | ||
276 | , NSTAT_SYSINFO_API_NEXUS_FLOW_INET6_STREAM = 149 | |
277 | , NSTAT_SYSINFO_API_NEXUS_FLOW_INET6_DATAGRAM = 150 | |
278 | ||
279 | , NSTAT_SYSINFO_API_IFNET_ALLOC = 151 | |
280 | , NSTAT_SYSINFO_API_IFNET_ALLOC_OS = 152 | |
281 | ||
282 | , NSTAT_SYSINFO_API_PF_ADDRULE = 153 | |
283 | , NSTAT_SYSINFO_API_PF_ADDRULE_OS = 154 | |
284 | ||
285 | , NSTAT_SYSINFO_API_VMNET_START = 155 | |
286 | ||
287 | , NSTAT_SYSINFO_API_IF_NETAGENT_ENABLED = 156 | |
288 | ||
289 | , NSTAT_SYSINFO_API_REPORT_INTERVAL = 157 | |
290 | ||
291 | , NSTAT_SYSINFO_MPTCP_HANDOVER_ATTEMPT = 158 | |
292 | , NSTAT_SYSINFO_MPTCP_INTERACTIVE_ATTEMPT = 159 | |
293 | , NSTAT_SYSINFO_MPTCP_AGGREGATE_ATTEMPT = 160 | |
294 | , NSTAT_SYSINFO_MPTCP_FP_HANDOVER_ATTEMPT = 161 /* _FP_ stands for first-party */ | |
295 | , NSTAT_SYSINFO_MPTCP_FP_INTERACTIVE_ATTEMPT = 162 | |
296 | , NSTAT_SYSINFO_MPTCP_FP_AGGREGATE_ATTEMPT = 163 | |
297 | , NSTAT_SYSINFO_MPTCP_HEURISTIC_FALLBACK = 164 | |
298 | , NSTAT_SYSINFO_MPTCP_FP_HEURISTIC_FALLBACK = 165 | |
299 | , NSTAT_SYSINFO_MPTCP_HANDOVER_SUCCESS_WIFI = 166 | |
300 | , NSTAT_SYSINFO_MPTCP_HANDOVER_SUCCESS_CELL = 167 | |
301 | , NSTAT_SYSINFO_MPTCP_INTERACTIVE_SUCCESS = 168 | |
302 | , NSTAT_SYSINFO_MPTCP_AGGREGATE_SUCCESS = 169 | |
303 | , NSTAT_SYSINFO_MPTCP_FP_HANDOVER_SUCCESS_WIFI = 170 | |
304 | , NSTAT_SYSINFO_MPTCP_FP_HANDOVER_SUCCESS_CELL = 171 | |
305 | , NSTAT_SYSINFO_MPTCP_FP_INTERACTIVE_SUCCESS = 172 | |
306 | , NSTAT_SYSINFO_MPTCP_FP_AGGREGATE_SUCCESS = 173 | |
307 | , NSTAT_SYSINFO_MPTCP_HANDOVER_CELL_FROM_WIFI = 174 | |
308 | , NSTAT_SYSINFO_MPTCP_HANDOVER_WIFI_FROM_CELL = 175 | |
309 | , NSTAT_SYSINFO_MPTCP_INTERACTIVE_CELL_FROM_WIFI = 176 | |
310 | , NSTAT_SYSINFO_MPTCP_HANDOVER_CELL_BYTES = 177 | |
311 | , NSTAT_SYSINFO_MPTCP_INTERACTIVE_CELL_BYTES = 178 | |
312 | , NSTAT_SYSINFO_MPTCP_AGGREGATE_CELL_BYTES = 179 | |
313 | , NSTAT_SYSINFO_MPTCP_HANDOVER_ALL_BYTES = 180 | |
314 | , NSTAT_SYSINFO_MPTCP_INTERACTIVE_ALL_BYTES = 181 | |
315 | , NSTAT_SYSINFO_MPTCP_AGGREGATE_ALL_BYTES = 182 | |
316 | , NSTAT_SYSINFO_MPTCP_BACK_TO_WIFI = 183 | |
317 | , NSTAT_SYSINFO_MPTCP_WIFI_PROXY = 184 | |
318 | , NSTAT_SYSINFO_MPTCP_CELL_PROXY = 185 | |
319 | , NSTAT_SYSINFO_ECN_IFNET_FALLBACK_SYNRST = 186 | |
320 | , NSTAT_SYSINFO_MPTCP_TRIGGERED_CELL = 187 | |
5ba3f43e | 321 | |
490019cf | 322 | // NSTAT_SYSINFO_ENUM_VERSION must be updated any time a value is added |
0a7de745 | 323 | #define NSTAT_SYSINFO_ENUM_VERSION 20180416 |
fe8ab488 A |
324 | }; |
325 | ||
0a7de745 A |
326 | #define NSTAT_SYSINFO_API_FIRST NSTAT_SYSINFO_API_IF_FLTR_ATTACH |
327 | #define NSTAT_SYSINFO_API_LAST NSTAT_SYSINFO_API_REPORT_INTERVAL | |
5ba3f43e | 328 | |
6d2010ae A |
329 | #pragma mark -- Network Statistics Providers -- |
330 | ||
3e170ce0 A |
331 | |
332 | // Interface properties | |
333 | ||
cb323159 A |
334 | #define NSTAT_IFNET_IS_UNKNOWN_TYPE 0x0001 |
335 | #define NSTAT_IFNET_IS_LOOPBACK 0x0002 | |
336 | #define NSTAT_IFNET_IS_CELLULAR 0x0004 | |
337 | #define NSTAT_IFNET_IS_WIFI 0x0008 | |
338 | #define NSTAT_IFNET_IS_WIRED 0x0010 | |
339 | #define NSTAT_IFNET_IS_AWDL 0x0020 | |
340 | #define NSTAT_IFNET_IS_EXPENSIVE 0x0040 | |
341 | #define NSTAT_IFNET_IS_VPN 0x0080 | |
342 | #define NSTAT_IFNET_VIA_CELLFALLBACK 0x0100 | |
343 | #define NSTAT_IFNET_IS_COMPANIONLINK 0x0200 | |
344 | #define NSTAT_IFNET_IS_CONSTRAINED 0x0400 | |
345 | // The following local and non-local flags are set only if fully known | |
346 | // They are mutually exclusive but there is no guarantee that one or the other will be set | |
347 | #define NSTAT_IFNET_IS_LOCAL 0x0800 | |
348 | #define NSTAT_IFNET_IS_NON_LOCAL 0x1000 | |
5ba3f43e | 349 | // Temporary properties of use for bringing up userland providers |
cb323159 A |
350 | #define NSTAT_IFNET_ROUTE_VALUE_UNOBTAINABLE 0x2000 |
351 | #define NSTAT_IFNET_FLOWSWITCH_VALUE_UNOBTAINABLE 0x4000 | |
3e170ce0 A |
352 | |
353 | ||
cb323159 A |
354 | typedef enum { |
355 | NSTAT_PROVIDER_NONE = 0 | |
356 | , NSTAT_PROVIDER_ROUTE = 1 | |
357 | , NSTAT_PROVIDER_TCP_KERNEL = 2 | |
0a7de745 | 358 | , NSTAT_PROVIDER_TCP_USERLAND = 3 |
cb323159 | 359 | , NSTAT_PROVIDER_UDP_KERNEL = 4 |
0a7de745 | 360 | , NSTAT_PROVIDER_UDP_USERLAND = 5 |
cb323159 A |
361 | , NSTAT_PROVIDER_IFNET = 6 |
362 | , NSTAT_PROVIDER_SYSINFO = 7 | |
363 | , NSTAT_PROVIDER_QUIC_USERLAND = 8 | |
364 | } nstat_provider_type_t; | |
365 | #define NSTAT_PROVIDER_LAST NSTAT_PROVIDER_QUIC_USERLAND | |
3e170ce0 | 366 | #define NSTAT_PROVIDER_COUNT (NSTAT_PROVIDER_LAST+1) |
6d2010ae | 367 | |
0a7de745 A |
368 | typedef struct nstat_route_add_param { |
369 | union{ | |
370 | struct sockaddr_in v4; | |
371 | struct sockaddr_in6 v6; | |
6d2010ae | 372 | } dst; |
0a7de745 A |
373 | union{ |
374 | struct sockaddr_in v4; | |
375 | struct sockaddr_in6 v6; | |
6d2010ae | 376 | } mask; |
0a7de745 | 377 | u_int32_t ifindex; |
6d2010ae A |
378 | } nstat_route_add_param; |
379 | ||
0a7de745 A |
380 | typedef struct nstat_tcp_add_param { |
381 | union{ | |
382 | struct sockaddr_in v4; | |
383 | struct sockaddr_in6 v6; | |
6d2010ae | 384 | } local; |
0a7de745 A |
385 | union{ |
386 | struct sockaddr_in v4; | |
387 | struct sockaddr_in6 v6; | |
6d2010ae A |
388 | } remote; |
389 | } nstat_tcp_add_param; | |
390 | ||
0a7de745 A |
391 | typedef struct nstat_tcp_descriptor { |
392 | u_int64_t upid __attribute__((aligned(sizeof(u_int64_t)))); | |
393 | u_int64_t eupid __attribute__((aligned(sizeof(u_int64_t)))); | |
394 | u_int64_t start_timestamp __attribute__((aligned(sizeof(u_int64_t)))); | |
395 | u_int64_t timestamp __attribute__((aligned(sizeof(u_int64_t)))); | |
39037602 | 396 | |
f427ee49 A |
397 | u_int64_t rx_transfer_size __attribute__((aligned(sizeof(u_int64_t)))); |
398 | u_int64_t tx_transfer_size __attribute__((aligned(sizeof(u_int64_t)))); | |
399 | ||
5ba3f43e | 400 | activity_bitmap_t activity_bitmap; |
39037602 | 401 | |
0a7de745 A |
402 | u_int32_t ifindex; |
403 | u_int32_t state; | |
404 | ||
405 | u_int32_t sndbufsize; | |
406 | u_int32_t sndbufused; | |
407 | u_int32_t rcvbufsize; | |
408 | u_int32_t rcvbufused; | |
409 | u_int32_t txunacked; | |
410 | u_int32_t txwindow; | |
411 | u_int32_t txcwindow; | |
412 | u_int32_t traffic_class; | |
413 | u_int32_t traffic_mgt_flags; | |
414 | ||
415 | u_int32_t pid; | |
416 | u_int32_t epid; | |
417 | ||
418 | union{ | |
419 | struct sockaddr_in v4; | |
420 | struct sockaddr_in6 v6; | |
5ba3f43e A |
421 | } local; |
422 | ||
0a7de745 A |
423 | union{ |
424 | struct sockaddr_in v4; | |
425 | struct sockaddr_in6 v6; | |
5ba3f43e A |
426 | } remote; |
427 | ||
0a7de745 A |
428 | char cc_algo[16]; |
429 | char pname[64]; | |
5ba3f43e | 430 | |
0a7de745 A |
431 | uuid_t uuid; |
432 | uuid_t euuid; | |
433 | uuid_t vuuid; | |
f427ee49 | 434 | uuid_t fuuid; |
5ba3f43e A |
435 | union { |
436 | struct tcp_conn_status connstatus; | |
437 | // On armv7k, tcp_conn_status is 1 byte instead of 4 | |
0a7de745 | 438 | uint8_t __pad_connstatus[4]; |
5ba3f43e | 439 | }; |
0a7de745 | 440 | uint16_t ifnet_properties __attribute__((aligned(4))); |
5ba3f43e | 441 | |
0a7de745 | 442 | u_int8_t reserved[6]; |
6d2010ae A |
443 | } nstat_tcp_descriptor; |
444 | ||
0a7de745 | 445 | typedef struct nstat_tcp_add_param nstat_udp_add_param; |
6d2010ae | 446 | |
0a7de745 A |
447 | typedef struct nstat_udp_descriptor { |
448 | u_int64_t upid __attribute__((aligned(sizeof(u_int64_t)))); | |
449 | u_int64_t eupid __attribute__((aligned(sizeof(u_int64_t)))); | |
450 | u_int64_t start_timestamp __attribute__((aligned(sizeof(u_int64_t)))); | |
451 | u_int64_t timestamp __attribute__((aligned(sizeof(u_int64_t)))); | |
5ba3f43e A |
452 | |
453 | activity_bitmap_t activity_bitmap; | |
454 | ||
0a7de745 A |
455 | union{ |
456 | struct sockaddr_in v4; | |
457 | struct sockaddr_in6 v6; | |
6d2010ae | 458 | } local; |
39037602 | 459 | |
0a7de745 A |
460 | union{ |
461 | struct sockaddr_in v4; | |
462 | struct sockaddr_in6 v6; | |
6d2010ae | 463 | } remote; |
39037602 | 464 | |
0a7de745 | 465 | u_int32_t ifindex; |
39037602 | 466 | |
0a7de745 A |
467 | u_int32_t rcvbufsize; |
468 | u_int32_t rcvbufused; | |
469 | u_int32_t traffic_class; | |
39037602 | 470 | |
0a7de745 A |
471 | u_int32_t pid; |
472 | char pname[64]; | |
473 | u_int32_t epid; | |
39236c6e | 474 | |
0a7de745 A |
475 | uuid_t uuid; |
476 | uuid_t euuid; | |
477 | uuid_t vuuid; | |
f427ee49 | 478 | uuid_t fuuid; |
0a7de745 | 479 | uint16_t ifnet_properties; |
5ba3f43e | 480 | |
0a7de745 | 481 | u_int8_t reserved[6]; |
6d2010ae A |
482 | } nstat_udp_descriptor; |
483 | ||
cb323159 A |
484 | /* |
485 | * XXX For now just typedef'ing TCP Nstat descriptor to nstat_quic_descriptor | |
486 | * as for now they report very similar data. | |
487 | * Later when we extend the QUIC descriptor we can just declare its own | |
488 | * descriptor struct. | |
489 | */ | |
490 | typedef struct nstat_tcp_add_param nstat_quic_add_param; | |
491 | typedef struct nstat_tcp_descriptor nstat_quic_descriptor; | |
492 | ||
0a7de745 A |
493 | typedef struct nstat_route_descriptor { |
494 | u_int64_t id __attribute__((aligned(sizeof(u_int64_t)))); | |
495 | u_int64_t parent_id __attribute__((aligned(sizeof(u_int64_t)))); | |
496 | u_int64_t gateway_id __attribute__((aligned(sizeof(u_int64_t)))); | |
497 | ||
498 | union{ | |
499 | struct sockaddr_in v4; | |
500 | struct sockaddr_in6 v6; | |
501 | struct sockaddr sa; | |
6d2010ae | 502 | } dst; |
39037602 | 503 | |
0a7de745 A |
504 | union{ |
505 | struct sockaddr_in v4; | |
506 | struct sockaddr_in6 v6; | |
507 | struct sockaddr sa; | |
6d2010ae | 508 | } mask; |
39037602 | 509 | |
0a7de745 A |
510 | union{ |
511 | struct sockaddr_in v4; | |
512 | struct sockaddr_in6 v6; | |
513 | struct sockaddr sa; | |
6d2010ae | 514 | } gateway; |
39037602 | 515 | |
0a7de745 A |
516 | u_int32_t ifindex; |
517 | u_int32_t flags; | |
39037602 | 518 | |
0a7de745 | 519 | u_int8_t reserved[4]; |
6d2010ae A |
520 | } nstat_route_descriptor; |
521 | ||
0a7de745 A |
522 | typedef struct nstat_ifnet_add_param { |
523 | u_int64_t threshold __attribute__((aligned(sizeof(u_int64_t)))); | |
524 | u_int32_t ifindex; | |
5ba3f43e | 525 | |
0a7de745 | 526 | u_int8_t reserved[4]; |
39236c6e A |
527 | } nstat_ifnet_add_param; |
528 | ||
0a7de745 | 529 | typedef struct nstat_ifnet_desc_cellular_status { |
3e170ce0 | 530 | u_int32_t valid_bitmask; /* indicates which fields are valid */ |
0a7de745 A |
531 | #define NSTAT_IFNET_DESC_CELL_LINK_QUALITY_METRIC_VALID 0x1 |
532 | #define NSTAT_IFNET_DESC_CELL_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
533 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_BANDWIDTH_VALID 0x4 | |
534 | #define NSTAT_IFNET_DESC_CELL_UL_MIN_LATENCY_VALID 0x8 | |
535 | #define NSTAT_IFNET_DESC_CELL_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
536 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_LATENCY_VALID 0x20 | |
537 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_VALID 0x40 | |
538 | #define NSTAT_IFNET_DESC_CELL_UL_BYTES_LOST_VALID 0x80 | |
539 | #define NSTAT_IFNET_DESC_CELL_UL_MIN_QUEUE_SIZE_VALID 0x100 | |
540 | #define NSTAT_IFNET_DESC_CELL_UL_AVG_QUEUE_SIZE_VALID 0x200 | |
541 | #define NSTAT_IFNET_DESC_CELL_UL_MAX_QUEUE_SIZE_VALID 0x400 | |
542 | #define NSTAT_IFNET_DESC_CELL_DL_EFFECTIVE_BANDWIDTH_VALID 0x800 | |
543 | #define NSTAT_IFNET_DESC_CELL_DL_MAX_BANDWIDTH_VALID 0x1000 | |
544 | #define NSTAT_IFNET_DESC_CELL_CONFIG_INACTIVITY_TIME_VALID 0x2000 | |
545 | #define NSTAT_IFNET_DESC_CELL_CONFIG_BACKOFF_TIME_VALID 0x4000 | |
546 | #define NSTAT_IFNET_DESC_CELL_MSS_RECOMMENDED_VALID 0x8000 | |
3e170ce0 A |
547 | u_int32_t link_quality_metric; |
548 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on | |
0a7de745 | 549 | * current activity (bps) */ |
3e170ce0 | 550 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth |
0a7de745 | 551 | * (bps) */ |
3e170ce0 | 552 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop |
0a7de745 | 553 | * (ms) */ |
3e170ce0 | 554 | u_int32_t ul_effective_latency; /* current expected uplink latency for |
0a7de745 | 555 | * first hop (ms) */ |
3e170ce0 | 556 | u_int32_t ul_max_latency; /* max expected uplink latency first hop |
0a7de745 | 557 | * (ms) */ |
3e170ce0 | 558 | u_int32_t ul_retxt_level; /* Retransmission metric */ |
0a7de745 A |
559 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_NONE 1 |
560 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_LOW 2 | |
561 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_MEDIUM 3 | |
562 | #define NSTAT_IFNET_DESC_CELL_UL_RETXT_LEVEL_HIGH 4 | |
3e170ce0 A |
563 | |
564 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 | |
0a7de745 | 565 | * format */ |
3e170ce0 A |
566 | u_int32_t ul_min_queue_size; /* minimum bytes in queue */ |
567 | u_int32_t ul_avg_queue_size; /* average bytes in queue */ | |
568 | u_int32_t ul_max_queue_size; /* maximum bytes in queue */ | |
569 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based | |
0a7de745 | 570 | * on current activity (bps) */ |
3e170ce0 | 571 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth |
0a7de745 | 572 | * (bps) */ |
3e170ce0 A |
573 | u_int32_t config_inactivity_time; /* ms */ |
574 | u_int32_t config_backoff_time; /* new connections backoff time in ms */ | |
0a7de745 A |
575 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_NONE 0x0 |
576 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_MEDIUM 0x1 | |
577 | #define NSTAT_IFNET_DESC_MSS_RECOMMENDED_LOW 0x2 | |
39037602 | 578 | u_int16_t mss_recommended; /* recommended MSS */ |
0a7de745 | 579 | u_int8_t reserved[2]; |
3e170ce0 A |
580 | } nstat_ifnet_desc_cellular_status; |
581 | ||
582 | typedef struct nstat_ifnet_desc_wifi_status { | |
583 | u_int32_t valid_bitmask; | |
0a7de745 A |
584 | #define NSTAT_IFNET_DESC_WIFI_LINK_QUALITY_METRIC_VALID 0x1 |
585 | #define NSTAT_IFNET_DESC_WIFI_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 | |
586 | #define NSTAT_IFNET_DESC_WIFI_UL_MAX_BANDWIDTH_VALID 0x4 | |
587 | #define NSTAT_IFNET_DESC_WIFI_UL_MIN_LATENCY_VALID 0x8 | |
588 | #define NSTAT_IFNET_DESC_WIFI_UL_EFFECTIVE_LATENCY_VALID 0x10 | |
589 | #define NSTAT_IFNET_DESC_WIFI_UL_MAX_LATENCY_VALID 0x20 | |
590 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_VALID 0x40 | |
591 | #define NSTAT_IFNET_DESC_WIFI_UL_ERROR_RATE_VALID 0x80 | |
592 | #define NSTAT_IFNET_DESC_WIFI_UL_BYTES_LOST_VALID 0x100 | |
593 | #define NSTAT_IFNET_DESC_WIFI_DL_EFFECTIVE_BANDWIDTH_VALID 0x200 | |
594 | #define NSTAT_IFNET_DESC_WIFI_DL_MAX_BANDWIDTH_VALID 0x400 | |
595 | #define NSTAT_IFNET_DESC_WIFI_DL_MIN_LATENCY_VALID 0x800 | |
596 | #define NSTAT_IFNET_DESC_WIFI_DL_EFFECTIVE_LATENCY_VALID 0x1000 | |
597 | #define NSTAT_IFNET_DESC_WIFI_DL_MAX_LATENCY_VALID 0x2000 | |
598 | #define NSTAT_IFNET_DESC_WIFI_DL_ERROR_RATE_VALID 0x4000 | |
599 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_VALID 0x8000 | |
600 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_MULTICAST_RATE_VALID 0x10000 | |
601 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_SCAN_COUNT_VALID 0x20000 | |
602 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_SCAN_DURATION_VALID 0x40000 | |
3e170ce0 A |
603 | u_int32_t link_quality_metric; /* link quality metric */ |
604 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on | |
0a7de745 | 605 | * current activity (bps) */ |
3e170ce0 | 606 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth |
0a7de745 | 607 | * (bps) */ |
3e170ce0 | 608 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop |
0a7de745 | 609 | * (ms) */ |
3e170ce0 | 610 | u_int32_t ul_effective_latency; /* current expected uplink latency for |
0a7de745 | 611 | * first hop (ms) */ |
3e170ce0 | 612 | u_int32_t ul_max_latency; /* max expected uplink latency for first hop |
0a7de745 | 613 | * (ms) */ |
3e170ce0 | 614 | u_int32_t ul_retxt_level; /* Retransmission metric */ |
0a7de745 A |
615 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_NONE 1 |
616 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_LOW 2 | |
617 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_MEDIUM 3 | |
618 | #define NSTAT_IFNET_DESC_WIFI_UL_RETXT_LEVEL_HIGH 4 | |
3e170ce0 A |
619 | |
620 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 | |
0a7de745 | 621 | * format */ |
3e170ce0 | 622 | u_int32_t ul_error_rate; /* % of bytes dropped on uplink after many |
0a7de745 | 623 | * retransmissions in Q10 format */ |
3e170ce0 | 624 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based |
0a7de745 | 625 | * on current activity (bps) */ |
3e170ce0 | 626 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth |
0a7de745 | 627 | * (bps) */ |
3e170ce0 A |
628 | /* |
629 | * The download latency values indicate the time AP may have to wait | |
630 | * for the driver to receive the packet. These values give the range | |
631 | * of expected latency mainly due to co-existence events and channel | |
632 | * hopping where the interface becomes unavailable. | |
633 | */ | |
634 | u_int32_t dl_min_latency; /* min expected latency for first hop in ms */ | |
635 | u_int32_t dl_effective_latency; /* current expected latency for first | |
0a7de745 | 636 | * hop in ms */ |
3e170ce0 A |
637 | u_int32_t dl_max_latency; /* max expected latency for first hop in ms */ |
638 | u_int32_t dl_error_rate; /* % of CRC or other errors in Q10 format */ | |
639 | u_int32_t config_frequency; /* 2.4 or 5 GHz */ | |
0a7de745 A |
640 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_2_4_GHZ 1 |
641 | #define NSTAT_IFNET_DESC_WIFI_CONFIG_FREQUENCY_5_0_GHZ 2 | |
3e170ce0 A |
642 | u_int32_t config_multicast_rate; /* bps */ |
643 | u_int32_t scan_count; /* scan count during the previous period */ | |
644 | u_int32_t scan_duration; /* scan duration in ms */ | |
645 | } nstat_ifnet_desc_wifi_status; | |
646 | ||
0a7de745 | 647 | enum{ |
3e170ce0 | 648 | NSTAT_IFNET_DESC_LINK_STATUS_TYPE_NONE = 0 |
0a7de745 A |
649 | , NSTAT_IFNET_DESC_LINK_STATUS_TYPE_CELLULAR = 1 |
650 | , NSTAT_IFNET_DESC_LINK_STATUS_TYPE_WIFI = 2 | |
651 | , NSTAT_IFNET_DESC_LINK_STATUS_TYPE_ETHERNET = 3 | |
3e170ce0 A |
652 | }; |
653 | ||
0a7de745 A |
654 | typedef struct nstat_ifnet_desc_link_status { |
655 | u_int32_t link_status_type; | |
3e170ce0 | 656 | union { |
0a7de745 A |
657 | nstat_ifnet_desc_cellular_status cellular; |
658 | nstat_ifnet_desc_wifi_status wifi; | |
3e170ce0 A |
659 | } u; |
660 | } nstat_ifnet_desc_link_status; | |
661 | ||
0a7de745 A |
662 | #ifndef IF_DESCSIZE |
663 | #define IF_DESCSIZE 128 | |
39236c6e | 664 | #endif |
0a7de745 A |
665 | typedef struct nstat_ifnet_descriptor { |
666 | u_int64_t threshold __attribute__((aligned(sizeof(u_int64_t)))); | |
667 | u_int32_t ifindex; | |
668 | nstat_ifnet_desc_link_status link_status; | |
669 | unsigned int type; | |
670 | char description[IF_DESCSIZE]; | |
671 | char name[IFNAMSIZ + 1]; | |
672 | u_int8_t reserved[3]; | |
39236c6e A |
673 | } nstat_ifnet_descriptor; |
674 | ||
0a7de745 A |
675 | typedef struct nstat_sysinfo_descriptor { |
676 | u_int32_t flags; | |
fe8ab488 A |
677 | } nstat_sysinfo_descriptor; |
678 | ||
0a7de745 | 679 | typedef struct nstat_sysinfo_add_param { |
fe8ab488 | 680 | /* To indicate which system level information should be collected */ |
0a7de745 | 681 | u_int32_t flags; |
fe8ab488 A |
682 | } nstat_sysinfo_add_param; |
683 | ||
0a7de745 A |
684 | #define NSTAT_SYSINFO_MBUF_STATS 0x0001 |
685 | #define NSTAT_SYSINFO_TCP_STATS 0x0002 | |
686 | #define NSTAT_SYSINFO_IFNET_ECN_STATS 0x0003 | |
687 | #define NSTAT_SYSINFO_LIM_STATS 0x0004 /* Low Internet mode stats */ | |
688 | #define NSTAT_SYSINFO_NET_API_STATS 0x0005 /* API and KPI stats */ | |
fe8ab488 | 689 | |
6d2010ae A |
690 | #pragma mark -- Network Statistics User Client -- |
691 | ||
0a7de745 | 692 | #define NET_STAT_CONTROL_NAME "com.apple.network.statistics" |
6d2010ae | 693 | |
0a7de745 | 694 | enum{ |
316670eb | 695 | // generic response messages |
cb323159 A |
696 | NSTAT_MSG_TYPE_SUCCESS = 0 |
697 | , NSTAT_MSG_TYPE_ERROR = 1 | |
0a7de745 A |
698 | |
699 | // Requests | |
cb323159 A |
700 | , NSTAT_MSG_TYPE_ADD_SRC = 1001 |
701 | , NSTAT_MSG_TYPE_ADD_ALL_SRCS = 1002 | |
702 | , NSTAT_MSG_TYPE_REM_SRC = 1003 | |
703 | , NSTAT_MSG_TYPE_QUERY_SRC = 1004 | |
704 | , NSTAT_MSG_TYPE_GET_SRC_DESC = 1005 | |
f427ee49 | 705 | , NSTAT_MSG_TYPE_SET_FILTER = 1006 // Obsolete |
cb323159 A |
706 | , NSTAT_MSG_TYPE_GET_UPDATE = 1007 |
707 | , NSTAT_MSG_TYPE_SUBSCRIBE_SYSINFO = 1008 | |
0a7de745 A |
708 | |
709 | // Responses/Notfications | |
cb323159 A |
710 | , NSTAT_MSG_TYPE_SRC_ADDED = 10001 |
711 | , NSTAT_MSG_TYPE_SRC_REMOVED = 10002 | |
712 | , NSTAT_MSG_TYPE_SRC_DESC = 10003 | |
713 | , NSTAT_MSG_TYPE_SRC_COUNTS = 10004 | |
714 | , NSTAT_MSG_TYPE_SYSINFO_COUNTS = 10005 | |
715 | , NSTAT_MSG_TYPE_SRC_UPDATE = 10006 | |
6d2010ae A |
716 | }; |
717 | ||
0a7de745 A |
718 | enum{ |
719 | NSTAT_SRC_REF_ALL = 0xffffffffffffffffULL | |
720 | , NSTAT_SRC_REF_INVALID = 0 | |
6d2010ae A |
721 | }; |
722 | ||
3e170ce0 | 723 | /* Source-level filters */ |
0a7de745 | 724 | enum{ |
3e170ce0 A |
725 | NSTAT_FILTER_NOZEROBYTES = 0x00000001 |
726 | }; | |
727 | ||
728 | /* Provider-level filters */ | |
0a7de745 | 729 | enum{ |
cb323159 | 730 | NSTAT_FILTER_ACCEPT_UNKNOWN = 0x00000001 |
0a7de745 A |
731 | , NSTAT_FILTER_ACCEPT_LOOPBACK = 0x00000002 |
732 | , NSTAT_FILTER_ACCEPT_CELLULAR = 0x00000004 | |
733 | , NSTAT_FILTER_ACCEPT_WIFI = 0x00000008 | |
734 | , NSTAT_FILTER_ACCEPT_WIRED = 0x00000010 | |
735 | , NSTAT_FILTER_ACCEPT_AWDL = 0x00000020 | |
736 | , NSTAT_FILTER_ACCEPT_EXPENSIVE = 0x00000040 | |
737 | , NSTAT_FILTER_ACCEPT_CELLFALLBACK = 0x00000100 | |
cb323159 A |
738 | , NSTAT_FILTER_ACCEPT_COMPANIONLINK = 0x00000200 |
739 | , NSTAT_FILTER_ACCEPT_IS_CONSTRAINED = 0x00000400 | |
740 | , NSTAT_FILTER_ACCEPT_IS_LOCAL = 0x00000800 | |
741 | , NSTAT_FILTER_ACCEPT_IS_NON_LOCAL = 0x00001000 | |
f427ee49 A |
742 | , NSTAT_FILTER_ACCEPT_ROUTE_VAL_ERR = 0x00002000 |
743 | , NSTAT_FILTER_ACCEPT_FLOWSWITCH_ERR = 0x00004000 | |
744 | , NSTAT_FILTER_IFNET_FLAGS = 0x0000FFFF | |
0a7de745 A |
745 | |
746 | , NSTAT_FILTER_UDP_INTERFACE_ATTACH = 0x00010000 | |
f427ee49 A |
747 | , NSTAT_FILTER_UDP_FLAGS = 0x00010000 |
748 | ||
749 | , NSTAT_FILTER_TCP_INTERFACE_ATTACH = 0x00040000 | |
750 | , NSTAT_FILTER_TCP_NO_EARLY_CLOSE = 0x00080000 | |
751 | , NSTAT_FILTER_TCP_FLAGS = 0x000C0000 | |
0a7de745 A |
752 | |
753 | , NSTAT_FILTER_SUPPRESS_SRC_ADDED = 0x00100000 | |
754 | , NSTAT_FILTER_REQUIRE_SRC_ADDED = 0x00200000 | |
755 | , NSTAT_FILTER_PROVIDER_NOZEROBYTES = 0x00400000 | |
756 | ||
757 | , NSTAT_FILTER_SPECIFIC_USER_BY_PID = 0x01000000 | |
758 | , NSTAT_FILTER_SPECIFIC_USER_BY_EPID = 0x02000000 | |
759 | , NSTAT_FILTER_SPECIFIC_USER_BY_UUID = 0x04000000 | |
760 | , NSTAT_FILTER_SPECIFIC_USER_BY_EUUID = 0x08000000 | |
761 | , NSTAT_FILTER_SPECIFIC_USER = 0x0F000000 | |
3e170ce0 A |
762 | }; |
763 | ||
0a7de745 A |
764 | enum{ |
765 | NSTAT_MSG_HDR_FLAG_SUPPORTS_AGGREGATE = 1 << 0, | |
766 | NSTAT_MSG_HDR_FLAG_CONTINUATION = 1 << 1, | |
767 | NSTAT_MSG_HDR_FLAG_CLOSING = 1 << 2, | |
39236c6e A |
768 | }; |
769 | ||
0a7de745 A |
770 | typedef struct nstat_msg_hdr { |
771 | u_int64_t context __attribute__((aligned(sizeof(u_int64_t)))); | |
772 | u_int32_t type; | |
773 | u_int16_t length; | |
774 | u_int16_t flags; | |
6d2010ae A |
775 | } nstat_msg_hdr; |
776 | ||
f427ee49 A |
777 | #define MAX_NSTAT_MSG_HDR_LENGTH 65532 |
778 | ||
0a7de745 A |
779 | typedef struct nstat_msg_error { |
780 | nstat_msg_hdr hdr; | |
781 | u_int32_t error; // errno error | |
782 | u_int8_t reserved[4]; | |
6d2010ae A |
783 | } nstat_msg_error; |
784 | ||
0a7de745 A |
785 | #define NSTAT_ADD_SRC_FIELDS \ |
786 | nstat_msg_hdr hdr; \ | |
787 | nstat_provider_id_t provider; \ | |
788 | u_int8_t reserved[4] \ | |
5ba3f43e | 789 | |
0a7de745 | 790 | typedef struct nstat_msg_add_src { |
5ba3f43e | 791 | NSTAT_ADD_SRC_FIELDS; |
0a7de745 | 792 | u_int8_t param[]; |
6d2010ae A |
793 | } nstat_msg_add_src_req; |
794 | ||
0a7de745 | 795 | typedef struct nstat_msg_add_src_header { |
5ba3f43e A |
796 | NSTAT_ADD_SRC_FIELDS; |
797 | } nstat_msg_add_src_header; | |
798 | ||
0a7de745 A |
799 | typedef struct nstat_msg_add_src_convenient { |
800 | nstat_msg_add_src_header hdr; | |
5ba3f43e | 801 | union { |
0a7de745 A |
802 | nstat_route_add_param route; |
803 | nstat_tcp_add_param tcp; | |
804 | nstat_udp_add_param udp; | |
805 | nstat_ifnet_add_param ifnet; | |
806 | nstat_sysinfo_add_param sysinfo; | |
5ba3f43e A |
807 | }; |
808 | } nstat_msg_add_src_convenient; | |
809 | ||
810 | #undef NSTAT_ADD_SRC_FIELDS | |
811 | ||
0a7de745 A |
812 | typedef struct nstat_msg_add_all_srcs { |
813 | nstat_msg_hdr hdr; | |
cb323159 | 814 | u_int64_t filter __attribute__((aligned(sizeof(u_int64_t)))); |
0a7de745 A |
815 | nstat_event_flags_t events __attribute__((aligned(sizeof(u_int64_t)))); |
816 | nstat_provider_id_t provider; | |
cb323159 A |
817 | pid_t target_pid; |
818 | uuid_t target_uuid; | |
6d2010ae A |
819 | } nstat_msg_add_all_srcs; |
820 | ||
0a7de745 A |
821 | typedef struct nstat_msg_src_added { |
822 | nstat_msg_hdr hdr; | |
823 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
824 | nstat_provider_id_t provider; | |
cb323159 | 825 | u_int8_t reserved[4]; |
6d2010ae A |
826 | } nstat_msg_src_added; |
827 | ||
0a7de745 A |
828 | typedef struct nstat_msg_rem_src { |
829 | nstat_msg_hdr hdr; | |
830 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
6d2010ae A |
831 | } nstat_msg_rem_src_req; |
832 | ||
0a7de745 A |
833 | typedef struct nstat_msg_get_src_description { |
834 | nstat_msg_hdr hdr; | |
835 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
6d2010ae A |
836 | } nstat_msg_get_src_description; |
837 | ||
0a7de745 A |
838 | typedef struct nstat_msg_set_filter { |
839 | nstat_msg_hdr hdr; | |
840 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
cb323159 A |
841 | u_int32_t filter; |
842 | u_int8_t reserved[4]; | |
39236c6e A |
843 | } nstat_msg_set_filter; |
844 | ||
0a7de745 A |
845 | #define NSTAT_SRC_DESCRIPTION_FIELDS \ |
846 | nstat_msg_hdr hdr; \ | |
847 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); \ | |
848 | nstat_event_flags_t event_flags __attribute__((aligned(sizeof(u_int64_t)))); \ | |
849 | nstat_provider_id_t provider; \ | |
5ba3f43e A |
850 | u_int8_t reserved[4] |
851 | ||
0a7de745 | 852 | typedef struct nstat_msg_src_description { |
5ba3f43e | 853 | NSTAT_SRC_DESCRIPTION_FIELDS; |
0a7de745 | 854 | u_int8_t data[]; |
6d2010ae A |
855 | } nstat_msg_src_description; |
856 | ||
0a7de745 | 857 | typedef struct nstat_msg_src_description_header { |
5ba3f43e A |
858 | NSTAT_SRC_DESCRIPTION_FIELDS; |
859 | } nstat_msg_src_description_header; | |
860 | ||
0a7de745 | 861 | typedef struct nstat_msg_src_description_convenient { |
cb323159 | 862 | nstat_msg_src_description_header hdr; |
5ba3f43e | 863 | union { |
cb323159 A |
864 | nstat_tcp_descriptor tcp; |
865 | nstat_udp_descriptor udp; | |
866 | nstat_route_descriptor route; | |
867 | nstat_ifnet_descriptor ifnet; | |
868 | nstat_sysinfo_descriptor sysinfo; | |
869 | nstat_quic_descriptor quic; | |
5ba3f43e A |
870 | }; |
871 | } nstat_msg_src_description_convenient; | |
872 | ||
873 | #undef NSTAT_SRC_DESCRIPTION_FIELDS | |
874 | ||
0a7de745 A |
875 | typedef struct nstat_msg_query_src { |
876 | nstat_msg_hdr hdr; | |
877 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
6d2010ae A |
878 | } nstat_msg_query_src_req; |
879 | ||
0a7de745 A |
880 | typedef struct nstat_msg_src_counts { |
881 | nstat_msg_hdr hdr; | |
882 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
883 | nstat_event_flags_t event_flags __attribute__((aligned(sizeof(u_int64_t)))); | |
884 | nstat_counts counts; | |
6d2010ae A |
885 | } nstat_msg_src_counts; |
886 | ||
0a7de745 A |
887 | #define NSTAT_SRC_UPDATE_FIELDS \ |
888 | nstat_msg_hdr hdr; \ | |
889 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); \ | |
890 | nstat_event_flags_t event_flags __attribute__((aligned(sizeof(u_int64_t)))); \ | |
891 | nstat_counts counts; \ | |
892 | nstat_provider_id_t provider; \ | |
5ba3f43e A |
893 | u_int8_t reserved[4] |
894 | ||
0a7de745 | 895 | typedef struct nstat_msg_src_update { |
5ba3f43e | 896 | NSTAT_SRC_UPDATE_FIELDS; |
0a7de745 | 897 | u_int8_t data[]; |
3e170ce0 A |
898 | } nstat_msg_src_update; |
899 | ||
0a7de745 | 900 | typedef struct nstat_msg_src_update_hdr { |
5ba3f43e A |
901 | NSTAT_SRC_UPDATE_FIELDS; |
902 | } nstat_msg_src_update_hdr; | |
903 | ||
0a7de745 A |
904 | typedef struct nstat_msg_src_update_convenient { |
905 | nstat_msg_src_update_hdr hdr; | |
5ba3f43e | 906 | union { |
0a7de745 A |
907 | nstat_tcp_descriptor tcp; |
908 | nstat_udp_descriptor udp; | |
909 | nstat_route_descriptor route; | |
910 | nstat_ifnet_descriptor ifnet; | |
911 | nstat_sysinfo_descriptor sysinfo; | |
cb323159 | 912 | nstat_quic_descriptor quic; |
5ba3f43e A |
913 | }; |
914 | } nstat_msg_src_update_convenient; | |
915 | ||
916 | #undef NSTAT_SRC_UPDATE_FIELDS | |
917 | ||
0a7de745 A |
918 | typedef struct nstat_msg_src_removed { |
919 | nstat_msg_hdr hdr; | |
920 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
6d2010ae A |
921 | } nstat_msg_src_removed; |
922 | ||
0a7de745 A |
923 | typedef struct nstat_msg_sysinfo_counts { |
924 | nstat_msg_hdr hdr; | |
925 | nstat_src_ref_t srcref __attribute__((aligned(sizeof(u_int64_t)))); | |
926 | nstat_sysinfo_counts counts; | |
5ba3f43e | 927 | } nstat_msg_sysinfo_counts; |
3e170ce0 A |
928 | |
929 | #pragma mark -- Statitiscs about Network Statistics -- | |
930 | ||
931 | struct nstat_stats { | |
932 | u_int32_t nstat_successmsgfailures; | |
933 | u_int32_t nstat_sendcountfailures; | |
934 | u_int32_t nstat_sysinfofailures; | |
935 | u_int32_t nstat_srcupatefailures; | |
936 | u_int32_t nstat_descriptionfailures; | |
937 | u_int32_t nstat_msgremovedfailures; | |
938 | u_int32_t nstat_srcaddedfailures; | |
939 | u_int32_t nstat_msgerrorfailures; | |
940 | u_int32_t nstat_copy_descriptor_failures; | |
941 | u_int32_t nstat_provider_counts_failures; | |
942 | u_int32_t nstat_control_send_description_failures; | |
943 | u_int32_t nstat_control_send_goodbye_failures; | |
944 | u_int32_t nstat_flush_accumulated_msgs_failures; | |
945 | u_int32_t nstat_accumulate_msg_failures; | |
946 | u_int32_t nstat_control_cleanup_source_failures; | |
947 | u_int32_t nstat_handle_msg_failures; | |
948 | }; | |
949 | ||
950 | #endif /* PRIVATE */ | |
951 | ||
952 | #ifdef XNU_KERNEL_PRIVATE | |
953 | #include <sys/mcache.h> | |
954 | ||
955 | #pragma mark -- System Information Internal Support -- | |
fe8ab488 | 956 | |
0a7de745 | 957 | typedef struct nstat_sysinfo_mbuf_stats { |
cb323159 A |
958 | u_int32_t total_256b; /* Peak usage, 256B pool */ |
959 | u_int32_t total_2kb; /* Peak usage, 2KB pool */ | |
960 | u_int32_t total_4kb; /* Peak usage, 4KB pool */ | |
961 | u_int32_t total_16kb; /* Peak usage, 16KB pool */ | |
962 | u_int32_t sbmb_total; /* Total mbufs in sock buffer pool */ | |
963 | u_int32_t sb_atmbuflimit; /* Memory limit reached for socket buffer autoscaling */ | |
964 | u_int32_t draincnt; /* Number of times mbuf pool has been drained under memory pressure */ | |
965 | u_int32_t memreleased; /* Memory (bytes) released from mbuf pool to VM */ | |
966 | u_int32_t sbmb_floor; /* Lowest mbufs in sock buffer pool */ | |
fe8ab488 A |
967 | } nstat_sysinfo_mbuf_stats; |
968 | ||
0a7de745 | 969 | typedef struct nstat_sysinfo_tcp_stats { |
5ba3f43e | 970 | /* When adding/removing here, also adjust NSTAT_SYSINFO_TCP_STATS_COUNT */ |
cb323159 A |
971 | u_int32_t ipv4_avgrtt; /* Average RTT for IPv4 */ |
972 | u_int32_t ipv6_avgrtt; /* Average RTT for IPv6 */ | |
973 | u_int32_t send_plr; /* Average uplink packet loss rate */ | |
974 | u_int32_t recv_plr; /* Average downlink packet loss rate */ | |
975 | u_int32_t send_tlrto_rate; /* Average rxt timeout after tail loss */ | |
976 | u_int32_t send_reorder_rate; /* Average packet reordering rate */ | |
977 | u_int32_t connection_attempts; /* TCP client connection attempts */ | |
978 | u_int32_t connection_accepts; /* TCP server connection accepts */ | |
979 | u_int32_t ecn_client_enabled; /* Global setting for ECN client side */ | |
980 | u_int32_t ecn_server_enabled; /* Global setting for ECN server side */ | |
981 | u_int32_t ecn_client_setup; /* Attempts to setup TCP client connection with ECN */ | |
982 | u_int32_t ecn_server_setup; /* Attempts to setup TCP server connection with ECN */ | |
983 | u_int32_t ecn_client_success; /* Number of successful negotiations of ECN for a client connection */ | |
984 | u_int32_t ecn_server_success; /* Number of successful negotiations of ECN for a server connection */ | |
985 | u_int32_t ecn_not_supported; /* Number of falbacks to Non-ECN, no support from peer */ | |
986 | u_int32_t ecn_lost_syn; /* Number of SYNs lost with ECN bits */ | |
987 | u_int32_t ecn_lost_synack; /* Number of SYN-ACKs lost with ECN bits */ | |
988 | u_int32_t ecn_recv_ce; /* Number of CEs received from network */ | |
989 | u_int32_t ecn_recv_ece; /* Number of ECEs received from receiver */ | |
990 | u_int32_t ecn_sent_ece; /* Number of ECEs sent in response to CE */ | |
991 | u_int32_t ecn_conn_recv_ce; /* Number of connections using ECN received CE at least once */ | |
992 | u_int32_t ecn_conn_recv_ece; /* Number of connections using ECN received ECE at least once */ | |
993 | u_int32_t ecn_conn_plnoce; /* Number of connections using ECN seen packet loss but never received CE */ | |
994 | u_int32_t ecn_conn_pl_ce; /* Number of connections using ECN seen packet loss and CE */ | |
995 | u_int32_t ecn_conn_nopl_ce; /* Number of connections using ECN with no packet loss but received CE */ | |
996 | u_int32_t ecn_fallback_synloss; /* Number of times we did fall back due to SYN-Loss */ | |
997 | u_int32_t ecn_fallback_reorder; /* Number of times we fallback because we detected the PAWS-issue */ | |
998 | u_int32_t ecn_fallback_ce; /* Number of times we fallback because we received too many CEs */ | |
999 | u_int32_t tfo_syn_data_rcv; /* Number of SYN+data received with valid cookie */ | |
1000 | u_int32_t tfo_cookie_req_rcv;/* Number of TFO cookie-requests received */ | |
1001 | u_int32_t tfo_cookie_sent; /* Number of TFO-cookies offered to the client */ | |
1002 | u_int32_t tfo_cookie_invalid;/* Number of invalid TFO-cookies received */ | |
1003 | u_int32_t tfo_cookie_req; /* Number of SYNs with cookie request received*/ | |
1004 | u_int32_t tfo_cookie_rcv; /* Number of SYN/ACKs with Cookie received */ | |
1005 | u_int32_t tfo_syn_data_sent; /* Number of SYNs+data+cookie sent */ | |
1006 | u_int32_t tfo_syn_data_acked;/* Number of times our SYN+data has been acknowledged */ | |
1007 | u_int32_t tfo_syn_loss; /* Number of times SYN+TFO has been lost and we fallback */ | |
1008 | u_int32_t tfo_blackhole; /* Number of times SYN+TFO has been lost and we fallback */ | |
1009 | u_int32_t tfo_cookie_wrong; /* TFO-cookie we sent was wrong */ | |
1010 | u_int32_t tfo_no_cookie_rcv; /* We asked for a cookie but didn't get one */ | |
1011 | u_int32_t tfo_heuristics_disable; /* TFO got disabled due to heuristics */ | |
1012 | u_int32_t tfo_sndblackhole; /* TFO got blackholed in the sending direction */ | |
1013 | u_int32_t mptcp_handover_attempt; /* Total number of MPTCP-attempts using handover mode */ | |
1014 | u_int32_t mptcp_interactive_attempt; /* Total number of MPTCP-attempts using interactive mode */ | |
1015 | u_int32_t mptcp_aggregate_attempt; /* Total number of MPTCP-attempts using aggregate mode */ | |
1016 | u_int32_t mptcp_fp_handover_attempt; /* Same as previous three but only for first-party apps */ | |
1017 | u_int32_t mptcp_fp_interactive_attempt; | |
1018 | u_int32_t mptcp_fp_aggregate_attempt; | |
1019 | u_int32_t mptcp_heuristic_fallback; /* Total number of MPTCP-connections that fell back due to heuristics */ | |
1020 | u_int32_t mptcp_fp_heuristic_fallback; /* Same as previous but for first-party apps */ | |
1021 | u_int32_t mptcp_handover_success_wifi; /* Total number of successfull handover-mode connections that *started* on WiFi */ | |
1022 | u_int32_t mptcp_handover_success_cell; /* Total number of successfull handover-mode connections that *started* on Cell */ | |
1023 | u_int32_t mptcp_interactive_success; /* Total number of interactive-mode connections that negotiated MPTCP */ | |
1024 | u_int32_t mptcp_aggregate_success; /* Same as previous but for aggregate */ | |
1025 | u_int32_t mptcp_fp_handover_success_wifi; /* Same as previous four, but for first-party apps */ | |
1026 | u_int32_t mptcp_fp_handover_success_cell; | |
1027 | u_int32_t mptcp_fp_interactive_success; | |
1028 | u_int32_t mptcp_fp_aggregate_success; | |
1029 | u_int32_t mptcp_handover_cell_from_wifi; /* Total number of connections that use cell in handover-mode (coming from WiFi) */ | |
1030 | u_int32_t mptcp_handover_wifi_from_cell; /* Total number of connections that use WiFi in handover-mode (coming from cell) */ | |
1031 | u_int32_t mptcp_interactive_cell_from_wifi; /* Total number of connections that use cell in interactive mode (coming from WiFi) */ | |
1032 | u_int32_t mptcp_back_to_wifi; /* Total number of connections that succeed to move traffic away from cell (when starting on cell) */ | |
1033 | u_int64_t mptcp_handover_cell_bytes; /* Total number of bytes sent on cell in handover-mode (on new subflows, ignoring initial one) */ | |
1034 | u_int64_t mptcp_interactive_cell_bytes; /* Same as previous but for interactive */ | |
1035 | u_int64_t mptcp_aggregate_cell_bytes; | |
1036 | u_int64_t mptcp_handover_all_bytes; /* Total number of bytes sent in handover */ | |
1037 | u_int64_t mptcp_interactive_all_bytes; | |
1038 | u_int64_t mptcp_aggregate_all_bytes; | |
1039 | u_int32_t mptcp_wifi_proxy; /* Total number of new subflows that fell back to regular TCP on cell */ | |
1040 | u_int32_t mptcp_cell_proxy; /* Total number of new subflows that fell back to regular TCP on WiFi */ | |
1041 | u_int32_t mptcp_triggered_cell; /* Total number of times an MPTCP-connection triggered cell bringup */ | |
1042 | u_int32_t _padding; | |
5ba3f43e | 1043 | /* When adding/removing here, also adjust NSTAT_SYSINFO_TCP_STATS_COUNT */ |
fe8ab488 | 1044 | } nstat_sysinfo_tcp_stats; |
0a7de745 | 1045 | #define NSTAT_SYSINFO_TCP_STATS_COUNT 71 |
fe8ab488 | 1046 | |
4bd07ac2 A |
1047 | enum { |
1048 | NSTAT_IFNET_ECN_PROTO_IPV4 = 1 | |
0a7de745 | 1049 | , NSTAT_IFNET_ECN_PROTO_IPV6 |
4bd07ac2 A |
1050 | }; |
1051 | ||
1052 | enum { | |
1053 | NSTAT_IFNET_ECN_TYPE_CELLULAR = 1 | |
0a7de745 A |
1054 | , NSTAT_IFNET_ECN_TYPE_WIFI |
1055 | , NSTAT_IFNET_ECN_TYPE_ETHERNET | |
4bd07ac2 A |
1056 | }; |
1057 | ||
1058 | typedef struct nstat_sysinfo_ifnet_ecn_stats { | |
cb323159 A |
1059 | u_int32_t ifnet_proto; |
1060 | u_int32_t ifnet_type; | |
1061 | struct if_tcp_ecn_stat ecn_stat; | |
4bd07ac2 A |
1062 | } nstat_sysinfo_ifnet_ecn_stats; |
1063 | ||
5ba3f43e | 1064 | /* Total number of Low Internet stats that will be reported */ |
0a7de745 | 1065 | #define NSTAT_LIM_STAT_KEYVAL_COUNT 12 |
5ba3f43e | 1066 | typedef struct nstat_sysinfo_lim_stats { |
cb323159 A |
1067 | u_int8_t ifnet_signature[NSTAT_SYSINFO_KEYVAL_STRING_MAXSIZE]; |
1068 | u_int32_t ifnet_siglen; | |
1069 | u_int32_t ifnet_type; | |
1070 | struct if_lim_perf_stat lim_stat; | |
5ba3f43e A |
1071 | } nstat_sysinfo_lim_stats; |
1072 | ||
0a7de745 | 1073 | #define NSTAT_NET_API_STAT_KEYVAL_COUNT (NSTAT_SYSINFO_API_LAST - NSTAT_SYSINFO_API_FIRST + 1) |
5ba3f43e | 1074 | typedef struct nstat_sysinfo_net_api_stats { |
cb323159 A |
1075 | u_int32_t report_interval; |
1076 | u_int32_t _padding; | |
1077 | struct net_api_stats net_api_stats; | |
5ba3f43e A |
1078 | } nstat_sysinfo_net_api_stats; |
1079 | ||
0a7de745 A |
1080 | typedef struct nstat_sysinfo_data { |
1081 | uint32_t flags; | |
1082 | uint32_t unsent_data_cnt; /* Before sleeping */ | |
fe8ab488 A |
1083 | union { |
1084 | nstat_sysinfo_mbuf_stats mb_stats; | |
1085 | nstat_sysinfo_tcp_stats tcp_stats; | |
4bd07ac2 | 1086 | nstat_sysinfo_ifnet_ecn_stats ifnet_ecn_stats; |
5ba3f43e A |
1087 | nstat_sysinfo_lim_stats lim_stats; |
1088 | nstat_sysinfo_net_api_stats net_api_stats; | |
fe8ab488 A |
1089 | } u; |
1090 | } nstat_sysinfo_data; | |
1091 | ||
6d2010ae A |
1092 | #pragma mark -- Generic Network Statistics Provider -- |
1093 | ||
0a7de745 | 1094 | typedef void * nstat_provider_cookie_t; |
6d2010ae A |
1095 | |
1096 | #pragma mark -- Route Statistics Gathering Functions -- | |
1097 | struct rtentry; | |
1098 | ||
0a7de745 A |
1099 | enum{ |
1100 | NSTAT_TX_FLAG_RETRANSMIT = 1 | |
6d2010ae A |
1101 | }; |
1102 | ||
0a7de745 A |
1103 | enum{ |
1104 | NSTAT_RX_FLAG_DUPLICATE = 1, | |
1105 | NSTAT_RX_FLAG_OUT_OF_ORDER = 2 | |
6d2010ae A |
1106 | }; |
1107 | ||
1108 | // indicates whether or not collection of statistics is enabled | |
0a7de745 | 1109 | extern int nstat_collect; |
6d2010ae | 1110 | |
316670eb A |
1111 | void nstat_init(void); |
1112 | ||
6d2010ae A |
1113 | // Route collection routines |
1114 | void nstat_route_connect_attempt(struct rtentry *rte); | |
1115 | void nstat_route_connect_success(struct rtentry *rte); | |
1116 | void nstat_route_tx(struct rtentry *rte, u_int32_t packets, u_int32_t bytes, u_int32_t flags); | |
1117 | void nstat_route_rx(struct rtentry *rte, u_int32_t packets, u_int32_t bytes, u_int32_t flags); | |
1118 | void nstat_route_rtt(struct rtentry *rte, u_int32_t rtt, u_int32_t rtt_var); | |
5ba3f43e | 1119 | void nstat_route_update(struct rtentry *rte, uint32_t connect_attempts, uint32_t connect_successes, |
0a7de745 A |
1120 | uint32_t rx_packets, uint32_t rx_bytes, uint32_t rx_duplicatebytes, uint32_t rx_outoforderbytes, |
1121 | uint32_t tx_packets, uint32_t tx_bytes, uint32_t tx_retransmit, | |
1122 | uint32_t rtt, uint32_t rtt_var); | |
1123 | struct nstat_counts* nstat_route_attach(struct rtentry *rte); | |
6d2010ae A |
1124 | void nstat_route_detach(struct rtentry *rte); |
1125 | ||
1126 | // watcher support | |
1127 | struct inpcb; | |
1128 | void nstat_tcp_new_pcb(struct inpcb *inp); | |
1129 | void nstat_udp_new_pcb(struct inpcb *inp); | |
1130 | void nstat_route_new_entry(struct rtentry *rt); | |
316670eb | 1131 | void nstat_pcb_detach(struct inpcb *inp); |
cb323159 | 1132 | void nstat_pcb_event(struct inpcb *inp, u_int64_t event); |
fe8ab488 A |
1133 | void nstat_pcb_cache(struct inpcb *inp); |
1134 | void nstat_pcb_invalidate_cache(struct inpcb *inp); | |
6d2010ae | 1135 | |
39236c6e A |
1136 | |
1137 | void nstat_ifnet_threshold_reached(unsigned int ifindex); | |
1138 | ||
fe8ab488 A |
1139 | void nstat_sysinfo_send_data(struct nstat_sysinfo_data *); |
1140 | ||
d9a64523 A |
1141 | int ntstat_tcp_progress_indicators(struct sysctl_req *req); |
1142 | ||
39037602 | 1143 | |
5ba3f43e A |
1144 | // Utilities for userland stats reporting |
1145 | u_int16_t nstat_ifnet_to_flags(struct ifnet *ifp); | |
39037602 | 1146 | |
6d2010ae A |
1147 | // locked_add_64 uses atomic operations on 32bit so the 64bit |
1148 | // value can be properly read. The values are only ever incremented | |
1149 | // while under the socket lock, so on 64bit we don't actually need | |
1150 | // atomic operations to increment. | |
1151 | #if defined(__LP64__) | |
0a7de745 | 1152 | #define locked_add_64(__addr, __count) do { \ |
6d2010ae A |
1153 | *(__addr) += (__count); \ |
1154 | } while (0) | |
1155 | #else | |
0a7de745 | 1156 | #define locked_add_64(__addr, __count) do { \ |
6d2010ae A |
1157 | atomic_add_64((__addr), (__count)); \ |
1158 | } while (0) | |
1159 | #endif | |
1160 | ||
1161 | #endif /* XNU_KERNEL_PRIVATE */ | |
1162 | ||
1163 | #endif /* __NTSTAT_H__ */ |