blob: 560c9cf7a6970224a2405c589978dd173f752eb7 [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";
mukesh agrawalfc362912013-08-06 18:10:07 -070026static const char kPPPReasonAuthenticated[] = "authenticated";
27static const char kPPPReasonAuthenticating[] = "authenticating";
mukesh agrawal9da07772013-05-15 14:15:17 -070028static const char kPPPReasonConnect[] = "connect";
29static const char kPPPReasonDisconnect[] = "disconnect";
30
31class PPPDevice : public VirtualDevice {
32 public:
33 static const char kDaemonPath[];
34 static const char kPluginPath[];
35
36 PPPDevice(ControlInterface *control,
37 EventDispatcher *dispatcher,
38 Metrics *metrics,
39 Manager *manager,
40 const std::string &link_name,
41 int interface_index);
42 virtual ~PPPDevice();
43
44 // Set IPConfig for this device, based on the dictionary of
45 // configuration strings received from our PPP plugin.
46 virtual void UpdateIPConfigFromPPP(
47 const std::map<std::string, std::string> &configuration,
48 bool blackhole_ipv6);
49
50 // Get the network device name (e.g. "ppp0") from the dictionary of
51 // configuration strings received from our PPP plugin.
52 static std::string GetInterfaceName(
53 const std::map<std::string, std::string> &configuration);
54
55 private:
56 FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
57 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
58
mukesh agrawal4fef2492013-08-01 16:03:59 -070059 static IPConfig::Properties ParseIPConfiguration(
mukesh agrawal9da07772013-05-15 14:15:17 -070060 const std::string &link_name,
mukesh agrawal4fef2492013-08-01 16:03:59 -070061 const std::map<std::string, std::string> &configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070062
63 DISALLOW_COPY_AND_ASSIGN(PPPDevice);
64};
65
66} // namespace shill
67
68#endif // SHILL_PPP_DEVICE_H_