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