2 * Copyright (c) 2017 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef __NET_API_STATS__
30 #define __NET_API_STATS__
36 * net_api_stats counts the usage of the networking APIs
38 * Note: we are using signed 64 bit values to detect and prevent wrap around
40 struct net_api_stats
{
44 int64_t nas_iflt_attach_count
; // Currently attached
45 int64_t nas_iflt_attach_total
; // Total number of attachments
46 int64_t nas_iflt_attach_os_total
;
51 int64_t nas_ipf_add_count
; // Currently attached
52 int64_t nas_ipf_add_total
; // Total number of attachments
53 int64_t nas_ipf_add_os_total
;
58 int64_t nas_sfltr_register_count
; // Currently attached
59 int64_t nas_sfltr_register_total
; // Total number of attachments
60 int64_t nas_sfltr_register_os_total
;
65 int64_t nas_socket_alloc_total
;
66 int64_t nas_socket_in_kernel_total
;
67 int64_t nas_socket_in_kernel_os_total
;
68 int64_t nas_socket_necp_clientuuid_total
;
71 * Sockets per protocol domains
73 int64_t nas_socket_domain_local_total
;
74 int64_t nas_socket_domain_route_total
;
75 int64_t nas_socket_domain_inet_total
;
76 int64_t nas_socket_domain_inet6_total
;
77 int64_t nas_socket_domain_system_total
;
78 int64_t nas_socket_domain_multipath_total
;
79 int64_t nas_socket_domain_key_total
;
80 int64_t nas_socket_domain_ndrv_total
;
81 int64_t nas_socket_domain_other_total
;
84 * Sockets per domain and type
86 int64_t nas_socket_inet_stream_total
;
87 int64_t nas_socket_inet_dgram_total
;
88 int64_t nas_socket_inet_dgram_connected
;
89 int64_t nas_socket_inet_dgram_dns
; // port 53
90 int64_t nas_socket_inet_dgram_no_data
; // typically for interface ioctl
92 int64_t nas_socket_inet6_stream_total
;
93 int64_t nas_socket_inet6_dgram_total
;
94 int64_t nas_socket_inet6_dgram_connected
;
95 int64_t nas_socket_inet6_dgram_dns
; // port 53
96 int64_t nas_socket_inet6_dgram_no_data
; // typically for interface ioctl
101 int64_t nas_socket_mcast_join_total
;
102 int64_t nas_socket_mcast_join_os_total
;
105 * IPv6 Extension Header Socket API
107 int64_t nas_sock_inet6_stream_exthdr_in
;
108 int64_t nas_sock_inet6_stream_exthdr_out
;
109 int64_t nas_sock_inet6_dgram_exthdr_in
;
110 int64_t nas_sock_inet6_dgram_exthdr_out
;
115 int64_t nas_nx_flow_inet_stream_total
;
116 int64_t nas_nx_flow_inet_dgram_total
;
118 int64_t nas_nx_flow_inet6_stream_total
;
119 int64_t nas_nx_flow_inet6_dgram_total
;
124 int64_t nas_ifnet_alloc_count
;
125 int64_t nas_ifnet_alloc_total
;
126 int64_t nas_ifnet_alloc_os_count
;
127 int64_t nas_ifnet_alloc_os_total
;
132 int64_t nas_pf_addrule_total
;
133 int64_t nas_pf_addrule_os
;
138 int64_t nas_vmnet_total
;
141 #ifdef XNU_KERNEL_PRIVATE
142 extern struct net_api_stats net_api_stats
;
145 * Increment up to the max value of int64_t
147 #define INC_ATOMIC_INT64_LIM(counter) { \
151 if (val >= INT64_MAX) { \
154 } while (!OSCompareAndSwap64(val, val + 1, &(counter))); \
156 #endif /* XNU_KERNEL_PRIVATE */
160 #endif /* __NET_API_STATS__ */