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