blob: 8112eaae510902cb6d2615e7ce36f52262b31cb1 [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>
Chris Masone487b8bf2011-05-13 16:27:57 -070010#include <base/memory/scoped_ptr.h>
Paul Stewart0af98bf2011-05-10 17:38:08 -070011
Chris Masone9be4a9d2011-05-16 15:44:09 -070012#include "shill/device.h"
Paul Stewart0af98bf2011-05-10 17:38:08 -070013#include "shill/shill_event.h"
14
15namespace shill {
16
17class DeviceInfo {
18 public:
19 DeviceInfo(EventDispatcher *dispatcher);
20 ~DeviceInfo();
21 void Start();
22 void Stop();
23
24 private:
25 void ParseRTNL(InputData *data);
26 void NextRequest(uint32_t seq);
27 void LinkMsg(unsigned char *buf, bool del);
28 void AddrMsg(unsigned char *buf, bool del);
29 void RouteMsg(unsigned char *buf, bool del);
30
31 bool running_;
32 EventDispatcher *dispatcher_;
Chris Masone0e1d1042011-05-09 18:07:03 -070033 scoped_ptr<Callback1<InputData *>::Type> rtnl_callback_;
Paul Stewart0af98bf2011-05-10 17:38:08 -070034 int rtnl_socket_;
35 base::hash_map<int, Device *> devices_;
36 scoped_ptr<IOInputHandler> rtnl_handler_;
37 int request_flags_;
38 uint32_t request_sequence_;
Chris Masone9be4a9d2011-05-16 15:44:09 -070039 friend class DeviceInfoTest;
Paul Stewart0af98bf2011-05-10 17:38:08 -070040};
41
42enum {
43 REQUEST_LINK = 1,
44 REQUEST_ADDR = 2,
45 REQUEST_ROUTE = 4
46};
47
48} // namespace shill
49
50#endif // SHILL_DEVICE_INFO_