Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 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_DEVICE_INFO_ |
| 6 | #define SHILL_DEVICE_INFO_ |
| 7 | |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 8 | #include <map> |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 9 | #include <set> |
| 10 | #include <string> |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 11 | #include <vector> |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 12 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 13 | #include <base/callback.h> |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 14 | #include <base/cancelable_callback.h> |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 15 | #include <base/file_path.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 16 | #include <base/memory/ref_counted.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 17 | #include <base/memory/scoped_ptr.h> |
Darin Petkov | 5a85047 | 2012-06-06 15:44:24 +0200 | [diff] [blame] | 18 | #include <base/memory/weak_ptr.h> |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 19 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 20 | |
Darin Petkov | e3e1cfa | 2011-08-11 13:41:17 -0700 | [diff] [blame] | 21 | #include "shill/byte_string.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 22 | #include "shill/device.h" |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 23 | #include "shill/ip_address.h" |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 24 | #include "shill/rtnl_listener.h" |
Paul Stewart | cba0f7f | 2012-02-29 16:33:05 -0800 | [diff] [blame] | 25 | #include "shill/technology.h" |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 26 | |
| 27 | namespace shill { |
| 28 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 29 | class Manager; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 30 | class Metrics; |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 31 | class NetlinkManager; |
Wade Guthrie | 7347bf2 | 2013-04-30 11:21:51 -0700 | [diff] [blame] | 32 | class Nl80211Message; |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 33 | class RoutingTable; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 34 | class RTNLHandler; |
Chris Masone | 2aa9707 | 2011-08-09 17:35:08 -0700 | [diff] [blame] | 35 | class RTNLMessage; |
Gary Morain | 4178023 | 2012-07-31 15:08:31 -0700 | [diff] [blame] | 36 | class Sockets; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 37 | |
Darin Petkov | 5a85047 | 2012-06-06 15:44:24 +0200 | [diff] [blame] | 38 | class DeviceInfo : public base::SupportsWeakPtr<DeviceInfo> { |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 39 | public: |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 40 | struct AddressData { |
| 41 | AddressData() |
Paul Stewart | 7355ce1 | 2011-09-02 10:47:01 -0700 | [diff] [blame] | 42 | : address(IPAddress::kFamilyUnknown), flags(0), scope(0) {} |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 43 | AddressData(const IPAddress &address_in, |
| 44 | unsigned char flags_in, |
| 45 | unsigned char scope_in) |
| 46 | : address(address_in), flags(flags_in), scope(scope_in) {} |
| 47 | IPAddress address; |
| 48 | unsigned char flags; |
| 49 | unsigned char scope; |
| 50 | }; |
| 51 | |
Jason Glasgow | abc5403 | 2012-04-20 16:08:32 -0400 | [diff] [blame] | 52 | // Device name prefix for modem pseudo devices used in testing. |
| 53 | static const char kModemPseudoDeviceNamePrefix[]; |
Christopher Wiley | e049cc5 | 2012-09-10 14:36:57 -0700 | [diff] [blame] | 54 | // Device name prefix for virtual ethernet devices used in testing. |
| 55 | static const char kEthernetPseudoDeviceNamePrefix[]; |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 56 | // Time interval for polling for link statistics. |
| 57 | static const int kRequestLinkStatisticsIntervalMilliseconds; |
Jason Glasgow | abc5403 | 2012-04-20 16:08:32 -0400 | [diff] [blame] | 58 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 59 | DeviceInfo(ControlInterface *control_interface, |
| 60 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 61 | Metrics *metrics, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 62 | Manager *manager); |
Darin Petkov | 5a85047 | 2012-06-06 15:44:24 +0200 | [diff] [blame] | 63 | virtual ~DeviceInfo(); |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 64 | |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 65 | void AddDeviceToBlackList(const std::string &device_name); |
Eric Shienbrood | 5e628a5 | 2012-03-21 16:56:59 -0400 | [diff] [blame] | 66 | bool IsDeviceBlackListed(const std::string &device_name); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 67 | void Start(); |
| 68 | void Stop(); |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 69 | |
Ben Chan | 5086b97 | 2013-01-15 21:51:38 -0800 | [diff] [blame] | 70 | std::vector<std::string> GetUninitializedTechnologies() const; |
| 71 | |
Darin Petkov | 6f9eaa3 | 2011-08-09 15:26:44 -0700 | [diff] [blame] | 72 | // Adds |device| to this DeviceInfo instance so that we can handle its link |
| 73 | // messages, and registers it with the manager. |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 74 | virtual void RegisterDevice(const DeviceRefPtr &device); |
Darin Petkov | 6f9eaa3 | 2011-08-09 15:26:44 -0700 | [diff] [blame] | 75 | |
Jason Glasgow | e908949 | 2012-02-23 17:57:37 -0500 | [diff] [blame] | 76 | // Remove |device| from this DeviceInfo. This function should only |
| 77 | // be called for cellular devices because the lifetime of the |
| 78 | // cellular devices is controlled by the Modem object and its |
| 79 | // communication to modem manager, rather than by RTNL messages. |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 80 | virtual void DeregisterDevice(const DeviceRefPtr &device); |
Jason Glasgow | e908949 | 2012-02-23 17:57:37 -0500 | [diff] [blame] | 81 | |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 82 | virtual DeviceRefPtr GetDevice(int interface_index) const; |
Paul Stewart | 3285296 | 2011-08-30 14:06:53 -0700 | [diff] [blame] | 83 | virtual bool GetMACAddress(int interface_index, ByteString *address) const; |
Gary Morain | bf74a67 | 2012-07-30 16:27:19 -0700 | [diff] [blame] | 84 | |
| 85 | // Queries the kernel for a MAC address for |interface_index|. Returns an |
| 86 | // empty ByteString on failure. |
| 87 | virtual ByteString GetMACAddressFromKernel(int interface_index) const; |
Gary Morain | 4178023 | 2012-07-31 15:08:31 -0700 | [diff] [blame] | 88 | |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 89 | virtual bool GetFlags(int interface_index, unsigned int *flags) const; |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 90 | virtual bool GetByteCounts(int interface_index, |
| 91 | uint64 *rx_bytes, uint64 *tx_bytes) const; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 92 | virtual bool GetAddresses(int interface_index, |
| 93 | std::vector<AddressData> *addresses) const; |
Paul Stewart | 05a42c2 | 2012-08-02 16:47:21 -0700 | [diff] [blame] | 94 | // Flush all addresses associated with |interface_index|. |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 95 | virtual void FlushAddresses(int interface_index) const; |
Paul Stewart | 05a42c2 | 2012-08-02 16:47:21 -0700 | [diff] [blame] | 96 | // Returns whether this interface does not have |this_address| |
| 97 | // but has another non-temporary address of the same family. |
| 98 | virtual bool HasOtherAddress( |
| 99 | int interface_index, const IPAddress &this_address) const; |
Paul Stewart | ca6abd4 | 2012-03-01 15:45:29 -0800 | [diff] [blame] | 100 | virtual bool CreateTunnelInterface(std::string *interface_name) const; |
| 101 | virtual bool DeleteInterface(int interface_index) const; |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 102 | |
Darin Petkov | f8046b8 | 2012-04-24 16:29:23 +0200 | [diff] [blame] | 103 | // Returns the interface index for |interface_name| or -1 if unknown. |
| 104 | virtual int GetIndex(const std::string &interface_name) const; |
| 105 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 106 | private: |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 107 | friend class DeviceInfoDelayedCreationTest; |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 108 | friend class DeviceInfoTechnologyTest; |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 109 | friend class DeviceInfoTest; |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 110 | FRIEND_TEST(CellularTest, StartLinked); |
Ben Chan | 4b28586 | 2012-10-10 22:52:16 -0700 | [diff] [blame] | 111 | FRIEND_TEST(DeviceInfoTest, CreateDeviceWiMax); |
Ben Chan | 5086b97 | 2013-01-15 21:51:38 -0800 | [diff] [blame] | 112 | FRIEND_TEST(DeviceInfoTest, GetUninitializedTechnologies); |
Thieu Le | b27beee | 2012-04-20 09:19:06 -0700 | [diff] [blame] | 113 | FRIEND_TEST(DeviceInfoTest, HasSubdir); // For HasSubdir. |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 114 | FRIEND_TEST(DeviceInfoTest, RequestLinkStatistics); |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 115 | FRIEND_TEST(DeviceInfoTest, StartStop); |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 116 | |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 117 | struct Info { |
Ben Chan | 5086b97 | 2013-01-15 21:51:38 -0800 | [diff] [blame] | 118 | Info() |
| 119 | : flags(0), |
| 120 | rx_bytes(0), |
| 121 | tx_bytes(0), |
| 122 | has_addresses_only(false), |
| 123 | technology(Technology::kUnknown) |
| 124 | {} |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 125 | |
| 126 | DeviceRefPtr device; |
Darin Petkov | f8046b8 | 2012-04-24 16:29:23 +0200 | [diff] [blame] | 127 | std::string name; |
Paul Stewart | 3285296 | 2011-08-30 14:06:53 -0700 | [diff] [blame] | 128 | ByteString mac_address; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 129 | std::vector<AddressData> ip_addresses; |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 130 | unsigned int flags; |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 131 | uint64 rx_bytes; |
| 132 | uint64 tx_bytes; |
| 133 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 134 | // This flag indicates that link information has not been retrieved yet; |
| 135 | // only the ip_addresses field is valid. |
| 136 | bool has_addresses_only; |
Ben Chan | 5086b97 | 2013-01-15 21:51:38 -0800 | [diff] [blame] | 137 | |
| 138 | Technology::Identifier technology; |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 141 | // Root of the kernel sysfs directory holding network device info. |
| 142 | static const char kDeviceInfoRoot[]; |
Ben Chan | 4e64d2d | 2012-05-16 00:02:25 -0700 | [diff] [blame] | 143 | // Name of the "cdc_ether" driver. This driver is not included in the |
| 144 | // kModemDrivers list because we need to do additional checking. |
| 145 | static const char kDriverCdcEther[]; |
| 146 | // Name of the GDM WiMAX driver. |
| 147 | static const char kDriverGdmWiMax[]; |
mukesh agrawal | 93a29ed | 2012-04-17 16:13:01 -0700 | [diff] [blame] | 148 | // Name of the virtio network driver. |
| 149 | static const char kDriverVirtioNet[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 150 | // Sysfs path to a device uevent file. |
Paul Stewart | bf1861b | 2011-08-23 15:45:35 -0700 | [diff] [blame] | 151 | static const char kInterfaceUevent[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 152 | // Content of a device uevent file that indicates it is a wifi device. |
Paul Stewart | 9364c4c | 2011-12-06 17:12:42 -0800 | [diff] [blame] | 153 | static const char kInterfaceUeventWifiSignature[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 154 | // Sysfs path to a device via its interface name. |
| 155 | static const char kInterfaceDevice[]; |
| 156 | // Sysfs path to the driver of a device via its interface name. |
Paul Stewart | bf1861b | 2011-08-23 15:45:35 -0700 | [diff] [blame] | 157 | static const char kInterfaceDriver[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 158 | // Sysfs path to the file that is used to determine if this is tun device. |
Paul Stewart | cba0f7f | 2012-02-29 16:33:05 -0800 | [diff] [blame] | 159 | static const char kInterfaceTunFlags[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 160 | // Sysfs path to the file that is used to determine if a wifi device is |
| 161 | // operating in monitor mode. |
Paul Stewart | 2001a42 | 2011-12-15 10:20:09 -0800 | [diff] [blame] | 162 | static const char kInterfaceType[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 163 | // Modem drivers that we support. |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 164 | static const char *kModemDrivers[]; |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 165 | // Path to the tun device. |
Paul Stewart | cba0f7f | 2012-02-29 16:33:05 -0800 | [diff] [blame] | 166 | static const char kTunDeviceName[]; |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 167 | // Time to wait before registering devices which need extra time to detect. |
| 168 | static const int kDelayedDeviceCreationSeconds; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 169 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 170 | // Create a Device object for the interface named |linkname|, with a |
| 171 | // string-form MAC address |address|, whose kernel interface index |
| 172 | // is |interface_index| and detected technology is |technology|. |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 173 | virtual DeviceRefPtr CreateDevice(const std::string &link_name, |
| 174 | const std::string &address, |
| 175 | int interface_index, |
| 176 | Technology::Identifier technology); |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 177 | |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 178 | // Return the FilePath for a given |path_name| in the device sysinfo for |
| 179 | // a specific interface |iface_name|. |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 180 | base::FilePath GetDeviceInfoPath(const std::string &iface_name, |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 181 | const std::string &path_name); |
| 182 | // Return the contents of the device info file |path_name| for interface |
| 183 | // |iface_name| in output parameter |contents_out|. Returns true if file |
| 184 | // read succeeded, false otherwise. |
| 185 | bool GetDeviceInfoContents(const std::string &iface_name, |
| 186 | const std::string &path_name, |
| 187 | std::string *contents_out); |
| 188 | |
| 189 | // Return the filepath for the target of the device info symbolic link |
| 190 | // |path_name| for interface |iface_name| in output parameter |path_out|. |
| 191 | // Returns true if symbolic link read succeeded, false otherwise. |
| 192 | bool GetDeviceInfoSymbolicLink(const std::string &iface_name, |
| 193 | const std::string &path_name, |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 194 | base::FilePath *path_out); |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 195 | // Classify the device named |iface_name|, and return an identifier |
| 196 | // indicating its type. |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 197 | virtual Technology::Identifier GetDeviceTechnology( |
| 198 | const std::string &iface_name); |
Thieu Le | 8f1c835 | 2012-04-16 11:02:12 -0700 | [diff] [blame] | 199 | // Checks the device specified by |iface_name| to see if it's a modem device. |
| 200 | // This method assumes that |iface_name| has already been determined to be |
| 201 | // using the cdc_ether driver. |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 202 | bool IsCdcEtherModemDevice(const std::string &iface_name); |
Thieu Le | b27beee | 2012-04-20 09:19:06 -0700 | [diff] [blame] | 203 | // Returns true if |base_dir| has a subdirectory named |subdir|. |
| 204 | // |subdir| can be an immediate subdirectory of |base_dir| or can be |
| 205 | // several levels deep. |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 206 | static bool HasSubdir(const base::FilePath &base_dir, |
| 207 | const base::FilePath &subdir); |
Darin Petkov | 6f9eaa3 | 2011-08-09 15:26:44 -0700 | [diff] [blame] | 208 | |
Chris Masone | 2aa9707 | 2011-08-09 17:35:08 -0700 | [diff] [blame] | 209 | void AddLinkMsgHandler(const RTNLMessage &msg); |
| 210 | void DelLinkMsgHandler(const RTNLMessage &msg); |
| 211 | void LinkMsgHandler(const RTNLMessage &msg); |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 212 | void AddressMsgHandler(const RTNLMessage &msg); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 213 | |
Darin Petkov | e3e1cfa | 2011-08-11 13:41:17 -0700 | [diff] [blame] | 214 | const Info *GetInfo(int interface_index) const; |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 215 | void RemoveInfo(int interface_index); |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 216 | void DelayDeviceCreation(int interface_index); |
| 217 | void DelayedDeviceCreationTask(); |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 218 | void RetrieveLinkStatistics(int interface_index, const RTNLMessage &msg); |
| 219 | void RequestLinkStatistics(); |
Darin Petkov | 67d8ecf | 2011-07-26 16:03:30 -0700 | [diff] [blame] | 220 | |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 221 | // Use nl80211 to get information on |interface_index|. |
| 222 | void GetWiFiInterfaceInfo(int interface_index); |
Wade Guthrie | 7347bf2 | 2013-04-30 11:21:51 -0700 | [diff] [blame] | 223 | void OnWiFiInterfaceInfoReceived(const Nl80211Message &message); |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 224 | |
Gary Morain | 4178023 | 2012-07-31 15:08:31 -0700 | [diff] [blame] | 225 | void set_sockets(Sockets* sockets) { sockets_.reset(sockets); } |
| 226 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 227 | ControlInterface *control_interface_; |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 228 | EventDispatcher *dispatcher_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 229 | Metrics *metrics_; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 230 | Manager *manager_; |
Darin Petkov | f8046b8 | 2012-04-24 16:29:23 +0200 | [diff] [blame] | 231 | |
| 232 | std::map<int, Info> infos_; // Maps interface index to Info. |
| 233 | std::map<std::string, int> indices_; // Maps interface name to index. |
| 234 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 235 | base::Callback<void(const RTNLMessage &)> link_callback_; |
| 236 | base::Callback<void(const RTNLMessage &)> address_callback_; |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 237 | scoped_ptr<RTNLListener> link_listener_; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 238 | scoped_ptr<RTNLListener> address_listener_; |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 239 | std::set<std::string> black_list_; |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 240 | base::FilePath device_info_root_; |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 241 | |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 242 | // Keep track of devices that require a delayed call to CreateDevice(). |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 243 | base::CancelableClosure delayed_devices_callback_; |
| 244 | std::set<int> delayed_devices_; |
| 245 | |
Paul Stewart | 1ac4e84 | 2012-07-10 12:58:12 -0700 | [diff] [blame] | 246 | // Maintain a callback for the periodic link statistics poll task. |
| 247 | base::CancelableClosure request_link_statistics_callback_; |
| 248 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 249 | // Cache copy of singleton pointers. |
| 250 | RoutingTable *routing_table_; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 251 | RTNLHandler *rtnl_handler_; |
Paul Stewart | 2ddf2c6 | 2013-04-16 09:47:34 -0700 | [diff] [blame] | 252 | NetlinkManager *netlink_manager_; |
Paul Stewart | 9a90808 | 2011-08-31 12:18:48 -0700 | [diff] [blame] | 253 | |
Gary Morain | 4178023 | 2012-07-31 15:08:31 -0700 | [diff] [blame] | 254 | // A member of the class so that a mock can be injected for testing. |
| 255 | scoped_ptr<Sockets> sockets_; |
| 256 | |
Darin Petkov | e6193c0 | 2011-08-11 12:42:40 -0700 | [diff] [blame] | 257 | DISALLOW_COPY_AND_ASSIGN(DeviceInfo); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 258 | }; |
| 259 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 260 | } // namespace shill |
| 261 | |
| 262 | #endif // SHILL_DEVICE_INFO_ |