blob: d28a3980aa4de43d6c6d6fdb2c5b1e7725889ae1 [file] [log] [blame]
Paul Stewart0af98bf2011-05-10 17:38:08 -07001// 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 Masone487b8bf2011-05-13 16:27:57 -07008#include <base/callback_old.h>
Paul Stewart0af98bf2011-05-10 17:38:08 -07009#include <base/hash_tables.h>
Paul Stewartb50f0b92011-05-16 16:31:42 -070010#include <base/memory/ref_counted.h>
Chris Masone487b8bf2011-05-13 16:27:57 -070011#include <base/memory/scoped_ptr.h>
Paul Stewart0af98bf2011-05-10 17:38:08 -070012
Chris Masone9be4a9d2011-05-16 15:44:09 -070013#include "shill/device.h"
Paul Stewartb50f0b92011-05-16 16:31:42 -070014
Paul Stewarta3c56f92011-05-26 07:08:52 -070015#include "shill/rtnl_listener.h"
Paul Stewart0af98bf2011-05-10 17:38:08 -070016
Paul Stewartb50f0b92011-05-16 16:31:42 -070017struct nlmsghdr;
18
Paul Stewart0af98bf2011-05-10 17:38:08 -070019namespace shill {
20
Paul Stewartb50f0b92011-05-16 16:31:42 -070021class Manager;
22
Paul Stewart0af98bf2011-05-10 17:38:08 -070023class DeviceInfo {
24 public:
Paul Stewartb50f0b92011-05-16 16:31:42 -070025 DeviceInfo(ControlInterface *control_interface,
26 EventDispatcher *dispatcher,
27 Manager *manager);
Paul Stewart0af98bf2011-05-10 17:38:08 -070028 ~DeviceInfo();
29 void Start();
30 void Stop();
Paul Stewarta3c56f92011-05-26 07:08:52 -070031 static DeviceInfo *GetInstance();
Paul Stewartb50f0b92011-05-16 16:31:42 -070032 static Device::Technology GetDeviceTechnology(const char *interface_name);
Paul Stewart0af98bf2011-05-10 17:38:08 -070033
34 private:
Paul Stewartb50f0b92011-05-16 16:31:42 -070035 static const char *kInterfaceUevent;
36 static const char *kInterfaceDriver;
37 static const char *kModemDrivers[];
38
Paul Stewarta3c56f92011-05-26 07:08:52 -070039 void AddLinkMsgHandler(struct nlmsghdr *hdr);
40 void DelLinkMsgHandler(struct nlmsghdr *hdr);
41 void LinkMsgHandler(struct nlmsghdr *hdr);
Paul Stewart0af98bf2011-05-10 17:38:08 -070042
Paul Stewartb50f0b92011-05-16 16:31:42 -070043 ControlInterface *control_interface_;
Paul Stewart0af98bf2011-05-10 17:38:08 -070044 EventDispatcher *dispatcher_;
Paul Stewartb50f0b92011-05-16 16:31:42 -070045 Manager *manager_;
Chris Masonec1e50412011-06-07 13:04:53 -070046 base::hash_map<int, DeviceRefPtr> devices_;
Paul Stewarta3c56f92011-05-26 07:08:52 -070047 scoped_ptr<Callback1<struct nlmsghdr *>::Type> link_callback_;
48 scoped_ptr<RTNLListener> link_listener_;
Chris Masone9be4a9d2011-05-16 15:44:09 -070049 friend class DeviceInfoTest;
Paul Stewart0af98bf2011-05-10 17:38:08 -070050};
51
Paul Stewart0af98bf2011-05-10 17:38:08 -070052} // namespace shill
53
54#endif // SHILL_DEVICE_INFO_