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