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_VpnProvider instance.
  • Register the callback for PPB_VpnProvider.ReceivePacket().
  • In the extension follow the usual workflow for configuring a VPN connection via the chrome.vpnProvider API 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 for PPB_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_providerA PP_Resource corresponding to a VpnProvider.
[in]configuration_idA PP_VARTYPE_STRING representing the configuration id from the callback of chrome.vpnProvider.createConfig.
[in]configuration_nameA PP_VARTYPE_STRING representing the configuration name as defined by the user when calling chrome.vpnProvider.createConfig.
[in]callbackA PP_CompletionCallback called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_INPROGRESS if a previous call to Bind() has not completed. Returns PP_ERROR_BADARGUMENT if either configuration_id or configuration_name are not of type PP_VARTYPE_STRING. Returns PP_ERROR_NOACCESS if the caller does the have the required "vpnProvider" permission. Returns PP_ERROR_FAILED if connection_id and connection_name could not be matched with the existing connection, or if the plugin originates from a different extension than the one that created the connection.

Create() creates a VpnProvider instance.

Parameters:
[in]instanceA PP_Instance identifying the instance with the VpnProvider.
Returns:
A PP_Resource corresponding to a VpnProvider if successful.

IsVpnProvider() determines if the provided resource is a VpnProvider instance.

Parameters:
[in]resourceA PP_Resource corresponding to a VpnProvider.
Returns:
Returns PP_TRUE if resource is a PPB_VpnProvider, PP_FALSE if the resource is invalid or some type other than PPB_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_providerA PP_Resource corresponding to a VpnProvider.
[out]packetThe received packet is copied to provided packet. The packet must remain valid until ReceivePacket() completes. Its received PP_VarType will be PP_VARTYPE_ARRAY_BUFFER.
[in]callbackA PP_CompletionCallback called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_INPROGRESS if a previous call to ReceivePacket() 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_providerA PP_Resource corresponding to a VpnProvider.
[in]packetA PP_VARTYPE_ARRAY_BUFFER corresponding to an IP packet to be sent to the platform.
[in]callbackA PP_CompletionCallback called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_FAILED if the connection is not bound. Returns PP_ERROR_INPROGRESS if a previous call to SendPacket() has not completed. Returns PP_ERROR_BADARGUMENT if packet is not of type PP_VARTYPE_ARRAY_BUFFER.

The documentation for this struct was generated from the following file:
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.