xref: /xnu-12377.41.6/bsd/net/network_agent.h (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1*bbb1b6f9SApple OSS Distributions /*
2*bbb1b6f9SApple OSS Distributions  * Copyright (c) 2014-2017, 2023 Apple Inc. All rights reserved.
3*bbb1b6f9SApple OSS Distributions  *
4*bbb1b6f9SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*bbb1b6f9SApple OSS Distributions  *
6*bbb1b6f9SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*bbb1b6f9SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*bbb1b6f9SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*bbb1b6f9SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*bbb1b6f9SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*bbb1b6f9SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*bbb1b6f9SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*bbb1b6f9SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*bbb1b6f9SApple OSS Distributions  *
15*bbb1b6f9SApple OSS Distributions  * Please obtain a copy of the License at
16*bbb1b6f9SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*bbb1b6f9SApple OSS Distributions  *
18*bbb1b6f9SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*bbb1b6f9SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*bbb1b6f9SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*bbb1b6f9SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*bbb1b6f9SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*bbb1b6f9SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*bbb1b6f9SApple OSS Distributions  * limitations under the License.
25*bbb1b6f9SApple OSS Distributions  *
26*bbb1b6f9SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*bbb1b6f9SApple OSS Distributions  */
28*bbb1b6f9SApple OSS Distributions 
29*bbb1b6f9SApple OSS Distributions #ifndef _NETAGENT_H_
30*bbb1b6f9SApple OSS Distributions #define _NETAGENT_H_
31*bbb1b6f9SApple OSS Distributions #include <net/net_kev.h>
32*bbb1b6f9SApple OSS Distributions 
33*bbb1b6f9SApple OSS Distributions #ifdef PRIVATE
34*bbb1b6f9SApple OSS Distributions 
35*bbb1b6f9SApple OSS Distributions #include <netinet/in.h>
36*bbb1b6f9SApple OSS Distributions #include <sys/socket.h>
37*bbb1b6f9SApple OSS Distributions #include <uuid/uuid.h>
38*bbb1b6f9SApple OSS Distributions 
39*bbb1b6f9SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
40*bbb1b6f9SApple OSS Distributions #include <stdbool.h>
41*bbb1b6f9SApple OSS Distributions 
42*bbb1b6f9SApple OSS Distributions errno_t netagent_init(void);
43*bbb1b6f9SApple OSS Distributions #endif
44*bbb1b6f9SApple OSS Distributions /*
45*bbb1b6f9SApple OSS Distributions  * Name registered by the Network Agent kernel control
46*bbb1b6f9SApple OSS Distributions  */
47*bbb1b6f9SApple OSS Distributions #define NETAGENT_CONTROL_NAME "com.apple.net.netagent"
48*bbb1b6f9SApple OSS Distributions 
49*bbb1b6f9SApple OSS Distributions struct netagent_message_header {
50*bbb1b6f9SApple OSS Distributions 	u_int8_t                message_type;
51*bbb1b6f9SApple OSS Distributions 	u_int8_t                message_flags;
52*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_id;
53*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_error;
54*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_payload_length;
55*bbb1b6f9SApple OSS Distributions };
56*bbb1b6f9SApple OSS Distributions 
57*bbb1b6f9SApple OSS Distributions struct netagent_session_message_header {
58*bbb1b6f9SApple OSS Distributions 	u_int8_t                message_type;
59*bbb1b6f9SApple OSS Distributions 	u_int8_t                message_flags;
60*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_id;
61*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_error;
62*bbb1b6f9SApple OSS Distributions 	uuid_t                  message_agent_id;
63*bbb1b6f9SApple OSS Distributions 	u_int32_t               message_payload_length;
64*bbb1b6f9SApple OSS Distributions };
65*bbb1b6f9SApple OSS Distributions 
66*bbb1b6f9SApple OSS Distributions struct netagent_trigger_message {
67*bbb1b6f9SApple OSS Distributions 	u_int32_t               trigger_flags;
68*bbb1b6f9SApple OSS Distributions 	pid_t                   trigger_pid;
69*bbb1b6f9SApple OSS Distributions 	uuid_t                  trigger_proc_uuid;
70*bbb1b6f9SApple OSS Distributions };
71*bbb1b6f9SApple OSS Distributions 
72*bbb1b6f9SApple OSS Distributions struct netagent_client_message {
73*bbb1b6f9SApple OSS Distributions 	uuid_t                  client_id;
74*bbb1b6f9SApple OSS Distributions };
75*bbb1b6f9SApple OSS Distributions 
76*bbb1b6f9SApple OSS Distributions struct netagent_client_error_message {
77*bbb1b6f9SApple OSS Distributions 	uuid_t                  client_id;
78*bbb1b6f9SApple OSS Distributions 	int32_t                 error_code;
79*bbb1b6f9SApple OSS Distributions };
80*bbb1b6f9SApple OSS Distributions 
81*bbb1b6f9SApple OSS Distributions struct netagent_client_group_message {
82*bbb1b6f9SApple OSS Distributions 	uuid_t                  client_id;
83*bbb1b6f9SApple OSS Distributions 	u_int8_t                group_members[0];
84*bbb1b6f9SApple OSS Distributions };
85*bbb1b6f9SApple OSS Distributions 
86*bbb1b6f9SApple OSS Distributions struct netagent_assign_nexus_message {
87*bbb1b6f9SApple OSS Distributions 	uuid_t                  assign_client_id;
88*bbb1b6f9SApple OSS Distributions 	u_int8_t                assign_necp_results[0];
89*bbb1b6f9SApple OSS Distributions };
90*bbb1b6f9SApple OSS Distributions 
91*bbb1b6f9SApple OSS Distributions struct netagent_session_assign_nexus_message {
92*bbb1b6f9SApple OSS Distributions 	uuid_t                  agent_id;
93*bbb1b6f9SApple OSS Distributions 	uuid_t                  assign_client_id;
94*bbb1b6f9SApple OSS Distributions 	u_int8_t                assign_necp_results[0];
95*bbb1b6f9SApple OSS Distributions };
96*bbb1b6f9SApple OSS Distributions 
97*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_REGISTER                  1       // Pass netagent to set, no return value
98*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_UNREGISTER                2       // No value, no return value
99*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_UPDATE                    3       // Pass netagent to update, no return value
100*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_GET                               4       // No value, return netagent
101*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_TRIGGER                   5       // Kernel initiated, no reply expected
102*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_ASSERT                    6       // Deprecated
103*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_UNASSERT                  7       // Deprecated
104*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_TRIGGER_ASSERT    8       // Kernel initiated, no reply expected
105*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_TRIGGER_UNASSERT  9       // Kernel initiated, no reply expected
106*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_REQUEST_NEXUS             10      // Kernel initiated, struct netagent_client_message
107*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_ASSIGN_NEXUS              11      // Pass struct netagent_assign_nexus_message
108*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_CLOSE_NEXUS               12      // Kernel initiated, struct netagent_client_message
109*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_CLIENT_TRIGGER    13      // Kernel initiated, struct netagent_client_message
110*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_CLIENT_ASSERT             14      // Kernel initiated, struct netagent_client_message
111*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_CLIENT_UNASSERT   15      // Kernel initiated, struct netagent_client_message
112*bbb1b6f9SApple OSS Distributions 
113*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_REGISTER                   NETAGENT_MESSAGE_TYPE_REGISTER          // Pass netagent to set, no return value
114*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_UNREGISTER                 NETAGENT_MESSAGE_TYPE_UNREGISTER        // Pass agent uuid in session mode, no return value
115*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_UPDATE                             NETAGENT_MESSAGE_TYPE_UPDATE            // Pass netagent to update, no return value
116*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_ASSIGN_NEXUS               NETAGENT_MESSAGE_TYPE_ASSIGN_NEXUS      // Pass struct netagent_assign_nexus_message
117*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_USE_COUNT                  16                                                                      // Pass use count to set, get current use count
118*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_ABORT_NEXUS               17      // Kernel private
119*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_ADD_GROUP_MEMBERS         18      // Kernel initiated, struct netagent_client_group_message
120*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_REMOVE_GROUP_MEMBERS      19      // Kernel initiated, struct netagent_client_group_message
121*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_ASSIGN_GROUP_MEMBERS      20      // Pass struct netagent_assign_nexus_message
122*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_ADD_TOKEN                 21      // Set new token bytes
123*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_FLUSH_TOKENS              22      // Flush all tokens
124*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_TOKEN_COUNT               23      // Get remaining token count (uint32_t)
125*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_TOKEN_LOW_WATER           24      // Set/get token low water mark (uint32_t)
126*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_TOKENS_NEEDED            25      // Kernel intiated, no content
127*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_TYPE_CLIENT_ERROR             26      // Kernel intiated, struct netagent_client_error_message
128*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_RESET_CLIENT_ERROR        27      // Call to reset client error and counts
129*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_ENABLE_SESSION_MODE       28      // Enables registering multiple agents on a single fd "session". Must be set before registering an agent.
130*bbb1b6f9SApple OSS Distributions #define NETAGENT_OPTION_TYPE_UNREGISTER_ALL            29      // Applicable for session mode, unregisters all associated agents.
131*bbb1b6f9SApple OSS Distributions 
132*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_FLAGS_RESPONSE                 0x01    // Used for acks, errors, and query responses
133*bbb1b6f9SApple OSS Distributions 
134*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_NONE                     0
135*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_INTERNAL                 1
136*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_UNKNOWN_TYPE             2
137*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_INVALID_DATA             3
138*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_NOT_REGISTERED           4
139*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_ALREADY_REGISTERED       5
140*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_CANNOT_UPDATE            6
141*bbb1b6f9SApple OSS Distributions #define NETAGENT_MESSAGE_ERROR_CANNOT_ASSIGN            7
142*bbb1b6f9SApple OSS Distributions 
143*bbb1b6f9SApple OSS Distributions #define NETAGENT_DOMAINSIZE             32
144*bbb1b6f9SApple OSS Distributions #define NETAGENT_TYPESIZE               32
145*bbb1b6f9SApple OSS Distributions #define NETAGENT_DESCSIZE               128
146*bbb1b6f9SApple OSS Distributions 
147*bbb1b6f9SApple OSS Distributions #define NETAGENT_MAX_DATA_SIZE                  4096
148*bbb1b6f9SApple OSS Distributions 
149*bbb1b6f9SApple OSS Distributions #define NETAGENT_MAX_TOKEN_COUNT                256
150*bbb1b6f9SApple OSS Distributions 
151*bbb1b6f9SApple OSS Distributions 
152*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_REGISTERED                0x0001 // Agent is registered
153*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_ACTIVE                    0x0002 // Agent is active
154*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_KERNEL_ACTIVATED          0x0004 // Agent can be activated by kernel activity
155*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_USER_ACTIVATED            0x0008 // Agent can be activated by system call (netagent_trigger)
156*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_VOLUNTARY                 0x0010 // Use of agent is optional
157*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_SPECIFIC_USE_ONLY         0x0020 // Agent should only be used and activated when specifically required
158*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_NETWORK_PROVIDER          0x0040 // Agent provides network access
159*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_NEXUS_PROVIDER            0x0080 // Agent provides a skywalk nexus
160*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_SUPPORTS_BROWSE           0x0100 // Assertions will cause agent to fill in browse endpoints
161*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_REQUIRES_ASSERT           0x0200 // Assertions are expected to be taken against this agent
162*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_NEXUS_LISTENER            0x0400 // Nexus supports listeners
163*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_UPDATE_IMMEDIATELY        0x0800 // Updates the clients without waiting for a leeway
164*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_CUSTOM_ETHER_NEXUS        0x2000 // Agent provides a custom ethertype nexus
165*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_CUSTOM_IP_NEXUS           0x4000 // Agent provides a custom IP nexus
166*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_INTERPOSE_NEXUS           0x8000 // Agent provides an interpose nexus
167*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_SUPPORTS_RESOLVE          0x10000 // Assertions will cause agent to fill in resolved endpoints
168*bbb1b6f9SApple OSS Distributions #define NETAGENT_FLAG_SUPPORTS_GROUPS           0x20000 // Group actions can be performed
169*bbb1b6f9SApple OSS Distributions 
170*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_MAX_REQUEST_TYPES                        16
171*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_MAX_RESOLUTION_TYPE_PAIRS        15
172*bbb1b6f9SApple OSS Distributions 
173*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FRAME_TYPE_UNKNOWN               0
174*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FRAME_TYPE_LINK                  1
175*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FRAME_TYPE_INTERNET              2
176*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FRAME_TYPE_TRANSPORT             3
177*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FRAME_TYPE_APPLICATION   4
178*bbb1b6f9SApple OSS Distributions 
179*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_ENDPOINT_TYPE_ADDRESS    1
180*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_ENDPOINT_TYPE_HOST               2
181*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_ENDPOINT_TYPE_BONJOUR    3
182*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_ENDPOINT_TYPE_SRV        5
183*bbb1b6f9SApple OSS Distributions 
184*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FLAG_SUPPORTS_USER_PACKET_POOL   0x1
185*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FLAG_ASSERT_UNSUPPORTED          0x2 // No calls to assert the agent are required
186*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FLAG_SHOULD_USE_EVENT_RING       0x4 // indicates that nexus agent should use event rings
187*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FLAG_COMPLETE_RESOLVE_ON_CONNECT 0x8 // Indicates resolver should mark itself as complete once it has a connected child
188*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_FLAG_CANCEL_REMOVED_ENDPOINTS    0x10 // Indicates resolver should cancel connection attempts to endpoints removed from resolved endpoints list
189*bbb1b6f9SApple OSS Distributions 
190*bbb1b6f9SApple OSS Distributions struct netagent_nexus {
191*bbb1b6f9SApple OSS Distributions 	u_int32_t       frame_type;
192*bbb1b6f9SApple OSS Distributions 	u_int32_t       endpoint_assignment_type;
193*bbb1b6f9SApple OSS Distributions 	u_int32_t       endpoint_request_types[NETAGENT_NEXUS_MAX_REQUEST_TYPES];
194*bbb1b6f9SApple OSS Distributions 	u_int32_t       endpoint_resolution_type_pairs[NETAGENT_NEXUS_MAX_RESOLUTION_TYPE_PAIRS * 2];
195*bbb1b6f9SApple OSS Distributions 	u_int32_t       nexus_max_buf_size;
196*bbb1b6f9SApple OSS Distributions 	u_int32_t       reserved;
197*bbb1b6f9SApple OSS Distributions 	u_int32_t       nexus_flags;
198*bbb1b6f9SApple OSS Distributions };
199*bbb1b6f9SApple OSS Distributions 
200*bbb1b6f9SApple OSS Distributions #define NETAGENT_NEXUS_HAS_MAX_BUF_SIZE    1 // struct netagent_nexus includes nexus_max_buf_size
201*bbb1b6f9SApple OSS Distributions 
202*bbb1b6f9SApple OSS Distributions #define NETAGENT_TRIGGER_FLAG_USER              0x0001  // Userspace triggered agent
203*bbb1b6f9SApple OSS Distributions #define NETAGENT_TRIGGER_FLAG_KERNEL            0x0002  // Kernel triggered agent
204*bbb1b6f9SApple OSS Distributions 
205*bbb1b6f9SApple OSS Distributions struct kev_netagent_data {
206*bbb1b6f9SApple OSS Distributions 	uuid_t          netagent_uuid;
207*bbb1b6f9SApple OSS Distributions };
208*bbb1b6f9SApple OSS Distributions 
209*bbb1b6f9SApple OSS Distributions // To be used with kernel control socket
210*bbb1b6f9SApple OSS Distributions struct netagent {
211*bbb1b6f9SApple OSS Distributions 	uuid_t          netagent_uuid;
212*bbb1b6f9SApple OSS Distributions 	char            netagent_domain[NETAGENT_DOMAINSIZE];
213*bbb1b6f9SApple OSS Distributions 	char            netagent_type[NETAGENT_TYPESIZE];
214*bbb1b6f9SApple OSS Distributions 	char            netagent_desc[NETAGENT_DESCSIZE];
215*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_flags;
216*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_data_size;
217*bbb1b6f9SApple OSS Distributions 	u_int8_t        netagent_data[0];
218*bbb1b6f9SApple OSS Distributions };
219*bbb1b6f9SApple OSS Distributions 
220*bbb1b6f9SApple OSS Distributions // To be used with SIOCGAGENTDATA
221*bbb1b6f9SApple OSS Distributions struct netagent_req {
222*bbb1b6f9SApple OSS Distributions 	uuid_t          netagent_uuid;
223*bbb1b6f9SApple OSS Distributions 	char            netagent_domain[NETAGENT_DOMAINSIZE];
224*bbb1b6f9SApple OSS Distributions 	char            netagent_type[NETAGENT_TYPESIZE];
225*bbb1b6f9SApple OSS Distributions 	char            netagent_desc[NETAGENT_DESCSIZE];
226*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_flags;
227*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_data_size;
228*bbb1b6f9SApple OSS Distributions 	u_int8_t        *netagent_data;
229*bbb1b6f9SApple OSS Distributions };
230*bbb1b6f9SApple OSS Distributions 
231*bbb1b6f9SApple OSS Distributions // To be used with SIOCGAGENTLIST
232*bbb1b6f9SApple OSS Distributions struct netagentlist_req {
233*bbb1b6f9SApple OSS Distributions 	u_int32_t       data_size;
234*bbb1b6f9SApple OSS Distributions 	u_int8_t        *data;
235*bbb1b6f9SApple OSS Distributions };
236*bbb1b6f9SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
237*bbb1b6f9SApple OSS Distributions int netagent_ioctl(u_long cmd, caddr_t __sized_by(IOCPARM_LEN(cmd)) data);
238*bbb1b6f9SApple OSS Distributions 
239*bbb1b6f9SApple OSS Distributions struct netagent_req32 {
240*bbb1b6f9SApple OSS Distributions 	uuid_t          netagent_uuid;
241*bbb1b6f9SApple OSS Distributions 	char            netagent_domain[NETAGENT_DOMAINSIZE];
242*bbb1b6f9SApple OSS Distributions 	char            netagent_type[NETAGENT_TYPESIZE];
243*bbb1b6f9SApple OSS Distributions 	char            netagent_desc[NETAGENT_DESCSIZE];
244*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_flags;
245*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_data_size;
246*bbb1b6f9SApple OSS Distributions 	user32_addr_t   netagent_data;
247*bbb1b6f9SApple OSS Distributions };
248*bbb1b6f9SApple OSS Distributions struct netagent_req64 {
249*bbb1b6f9SApple OSS Distributions 	uuid_t          netagent_uuid;
250*bbb1b6f9SApple OSS Distributions 	char            netagent_domain[NETAGENT_DOMAINSIZE];
251*bbb1b6f9SApple OSS Distributions 	char            netagent_type[NETAGENT_TYPESIZE];
252*bbb1b6f9SApple OSS Distributions 	char            netagent_desc[NETAGENT_DESCSIZE];
253*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_flags;
254*bbb1b6f9SApple OSS Distributions 	u_int32_t       netagent_data_size;
255*bbb1b6f9SApple OSS Distributions 	user64_addr_t   netagent_data __attribute__((aligned(8)));
256*bbb1b6f9SApple OSS Distributions };
257*bbb1b6f9SApple OSS Distributions struct netagentlist_req32 {
258*bbb1b6f9SApple OSS Distributions 	u_int32_t       data_size;
259*bbb1b6f9SApple OSS Distributions 	user32_addr_t   data;
260*bbb1b6f9SApple OSS Distributions };
261*bbb1b6f9SApple OSS Distributions struct netagentlist_req64 {
262*bbb1b6f9SApple OSS Distributions 	u_int32_t       data_size;
263*bbb1b6f9SApple OSS Distributions 	user64_addr_t   data __attribute__((aligned(8)));
264*bbb1b6f9SApple OSS Distributions };
265*bbb1b6f9SApple OSS Distributions 
266*bbb1b6f9SApple OSS Distributions struct necp_client_agent_parameters;
267*bbb1b6f9SApple OSS Distributions 
268*bbb1b6f9SApple OSS Distributions // Kernel accessors
269*bbb1b6f9SApple OSS Distributions extern void netagent_post_updated_interfaces(uuid_t uuid); // To be called from interface ioctls
270*bbb1b6f9SApple OSS Distributions 
271*bbb1b6f9SApple OSS Distributions extern u_int32_t netagent_get_flags(uuid_t uuid);
272*bbb1b6f9SApple OSS Distributions 
273*bbb1b6f9SApple OSS Distributions extern errno_t netagent_set_flags(uuid_t uuid, u_int32_t flags);
274*bbb1b6f9SApple OSS Distributions 
275*bbb1b6f9SApple OSS Distributions extern u_int32_t netagent_get_generation(uuid_t uuid);
276*bbb1b6f9SApple OSS Distributions 
277*bbb1b6f9SApple OSS Distributions extern bool netagent_get_agent_domain_and_type(uuid_t uuid, char *domain __sized_by(NETAGENT_DOMAINSIZE), char *type __sized_by(NETAGENT_TYPESIZE));
278*bbb1b6f9SApple OSS Distributions 
279*bbb1b6f9SApple OSS Distributions extern int netagent_kernel_trigger(uuid_t uuid);
280*bbb1b6f9SApple OSS Distributions 
281*bbb1b6f9SApple OSS Distributions extern int netagent_client_message(uuid_t agent_uuid, uuid_t necp_client_uuid, pid_t pid, void *handle, u_int8_t message_type);
282*bbb1b6f9SApple OSS Distributions 
283*bbb1b6f9SApple OSS Distributions extern int netagent_client_message_with_params(uuid_t agent_uuid,
284*bbb1b6f9SApple OSS Distributions     uuid_t necp_client_uuid,
285*bbb1b6f9SApple OSS Distributions     pid_t pid,
286*bbb1b6f9SApple OSS Distributions     void *handle,
287*bbb1b6f9SApple OSS Distributions     u_int8_t message_type,
288*bbb1b6f9SApple OSS Distributions     struct necp_client_agent_parameters *parameters,
289*bbb1b6f9SApple OSS Distributions     void * __sized_by(*assigned_results_length) * assigned_results,
290*bbb1b6f9SApple OSS Distributions     size_t *assigned_results_length);
291*bbb1b6f9SApple OSS Distributions 
292*bbb1b6f9SApple OSS Distributions extern int netagent_copyout(uuid_t uuid, user_addr_t user_addr, u_int32_t user_size);
293*bbb1b6f9SApple OSS Distributions 
294*bbb1b6f9SApple OSS Distributions extern int netagent_acquire_token(uuid_t uuid, user_addr_t user_addr, u_int32_t user_size, int *retval);
295*bbb1b6f9SApple OSS Distributions 
296*bbb1b6f9SApple OSS Distributions 
297*bbb1b6f9SApple OSS Distributions // Kernel agent management
298*bbb1b6f9SApple OSS Distributions 
299*bbb1b6f9SApple OSS Distributions typedef void * netagent_session_t;
300*bbb1b6f9SApple OSS Distributions 
301*bbb1b6f9SApple OSS Distributions struct netagent_nexus_agent {
302*bbb1b6f9SApple OSS Distributions 	struct netagent                         agent;
303*bbb1b6f9SApple OSS Distributions 	struct netagent_nexus           nexus_data;
304*bbb1b6f9SApple OSS Distributions };
305*bbb1b6f9SApple OSS Distributions 
306*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_TRIGGER                                  NETAGENT_MESSAGE_TYPE_CLIENT_TRIGGER
307*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_ASSERT                                   NETAGENT_MESSAGE_TYPE_CLIENT_ASSERT
308*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_UNASSERT                                 NETAGENT_MESSAGE_TYPE_CLIENT_UNASSERT
309*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_NEXUS_FLOW_INSERT                        NETAGENT_MESSAGE_TYPE_REQUEST_NEXUS
310*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_NEXUS_FLOW_REMOVE                        NETAGENT_MESSAGE_TYPE_CLOSE_NEXUS
311*bbb1b6f9SApple OSS Distributions #define NETAGENT_EVENT_NEXUS_FLOW_ABORT                         NETAGENT_MESSAGE_TYPE_ABORT_NEXUS
312*bbb1b6f9SApple OSS Distributions 
313*bbb1b6f9SApple OSS Distributions typedef errno_t (*netagent_event_f)(u_int8_t event, uuid_t necp_client_uuid, pid_t pid, void *necp_handle, void *context, struct necp_client_agent_parameters *parameters, void * __sized_by (*assigned_results_length) *assigned_results, size_t *assigned_results_length);
314*bbb1b6f9SApple OSS Distributions 
315*bbb1b6f9SApple OSS Distributions extern netagent_session_t netagent_create(netagent_event_f event_handler, void *handle);
316*bbb1b6f9SApple OSS Distributions 
317*bbb1b6f9SApple OSS Distributions extern void netagent_destroy(netagent_session_t session);
318*bbb1b6f9SApple OSS Distributions 
319*bbb1b6f9SApple OSS Distributions extern errno_t netagent_register(netagent_session_t session, struct netagent *agent);
320*bbb1b6f9SApple OSS Distributions 
321*bbb1b6f9SApple OSS Distributions extern errno_t netagent_update(netagent_session_t session, struct netagent *agent);
322*bbb1b6f9SApple OSS Distributions 
323*bbb1b6f9SApple OSS Distributions extern errno_t netagent_unregister(netagent_session_t session);
324*bbb1b6f9SApple OSS Distributions 
325*bbb1b6f9SApple OSS Distributions extern errno_t netagent_assign_nexus(netagent_session_t _session,
326*bbb1b6f9SApple OSS Distributions     uuid_t necp_client_uuid,
327*bbb1b6f9SApple OSS Distributions     void *assign_message __sized_by(assigned_results_length),
328*bbb1b6f9SApple OSS Distributions     size_t assigned_results_length);                                                                      // Length of assigned_results_length
329*bbb1b6f9SApple OSS Distributions 
330*bbb1b6f9SApple OSS Distributions extern errno_t netagent_update_flow_protoctl_event(netagent_session_t _session,
331*bbb1b6f9SApple OSS Distributions     uuid_t client_id,
332*bbb1b6f9SApple OSS Distributions     uint32_t protoctl_event_code,
333*bbb1b6f9SApple OSS Distributions     uint32_t protoctl_event_val,
334*bbb1b6f9SApple OSS Distributions     uint32_t protoctl_event_tcp_seq_number);
335*bbb1b6f9SApple OSS Distributions 
336*bbb1b6f9SApple OSS Distributions extern int netagent_use(uuid_t agent_uuid, uint64_t *out_use_count);
337*bbb1b6f9SApple OSS Distributions 
338*bbb1b6f9SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */
339*bbb1b6f9SApple OSS Distributions 
340*bbb1b6f9SApple OSS Distributions #ifndef KERNEL
341*bbb1b6f9SApple OSS Distributions extern int netagent_trigger(uuid_t agent_uuid, size_t agent_uuidlen);
342*bbb1b6f9SApple OSS Distributions #endif /* !KERNEL */
343*bbb1b6f9SApple OSS Distributions 
344*bbb1b6f9SApple OSS Distributions #endif /* PRIVATE */
345*bbb1b6f9SApple OSS Distributions 
346*bbb1b6f9SApple OSS Distributions #endif /* _NETAGENT_H_ */
347