blob: e258517d043aa5571ef445f478c2213e9db88a0e [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 Masone8fe2c7e2011-06-09 15:51:19 -070011#include <base/basictypes.h>
Chris Masone487b8bf2011-05-13 16:27:57 -070012#include <base/memory/ref_counted.h>
Paul Stewartb50f0b92011-05-16 16:31:42 -070013#include <base/memory/scoped_ptr.h>
Paul Stewartd5843772011-05-11 15:40:42 -070014
Chris Masonec1e50412011-06-07 13:04:53 -070015#include "shill/device_config_interface.h"
Chris Masone8fe2c7e2011-06-09 15:51:19 -070016#include "shill/property_store_interface.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070017#include "shill/service.h"
Paul Stewart75897df2011-04-27 09:05:53 -070018#include "shill/shill_event.h"
19
20namespace shill {
21
Chris Masone9be4a9d2011-05-16 15:44:09 -070022class ControlInterface;
Chris Masonec1e50412011-06-07 13:04:53 -070023class Device;
Chris Masone9be4a9d2011-05-16 15:44:09 -070024class DeviceAdaptorInterface;
Chris Masonec1e50412011-06-07 13:04:53 -070025class DeviceInfo;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070026class Endpoint;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070027class Error;
28class EventDispatcher;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070029class Manager;
Chris Masone9be4a9d2011-05-16 15:44:09 -070030
Chris Masonec1e50412011-06-07 13:04:53 -070031typedef scoped_refptr<const Device> DeviceConstRefPtr;
32typedef scoped_refptr<Device> DeviceRefPtr;
33
Paul Stewart75897df2011-04-27 09:05:53 -070034// Device superclass. Individual network interfaces types will inherit from
35// this class.
Chris Masone8fe2c7e2011-06-09 15:51:19 -070036class Device : public DeviceConfigInterface, public PropertyStoreInterface {
Paul Stewart75897df2011-04-27 09:05:53 -070037 public:
Chris Masone9be4a9d2011-05-16 15:44:09 -070038 enum Technology {
39 kEthernet,
40 kWifi,
41 kCellular,
Paul Stewartb50f0b92011-05-16 16:31:42 -070042 kBlackListed,
43 kUnknown,
Chris Masone9be4a9d2011-05-16 15:44:09 -070044 kNumTechnologies
45 };
Chris Masone0e1d1042011-05-09 18:07:03 -070046
Chris Masone9be4a9d2011-05-16 15:44:09 -070047 // A constructor for the Device object
48 Device(ControlInterface *control_interface,
Paul Stewartb50f0b92011-05-16 16:31:42 -070049 EventDispatcher *dispatcher,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070050 Manager *manager,
Chris Masone46eaaf52011-05-24 13:08:30 -070051 const std::string& link_name,
Paul Stewartb50f0b92011-05-16 16:31:42 -070052 int interface_index);
Chris Masone9be4a9d2011-05-16 15:44:09 -070053 virtual ~Device();
54
55 virtual void Start();
56 virtual void Stop();
57
Paul Stewartb50f0b92011-05-16 16:31:42 -070058 virtual bool TechnologyIs(const Technology type) = 0;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070059 virtual void LinkEvent(unsigned flags, unsigned change);
60 virtual void Scan();
Paul Stewart75897df2011-04-27 09:05:53 -070061
Chris Masonec1e50412011-06-07 13:04:53 -070062 // Implementation of DeviceConfigInterface
63 virtual void ConfigIP() {}
64
Chris Masone8fe2c7e2011-06-09 15:51:19 -070065 // Implementation of PropertyStoreInterface
66 bool SetBoolProperty(const std::string& name, bool value, Error *error);
67 bool SetInt16Property(const std::string& name, int16 value, Error *error);
68 bool SetInt32Property(const std::string& name, int32 value, Error *error);
69 bool SetStringProperty(const std::string& name,
70 const std::string& value,
71 Error *error);
72 bool SetUint16Property(const std::string& name, uint16 value, Error *error);
73 bool SetUint32Property(const std::string& name, uint32 value, Error *error);
74
Chris Masonea82b7112011-05-25 15:16:29 -070075 // Returns a string that is guaranteed to uniquely identify this
76 // Device instance.
77 const std::string& UniqueName() const;
78
Paul Stewartd5843772011-05-11 15:40:42 -070079 protected:
Chris Masonec1e50412011-06-07 13:04:53 -070080 std::vector<ServiceRefPtr> services_;
Chris Masone46eaaf52011-05-24 13:08:30 -070081 std::string link_name_;
Paul Stewartb50f0b92011-05-16 16:31:42 -070082 int interface_index_;
83 bool running_;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070084 Manager *manager_;
Paul Stewartd5843772011-05-11 15:40:42 -070085
Paul Stewart75897df2011-04-27 09:05:53 -070086 private:
Paul Stewartb50f0b92011-05-16 16:31:42 -070087 scoped_ptr<DeviceAdaptorInterface> adaptor_;
Chris Masone413a3192011-05-09 17:10:05 -070088 friend class DeviceAdaptorInterface;
Chris Masone9be4a9d2011-05-16 15:44:09 -070089 DISALLOW_COPY_AND_ASSIGN(Device);
Paul Stewart75897df2011-04-27 09:05:53 -070090};
91
Paul Stewart75897df2011-04-27 09:05:53 -070092} // namespace shill
93
94#endif // SHILL_DEVICE_