OLD | NEW |
(Empty) | |
| 1 /* Copyright 2016 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 Tue Mar 15 12:04:58 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 Interfaces |
| 28 * @{ |
| 29 */ |
| 30 /** |
| 31 * Use the <code>PPB_VpnProvider</code> interface to implement a VPN client. |
| 32 * Important: This API is available only on Chrome OS. |
| 33 */ |
| 34 struct PPB_VpnProvider_0_1 { /* dev */ |
| 35 /** |
| 36 * Create() creates a VpnProvider instance. |
| 37 * |
| 38 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 39 * with the VpnProvider. |
| 40 * |
| 41 * @return A <code>PP_Resource</code> corresponding to a VpnProvider if |
| 42 * successful. |
| 43 */ |
| 44 PP_Resource (*Create)(PP_Instance instance); |
| 45 /** |
| 46 * IsVpnProvider() determines if the provided <code>resource</code> is a |
| 47 * VpnProvider instance. |
| 48 * |
| 49 * @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 50 * VpnProvider. |
| 51 * |
| 52 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a |
| 53 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the |
| 54 * <code>resource</code> is invalid or some type other than |
| 55 * <code>PPB_VpnProvider</code>. |
| 56 */ |
| 57 PP_Bool (*IsVpnProvider)(PP_Resource resource); |
| 58 /** |
| 59 * Bind() binds to an existing connection created by |
| 60 * <code>chrome.vpnProvider.createConfig</code>. All packets will be routed |
| 61 * via <code>SendPacket</code> and <code>GetPacket</code> in the Native |
| 62 * Client API. |
| 63 * |
| 64 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a |
| 65 * VpnProvider. |
| 66 * |
| 67 * @param[in] name A <code>PP_VARTYPE_STRING</code> representing the |
| 68 * connection name as defined by the user when calling |
| 69 * <code>chrome.vpnProvider.createConfig</code>. |
| 70 * |
| 71 * @param[in] id A <code>PP_VARTYPE_STRING</code> representing the connection |
| 72 * id from the callback of <code>chrome.vpnProvider.createConfig</code>. |
| 73 * |
| 74 * @param[in] callback A <code>PP_CompletionCallback</code> called when |
| 75 * the connection gets bound. |
| 76 * |
| 77 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a |
| 78 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the |
| 79 * <code>resource</code> is invalid or some type other than |
| 80 * <code>PPB_VpnProvider</code>. |
| 81 * |
| 82 */ |
| 83 int32_t (*Bind)(PP_Resource vpn_provider, |
| 84 struct PP_Var name, |
| 85 struct PP_Var id, |
| 86 struct PP_CompletionCallback callback); |
| 87 /** |
| 88 * GetUnBindEvent() registers a callback that will be called when the current |
| 89 * connection gets unbound. |
| 90 * |
| 91 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a |
| 92 * VpnProvider. |
| 93 * |
| 94 * @param[in] callback A <code>PP_CompletionCallback</code> called when |
| 95 * the current connection gets unbound. |
| 96 * |
| 97 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a |
| 98 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the |
| 99 * <code>resource</code> is invalid or some type other than |
| 100 * <code>PPB_VpnProvider</code>. |
| 101 * |
| 102 */ |
| 103 int32_t (*GetUnBindEvent)(PP_Resource vpn_provider, |
| 104 struct PP_CompletionCallback callback); |
| 105 /** |
| 106 * SendPacket() sends an IP packet through the tunnel created for the VPN |
| 107 * session. This will succeed only when the VPN session is owned by the |
| 108 * module. |
| 109 * |
| 110 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a |
| 111 * VpnProvider. |
| 112 * |
| 113 * @param[in] packet A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to |
| 114 * an IP packet to be sent to the platform. |
| 115 * |
| 116 * @param[in] callback A <code>PP_CompletionCallback</code> called |
| 117 * when SendPacket() completes. |
| 118 * |
| 119 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 120 * If an error is detected or connection is closed, GetPacket() returns |
| 121 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
| 122 * Until buffered packets become empty, GetPacket() continues to return |
| 123 * <code>PP_OK</code> as if connection is still established without errors. |
| 124 */ |
| 125 int32_t (*SendPacket)(PP_Resource vpn_provider, |
| 126 struct PP_Var packet, |
| 127 struct PP_CompletionCallback callback); |
| 128 /** |
| 129 * GetPacket() receives an IP packet from the tunnel for the VPN session. |
| 130 * This interface only returns a single packet. That is, this interface must |
| 131 * be called at least N times to receive N packet, no matter the size of |
| 132 * each packet. |
| 133 * |
| 134 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a |
| 135 * VpnProvider. |
| 136 * |
| 137 * @param[out] packet The received packet is copied to provided |
| 138 * <code>packet</code>. The <code>packet</code> must remain valid until |
| 139 * GetPacket() completes. Its received <code>PP_VarType</code> will be |
| 140 * <code>PP_VARTYPE_ARRAY_BUFFER</code>. |
| 141 * |
| 142 * @param[in] callback A <code>PP_CompletionCallback</code> called |
| 143 * when GetPacket() completes. |
| 144 * |
| 145 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 146 * If an error is detected or connection is closed, GetPacket() returns |
| 147 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
| 148 * Until buffered packets become empty, GetPacket() continues to return |
| 149 * <code>PP_OK</code> as if connection is still established without errors. |
| 150 */ |
| 151 int32_t (*GetPacket)(PP_Resource vpn_provider, |
| 152 struct PP_Var* packet, |
| 153 struct PP_CompletionCallback callback); |
| 154 }; |
| 155 /** |
| 156 * @} |
| 157 */ |
| 158 |
| 159 #endif /* PPAPI_C_PPB_VPN_PROVIDER_H_ */ |
| 160 |
OLD | NEW |