Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS 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 | #ifndef SHILL_OPENVPN_DRIVER_ |
| 6 | #define SHILL_OPENVPN_DRIVER_ |
| 7 | |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 11 | #include <base/memory/scoped_ptr.h> |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 12 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 13 | |
| 14 | #include "shill/key_value_store.h" |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 15 | #include "shill/vpn_driver.h" |
| 16 | |
| 17 | namespace shill { |
| 18 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 19 | class ControlInterface; |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 20 | class DeviceInfo; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 21 | class Error; |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 22 | class RPCTask; |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 23 | class DeviceStub; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 24 | |
| 25 | class OpenVPNDriver : public VPNDriver { |
| 26 | public: |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 27 | OpenVPNDriver(ControlInterface *control, |
| 28 | DeviceInfo *device_info, |
| 29 | const KeyValueStore &args); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 30 | virtual ~OpenVPNDriver(); |
| 31 | |
| 32 | // Inherited from VPNDriver. |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 33 | virtual bool ClaimInterface(const std::string &link_name, |
| 34 | int interface_index); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 35 | virtual void Connect(Error *error); |
| 36 | |
| 37 | private: |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 38 | friend class OpenVPNDriverTest; |
| 39 | FRIEND_TEST(OpenVPNDriverTest, AppendFlag); |
| 40 | FRIEND_TEST(OpenVPNDriverTest, AppendValueOption); |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 41 | FRIEND_TEST(OpenVPNDriverTest, ClaimInterface); |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 42 | FRIEND_TEST(OpenVPNDriverTest, InitOptions); |
| 43 | FRIEND_TEST(OpenVPNDriverTest, InitOptionsNoHost); |
| 44 | |
| 45 | void InitOptions(std::vector<std::string> *options, Error *error); |
| 46 | |
| 47 | void AppendValueOption(const std::string &property, |
| 48 | const std::string &option, |
| 49 | std::vector<std::string> *options); |
| 50 | void AppendFlag(const std::string &property, |
| 51 | const std::string &option, |
| 52 | std::vector<std::string> *options); |
| 53 | |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 54 | ControlInterface *control_; |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 55 | DeviceInfo *device_info_; |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 56 | KeyValueStore args_; |
Darin Petkov | a9b1fed | 2012-02-29 11:49:05 +0100 | [diff] [blame] | 57 | scoped_ptr<RPCTask> rpc_task_; |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame^] | 58 | std::string tunnel_interface_; |
| 59 | int interface_index_; |
Darin Petkov | fe6a937 | 2012-02-28 16:25:06 +0100 | [diff] [blame] | 60 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(OpenVPNDriver); |
| 62 | }; |
| 63 | |
| 64 | } // namespace shill |
| 65 | |
| 66 | #endif // SHILL_OPENVPN_DRIVER_ |