blob: 72d56a3aad503ddec30ae5c9363d50a2b7810d12 [file] [log] [blame]
mukesh agrawal9da07772013-05-15 14:15:17 -07001// Copyright (c) 2012 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 "shill/virtual_device.h"
6
7#include <netinet/ether.h>
8#include <linux/if.h> // Needs definitions from netinet/ether.h
9
10#include "shill/logging.h"
11#include "shill/rtnl_handler.h"
12
13using std::string;
14
15namespace shill {
16
17namespace {
18const char kHardwareAddressEmpty[] = "";
19} // namespace {}
20
21VirtualDevice::VirtualDevice(ControlInterface *control,
22 EventDispatcher *dispatcher,
23 Metrics *metrics,
24 Manager *manager,
25 const string &link_name,
26 int interface_index,
27 Technology::Identifier technology)
28 : Device(control, dispatcher, metrics, manager, link_name,
29 kHardwareAddressEmpty, interface_index, technology) {}
30
31VirtualDevice::~VirtualDevice() {}
32
33bool VirtualDevice::Load(StoreInterface */*storage*/) {
34 // Virtual devices have no persistent state.
35 return true;
36}
37
38bool VirtualDevice::Save(StoreInterface */*storage*/) {
39 // Virtual devices have no persistent state.
40 return true;
41}
42
43void VirtualDevice::Start(Error *error,
44 const EnabledStateChangedCallback &callback) {
45 RTNLHandler::GetInstance()->SetInterfaceFlags(interface_index(), IFF_UP,
46 IFF_UP);
47 if (error)
48 error->Reset();
49}
50
51void VirtualDevice::Stop(Error *error,
52 const EnabledStateChangedCallback &callback) {
53 if (error)
54 error->Reset();
55}
56
57void VirtualDevice::UpdateIPConfig(const IPConfig::Properties &properties) {
58 SLOG(Device, 2) << __func__ << " on " << link_name();
59 if (!ipconfig()) {
60 set_ipconfig(new IPConfig(control_interface(), link_name()));
61 }
62 ipconfig()->set_properties(properties);
63 OnIPConfigUpdated(ipconfig(), true);
64}
65
66void VirtualDevice::DropConnection() {
67 Device::DropConnection();
68}
69
70void VirtualDevice::SelectService(const ServiceRefPtr &service) {
71 Device::SelectService(service);
72}
73
74} // namespace shill