1//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#ifndef SHILL_VIRTUAL_DEVICE_H_
18#define SHILL_VIRTUAL_DEVICE_H_
19
20#include <string>
21
22#include <base/macros.h>
23
24#include "shill/device.h"
25#include "shill/ipconfig.h"
26#include "shill/service.h"
27#include "shill/technology.h"
28
29namespace shill {
30
31class StorageInterface;
32
33// A VirtualDevice represents a device that doesn't provide its own
34// physical layer. This includes, e.g., tunnel interfaces used for
35// OpenVPN, and PPP devices used for L2TPIPSec and 3G PPP dongles.
36// (PPP devices are represented via the PPPDevice subclass.)
37class VirtualDevice : public Device {
38 public:
39  VirtualDevice(ControlInterface* control,
40                EventDispatcher* dispatcher,
41                Metrics* metrics,
42                Manager* manager,
43                const std::string& link_name,
44                int interface_index,
45                Technology::Identifier technology);
46  ~VirtualDevice() override;
47
48  bool Load(StoreInterface* storage) override;
49  bool Save(StoreInterface* storage) override;
50
51  void Start(Error* error,
52             const EnabledStateChangedCallback& callback) override;
53  void Stop(Error* error,
54            const EnabledStateChangedCallback& callback) override;
55
56  virtual void UpdateIPConfig(const IPConfig::Properties& properties);
57
58  // Expose protected device methods to manager of this device.
59  // (E.g. Cellular, L2TPIPSecDriver, OpenVPNDriver.)
60  void DropConnection() override;
61  virtual void SelectService(const ServiceRefPtr& service);
62  void SetServiceState(Service::ConnectState state) override;
63  void SetServiceFailure(Service::ConnectFailure failure_state) override;
64  void SetServiceFailureSilent(Service::ConnectFailure failure_state) override;
65
66 private:
67  DISALLOW_COPY_AND_ASSIGN(VirtualDevice);
68};
69
70}  // namespace shill
71
72#endif  // SHILL_VIRTUAL_DEVICE_H_
73