blob: d731d00b83d8fbb091a42635a048fba9a6c1d66c [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
Ben Chancc67c522014-09-03 07:19:18 -07008#include <base/macros.h>
mukesh agrawal9da07772013-05-15 14:15:17 -07009
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:
mukesh agrawal9da07772013-05-15 14:15:17 -070033 PPPDevice(ControlInterface *control,
34 EventDispatcher *dispatcher,
35 Metrics *metrics,
36 Manager *manager,
37 const std::string &link_name,
38 int interface_index);
Ben Chan5ea763b2014-08-13 11:07:54 -070039 ~PPPDevice() override;
mukesh agrawal9da07772013-05-15 14:15:17 -070040
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
Paul Stewart34628592015-01-26 08:32:03 -080047 // Same as UpdateIPConfigFromPPP except overriding the default MTU
48 // in the IPConfig.
49 virtual void UpdateIPConfigFromPPPWithMTU(
50 const std::map<std::string, std::string> &configuration,
51 bool blackhole_ipv6,
52 int32_t mtu);
53
mukesh agrawal9da07772013-05-15 14:15:17 -070054 // Get the network device name (e.g. "ppp0") from the dictionary of
55 // configuration strings received from our PPP plugin.
56 static std::string GetInterfaceName(
57 const std::map<std::string, std::string> &configuration);
58
59 private:
60 FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
61 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
62
mukesh agrawal4fef2492013-08-01 16:03:59 -070063 static IPConfig::Properties ParseIPConfiguration(
mukesh agrawal9da07772013-05-15 14:15:17 -070064 const std::string &link_name,
mukesh agrawal4fef2492013-08-01 16:03:59 -070065 const std::map<std::string, std::string> &configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070066
67 DISALLOW_COPY_AND_ASSIGN(PPPDevice);
68};
69
70} // namespace shill
71
72#endif // SHILL_PPP_DEVICE_H_