1 // Copyright 2014 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.
5 // Use the <code>chrome.vpnProvider</code> API to implement a VPN
7 namespace vpnProvider
{
8 // A parameters class for the vpn interface
9 dictionary Parameters
{
10 // IP address for the VPN interface in CIDR notation.
11 // IPv4 is currently the only supported mode.
13 // Broadcast address for the VPN interface. (default: Deduced
14 // from IP address and mask).
15 DOMString? broadcastAddress
;
16 // MTU for the VPN interface. (default: 1500)
18 // Bypass network traffic to the below IPs (in CIDR notation)
19 // from the tunnel. Typically used to bypass traffic to/from
21 DOMString
[] bypassTunnelForIp
;
22 // A list of search domains (default: system setting).
23 DOMString
[]? domainSearch
;
24 // A list of DNS servers in CIDR notation (default: system
26 DOMString
[]? dnsServers
;
29 // The enum is used by the platform to notify the client of
30 // connection and network related status.
31 // TODO(kaliamoorthi) : Document the messages
32 enum PlatformMessage
{
38 // The enum is used by the VPN client to inform the platform
39 // of its current state. This helps provide meaningful messages
40 // to the user. The states listed below are currently known to
41 // the platform (Shill daemon).
42 // TODO(kaliamoorthi) : Document all states
43 // TODO(kaliamoorthi) : Make failure more informative by expanding the failure
45 enum VpnConnectionState
{
52 // The callback is used by <code>setParameters, sendPacket</code>
53 // to signal completion. The callback is called with
54 // <code>chrome.runtime.lastError</code> set to error code if
56 [inline_doc
] callback CallCompleteCallback
= void ();
58 // The callback is used by createConfig to signal completion.
59 callback ConfigCreatedCallback
= void (long handle);
62 // Creates a new VPN configuration.
63 static
void createConfig
(DOMString name
,
64 ConfigCreatedCallback
callback);
66 // Destroys a VPN configuration created by the extension.
67 static
void destroyConfig
(long handle,
68 optional CallCompleteCallback
callback);
70 // Sets the parameters for a VPN configuration. This should be
71 // called after connected is received from the platform.
72 static
void setParameters
(long handle, Parameters parameters
,
73 CallCompleteCallback
callback);
75 // Injects an IP packet into the network stack of Chrome OS.
76 static
void sendPacket
(long handle, ArrayBuffer data
,
77 optional CallCompleteCallback
callback);
79 // Notifies the VPN connection state to Chrome OS.
80 static
void notifyConnectionStateChanged
(
81 long handle, VpnConnectionState state
,
82 optional CallCompleteCallback
callback);
86 // Called when a message is received from the platform for a
87 // VPN configuration owned by the extension.
88 static
void onPlatformMessage
(long handle,
89 PlatformMessage
message);
91 // Called when an IP packet is received from the platform for a
92 // VPN configuration owned by the extension.
93 static
void onPacketReceived
(long handle, ArrayBuffer data
);