blob: 37d7b9ac829541a1ce48bc580efe283802de69d3 [file] [log] [blame]
Darin Petkovf20994f2012-03-05 16:12:19 +01001// 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/vpn.h"
6
Paul Stewart536820d2012-03-19 16:05:59 -07007#include <netinet/ether.h>
8#include <linux/if.h> // Needs definitions from netinet/ether.h
9
10#include "shill/rtnl_handler.h"
Darin Petkov79d74c92012-03-07 17:20:32 +010011#include "shill/vpn_service.h"
12
Darin Petkovf20994f2012-03-05 16:12:19 +010013using std::string;
14
15namespace shill {
16
17VPN::VPN(ControlInterface *control,
18 EventDispatcher *dispatcher,
19 Metrics *metrics,
20 Manager *manager,
21 const string &link_name,
22 int interface_index)
23 : Device(control, dispatcher, metrics, manager, link_name, "",
24 interface_index, Technology::kVPN) {}
25
26VPN::~VPN() {}
27
Eric Shienbrood9a245532012-03-07 14:20:39 -050028void VPN::Start(Error *error, const EnabledStateChangedCallback &callback) {
Paul Stewart536820d2012-03-19 16:05:59 -070029 RTNLHandler::GetInstance()->SetInterfaceFlags(interface_index(), IFF_UP,
30 IFF_UP);
Eric Shienbrood9a245532012-03-07 14:20:39 -050031 if (error)
32 error->Reset();
33}
34
35void VPN::Stop(Error *error, const EnabledStateChangedCallback &callback) {
36 if (error)
37 error->Reset();
Paul Stewart536820d2012-03-19 16:05:59 -070038}
39
Darin Petkovf20994f2012-03-05 16:12:19 +010040bool VPN::TechnologyIs(const Technology::Identifier type) const {
41 return type == Technology::kVPN;
42}
43
Darin Petkov79d74c92012-03-07 17:20:32 +010044void VPN::SelectService(const VPNServiceRefPtr &service) {
45 VLOG(2) << __func__;
46 Device::SelectService(service);
47}
48
49void VPN::UpdateIPConfig(const IPConfig::Properties &properties) {
50 VLOG(2) << __func__;
Darin Petkov31a2eca2012-03-14 11:07:18 +010051 if (!ipconfig()) {
52 set_ipconfig(new IPConfig(control_interface(), link_name()));
53 }
Darin Petkov79d74c92012-03-07 17:20:32 +010054 ipconfig()->set_properties(properties);
55 OnIPConfigUpdated(ipconfig(), true);
56}
57
58void VPN::OnDisconnected() {
59 VLOG(2) << __func__;
60 OnIPConfigUpdated(ipconfig(), false);
61}
62
Darin Petkovf20994f2012-03-05 16:12:19 +010063} // namespace shill