blob: 9e9506c42543e99517b222398d127a6b88d35297 [file] [log] [blame]
Darin Petkov7476a262012-04-12 16:30:46 +02001// 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 Petkovf7ef50a2012-04-16 20:54:31 +02008#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 Petkov7476a262012-04-12 16:30:46 +020014#include "shill/vpn_driver.h"
15
16namespace shill {
17
Darin Petkovf7ef50a2012-04-16 20:54:31 +020018class Manager;
19class NSS;
20
Darin Petkov7476a262012-04-12 16:30:46 +020021class L2TPIPSecDriver : public VPNDriver {
22 public:
Darin Petkovf7ef50a2012-04-16 20:54:31 +020023 explicit L2TPIPSecDriver(Manager *manager);
Darin Petkov7476a262012-04-12 16:30:46 +020024 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 Petkovf7ef50a2012-04-16 20:54:31 +020038 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 Petkov7476a262012-04-12 16:30:46 +020070
71 DISALLOW_COPY_AND_ASSIGN(L2TPIPSecDriver);
72};
73
74} // namespace shill
75
76#endif // SHILL_L2TP_IPSEC_DRIVER_