blob: e8105b605fdf6f0071fdb5c40f55d89809f912e3 [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -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_
6#define SHILL_DEVICE_
7
Chris Masone46eaaf52011-05-24 13:08:30 -07008#include <string>
Chris Masone9be4a9d2011-05-16 15:44:09 -07009#include <vector>
10
Chris Masone487b8bf2011-05-13 16:27:57 -070011#include <base/memory/ref_counted.h>
Paul Stewartb50f0b92011-05-16 16:31:42 -070012#include <base/memory/scoped_ptr.h>
Paul Stewartd5843772011-05-11 15:40:42 -070013
Chris Masonec1e50412011-06-07 13:04:53 -070014#include "shill/device_config_interface.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070015#include "shill/service.h"
Paul Stewart75897df2011-04-27 09:05:53 -070016#include "shill/shill_event.h"
17
18namespace shill {
19
Chris Masone9be4a9d2011-05-16 15:44:09 -070020class ControlInterface;
Chris Masonec1e50412011-06-07 13:04:53 -070021class Device;
Chris Masone9be4a9d2011-05-16 15:44:09 -070022class DeviceAdaptorInterface;
Chris Masonec1e50412011-06-07 13:04:53 -070023class DeviceInfo;
Chris Masone9be4a9d2011-05-16 15:44:09 -070024class EventDispatcher;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070025class Endpoint;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070026class Manager;
Chris Masone9be4a9d2011-05-16 15:44:09 -070027
Chris Masonec1e50412011-06-07 13:04:53 -070028typedef scoped_refptr<const Device> DeviceConstRefPtr;
29typedef scoped_refptr<Device> DeviceRefPtr;
30
Paul Stewart75897df2011-04-27 09:05:53 -070031// Device superclass. Individual network interfaces types will inherit from
32// this class.
Chris Masonec1e50412011-06-07 13:04:53 -070033class Device : public DeviceConfigInterface {
Paul Stewart75897df2011-04-27 09:05:53 -070034 public:
Chris Masone9be4a9d2011-05-16 15:44:09 -070035 enum Technology {
36 kEthernet,
37 kWifi,
38 kCellular,
Paul Stewartb50f0b92011-05-16 16:31:42 -070039 kBlackListed,
40 kUnknown,
Chris Masone9be4a9d2011-05-16 15:44:09 -070041 kNumTechnologies
42 };
Chris Masone0e1d1042011-05-09 18:07:03 -070043
Chris Masone9be4a9d2011-05-16 15:44:09 -070044 // A constructor for the Device object
45 Device(ControlInterface *control_interface,
Paul Stewartb50f0b92011-05-16 16:31:42 -070046 EventDispatcher *dispatcher,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070047 Manager *manager,
Chris Masone46eaaf52011-05-24 13:08:30 -070048 const std::string& link_name,
Paul Stewartb50f0b92011-05-16 16:31:42 -070049 int interface_index);
Chris Masone9be4a9d2011-05-16 15:44:09 -070050 virtual ~Device();
51
52 virtual void Start();
53 virtual void Stop();
54
Paul Stewartb50f0b92011-05-16 16:31:42 -070055 virtual bool TechnologyIs(const Technology type) = 0;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070056 virtual void LinkEvent(unsigned flags, unsigned change);
57 virtual void Scan();
Paul Stewart75897df2011-04-27 09:05:53 -070058
Chris Masonec1e50412011-06-07 13:04:53 -070059 // Implementation of DeviceConfigInterface
60 virtual void ConfigIP() {}
61
Chris Masonea82b7112011-05-25 15:16:29 -070062 // Returns a string that is guaranteed to uniquely identify this
63 // Device instance.
64 const std::string& UniqueName() const;
65
Paul Stewartd5843772011-05-11 15:40:42 -070066 protected:
Chris Masonec1e50412011-06-07 13:04:53 -070067 std::vector<ServiceRefPtr> services_;
Chris Masone46eaaf52011-05-24 13:08:30 -070068 std::string link_name_;
Paul Stewartb50f0b92011-05-16 16:31:42 -070069 int interface_index_;
70 bool running_;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070071 Manager *manager_;
Paul Stewartd5843772011-05-11 15:40:42 -070072
Paul Stewart75897df2011-04-27 09:05:53 -070073 private:
Paul Stewartb50f0b92011-05-16 16:31:42 -070074 scoped_ptr<DeviceAdaptorInterface> adaptor_;
Chris Masone413a3192011-05-09 17:10:05 -070075 friend class DeviceAdaptorInterface;
Chris Masone9be4a9d2011-05-16 15:44:09 -070076 DISALLOW_COPY_AND_ASSIGN(Device);
Paul Stewart75897df2011-04-27 09:05:53 -070077};
78
Paul Stewart75897df2011-04-27 09:05:53 -070079} // namespace shill
80
81#endif // SHILL_DEVICE_