Darin Petkov | 7476a26 | 2012-04-12 16:30:46 +0200 | [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_L2TP_IPSEC_DRIVER_ |
| 6 | #define SHILL_L2TP_IPSEC_DRIVER_ |
| 7 | |
Darin Petkov | f7ef50a | 2012-04-16 20:54:31 +0200 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
| 10 | #include <base/file_path.h> |
| 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 12 | |
| 13 | #include "shill/key_value_store.h" |
Darin Petkov | 7476a26 | 2012-04-12 16:30:46 +0200 | [diff] [blame] | 14 | #include "shill/vpn_driver.h" |
| 15 | |
| 16 | namespace shill { |
| 17 | |
Darin Petkov | f7ef50a | 2012-04-16 20:54:31 +0200 | [diff] [blame] | 18 | class Manager; |
| 19 | class NSS; |
| 20 | |
Darin Petkov | 7476a26 | 2012-04-12 16:30:46 +0200 | [diff] [blame] | 21 | class L2TPIPSecDriver : public VPNDriver { |
| 22 | public: |
Darin Petkov | f7ef50a | 2012-04-16 20:54:31 +0200 | [diff] [blame] | 23 | explicit L2TPIPSecDriver(Manager *manager); |
Darin Petkov | 7476a26 | 2012-04-12 16:30:46 +0200 | [diff] [blame] | 24 | virtual ~L2TPIPSecDriver(); |
| 25 | |
| 26 | // Inherited from VPNDriver. |
| 27 | virtual bool ClaimInterface(const std::string &link_name, |
| 28 | int interface_index); |
| 29 | virtual void Connect(const VPNServiceRefPtr &service, Error *error); |
| 30 | virtual void Disconnect(); |
| 31 | virtual bool Load(StoreInterface *storage, const std::string &storage_id); |
| 32 | virtual bool Save(StoreInterface *storage, const std::string &storage_id); |
| 33 | virtual void InitPropertyStore(PropertyStore *store); |
| 34 | virtual std::string GetProviderType() const; |
| 35 | |
| 36 | private: |
| 37 | friend class L2TPIPSecDriverTest; |
Darin Petkov | f7ef50a | 2012-04-16 20:54:31 +0200 | [diff] [blame] | 38 | FRIEND_TEST(L2TPIPSecDriverTest, AppendFlag); |
| 39 | FRIEND_TEST(L2TPIPSecDriverTest, AppendValueOption); |
| 40 | FRIEND_TEST(L2TPIPSecDriverTest, Cleanup); |
| 41 | FRIEND_TEST(L2TPIPSecDriverTest, InitNSSOptions); |
| 42 | FRIEND_TEST(L2TPIPSecDriverTest, InitOptions); |
| 43 | FRIEND_TEST(L2TPIPSecDriverTest, InitOptionsNoHost); |
| 44 | FRIEND_TEST(L2TPIPSecDriverTest, InitPSKOptions); |
| 45 | |
| 46 | static const char kPPPDPlugin[]; |
| 47 | |
| 48 | void InitOptions(std::vector<std::string> *options, Error *error); |
| 49 | bool InitPSKOptions(std::vector<std::string> *options, Error *error); |
| 50 | void InitNSSOptions(std::vector<std::string> *options); |
| 51 | |
| 52 | void Cleanup(); |
| 53 | |
| 54 | // Returns true if an opton was appended. |
| 55 | bool AppendValueOption(const std::string &property, |
| 56 | const std::string &option, |
| 57 | std::vector<std::string> *options); |
| 58 | |
| 59 | // Returns true if a flag was appended. |
| 60 | bool AppendFlag(const std::string &property, |
| 61 | const std::string &true_option, |
| 62 | const std::string &false_option, |
| 63 | std::vector<std::string> *options); |
| 64 | |
| 65 | Manager *manager_; |
| 66 | NSS *nss_; |
| 67 | KeyValueStore args_; |
| 68 | |
| 69 | FilePath psk_file_; |
Darin Petkov | 7476a26 | 2012-04-12 16:30:46 +0200 | [diff] [blame] | 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(L2TPIPSecDriver); |
| 72 | }; |
| 73 | |
| 74 | } // namespace shill |
| 75 | |
| 76 | #endif // SHILL_L2TP_IPSEC_DRIVER_ |