Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 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_DEVICE_INFO_ |
| 6 | #define SHILL_DEVICE_INFO_ |
| 7 | |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 8 | #include <base/callback_old.h> |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 9 | #include <base/hash_tables.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 10 | #include <base/memory/ref_counted.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 11 | #include <base/memory/scoped_ptr.h> |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 12 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 13 | #include "shill/device.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 14 | |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 15 | #include "shill/rtnl_listener.h" |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 16 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 17 | struct nlmsghdr; |
| 18 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 19 | namespace shill { |
| 20 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 21 | class Manager; |
| 22 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 23 | class DeviceInfo { |
| 24 | public: |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 25 | DeviceInfo(ControlInterface *control_interface, |
| 26 | EventDispatcher *dispatcher, |
| 27 | Manager *manager); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 28 | ~DeviceInfo(); |
| 29 | void Start(); |
| 30 | void Stop(); |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 31 | static DeviceInfo *GetInstance(); |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 32 | static Device::Technology GetDeviceTechnology(const char *interface_name); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 33 | |
| 34 | private: |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 35 | static const char *kInterfaceUevent; |
| 36 | static const char *kInterfaceDriver; |
| 37 | static const char *kModemDrivers[]; |
| 38 | |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 39 | void AddLinkMsgHandler(struct nlmsghdr *hdr); |
| 40 | void DelLinkMsgHandler(struct nlmsghdr *hdr); |
| 41 | void LinkMsgHandler(struct nlmsghdr *hdr); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 42 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 43 | ControlInterface *control_interface_; |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 44 | EventDispatcher *dispatcher_; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 45 | Manager *manager_; |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 46 | base::hash_map<int, DeviceRefPtr> devices_; |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 47 | scoped_ptr<Callback1<struct nlmsghdr *>::Type> link_callback_; |
| 48 | scoped_ptr<RTNLListener> link_listener_; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 49 | friend class DeviceInfoTest; |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 52 | } // namespace shill |
| 53 | |
| 54 | #endif // SHILL_DEVICE_INFO_ |