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_VPN_DRIVER_ |
| 6 | #define SHILL_VPN_DRIVER_ |
| 7 | |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 10 | #include <base/basictypes.h> |
Darin Petkov | 0e9735d | 2012-04-24 12:33:45 +0200 | [diff] [blame] | 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 12 | |
Darin Petkov | b451d6e | 2012-04-23 11:56:41 +0200 | [diff] [blame] | 13 | #include "shill/accessor_interface.h" |
| 14 | #include "shill/key_value_store.h" |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 15 | #include "shill/refptr_types.h" |
| 16 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 17 | namespace shill { |
| 18 | |
| 19 | class Error; |
Darin Petkov | 0e9735d | 2012-04-24 12:33:45 +0200 | [diff] [blame] | 20 | class Manager; |
Paul Stewart | ebd3856 | 2012-03-23 13:06:40 -0700 | [diff] [blame] | 21 | class PropertyStore; |
Darin Petkov | f3c71d7 | 2012-03-21 12:32:15 +0100 | [diff] [blame] | 22 | class StoreInterface; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 23 | |
| 24 | class VPNDriver { |
| 25 | public: |
Darin Petkov | b451d6e | 2012-04-23 11:56:41 +0200 | [diff] [blame] | 26 | virtual ~VPNDriver(); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 27 | |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame] | 28 | virtual bool ClaimInterface(const std::string &link_name, |
| 29 | int interface_index) = 0; |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 30 | virtual void Connect(const VPNServiceRefPtr &service, Error *error) = 0; |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 31 | virtual void Disconnect() = 0; |
Paul Stewart | 39964fa | 2012-04-04 09:50:25 -0700 | [diff] [blame] | 32 | virtual std::string GetProviderType() const = 0; |
Darin Petkov | b451d6e | 2012-04-23 11:56:41 +0200 | [diff] [blame] | 33 | |
| 34 | virtual void InitPropertyStore(PropertyStore *store); |
| 35 | |
| 36 | virtual bool Load(StoreInterface *storage, const std::string &storage_id); |
| 37 | virtual bool Save(StoreInterface *storage, const std::string &storage_id); |
| 38 | |
| 39 | KeyValueStore *args() { return &args_; } |
| 40 | |
| 41 | protected: |
| 42 | struct Property { |
| 43 | enum Flags { |
| 44 | kEphemeral = 1 << 0, |
| 45 | kCrypted = 1 << 1, |
| 46 | }; |
| 47 | |
| 48 | const char *property; |
| 49 | int flags; |
| 50 | }; |
| 51 | |
Darin Petkov | 0e9735d | 2012-04-24 12:33:45 +0200 | [diff] [blame] | 52 | VPNDriver(Manager *manager, |
| 53 | const Property *properties, |
| 54 | size_t property_count); |
| 55 | |
| 56 | Manager *manager() const { return manager_; } |
| 57 | |
Darin Petkov | b451d6e | 2012-04-23 11:56:41 +0200 | [diff] [blame] | 58 | private: |
| 59 | Stringmap GetProvider(Error *error); |
| 60 | void ClearMappedProperty(const size_t &index, Error *error); |
| 61 | std::string GetMappedProperty(const size_t &index, Error *error); |
| 62 | void SetMappedProperty( |
| 63 | const size_t &index, const std::string &value, Error *error); |
| 64 | |
Darin Petkov | 0e9735d | 2012-04-24 12:33:45 +0200 | [diff] [blame] | 65 | Manager *manager_; |
Darin Petkov | b451d6e | 2012-04-23 11:56:41 +0200 | [diff] [blame] | 66 | const Property * const properties_; |
| 67 | const size_t property_count_; |
| 68 | KeyValueStore args_; |
| 69 | |
| 70 | DISALLOW_COPY_AND_ASSIGN(VPNDriver); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace shill |
| 74 | |
| 75 | #endif // SHILL_VPN_DRIVER_ |