1 // 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 // 16 17 #ifndef SHILL_PPP_DEVICE_H_ 18 #define SHILL_PPP_DEVICE_H_ 19 20 #include <base/macros.h> 21 22 #include <map> 23 #include <string> 24 25 #include "shill/ipconfig.h" 26 #include "shill/virtual_device.h" 27 28 namespace shill { 29 30 // Declared in the header to avoid linking unused code into shims. 31 static const char kPPPDNS1[] = "DNS1"; 32 static const char kPPPDNS2[] = "DNS2"; 33 static const char kPPPExternalIP4Address[] = "EXTERNAL_IP4_ADDRESS"; 34 static const char kPPPGatewayAddress[] = "GATEWAY_ADDRESS"; 35 static const char kPPPInterfaceName[] = "INTERNAL_IFNAME"; 36 static const char kPPPInternalIP4Address[] = "INTERNAL_IP4_ADDRESS"; 37 static const char kPPPLNSAddress[] = "LNS_ADDRESS"; 38 static const char kPPPMRU[] = "MRU"; 39 static const char kPPPReasonAuthenticated[] = "authenticated"; 40 static const char kPPPReasonAuthenticating[] = "authenticating"; 41 static const char kPPPReasonConnect[] = "connect"; 42 static const char kPPPReasonDisconnect[] = "disconnect"; 43 44 class PPPDevice : public VirtualDevice { 45 public: 46 PPPDevice(ControlInterface* control, 47 EventDispatcher* dispatcher, 48 Metrics* metrics, 49 Manager* manager, 50 const std::string& link_name, 51 int interface_index); 52 ~PPPDevice() override; 53 54 // Set IPConfig for this device, based on the dictionary of 55 // configuration strings received from our PPP plugin. 56 virtual void UpdateIPConfigFromPPP( 57 const std::map<std::string, std::string>& configuration, 58 bool blackhole_ipv6); 59 60 // Same as UpdateIPConfigFromPPP except overriding the default MTU 61 // in the IPConfig. 62 virtual void UpdateIPConfigFromPPPWithMTU( 63 const std::map<std::string, std::string>& configuration, 64 bool blackhole_ipv6, 65 int32_t mtu); 66 67 #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 76 // 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( 79 const std::map<std::string, std::string>& configuration); 80 81 private: 82 FRIEND_TEST(PPPDeviceTest, GetInterfaceName); 83 FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration); 84 85 IPConfig::Properties ParseIPConfiguration( 86 const std::string& link_name, 87 const std::map<std::string, std::string>& configuration); 88 89 DISALLOW_COPY_AND_ASSIGN(PPPDevice); 90 }; 91 92 } // namespace shill 93 94 #endif // SHILL_PPP_DEVICE_H_ 95