blob: 71e30f41a2e8cf27e39ea8dd1f6b9d0279ddcd53 [file] [log] [blame]
Peter Qiuc0beca52015-09-03 11:25:46 -07001//
2// Copyright (C) 2013 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
mukesh agrawal9da07772013-05-15 14:15:17 -070016
17#ifndef SHILL_PPP_DEVICE_H_
18#define SHILL_PPP_DEVICE_H_
19
Ben Chancc67c522014-09-03 07:19:18 -070020#include <base/macros.h>
mukesh agrawal9da07772013-05-15 14:15:17 -070021
22#include <map>
23#include <string>
24
25#include "shill/ipconfig.h"
26#include "shill/virtual_device.h"
27
28namespace shill {
29
30// Declared in the header to avoid linking unused code into shims.
31static const char kPPPDNS1[] = "DNS1";
32static const char kPPPDNS2[] = "DNS2";
33static const char kPPPExternalIP4Address[] = "EXTERNAL_IP4_ADDRESS";
34static const char kPPPGatewayAddress[] = "GATEWAY_ADDRESS";
35static const char kPPPInterfaceName[] = "INTERNAL_IFNAME";
36static const char kPPPInternalIP4Address[] = "INTERNAL_IP4_ADDRESS";
37static const char kPPPLNSAddress[] = "LNS_ADDRESS";
Garret Kelly16ff6eb2015-06-24 16:11:38 -040038static const char kPPPMRU[] = "MRU";
mukesh agrawalfc362912013-08-06 18:10:07 -070039static const char kPPPReasonAuthenticated[] = "authenticated";
40static const char kPPPReasonAuthenticating[] = "authenticating";
mukesh agrawal9da07772013-05-15 14:15:17 -070041static const char kPPPReasonConnect[] = "connect";
42static const char kPPPReasonDisconnect[] = "disconnect";
43
44class PPPDevice : public VirtualDevice {
45 public:
Paul Stewart1a212a62015-06-16 13:13:10 -070046 PPPDevice(ControlInterface* control,
47 EventDispatcher* dispatcher,
48 Metrics* metrics,
49 Manager* manager,
50 const std::string& link_name,
mukesh agrawal9da07772013-05-15 14:15:17 -070051 int interface_index);
Ben Chan5ea763b2014-08-13 11:07:54 -070052 ~PPPDevice() override;
mukesh agrawal9da07772013-05-15 14:15:17 -070053
54 // Set IPConfig for this device, based on the dictionary of
55 // configuration strings received from our PPP plugin.
56 virtual void UpdateIPConfigFromPPP(
Paul Stewart1a212a62015-06-16 13:13:10 -070057 const std::map<std::string, std::string>& configuration,
mukesh agrawal9da07772013-05-15 14:15:17 -070058 bool blackhole_ipv6);
59
Paul Stewart34628592015-01-26 08:32:03 -080060 // Same as UpdateIPConfigFromPPP except overriding the default MTU
61 // in the IPConfig.
62 virtual void UpdateIPConfigFromPPPWithMTU(
Paul Stewart1a212a62015-06-16 13:13:10 -070063 const std::map<std::string, std::string>& configuration,
Paul Stewart34628592015-01-26 08:32:03 -080064 bool blackhole_ipv6,
65 int32_t mtu);
66
Peter Qiud1d32782015-08-20 23:16:00 -070067#ifndef DISABLE_DHCPV6
68 // Start a DHCPv6 configuration client for this device. The generic
69 // file name (based on the device name) will be used for the acquired
70 // lease, so that the lease file will be removed when the DHCPv6 client
71 // terminates. For PPP devices, there is no correlation between
72 // the service name and the network that it connected to.
73 virtual bool AcquireIPv6Config();
74#endif // DISABLE_DHCPV6
75
mukesh agrawal9da07772013-05-15 14:15:17 -070076 // Get the network device name (e.g. "ppp0") from the dictionary of
77 // configuration strings received from our PPP plugin.
78 static std::string GetInterfaceName(
Paul Stewart1a212a62015-06-16 13:13:10 -070079 const std::map<std::string, std::string>& configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070080
81 private:
82 FRIEND_TEST(PPPDeviceTest, GetInterfaceName);
83 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration);
84
Garret Kelly9dd6d6d2015-06-25 16:19:38 -040085 IPConfig::Properties ParseIPConfiguration(
Paul Stewart1a212a62015-06-16 13:13:10 -070086 const std::string& link_name,
87 const std::map<std::string, std::string>& configuration);
mukesh agrawal9da07772013-05-15 14:15:17 -070088
89 DISALLOW_COPY_AND_ASSIGN(PPPDevice);
90};
91
92} // namespace shill
93
94#endif // SHILL_PPP_DEVICE_H_