Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / extensions / common / api / vpn_provider.idl
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.
4
5 // Use the <code>chrome.vpnProvider</code> API to implement a VPN
6 // client.
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.
12     DOMString address;
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)
17     DOMString? mtu;
18     // Bypass network traffic to the below IPs (in CIDR notation)
19     // from the tunnel. Typically used to bypass traffic to/from
20     // VPN server.
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
25     // setting).
26     DOMString[]? dnsServers;
27   };
28
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 {
33     connected,
34     disconnected,
35     underlyingNetworkDisconnected,
36     error
37   };
38
39   // The enum is used by the VPN client to inform the platform
40   // of its current state. This helps provide meaningful messages
41   // to the user. The states listed below are currently known to
42   // the platform (Shill daemon).
43   // TODO(kaliamoorthi) : Document all states
44   // TODO(kaliamoorthi) : Make failure more informative by expanding the failure
45   // conditions.
46   enum VpnConnectionState {
47     connected,
48     portal,
49     online,
50     failure
51   };
52
53   // The callback is used by <code>setParameters, sendPacket</code>
54   // to signal completion. The callback is called with
55   // <code>chrome.runtime.lastError</code> set to error code if
56   // there is an error.
57   [inline_doc] callback CallCompleteCallback = void ();
58
59   // The callback is used by createConfig to signal completion.
60   callback ConfigCreatedCallback = void (long handle);
61
62   interface Functions {
63     // Creates a new VPN configuration.
64     static void createConfig(DOMString name,
65                              ConfigCreatedCallback callback);
66
67     // Destroys a VPN configuration created by the extension.
68     static void destroyConfig(long handle,
69                               optional CallCompleteCallback callback);
70
71     // Sets the parameters for a VPN configuration. This should be
72     // called after connected is received from the platform.
73     static void setParameters(long handle, Parameters parameters,
74                               CallCompleteCallback callback);
75
76     // Injects an IP packet into the network stack of Chrome OS.
77     static void sendPacket(long handle, ArrayBuffer data,
78                            optional CallCompleteCallback callback);
79
80     // Notifies the VPN connection state to Chrome OS.
81     static void notifyConnectionStateChanged(
82         long handle, VpnConnectionState state,
83         optional CallCompleteCallback callback);
84   };
85
86   interface Events {
87     // Called when a message is received from the platform for a
88     // VPN configuration owned by the extension.
89     static void onPlatformMessage(long handle,
90                                   PlatformMessage message);
91
92     // Called when an IP packet is received from the platform for a
93     // VPN configuration owned by the extension.
94     static void onPacketReceived(long handle, ArrayBuffer data);
95   };
96 };