blob: becc484e798d1f1b2b5a09b8bf21d5e4a13bd115 [file] [log] [blame]
mukesh agrawal9da07772013-05-15 14:15:17 -07001// 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/basictypes.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 kPPPReasonConnect[] = "connect";
27static const char kPPPReasonDisconnect[] = "disconnect";
28
29class PPPDevice : public VirtualDevice {
30 public:
31 static const char kDaemonPath[];
32 static const char kPluginPath[];
33
34 PPPDevice(ControlInterface *control,
35 EventDispatcher *dispatcher,
36 Metrics *metrics,
37 Manager *manager,
38 const std::string &link_name,
39 int interface_index);
40 virtual ~PPPDevice();
41
42 // Set IPConfig for this device, based on the dictionary of
43 // configuration strings received from our PPP plugin.
44 virtual void UpdateIPConfigFromPPP(
45 const std::map<std::string, std::string> &configuration,
46 bool blackhole_ipv6);
47
48 // Get the network device name (e.g. "ppp0") from the dictionary of
49 // configuration strings received from our PPP plugin.
50 static std::string GetInterfaceName(
51 const std::map<std::string, std::string> &configuration);
52
53 private:
54 FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
55 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
56
57 static void ParseIPConfiguration(
58 const std::string &link_name,
59 const std::map<std::string, std::string> &configuration,
60 IPConfig::Properties *properties);
61
62 DISALLOW_COPY_AND_ASSIGN(PPPDevice);
63};
64
65} // namespace shill
66
67#endif // SHILL_PPP_DEVICE_H_