blob: 2a798e707f239e7ba1e106ef6f4fb2c9ef1864c8 [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";
Garret Kelly16ff6eb2015-06-24 16:11:38 -040026static const char kPPPMRU[] = "MRU";
mukesh agrawalfc362912013-08-06 18:10:07 -070027static const char kPPPReasonAuthenticated[] = "authenticated";
28static const char kPPPReasonAuthenticating[] = "authenticating";
mukesh agrawal9da07772013-05-15 14:15:17 -070029static const char kPPPReasonConnect[] = "connect";
30static const char kPPPReasonDisconnect[] = "disconnect";
31
32class PPPDevice : public VirtualDevice {
33 public:
Paul Stewart1a212a62015-06-16 13:13:10 -070034 PPPDevice(ControlInterface* control,
35 EventDispatcher* dispatcher,
36 Metrics* metrics,
37 Manager* manager,
38 const std::string& link_name,
mukesh agrawal9da07772013-05-15 14:15:17 -070039 int interface_index);
Ben Chan5ea763b2014-08-13 11:07:54 -070040 ~PPPDevice() override;
mukesh agrawal9da07772013-05-15 14:15:17 -070041
42 // Set IPConfig for this device, based on the dictionary of
43 // configuration strings received from our PPP plugin.
44 virtual void UpdateIPConfigFromPPP(
Paul Stewart1a212a62015-06-16 13:13:10 -070045 const std::map<std::string, std::string>& configuration,
mukesh agrawal9da07772013-05-15 14:15:17 -070046 bool blackhole_ipv6);
47
Paul Stewart34628592015-01-26 08:32:03 -080048 // Same as UpdateIPConfigFromPPP except overriding the default MTU
49 // in the IPConfig.
50 virtual void UpdateIPConfigFromPPPWithMTU(
Paul Stewart1a212a62015-06-16 13:13:10 -070051 const std::map<std::string, std::string>& configuration,
Paul Stewart34628592015-01-26 08:32:03 -080052 bool blackhole_ipv6,
53 int32_t mtu);
54
mukesh agrawal9da07772013-05-15 14:15:17 -070055 // Get the network device name (e.g. "ppp0") from the dictionary of
56 // configuration strings received from our PPP plugin.
57 static std::string GetInterfaceName(
Paul Stewart1a212a62015-06-16 13:13:10 -070058 const std::map<std::string, std::string>& configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070059
60 private:
61 FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
62 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
63
Garret Kelly9dd6d6d2015-06-25 16:19:38 -040064 IPConfig::Properties ParseIPConfiguration(
Paul Stewart1a212a62015-06-16 13:13:10 -070065 const std::string& link_name,
66 const std::map<std::string, std::string>& configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070067
68 DISALLOW_COPY_AND_ASSIGN(PPPDevice);
69};
70
71} // namespace shill
72
73#endif // SHILL_PPP_DEVICE_H_