blob: 3c07bcb9bea17d2cc588aedda6c61ad13f20fada [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#include <time.h>
Paul Stewart75897df2011-04-27 09:05:53 -07006#include <stdio.h>
Chris Masoneee929b72011-05-10 10:02:18 -07007
Paul Stewart75897df2011-04-27 09:05:53 -07008#include <string>
Chris Masone8fe2c7e2011-06-09 15:51:19 -07009#include <vector>
Paul Stewart75897df2011-04-27 09:05:53 -070010
Chris Masoneee929b72011-05-10 10:02:18 -070011#include <base/logging.h>
Chris Masone487b8bf2011-05-13 16:27:57 -070012#include <base/memory/ref_counted.h>
Chris Masoneee929b72011-05-10 10:02:18 -070013
Paul Stewart75897df2011-04-27 09:05:53 -070014#include "shill/control_interface.h"
15#include "shill/device.h"
Chris Masoned7732e42011-05-20 11:08:56 -070016#include "shill/device_dbus_adaptor.h"
Chris Masone8fe2c7e2011-06-09 15:51:19 -070017#include "shill/error.h"
18#include "shill/manager.h"
Chris Masone0e1d1042011-05-09 18:07:03 -070019#include "shill/shill_event.h"
Paul Stewart75897df2011-04-27 09:05:53 -070020
Chris Masone8fe2c7e2011-06-09 15:51:19 -070021using std::string;
22using std::vector;
23
Paul Stewart75897df2011-04-27 09:05:53 -070024namespace shill {
25Device::Device(ControlInterface *control_interface,
Paul Stewartb50f0b92011-05-16 16:31:42 -070026 EventDispatcher *dispatcher,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070027 Manager *manager,
Chris Masone8fe2c7e2011-06-09 15:51:19 -070028 const string& link_name,
Paul Stewartb50f0b92011-05-16 16:31:42 -070029 int interface_index)
Paul Stewartf1ce5d22011-05-19 13:10:20 -070030 : link_name_(link_name),
31 manager_(manager),
32 adaptor_(control_interface->CreateDeviceAdaptor(this)),
33 interface_index_(interface_index),
34 running_(false) {
Chris Masoneee929b72011-05-10 10:02:18 -070035 // Initialize Interface monitor, so we can detect new interfaces
Paul Stewartb50f0b92011-05-16 16:31:42 -070036 VLOG(2) << "Device " << link_name_ << " index " << interface_index;
Paul Stewart75897df2011-04-27 09:05:53 -070037}
38
39Device::~Device() {
Paul Stewartb50f0b92011-05-16 16:31:42 -070040 VLOG(2) << "Device " << link_name_ << " destroyed.";
Paul Stewart75897df2011-04-27 09:05:53 -070041}
42
43void Device::Start() {
44 running_ = true;
Paul Stewartf1ce5d22011-05-19 13:10:20 -070045 VLOG(2) << "Device " << link_name_ << " starting.";
Chris Masone413a3192011-05-09 17:10:05 -070046 adaptor_->UpdateEnabled();
Paul Stewart75897df2011-04-27 09:05:53 -070047}
48
49void Device::Stop() {
50 running_ = false;
Chris Masone413a3192011-05-09 17:10:05 -070051 adaptor_->UpdateEnabled();
Paul Stewart75897df2011-04-27 09:05:53 -070052}
53
Paul Stewartf1ce5d22011-05-19 13:10:20 -070054void Device::LinkEvent(unsigned flags, unsigned change) {
55 VLOG(2) << "Device " << link_name_ << " flags " << flags << " changed "
56 << change;
57}
58
59void Device::Scan() {
60 VLOG(2) << "Device " << link_name_ << " scan requested.";
61}
62
Chris Masone8fe2c7e2011-06-09 15:51:19 -070063bool 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
69bool 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
77bool 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
85bool 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
93bool 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
101bool 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
109const 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 Stewart75897df2011-04-27 09:05:53 -0700114} // namespace shill