Data Fields
| PP_Resource(* | Create )(PP_Instance instance) |
| PP_Bool(* | IsVpnProvider )(PP_Resource resource) |
| int32_t(* | Bind )(PP_Resource vpn_provider, struct PP_Var configuration_id, struct PP_Var configuration_name, struct PP_CompletionCallback callback) |
| int32_t(* | SendPacket )(PP_Resource vpn_provider, struct PP_Var packet, struct PP_CompletionCallback callback) |
| int32_t(* | ReceivePacket )(PP_Resource vpn_provider, struct PP_Var *packet, struct PP_CompletionCallback callback) |
Detailed Description
Use the PPB_VpnProvider interface to implement a VPN client.
Important: This API is available only on ChromeOS.
This interface enhances the chrome.vpnProvider JavaScript API by providing a high performance path for packet handling.
Permissions: Apps permission vpnProvider is required for PPB_VpnProvider.Bind().
Typical usage:
- Create a
PPB_VpnProviderinstance. - Register the callback for
PPB_VpnProvider.ReceivePacket(). - In the extension follow the usual workflow for configuring a VPN connection via the
chrome.vpnProviderAPI until the step for notifying the connection state as "connected". - Bind to the previously created connection using
PPB_VpnProvider.Bind(). - Notify the connection state as "connected" from JavaScript using
chrome.vpnProvider.notifyConnectionStateChanged. - When the steps above are completed without errors, a virtual tunnel is created to the network stack of ChromeOS. IP packets can be sent through the tunnel using
PPB_VpnProvider.SendPacket()and any packets originating on the ChromeOS device will be received using the callback registered forPPB_VpnProvider.ReceivePacket(). - When the user disconnects from the VPN configuration or there is an error the extension will be notfied via
chrome.vpnProvider.onPlatformMessage.
Field Documentation
| int32_t(* PPB_VpnProvider::Bind)(PP_Resource vpn_provider, struct PP_Var configuration_id, struct PP_Var configuration_name, struct PP_CompletionCallback callback) |
Bind() binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig.
All packets will be routed via SendPacket and ReceivePacket. The user should register the callback for ReceivePacket before calling Bind().
- Parameters:
[in] vpn_provider A PP_Resourcecorresponding to a VpnProvider.[in] configuration_id A PP_VARTYPE_STRINGrepresenting the configuration id from the callback ofchrome.vpnProvider.createConfig.[in] configuration_name A PP_VARTYPE_STRINGrepresenting the configuration name as defined by the user when callingchrome.vpnProvider.createConfig.[in] callback A PP_CompletionCallbackcalled on completion.
- Returns:
- An int32_t containing an error code from
pp_errors.h. ReturnsPP_ERROR_INPROGRESSif a previous call toBind()has not completed. ReturnsPP_ERROR_BADARGUMENTif eitherconfiguration_idorconfiguration_nameare not of typePP_VARTYPE_STRING. ReturnsPP_ERROR_NOACCESSif the caller does the have the required "vpnProvider" permission. ReturnsPP_ERROR_FAILEDifconnection_idandconnection_namecould not be matched with the existing connection, or if the plugin originates from a different extension than the one that created the connection.
| PP_Resource(* PPB_VpnProvider::Create)(PP_Instance instance) |
Create() creates a VpnProvider instance.
- Parameters:
[in] instance A PP_Instanceidentifying the instance with the VpnProvider.
- Returns:
- A
PP_Resourcecorresponding to a VpnProvider if successful.
| PP_Bool(* PPB_VpnProvider::IsVpnProvider)(PP_Resource resource) |
IsVpnProvider() determines if the provided resource is a VpnProvider instance.
- Parameters:
[in] resource A PP_Resourcecorresponding to a VpnProvider.
- Returns:
- Returns
PP_TRUEifresourceis aPPB_VpnProvider,PP_FALSEif theresourceis invalid or some type other thanPPB_VpnProvider.
| int32_t(* PPB_VpnProvider::ReceivePacket)(PP_Resource vpn_provider, struct PP_Var *packet, struct PP_CompletionCallback callback) |
ReceivePacket() receives an IP packet from the tunnel for the VPN session.
This function only returns a single packet. This function must be called at least N times to receive N packets, no matter the size of each packet. The callback should be registered before calling Bind().
- Parameters:
[in] vpn_provider A PP_Resourcecorresponding to a VpnProvider.[out] packet The received packet is copied to provided packet. Thepacketmust remain valid until ReceivePacket() completes. Its receivedPP_VarTypewill bePP_VARTYPE_ARRAY_BUFFER.[in] callback A PP_CompletionCallbackcalled on completion.
- Returns:
- An int32_t containing an error code from
pp_errors.h. ReturnsPP_ERROR_INPROGRESSif a previous call toReceivePacket()has not completed.
| int32_t(* PPB_VpnProvider::SendPacket)(PP_Resource vpn_provider, struct PP_Var packet, struct PP_CompletionCallback callback) |
SendPacket() sends an IP packet through the tunnel created for the VPN session.
This will succeed only when the VPN session is owned by the module and the connection is bound.
- Parameters:
[in] vpn_provider A PP_Resourcecorresponding to a VpnProvider.[in] packet A PP_VARTYPE_ARRAY_BUFFERcorresponding to an IP packet to be sent to the platform.[in] callback A PP_CompletionCallbackcalled on completion.
- Returns:
- An int32_t containing an error code from
pp_errors.h. ReturnsPP_ERROR_FAILEDif the connection is not bound. ReturnsPP_ERROR_INPROGRESSif a previous call toSendPacket()has not completed. ReturnsPP_ERROR_BADARGUMENTifpacketis not of typePP_VARTYPE_ARRAY_BUFFER.
The documentation for this struct was generated from the following file: