{{+bindTo:partials.standard_nacl_api}}
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) |
Use the PPB_VpnProvider
interface to implement a VPN client.
Important: This API is available only on Chrome OS.
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:
PPB_VpnProvider
instance.PPB_VpnProvider.ReceivePacket()
.chrome.vpnProvider
API until the step for notifying the connection state as "connected".PPB_VpnProvider.Bind()
.chrome.vpnProvider.notifyConnectionStateChanged
.PPB_VpnProvider.SendPacket()
and any packets originating on the Chrome OS device will be received using the callback registered for PPB_VpnProvider.ReceivePacket()
.chrome.vpnProvider.onPlatformMessage
. 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()
.
[in] | vpn_provider | A PP_Resource corresponding to a VpnProvider. |
[in] | configuration_id | A PP_VARTYPE_STRING representing the configuration id from the callback of chrome.vpnProvider.createConfig . |
[in] | configuration_name | A PP_VARTYPE_STRING representing the configuration name as defined by the user when calling chrome.vpnProvider.createConfig . |
[in] | callback | A PP_CompletionCallback called on completion. |
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. PP_Resource(* PPB_VpnProvider::Create)(PP_Instance instance) |
Create() creates a VpnProvider instance.
[in] | instance | A PP_Instance identifying the instance with the VpnProvider. |
PP_Resource
corresponding to a VpnProvider if successful. PP_Bool(* PPB_VpnProvider::IsVpnProvider)(PP_Resource resource) |
IsVpnProvider() determines if the provided resource
is a VpnProvider instance.
[in] | resource | A PP_Resource corresponding to a VpnProvider. |
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()
.
[in] | vpn_provider | A PP_Resource corresponding to a VpnProvider. |
[out] | packet | The 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] | callback | A PP_CompletionCallback called on completion. |
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.
[in] | vpn_provider | A PP_Resource corresponding to a VpnProvider. |
[in] | packet | A PP_VARTYPE_ARRAY_BUFFER corresponding to an IP packet to be sent to the platform. |
[in] | callback | A PP_CompletionCallback called on completion. |
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
.