ppp_device.h revision cb832e8df5f61b223de86a9d4204c86f1e7d9c36
1// Copyright (c) 2013 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#ifndef SHILL_PPP_DEVICE_H_
6#define SHILL_PPP_DEVICE_H_
7
8#include <base/macros.h>
9
10#include <map>
11#include <string>
12
13#include "shill/ipconfig.h"
14#include "shill/virtual_device.h"
15
16namespace shill {
17
18// Declared in the header to avoid linking unused code into shims.
19static const char kPPPDNS1[] = "DNS1";
20static const char kPPPDNS2[] = "DNS2";
21static const char kPPPExternalIP4Address[] = "EXTERNAL_IP4_ADDRESS";
22static const char kPPPGatewayAddress[] = "GATEWAY_ADDRESS";
23static const char kPPPInterfaceName[] = "INTERNAL_IFNAME";
24static const char kPPPInternalIP4Address[] = "INTERNAL_IP4_ADDRESS";
25static const char kPPPLNSAddress[] = "LNS_ADDRESS";
26static const char kPPPReasonAuthenticated[] = "authenticated";
27static const char kPPPReasonAuthenticating[] = "authenticating";
28static const char kPPPReasonConnect[] = "connect";
29static const char kPPPReasonDisconnect[] = "disconnect";
30
31class PPPDevice : public VirtualDevice {
32 public:
33  PPPDevice(ControlInterface *control,
34            EventDispatcher *dispatcher,
35            Metrics *metrics,
36            Manager *manager,
37            const std::string &link_name,
38            int interface_index);
39  ~PPPDevice() override;
40
41  // Set IPConfig for this device, based on the dictionary of
42  // configuration strings received from our PPP plugin.
43  virtual void UpdateIPConfigFromPPP(
44      const std::map<std::string, std::string> &configuration,
45      bool blackhole_ipv6);
46
47  // Get the network device name (e.g. "ppp0") from the dictionary of
48  // configuration strings received from our PPP plugin.
49  static std::string GetInterfaceName(
50      const std::map<std::string, std::string> &configuration);
51
52 private:
53  FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
54  FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
55
56  static IPConfig::Properties ParseIPConfiguration(
57      const std::string &link_name,
58      const std::map<std::string, std::string> &configuration);
59
60  DISALLOW_COPY_AND_ASSIGN(PPPDevice);
61};
62
63}  // namespace shill
64
65#endif  // SHILL_PPP_DEVICE_H_
66