Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: ppapi/c/ppb_vpn_provider.h

Issue 1726303003: ppapi: PPB_VpnProvider: Define API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright 2015 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 /* From ppb_vpn_provider.idl modified Mon Feb 22 12:12:48 2016. */
7
8 #ifndef PPAPI_C_PPB_VPN_PROVIDER_H_
9 #define PPAPI_C_PPB_VPN_PROVIDER_H_
10
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_var.h"
18
19 #define PPB_VPNPROVIDER_INTERFACE_0_1 "PPB_VpnProvider;0.1" /* dev */
20 /**
21 * @file
22 * This file defines the <code>PPB_VpnProvider</code> interface.
23 */
24
25
26 /**
27 * @addtogroup Enums
28 * @{
29 */
30 /**
31 * This enumeration is used by the VPN client to inform the platform of its
32 * current state. This helps provide meaningful messages to the user.
33 */
34 typedef enum {
35 /* Only for compatibility with the JS API */
36 PP_VPN_PROVIDER_CONNECTION_STATE_NONE,
37 /* VPN connection was successful. */
38 PP_VPN_PROVIDER_CONNECTION_STATE_CONNECTED,
39 /* VPN connection failed. */
40 PP_VPN_PROVIDER_CONNECTION_STATE_FAILURE,
41 PP_VPN_PROVIDER_CONNECTION_STATE_LAST =
42 PP_VPN_PROVIDER_CONNECTION_STATE_FAILURE
43 } PP_VpnProvider_VpnConnectionState;
44 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VpnProvider_VpnConnectionState, 4);
45
46 /**
47 * This enumeration is used by the platform to notify the client of the VPN
48 * session status.
49 */
50 typedef enum {
51 /* Only for compatibility with the JS API */
52 PP_VPN_PROVIDER_PLATFORM_MESSAGE_NONE,
53 /* VPN configuration connected. */
54 PP_VPN_PROVIDER_PLATFORM_MESSAGE_CONNECTED,
55 /* VPN configuration disconnected. */
56 PP_VPN_PROVIDER_PLATFORM_MESSAGE_DISCONNECTED,
57 /* An error occurred in VPN connection, for example a timeout. A description
58 * of the error is give as the error argument to
59 * <code>GetPlatformMessage</code>. */
60 PP_VPN_PROVIDER_PLATFORM_MESSAGE_ERROR,
61 PP_VPN_PROVIDER_PLATFORM_MESSAGE_LAST = PP_VPN_PROVIDER_PLATFORM_MESSAGE_ERROR
62 } PP_VpnProvider_PlatformMessage;
63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VpnProvider_PlatformMessage, 4);
64
65 /**
66 * This enumeration is used by the platform to notify the client of the VPN
67 * configuration status.
68 */
69 typedef enum {
70 /* Only for compatibility with the JS API */
71 PP_VPN_PROVIDER_CONFIG_NONE,
72 /* VPN configuration created by the platform. */
73 PP_VPN_PROVIDER_CONFIG_CREATED,
74 /* VPN configuration removed by the platform. */
75 PP_VPN_PROVIDER_CONFIG_REMOVED,
76 PP_VPN_PROVIDER_CONFIG_LAST = PP_VPN_PROVIDER_CONFIG_REMOVED
77 } PP_VpnProvider_ConfigMessage;
78 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VpnProvider_ConfigMessage, 4);
79
80 /**
81 * This enumeration is used by the platform to notify the client of the UI event
82 * type.
83 */
84 typedef enum {
85 /* Only for compatibility with the JS API */
86 PP_VPN_PROVIDER_UI_EVENT_NONE,
87 /* Request the VPN client to show add configuration dialog to the user. */
88 PP_VPN_PROVIDER_UI_EVENT_SHOWADDDIALOG,
89 /* Request the VPN client to show configuration settings dialog to the user.
90 */
91 PP_VPN_PROVIDER_UI_EVENT_SHOWCONFIGUREDIALOG,
92 PP_VPN_PROVIDER_UI_EVENT_LAST = PP_VPN_PROVIDER_UI_EVENT_SHOWCONFIGUREDIALOG
93 } PP_VpnProvider_UIEvent;
94 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VpnProvider_UIEvent, 4);
95 /**
96 * @}
97 */
98
99 /**
100 * @addtogroup Interfaces
101 * @{
102 */
103 /**
104 * Use the <code>PPB_VpnProvider</code> interface to implement a VPN client.
105 * Important: This API is available only on Chrome OS.
106 *
107 * VPN Provider interface:
108 *
109 * Typical usage:
110 * - Create VPN configurations using the
111 * <code>PPB_VpnProvider.CreateConfig()</code> method. A VPN configuration is
112 * a persistent entry shown to the user in a native Chrome OS UI. The user can
113 * select a VPN configuration from a list and connect to it or disconnect from
114 * it.
115 * - Register callbacks to the events via
116 * <code>PPB_VpnProvider.GetPlatformMessage()</code>,
117 * <code>PPB_VpnProvider.GetPacket()</code>,
118 * <code>PPB_VpnProvider.GetConfigMessage()</code> and
119 * <code>PPB_VpnProvider.GetUIMessage()</code>.
120 * - When the user connects to the VPN configuration, the
121 * <code>PPB_VpnProvider.GetPlatformMessage()</code> callback will be called
122 * with the message <code>PP_VPN_PROVIDER_PLATFORM_MESSAGE_CONNECTED</code>.
123 * We refer to the period between the messages
124 * <code>PP_VPN_PROVIDER_PLATFORM_MESSAGE_CONNECTED</code> and
125 * <code>PP_VPN_PROVIDER_PLATFORM_MESSAGE_DISCONNECTED</code> as a VPN
126 * session. In this time period, the module that receives the message is said
127 * to own the VPN session.
128 * - You will need to re-register the callbacks after they are called.
129 * - Initiate connection to the VPN server and start the VPN client.
130 * - Set the Parameters of the connection using
131 * <code>PPB_VpnProvider.SetParameters()</code> .
132 * - Notify the connection state as
133 * <code>PP_VPN_PROVIDER_CONNECTION_STATE_CONNECTED</code> using
134 * <code>PPB_VpnProvider.NotifyConnectionStateChanged()</code>.
135 * - When the steps above are completed without errors, a virtual tunnel is
136 * created to the network stack of Chrome OS. IP packets can be sent through
137 * the tunnel using <code>PPB_VpnProvider.SendPacket()</code> and any packets
138 * originating on the Chrome OS device will be received using the callback of
139 * <code>PPB_VpnProvider.GetPacket()</code>.
140 * - When the user disconnects from the VPN configuration, the
141 * <code>PPB_VpnProvider.GetPlatformMessage()</code> callback will be fired
142 * with the message <code>PP_VPN_PROVIDER_PLATFORM_MESSAGE_DISCONNECTED
143 * </code>.
144 * - If the VPN configuration is no longer necessary, it can be destroyed using
145 * <code>PPB_VpnProvider.DestroyConfig()</code>
146 */
147 struct PPB_VpnProvider_0_1 { /* dev */
148 /**
149 * Create() creates a VpnProvider instance.
150 *
151 * @param[in] instance A <code>PP_Instance</code> identifying the instance
152 * with the VpnProvider.
153 *
154 * @return A <code>PP_Resource</code> corresponding to a WebSocket if
155 * successful.
156 */
157 PP_Resource (*Create)(PP_Instance instance);
158 /**
159 * IsVpnProvider() determines if the provided <code>resource</code> is a
160 * VpnProvider instance.
161 *
162 * @param[in] resource A <code>PP_Resource</code> corresponding to a
163 * VpnProvider.
164 *
165 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a
166 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the
167 * <code>resource</code> is invalid or some type other than
168 * <code>PPB_VpnProvider</code>.
169 */
170 PP_Bool (*IsVpnProvider)(PP_Resource resource);
171 /**
172 * CreateConfig() creates a new VPN configuration that persists across
173 * multiple login sessions of the user.
174 *
175 * @param[in] resource A <code>PP_Resource</code> corresponding to a
176 * VpnProvider.
177 *
178 * @param[in] name A <code>PP_Var</code> representing the name of the VPN
179 * configuration. The <code>PP_VarType</code> must be
180 * <code>PP_VARTYPE_STRING</code>.
181 *
182 * @param[out] id A unique ID for the created configuration. The ID is copied
183 * to provided <code>id</code>. The <code>id</code> must remain valid
184 * until CreateConfig() completes. Its received <code>PP_VarType</code>
185 * will be <code>PP_VARTYPE_STRING</code> if a configuration was created,
186 * otherwise it will be <code>PP_VARTYPE_UNDEFINED</code>
187 *
188 * @param[in] callback A <code>PP_CompletionCallback</code> called
189 * when CreateConfig() completes.</code>.
190 *
191 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
192 */
193 int32_t (*CreateConfig)(PP_Resource vpn_provider,
194 struct PP_Var name,
195 struct PP_Var* id,
196 struct PP_CompletionCallback callback);
197 /**
198 * DestroyConfig() destroys a VPN configuration created using this API.
199 *
200 * @param[in] resource A <code>PP_Resource</code> corresponding to a
201 * VpnProvider.
202 *
203 * @param[in] name A <code>PP_Var</code> representing the ID of the VPN
204 * configuration to destroy. The <code>PP_VarType</code> must be
205 * <code>PP_VARTYPE_STRING</code>.
206 *
207 * @param[in] callback A <code>PP_CompletionCallback</code> called
208 * when CreateConfig() completes.</code>.
209 *
210 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
211 */
212 int32_t (*DestroyConfig)(PP_Resource vpn_provider,
213 struct PP_Var id,
214 struct PP_CompletionCallback callback);
215 /**
216 * SetParameters() sets the parameters for the VPN session. This should be
217 * called immediately after <code>PP_VPN_PROVIDER_CONNECTION_STATE_CONNECTED
218 * </code> is received from the platform. This will succeed only when the VPN
219 * session is owned by the module.
220 *
221 * @param[in] address A <code>PP_VARTYPE_STRING</code> corresponding to the
222 * IP address for the VPN interface in CIDR notation. IPv4 is currently the
223 * only supported mode.
224 *
225 * @param[in] broadcast_address A <code>PP_VARTYPE_STRING</code> corresponding
226 * to the broadcast address for the VPN interface. Default: deduced from IP
227 * address and mask.
228 *
229 * @param[in] mtu A <code>int32_t</code> corresponding to the MTU setting for
230 * the VPN interface. Default: 1500 bytes.
231 *
232 * @param[in] exclusion_list A <code>PP_VARTYPE_ARRAY</code> of
233 * <code>PP_VARTYPE_STRING</code>. Exclude network traffic to the list of IP
234 * blocks in CIDR notation from the tunnel. This can be used to bypass traffic
235 * to and from the VPN server. When many rules match a destination, the rule
236 * with the longest matching prefix wins. Entries that correspond to the same
237 * CIDR block are treated as duplicates. Such duplicates in the collated
238 * (exclusion_list + inclusion_list) list are eliminated and the exact
239 * duplicate entry that will be eliminated is undefined.
240 *
241 * @param[in] inclusion_list A <code>PP_VARTYPE_ARRAY</code> of
242 * <code>PP_VARTYPE_STRING</code>. Include network traffic to the list of IP
243 * blocks in CIDR notation to the tunnel. This parameter can be used to set up
244 * a split tunnel. By default no traffic is directed to the tunnel. Adding the
245 * entry "0.0.0.0/0" to this list gets all the user traffic redirected to the
246 * tunnel. When many rules match a destination, the rule with the longest
247 * matching prefix wins. Entries that correspond to the same CIDR block are
248 * treated as duplicates. Such duplicates in the collated (exclusion_list +
249 * inclusion_list) list are eliminated and the exact duplicate entry that will
250 * be eliminated is undefined.
251 *
252 * @param[in] domain_search A <code>PP_VARTYPE_ARRAY</code> of
253 * <code>PP_VARTYPE_STRING</code> corresponding to a list of search domains.
254 * Default: no search domain.
255 *
256 * @param[in] dns_servers A <code>PP_VARTYPE_ARRAY</code> of
257 * <code>PP_VARTYPE_STRING</code> values corresponding to a list of IPs for
258 * the DNS servers.
259 *
260 * @param[in] callback A <code>PP_CompletionCallback</code> called
261 * when SetParameters() completes.
262 */
263 int32_t (*SetParameters)(PP_Resource vpn_provider,
264 struct PP_Var address,
265 struct PP_Var broadcast_address,
266 int32_t mtu,
267 struct PP_Var exclusion_list,
268 struct PP_Var inclusion_list,
269 struct PP_Var domain_search,
270 struct PP_Var dns_servers,
271 struct PP_CompletionCallback callback);
272 /**
273 * SendPacket() sends an IP packet through the tunnel created for the VPN
274 * session. This will succeed only when the VPN session is owned by the
275 * module.
276 *
277 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
278 * VpnProvider.
279 *
280 * @param[in] packet A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to
281 * an IP packet to be sent to the platform.
282 */
283 int32_t (*SendPacket)(PP_Resource vpn_provider, struct PP_Var packet);
284 /**
285 * NotifyConnectionStateChanged() notifies the VPN session state to the
286 * platform. This will succeed only when the VPN session is owned by the
287 * module.
288 *
289 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
290 * VpnProvider.
291 *
292 * @param[in] status A <code>PP_VpnProvider_VpnConnectionState</code>
293 * corresponding to the VPN session state of the VPN client.
294 *
295 * @param[in] callback A <code>PP_CompletionCallback</code> called
296 * when NotifyConnectionStateChanged() completes.</code>.
297 */
298 int32_t (*NotifyConnectionStateChanged)(
299 PP_Resource vpn_provider,
300 PP_VpnProvider_VpnConnectionState status,
301 struct PP_CompletionCallback callback);
302 /**
303 * GetPacket() receives an IP packet from the tunnel for the VPN session.
304 * This interface only returns a single packet. That is, this interface must
305 * be called at least N times to receive N packet, no matter the size of
306 * each packet.
307 *
308 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
309 * VpnProvider.
310 *
311 * @param[out] packet The received packet is copied to provided
312 * <code>packet</code>. The <code>packet</code> must remain valid until
313 * GetPacket() completes. Its received <code>PP_VarType</code> will be
314 * <code>PP_VARTYPE_ARRAY_BUFFER</code>.
315 *
316 * @param[in] callback A <code>PP_CompletionCallback</code> called
317 * when GetPacket() completes.</code>.
318 *
319 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
320 * If an error is detected or connection is closed, GetPacket() returns
321 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
322 * Until buffered packets become empty, GetPacket() continues to return
323 * <code>PP_OK</code> as if connection is still established without errors.
324 */
325 int32_t (*GetPacket)(PP_Resource vpn_provider,
326 struct PP_Var* packet,
327 struct PP_CompletionCallback callback);
328 /**
329 * GetPlatformMessage() receives a platform message from the platform for a
330 * VPN configuration.
331 * This interface only returns a single message. That is, this interface must
332 * be called at least N times to receive N messages.
333 *
334 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
335 * VpnProvider.
336 *
337 * @param[out] message A platform message. The message is copied to the
338 * provided <code>message</code>. The <code>message</code> must remain valid
339 * until GetPlatformMessage() completes. Its received <code>PP_VarType</code>
340 * will be <code>PP_VARTYPE_DICTIONARY</code>. Its key value pairs must be
341 * interpreted as:
342 * - "id": ID of the configuration the message is intended for. Its received
343 * <code>PP_VarType</code> will be <code>PP_VARTYPE_STRING</code>.
344 * - "message": The message type received from the platform. Its received
345 * <code>PP_VarType</code> will be <code>PP_VARTYPE_INT32</code> and must
346 * interpreted as a value in <code>PP_VpnProvider_PlatformMessage</code>.
347 * - "error": Error message when there is an error. Its received
348 * <code>PP_VarType</code> will be <code>PP_VARTYPE_STRING</code>.
349 *
350 * @param[in] callback A <code>PP_CompletionCallback</code> called
351 * when GetPlatformMessage() completes.</code>.
352 *
353 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
354 * If an error is detected, GetPlatformMessage() returns
355 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
356 * Until buffered messages become empty, GetPlatformMessage() continues to
357 * return <code>PP_OK</code> as if connection is still established without
358 * errors.
359 */
360 int32_t (*GetPlatformMessage)(PP_Resource vpn_provider,
361 struct PP_Var* message,
362 struct PP_CompletionCallback callback);
363 /**
364 * GetConfigMessage() receives an event from the platform for the creation or
365 * destruction of a VPN configuration.
366 * This interface only returns a single message. That is, this interface must
367 * be called at least N times to receive N messages.
368 *
369 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
370 * VpnProvider.
371 *
372 * @param[out] message A configuration message. The message is copied to the
373 * provided <code>message</code>. The <code>message</code> must remain valid
374 * until GetConfigMessage() completes. Its received <code>PP_VarType</code>
375 * will be <code>PP_VARTYPE_DICTIONARY</code>. Its key value pairs must be
376 * interpreted as:
377 * - "id": ID of the configuration the message is intended for. Its received
378 * <code>PP_VarType</code> will be <code>PP_VARTYPE_STRING</code>.
379 * - "message": The message type received from the platform. Its received
380 * <code>PP_VarType</code> will be <code>PP_VARTYPE_INT32</code> and must
381 * interpreted as a value in <code>PP_VpnProvider_ConfigMessage</code>.
382 * - "name": Name of the configuration created. Its received
383 * <code>PP_VarType</code> will be <code>PP_VARTYPE_STRING</code> if a
384 * configuration was created, otherwise it will be
385 * <code>PP_VARTYPE_UNDEFINED</code>.
386 * - "data": Configuration data provided by the administrator.
387 *
388 * @param[in] callback A <code>PP_CompletionCallback</code> called
389 * when GetConfigMessage() completes.</code>.
390 *
391 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
392 * If an error is detected, GetConfigMessage() returns
393 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
394 * Until buffered messages become empty, GetConfigMessage() continues to
395 * return <code>PP_OK</code> as if connection is still established without
396 * errors.
397 */
398 int32_t (*GetConfigMessage)(PP_Resource vpn_provider,
399 struct PP_Var* message,
400 struct PP_CompletionCallback callback);
401 /**
402 * GetUIMessage() receives an UI event for the extension. UI events are
403 * signals from the platform that indicate to the app that a UI dialog needs
404 * to be shown to the user.
405 * This interface only returns a single message. That is, this interface must
406 * be called at least N times to receive N messages.
407 *
408 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
409 * VpnProvider.
410 *
411 * @param[out] message A configuration message. The message is copied to the
412 * provided <code>message</code>. The <code>message</code> must remain valid
413 * until GetConfigMessage() completes. Its received <code>PP_VarType</code>
414 * will be <code>PP_VARTYPE_DICTIONARY</code>. Its key value pairs must be
415 * interpreted as:
416 * - "event": The UI event that is triggered. Its received
417 * <code>PP_VarType</code> will be <code>PP_VARTYPE_INT32</code> and must
418 * interpreted as a value in <code>PP_VpnProvider_UIEvent</code>.
419 * - "id": ID of the configuration the message is intended for. Its received
420 * <code>PP_VarType</code> will be <code>PP_VARTYPE_STRING</code>.
421 *
422 * @param[in] callback A <code>PP_CompletionCallback</code> called
423 * when GetUIMessage() completes.</code>.
424 *
425 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
426 * If an error is detected, GetUIMessage() returns
427 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
428 * Until buffered messages become empty, GetUIMessage() continues to
429 * return <code>PP_OK</code> as if connection is still established without
430 * errors.
431 */
432 int32_t (*GetUIMessage)(PP_Resource vpn_provider,
433 struct PP_Var* message,
434 struct PP_CompletionCallback callback);
435 };
436 /**
437 * @}
438 */
439
440 #endif /* PPAPI_C_PPB_VPN_PROVIDER_H_ */
441
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698