mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 1 | // 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 Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 8 | #include <base/macros.h> |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 9 | |
| 10 | #include <map> |
| 11 | #include <string> |
| 12 | |
| 13 | #include "shill/ipconfig.h" |
| 14 | #include "shill/virtual_device.h" |
| 15 | |
| 16 | namespace shill { |
| 17 | |
| 18 | // Declared in the header to avoid linking unused code into shims. |
| 19 | static const char kPPPDNS1[] = "DNS1"; |
| 20 | static const char kPPPDNS2[] = "DNS2"; |
| 21 | static const char kPPPExternalIP4Address[] = "EXTERNAL_IP4_ADDRESS"; |
| 22 | static const char kPPPGatewayAddress[] = "GATEWAY_ADDRESS"; |
| 23 | static const char kPPPInterfaceName[] = "INTERNAL_IFNAME"; |
| 24 | static const char kPPPInternalIP4Address[] = "INTERNAL_IP4_ADDRESS"; |
| 25 | static const char kPPPLNSAddress[] = "LNS_ADDRESS"; |
Garret Kelly | 16ff6eb | 2015-06-24 16:11:38 -0400 | [diff] [blame^] | 26 | static const char kPPPMRU[] = "MRU"; |
mukesh agrawal | fc36291 | 2013-08-06 18:10:07 -0700 | [diff] [blame] | 27 | static const char kPPPReasonAuthenticated[] = "authenticated"; |
| 28 | static const char kPPPReasonAuthenticating[] = "authenticating"; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 29 | static const char kPPPReasonConnect[] = "connect"; |
| 30 | static const char kPPPReasonDisconnect[] = "disconnect"; |
| 31 | |
| 32 | class PPPDevice : public VirtualDevice { |
| 33 | public: |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 34 | PPPDevice(ControlInterface* control, |
| 35 | EventDispatcher* dispatcher, |
| 36 | Metrics* metrics, |
| 37 | Manager* manager, |
| 38 | const std::string& link_name, |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 39 | int interface_index); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 40 | ~PPPDevice() override; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 41 | |
| 42 | // Set IPConfig for this device, based on the dictionary of |
| 43 | // configuration strings received from our PPP plugin. |
| 44 | virtual void UpdateIPConfigFromPPP( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 45 | const std::map<std::string, std::string>& configuration, |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 46 | bool blackhole_ipv6); |
| 47 | |
Paul Stewart | 3462859 | 2015-01-26 08:32:03 -0800 | [diff] [blame] | 48 | // Same as UpdateIPConfigFromPPP except overriding the default MTU |
| 49 | // in the IPConfig. |
| 50 | virtual void UpdateIPConfigFromPPPWithMTU( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 51 | const std::map<std::string, std::string>& configuration, |
Paul Stewart | 3462859 | 2015-01-26 08:32:03 -0800 | [diff] [blame] | 52 | bool blackhole_ipv6, |
| 53 | int32_t mtu); |
| 54 | |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 55 | // 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 Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 58 | const std::map<std::string, std::string>& configuration); |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 59 | |
| 60 | private: |
| 61 | FRIEND_TEST(PPPDeviceTest, GetInterfaceName); |
| 62 | FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration); |
| 63 | |
mukesh agrawal | 4fef249 | 2013-08-01 16:03:59 -0700 | [diff] [blame] | 64 | static IPConfig::Properties ParseIPConfiguration( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 65 | const std::string& link_name, |
| 66 | const std::map<std::string, std::string>& configuration); |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 67 | |
| 68 | DISALLOW_COPY_AND_ASSIGN(PPPDevice); |
| 69 | }; |
| 70 | |
| 71 | } // namespace shill |
| 72 | |
| 73 | #endif // SHILL_PPP_DEVICE_H_ |