Peter Qiu | 326b6cf | 2015-09-02 11:11:42 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2014 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 16 | |
Peter Qiu | 2a6fb33 | 2015-09-17 22:19:17 -0700 | [diff] [blame] | 17 | #ifndef APMANAGER_SHILL_MANAGER_H_ |
| 18 | #define APMANAGER_SHILL_MANAGER_H_ |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 19 | |
| 20 | #include <set> |
| 21 | #include <string> |
| 22 | |
| 23 | #include <base/macros.h> |
Peter Qiu | 37328b8 | 2015-09-18 09:28:18 -0700 | [diff] [blame] | 24 | #include <base/memory/weak_ptr.h> |
Peter Qiu | 37328b8 | 2015-09-18 09:28:18 -0700 | [diff] [blame] | 25 | |
| 26 | #include "apmanager/shill_proxy_interface.h" |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 27 | |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 28 | namespace apmanager { |
| 29 | |
Peter Qiu | be12882 | 2015-10-13 13:55:03 -0700 | [diff] [blame] | 30 | class ControlInterface; |
| 31 | |
Peter Qiu | 2a6fb33 | 2015-09-17 22:19:17 -0700 | [diff] [blame] | 32 | class ShillManager { |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 33 | public: |
Peter Qiu | 2a6fb33 | 2015-09-17 22:19:17 -0700 | [diff] [blame] | 34 | ShillManager(); |
| 35 | virtual ~ShillManager(); |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 36 | |
Peter Qiu | be12882 | 2015-10-13 13:55:03 -0700 | [diff] [blame] | 37 | void Init(ControlInterface* control_interface); |
Peter Qiu | c9ce1f1 | 2014-12-05 11:14:29 -0800 | [diff] [blame] | 38 | |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 39 | // Claim the given interface |interface_name| from shill. |
| 40 | virtual void ClaimInterface(const std::string& interface_name); |
| 41 | // Release the given interface |interface_name| to shill. |
| 42 | virtual void ReleaseInterface(const std::string& interface_name); |
Peter Qiu | c7717b6 | 2015-10-22 15:21:27 -0700 | [diff] [blame] | 43 | #if defined(__BRILLO__) |
| 44 | // Setup an AP mode interface. |
| 45 | virtual bool SetupApModeInterface(std::string* interface_name); |
| 46 | // Setup a station mode interface. |
| 47 | virtual bool SetupStationModeInterface(std::string* interface_name); |
| 48 | #endif // __BRILLO__ |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 49 | |
| 50 | private: |
Peter Qiu | 37328b8 | 2015-09-18 09:28:18 -0700 | [diff] [blame] | 51 | void OnShillServiceAppeared(); |
| 52 | void OnShillServiceVanished(); |
Peter Qiu | 267fff3 | 2014-12-10 14:01:58 -0800 | [diff] [blame] | 53 | |
Peter Qiu | 37328b8 | 2015-09-18 09:28:18 -0700 | [diff] [blame] | 54 | std::unique_ptr<ShillProxyInterface> shill_proxy_; |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 55 | // List of interfaces apmanager have claimed. |
| 56 | std::set<std::string> claimed_interfaces_; |
| 57 | |
Peter Qiu | 37328b8 | 2015-09-18 09:28:18 -0700 | [diff] [blame] | 58 | base::WeakPtrFactory<ShillManager> weak_factory_{this}; |
Peter Qiu | 2a6fb33 | 2015-09-17 22:19:17 -0700 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(ShillManager); |
Peter Qiu | 7e0ffcf | 2014-12-02 12:53:27 -0800 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | } // namespace apmanager |
| 63 | |
Peter Qiu | 2a6fb33 | 2015-09-17 22:19:17 -0700 | [diff] [blame] | 64 | #endif // APMANAGER_SHILL_MANAGER_H_ |