{{+bindTo:partials.standard_nacl_api}}
<h1>PPB_VpnProvider Struct Reference</h1>
<div id="doxygen-ref">
{{- dummy div to appease doxygen -}}
<div>
<!-- Generated by Doxygen 1.7.6.1 -->
</div>
<!--header-->
<div class="contents">
<!-- doxytag: class="PPB_VpnProvider" --><h2>
Data Fields</h2><table class="memberdecls">
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a2ec07eb1aaf01c4e7050c198e96a8f76">Create</a> )(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a55919d9d06bd5ecd2c8365b872e1db9f">IsVpnProvider</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t(* </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833">Bind</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> configuration_id, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> configuration_name, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t(* </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a43d8ddc1da63d7ee94c26721599c34db">SendPacket</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> packet, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t(* </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a767149d43eb103ad379dddcb04d1ca22">ReceivePacket</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> *packet, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Use the <code>PPB_VpnProvider</code> interface to implement a VPN client. </p>
<p>Important: This API is available only on Chrome OS.</p>
<p>This interface enhances the <code>chrome.vpnProvider</code> JavaScript API by providing a high performance path for packet handling.</p>
<p>Permissions: Apps permission <code>vpnProvider</code> is required for <code>PPB_VpnProvider.Bind()</code>.</p>
<p>Typical usage:</p>
<ul>
<li>Create a <code>PPB_VpnProvider</code> instance.</li>
<li>Register the callback for <code>PPB_VpnProvider.ReceivePacket()</code>.</li>
<li>In the extension follow the usual workflow for configuring a VPN connection via the <code>chrome.vpnProvider</code> API until the step for notifying the connection state as "connected".</li>
<li>Bind to the previously created connection using <code>PPB_VpnProvider.Bind()</code>.</li>
<li>Notify the connection state as "connected" from JavaScript using <code>chrome.vpnProvider.notifyConnectionStateChanged</code>.</li>
<li>When the steps above are completed without errors, a virtual tunnel is created to the network stack of Chrome OS. IP packets can be sent through the tunnel using <code>PPB_VpnProvider.SendPacket()</code> and any packets originating on the Chrome OS device will be received using the callback registered for <code>PPB_VpnProvider.ReceivePacket()</code>.</li>
<li>When the user disconnects from the VPN configuration or there is an error the extension will be notfied via <code>chrome.vpnProvider.onPlatformMessage</code>. </li>
</ul>
</div><hr /><h2>Field Documentation</h2>
<a class="anchor" id="a7b925b10a83d769e6d80d22fcace7833"></a><!-- doxytag: member="PPB_VpnProvider::Bind" ref="a7b925b10a83d769e6d80d22fcace7833" args=")(PP_Resource vpn_provider, struct PP_Var configuration_id, struct PP_Var configuration_name, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833">PPB_VpnProvider::Bind</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> configuration_id, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> configuration_name, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833" title="Bind() binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig.">Bind()</a> binds to an existing configuration created from JavaScript by <code>chrome.vpnProvider.createConfig</code>. </p>
<p>All packets will be routed via <code>SendPacket</code> and <code>ReceivePacket</code>. The user should register the callback for <code>ReceivePacket</code> before calling <code><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833" title="Bind() binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig.">Bind()</a></code>.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">vpn_provider</td><td>A <code>PP_Resource</code> corresponding to a VpnProvider.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">configuration_id</td><td>A <code>PP_VARTYPE_STRING</code> representing the configuration id from the callback of <code>chrome.vpnProvider.createConfig</code>.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">configuration_name</td><td>A <code>PP_VARTYPE_STRING</code> representing the configuration name as defined by the user when calling <code>chrome.vpnProvider.createConfig</code>.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> called on completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to <code><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833" title="Bind() binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig.">Bind()</a></code> has not completed. Returns <code>PP_ERROR_BADARGUMENT</code> if either <code>configuration_id</code> or <code>configuration_name</code> are not of type <code>PP_VARTYPE_STRING</code>. Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the required "vpnProvider" permission. Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and <code>connection_name</code> could not be matched with the existing connection, or if the plugin originates from a different extension than the one that created the connection. </dd></dl>
</div>
</div>
<a class="anchor" id="a2ec07eb1aaf01c4e7050c198e96a8f76"></a><!-- doxytag: member="PPB_VpnProvider::Create" ref="a2ec07eb1aaf01c4e7050c198e96a8f76" args=")(PP_Instance instance)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a2ec07eb1aaf01c4e7050c198e96a8f76">PPB_VpnProvider::Create</a>)(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a2ec07eb1aaf01c4e7050c198e96a8f76" title="Create() creates a VpnProvider instance.">Create()</a> creates a VpnProvider instance. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>A <code>PP_Instance</code> identifying the instance with the VpnProvider.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> corresponding to a VpnProvider if successful. </dd></dl>
</div>
</div>
<a class="anchor" id="a55919d9d06bd5ecd2c8365b872e1db9f"></a><!-- doxytag: member="PPB_VpnProvider::IsVpnProvider" ref="a55919d9d06bd5ecd2c8365b872e1db9f" args=")(PP_Resource resource)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a55919d9d06bd5ecd2c8365b872e1db9f">PPB_VpnProvider::IsVpnProvider</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a55919d9d06bd5ecd2c8365b872e1db9f" title="IsVpnProvider() determines if the provided resource is a VpnProvider instance.">IsVpnProvider()</a> determines if the provided <code>resource</code> is a VpnProvider instance. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">resource</td><td>A <code>PP_Resource</code> corresponding to a VpnProvider.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns <code>PP_TRUE</code> if <code>resource</code> is a <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the <code>resource</code> is invalid or some type other than <code>PPB_VpnProvider</code>. </dd></dl>
</div>
</div>
<a class="anchor" id="a767149d43eb103ad379dddcb04d1ca22"></a><!-- doxytag: member="PPB_VpnProvider::ReceivePacket" ref="a767149d43eb103ad379dddcb04d1ca22" args=")(PP_Resource vpn_provider, struct PP_Var *packet, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a767149d43eb103ad379dddcb04d1ca22">PPB_VpnProvider::ReceivePacket</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> *packet, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a767149d43eb103ad379dddcb04d1ca22" title="ReceivePacket() receives an IP packet from the tunnel for the VPN session.">ReceivePacket()</a> receives an IP packet from the tunnel for the VPN session. </p>
<p>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 <code><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a7b925b10a83d769e6d80d22fcace7833" title="Bind() binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig.">Bind()</a></code>.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">vpn_provider</td><td>A <code>PP_Resource</code> corresponding to a VpnProvider.</td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">packet</td><td>The received packet is copied to provided <code>packet</code>. The <code>packet</code> must remain valid until <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a767149d43eb103ad379dddcb04d1ca22" title="ReceivePacket() receives an IP packet from the tunnel for the VPN session.">ReceivePacket()</a> completes. Its received <code>PP_VarType</code> will be <code>PP_VARTYPE_ARRAY_BUFFER</code>.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> called on completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to <code><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a767149d43eb103ad379dddcb04d1ca22" title="ReceivePacket() receives an IP packet from the tunnel for the VPN session.">ReceivePacket()</a></code> has not completed. </dd></dl>
</div>
</div>
<a class="anchor" id="a43d8ddc1da63d7ee94c26721599c34db"></a><!-- doxytag: member="PPB_VpnProvider::SendPacket" ref="a43d8ddc1da63d7ee94c26721599c34db" args=")(PP_Resource vpn_provider, struct PP_Var packet, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a43d8ddc1da63d7ee94c26721599c34db">PPB_VpnProvider::SendPacket</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> vpn_provider, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> packet, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a43d8ddc1da63d7ee94c26721599c34db" title="SendPacket() sends an IP packet through the tunnel created for the VPN session.">SendPacket()</a> sends an IP packet through the tunnel created for the VPN session. </p>
<p>This will succeed only when the VPN session is owned by the module and the connection is bound.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">vpn_provider</td><td>A <code>PP_Resource</code> corresponding to a VpnProvider.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">packet</td><td>A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to an IP packet to be sent to the platform.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> called on completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. Returns <code>PP_ERROR_FAILED</code> if the connection is not bound. Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to <code><a class="el" href="struct_p_p_b___vpn_provider__0__1.html#a43d8ddc1da63d7ee94c26721599c34db" title="SendPacket() sends an IP packet through the tunnel created for the VPN session.">SendPacket()</a></code> has not completed. Returns <code>PP_ERROR_BADARGUMENT</code> if <code>packet</code> is not of type <code>PP_VARTYPE_ARRAY_BUFFER</code>. </dd></dl>
</div>
</div>
<hr />The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="ppb__vpn__provider_8h.html">ppb_vpn_provider.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}