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 | #include <time.h> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 6 | #include <stdio.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 7 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 8 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 9 | #include <vector> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 10 | |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 11 | #include <base/logging.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 12 | #include <base/memory/ref_counted.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 13 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 14 | #include "shill/control_interface.h" |
| 15 | #include "shill/device.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 16 | #include "shill/device_dbus_adaptor.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 17 | #include "shill/error.h" |
| 18 | #include "shill/manager.h" |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 19 | #include "shill/shill_event.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 20 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 21 | using std::string; |
| 22 | using std::vector; |
| 23 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 24 | namespace shill { |
| 25 | Device::Device(ControlInterface *control_interface, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 26 | EventDispatcher *dispatcher, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 27 | Manager *manager, |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 28 | const string& link_name, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 29 | int interface_index) |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 30 | : link_name_(link_name), |
| 31 | manager_(manager), |
| 32 | adaptor_(control_interface->CreateDeviceAdaptor(this)), |
| 33 | interface_index_(interface_index), |
| 34 | running_(false) { |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 35 | // Initialize Interface monitor, so we can detect new interfaces |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 36 | VLOG(2) << "Device " << link_name_ << " index " << interface_index; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | Device::~Device() { |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 40 | VLOG(2) << "Device " << link_name_ << " destroyed."; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void Device::Start() { |
| 44 | running_ = true; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 45 | VLOG(2) << "Device " << link_name_ << " starting."; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 46 | adaptor_->UpdateEnabled(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void Device::Stop() { |
| 50 | running_ = false; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 51 | adaptor_->UpdateEnabled(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 54 | void Device::LinkEvent(unsigned flags, unsigned change) { |
| 55 | VLOG(2) << "Device " << link_name_ << " flags " << flags << " changed " |
| 56 | << change; |
| 57 | } |
| 58 | |
| 59 | void Device::Scan() { |
| 60 | VLOG(2) << "Device " << link_name_ << " scan requested."; |
| 61 | } |
| 62 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 63 | bool Device::SetBoolProperty(const string& name, bool value, Error *error) { |
| 64 | VLOG(2) << "Setting " << name << " as a bool."; |
| 65 | // TODO(cmasone): Set actual properties. |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | bool Device::SetInt16Property(const std::string& name, |
| 70 | int16 value, |
| 71 | Error *error) { |
| 72 | VLOG(2) << "Setting " << name << " as an int16."; |
| 73 | // TODO(cmasone): Set actual properties. |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | bool Device::SetInt32Property(const std::string& name, |
| 78 | int32 value, |
| 79 | Error *error) { |
| 80 | VLOG(2) << "Setting " << name << " as an int32."; |
| 81 | // TODO(cmasone): Set actual properties. |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | bool Device::SetStringProperty(const string& name, |
| 86 | const string& value, |
| 87 | Error *error) { |
| 88 | VLOG(2) << "Setting " << name << " as a string."; |
| 89 | // TODO(cmasone): Set actual properties. |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | bool Device::SetUint16Property(const std::string& name, |
| 94 | uint16 value, |
| 95 | Error *error) { |
| 96 | VLOG(2) << "Setting " << name << " as a uint16."; |
| 97 | // TODO(cmasone): Set actual properties. |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | bool Device::SetUint32Property(const std::string& name, |
| 102 | uint32 value, |
| 103 | Error *error) { |
| 104 | VLOG(2) << "Setting " << name << " as a uint32."; |
| 105 | // TODO(cmasone): Set actual properties. |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | const string& Device::UniqueName() const { |
| 110 | // TODO(pstew): link_name is only run-time unique and won't persist |
| 111 | return link_name_; |
| 112 | } |
| 113 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 114 | } // namespace shill |