blob: 403400a04d54eb2c08d06e87165da82958db4656 [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 Masone9be4a9d2011-05-16 15:44:09 -070014#include "shill/service.h"
Paul Stewart75897df2011-04-27 09:05:53 -070015#include "shill/shill_event.h"
16
17namespace shill {
18
Chris Masone9be4a9d2011-05-16 15:44:09 -070019class ControlInterface;
20class DeviceAdaptorInterface;
21class EventDispatcher;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070022class Endpoint;
23class DeviceInfo;
24class Manager;
Chris Masone9be4a9d2011-05-16 15:44:09 -070025
Paul Stewart75897df2011-04-27 09:05:53 -070026// Device superclass. Individual network interfaces types will inherit from
27// this class.
Paul Stewartd5843772011-05-11 15:40:42 -070028class Device : public base::RefCounted<Device> {
Paul Stewart75897df2011-04-27 09:05:53 -070029 public:
Chris Masone9be4a9d2011-05-16 15:44:09 -070030 enum Technology {
31 kEthernet,
32 kWifi,
33 kCellular,
Paul Stewartb50f0b92011-05-16 16:31:42 -070034 kBlackListed,
35 kUnknown,
Chris Masone9be4a9d2011-05-16 15:44:09 -070036 kNumTechnologies
37 };
Chris Masone0e1d1042011-05-09 18:07:03 -070038
Chris Masone9be4a9d2011-05-16 15:44:09 -070039 // A constructor for the Device object
40 Device(ControlInterface *control_interface,
Paul Stewartb50f0b92011-05-16 16:31:42 -070041 EventDispatcher *dispatcher,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070042 Manager *manager,
Chris Masone46eaaf52011-05-24 13:08:30 -070043 const std::string& link_name,
Paul Stewartb50f0b92011-05-16 16:31:42 -070044 int interface_index);
Chris Masone9be4a9d2011-05-16 15:44:09 -070045 virtual ~Device();
Darin Petkove02b3ca2011-05-31 16:00:44 -070046 const std::string& Name() const;
Chris Masone9be4a9d2011-05-16 15:44:09 -070047
48 virtual void Start();
49 virtual void Stop();
50
Paul Stewartb50f0b92011-05-16 16:31:42 -070051 virtual bool TechnologyIs(const Technology type) = 0;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070052 virtual void LinkEvent(unsigned flags, unsigned change);
53 virtual void Scan();
Paul Stewart75897df2011-04-27 09:05:53 -070054
Paul Stewartd5843772011-05-11 15:40:42 -070055 protected:
Chris Masone9be4a9d2011-05-16 15:44:09 -070056 std::vector<scoped_refptr<Service> > services_;
Chris Masone46eaaf52011-05-24 13:08:30 -070057 std::string link_name_;
Paul Stewartb50f0b92011-05-16 16:31:42 -070058 int interface_index_;
59 bool running_;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070060 Manager *manager_;
Paul Stewartd5843772011-05-11 15:40:42 -070061
Paul Stewart75897df2011-04-27 09:05:53 -070062 private:
Paul Stewartb50f0b92011-05-16 16:31:42 -070063 scoped_ptr<DeviceAdaptorInterface> adaptor_;
64 friend class base::RefCounted<Device>;
Chris Masone413a3192011-05-09 17:10:05 -070065 friend class DeviceAdaptorInterface;
Chris Masone9be4a9d2011-05-16 15:44:09 -070066 DISALLOW_COPY_AND_ASSIGN(Device);
Paul Stewart75897df2011-04-27 09:05:53 -070067};
68
Paul Stewart75897df2011-04-27 09:05:53 -070069} // namespace shill
70
71#endif // SHILL_DEVICE_