Peter Qiu | c0beca5 | 2015-09-03 11:25:46 -0700 | [diff] [blame] | 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 | // |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef SHILL_PPP_DEVICE_H_ |
| 18 | #define SHILL_PPP_DEVICE_H_ |
| 19 | |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 20 | #include <base/macros.h> |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 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"; |
Garret Kelly | 16ff6eb | 2015-06-24 16:11:38 -0400 | [diff] [blame] | 38 | static const char kPPPMRU[] = "MRU"; |
mukesh agrawal | fc36291 | 2013-08-06 18:10:07 -0700 | [diff] [blame] | 39 | static const char kPPPReasonAuthenticated[] = "authenticated"; |
| 40 | static const char kPPPReasonAuthenticating[] = "authenticating"; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 41 | static const char kPPPReasonConnect[] = "connect"; |
| 42 | static const char kPPPReasonDisconnect[] = "disconnect"; |
| 43 | |
| 44 | class PPPDevice : public VirtualDevice { |
| 45 | public: |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 46 | PPPDevice(ControlInterface* control, |
| 47 | EventDispatcher* dispatcher, |
| 48 | Metrics* metrics, |
| 49 | Manager* manager, |
| 50 | const std::string& link_name, |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 51 | int interface_index); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 52 | ~PPPDevice() override; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 53 | |
| 54 | // Set IPConfig for this device, based on the dictionary of |
| 55 | // configuration strings received from our PPP plugin. |
| 56 | virtual void UpdateIPConfigFromPPP( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 57 | const std::map<std::string, std::string>& configuration, |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 58 | bool blackhole_ipv6); |
| 59 | |
Paul Stewart | 3462859 | 2015-01-26 08:32:03 -0800 | [diff] [blame] | 60 | // Same as UpdateIPConfigFromPPP except overriding the default MTU |
| 61 | // in the IPConfig. |
| 62 | virtual void UpdateIPConfigFromPPPWithMTU( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 63 | const std::map<std::string, std::string>& configuration, |
Paul Stewart | 3462859 | 2015-01-26 08:32:03 -0800 | [diff] [blame] | 64 | bool blackhole_ipv6, |
| 65 | int32_t mtu); |
| 66 | |
Peter Qiu | d1d3278 | 2015-08-20 23:16:00 -0700 | [diff] [blame] | 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 | |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 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( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 79 | const std::map<std::string, std::string>& configuration); |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 80 | |
| 81 | private: |
| 82 | FRIEND_TEST(PPPDeviceTest, GetInterfaceName); |
| 83 | FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration); |
| 84 | |
Garret Kelly | 9dd6d6d | 2015-06-25 16:19:38 -0400 | [diff] [blame] | 85 | IPConfig::Properties ParseIPConfiguration( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 86 | const std::string& link_name, |
| 87 | const std::map<std::string, std::string>& configuration); |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 88 | |
| 89 | DISALLOW_COPY_AND_ASSIGN(PPPDevice); |
| 90 | }; |
| 91 | |
| 92 | } // namespace shill |
| 93 | |
| 94 | #endif // SHILL_PPP_DEVICE_H_ |