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 | |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 5 | #ifndef SHILL_VPN_SERVICE_H_ |
| 6 | #define SHILL_VPN_SERVICE_H_ |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 7 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 10 | #include <base/memory/scoped_ptr.h> |
| 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 12 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 13 | #include "shill/connection.h" |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 14 | #include "shill/service.h" |
| 15 | |
| 16 | namespace shill { |
| 17 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 18 | class KeyValueStore; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 19 | class VPNDriver; |
| 20 | |
| 21 | class VPNService : public Service { |
| 22 | public: |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 23 | VPNService(ControlInterface *control, |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 24 | EventDispatcher *dispatcher, |
| 25 | Metrics *metrics, |
| 26 | Manager *manager, |
| 27 | VPNDriver *driver); // Takes ownership of |driver|. |
| 28 | virtual ~VPNService(); |
| 29 | |
| 30 | // Inherited from Service. |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 31 | virtual void Connect(Error *error, const char *reason); |
Samuel Tan | 0d06119 | 2014-07-07 15:45:15 -0700 | [diff] [blame] | 32 | virtual void Disconnect(Error *error, const char *reason); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 33 | virtual std::string GetStorageIdentifier() const; |
Darin Petkov | f3c71d7 | 2012-03-21 12:32:15 +0100 | [diff] [blame] | 34 | virtual bool Load(StoreInterface *storage); |
| 35 | virtual bool Save(StoreInterface *storage); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 36 | virtual bool Unload(); |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 37 | virtual void EnableAndRetainAutoConnect(); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 38 | virtual void SetConnection(const ConnectionRefPtr &connection); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 39 | virtual bool SetNameProperty(const std::string &name, Error *error); |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 40 | |
Paul Stewart | ebd3856 | 2012-03-23 13:06:40 -0700 | [diff] [blame] | 41 | virtual void InitDriverPropertyStore(); |
| 42 | |
Darin Petkov | 6aa2187 | 2012-03-09 16:10:19 +0100 | [diff] [blame] | 43 | VPNDriver *driver() const { return driver_.get(); } |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 44 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 45 | static std::string CreateStorageIdentifier(const KeyValueStore &args, |
| 46 | Error *error); |
| 47 | void set_storage_id(const std::string &id) { storage_id_ = id; } |
| 48 | |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 49 | protected: |
| 50 | // Inherited from Service. |
Alex Vakulenko | 016fa0e | 2014-08-11 15:59:58 -0700 | [diff] [blame^] | 51 | bool IsAutoConnectable(const char **reason) const override; |
| 52 | std::string GetTethering(Error *error) const override; |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 53 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 54 | private: |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 55 | friend class VPNServiceTest; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 56 | FRIEND_TEST(VPNServiceTest, GetDeviceRpcId); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 57 | FRIEND_TEST(VPNServiceTest, SetConnection); |
Alex Deymo | fddc09a | 2013-07-03 18:41:31 -0700 | [diff] [blame] | 58 | FRIEND_TEST(VPNServiceTest, GetPhysicalTechologyPropertyFailsIfNoCarrier); |
| 59 | FRIEND_TEST(VPNServiceTest, GetPhysicalTechologyPropertyOverWifi); |
Paul Stewart | 7f5d9c0 | 2013-12-03 18:26:00 -0800 | [diff] [blame] | 60 | FRIEND_TEST(VPNServiceTest, GetTethering); |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 61 | |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 62 | static const char kAutoConnNeverConnected[]; |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 63 | static const char kAutoConnVPNAlreadyActive[]; |
Darin Petkov | 79349f0 | 2013-01-24 16:18:26 +0100 | [diff] [blame] | 64 | |
Paul Stewart | 1cf7eb8 | 2013-12-03 19:34:36 -0800 | [diff] [blame] | 65 | virtual std::string GetDeviceRpcId(Error *error) const; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 66 | |
Alex Deymo | fddc09a | 2013-07-03 18:41:31 -0700 | [diff] [blame] | 67 | // Returns the Type name of the lowest connection (presumably the "physical" |
| 68 | // connection) that this service depends on. |
| 69 | std::string GetPhysicalTechologyProperty(Error *error); |
| 70 | |
Darin Petkov | 0286771 | 2012-03-12 14:25:05 +0100 | [diff] [blame] | 71 | std::string storage_id_; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 72 | scoped_ptr<VPNDriver> driver_; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 73 | scoped_ptr<Connection::Binder> connection_binder_; |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 74 | |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 75 | // Provided only for compatibility. crbug.com/211858 |
Paul Stewart | 2280799 | 2012-04-11 08:48:31 -0700 | [diff] [blame] | 76 | std::string vpn_domain_; |
| 77 | |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 78 | DISALLOW_COPY_AND_ASSIGN(VPNService); |
| 79 | }; |
| 80 | |
| 81 | } // namespace shill |
| 82 | |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 83 | #endif // SHILL_VPN_SERVICE_H_ |