Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1 | // 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 Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 8 | #include <string> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 11 | #include <base/memory/ref_counted.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 12 | #include <base/memory/scoped_ptr.h> |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 13 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 14 | #include "shill/device_config_interface.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 15 | #include "shill/service.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 16 | #include "shill/shill_event.h" |
| 17 | |
| 18 | namespace shill { |
| 19 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 20 | class ControlInterface; |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 21 | class Device; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 22 | class DeviceAdaptorInterface; |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 23 | class DeviceInfo; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 24 | class EventDispatcher; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 25 | class Endpoint; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 26 | class Manager; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 27 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 28 | typedef scoped_refptr<const Device> DeviceConstRefPtr; |
| 29 | typedef scoped_refptr<Device> DeviceRefPtr; |
| 30 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 31 | // Device superclass. Individual network interfaces types will inherit from |
| 32 | // this class. |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 33 | class Device : public DeviceConfigInterface { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 34 | public: |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 35 | enum Technology { |
| 36 | kEthernet, |
| 37 | kWifi, |
| 38 | kCellular, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 39 | kBlackListed, |
| 40 | kUnknown, |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 41 | kNumTechnologies |
| 42 | }; |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 43 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 44 | // A constructor for the Device object |
| 45 | Device(ControlInterface *control_interface, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 46 | EventDispatcher *dispatcher, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 47 | Manager *manager, |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 48 | const std::string& link_name, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 49 | int interface_index); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 50 | virtual ~Device(); |
| 51 | |
| 52 | virtual void Start(); |
| 53 | virtual void Stop(); |
| 54 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 55 | virtual bool TechnologyIs(const Technology type) = 0; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 56 | virtual void LinkEvent(unsigned flags, unsigned change); |
| 57 | virtual void Scan(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 58 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 59 | // Implementation of DeviceConfigInterface |
| 60 | virtual void ConfigIP() {} |
| 61 | |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 62 | // Returns a string that is guaranteed to uniquely identify this |
| 63 | // Device instance. |
| 64 | const std::string& UniqueName() const; |
| 65 | |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 66 | protected: |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 67 | std::vector<ServiceRefPtr> services_; |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 68 | std::string link_name_; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 69 | int interface_index_; |
| 70 | bool running_; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 71 | Manager *manager_; |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 72 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 73 | private: |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 74 | scoped_ptr<DeviceAdaptorInterface> adaptor_; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 75 | friend class DeviceAdaptorInterface; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 76 | DISALLOW_COPY_AND_ASSIGN(Device); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 79 | } // namespace shill |
| 80 | |
| 81 | #endif // SHILL_DEVICE_ |