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"; |
mukesh agrawal | fc36291 | 2013-08-06 18:10:07 -0700 | [diff] [blame] | 26 | static const char kPPPReasonAuthenticated[] = "authenticated"; |
| 27 | static const char kPPPReasonAuthenticating[] = "authenticating"; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 28 | static const char kPPPReasonConnect[] = "connect"; |
| 29 | static const char kPPPReasonDisconnect[] = "disconnect"; |
| 30 | |
| 31 | class PPPDevice : public VirtualDevice { |
| 32 | public: |
| 33 | static const char kDaemonPath[]; |
| 34 | static const char kPluginPath[]; |
| 35 | |
| 36 | PPPDevice(ControlInterface *control, |
| 37 | EventDispatcher *dispatcher, |
| 38 | Metrics *metrics, |
| 39 | Manager *manager, |
| 40 | const std::string &link_name, |
| 41 | int interface_index); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 42 | ~PPPDevice() override; |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 43 | |
| 44 | // Set IPConfig for this device, based on the dictionary of |
| 45 | // configuration strings received from our PPP plugin. |
| 46 | virtual void UpdateIPConfigFromPPP( |
| 47 | const std::map<std::string, std::string> &configuration, |
| 48 | bool blackhole_ipv6); |
| 49 | |
| 50 | // Get the network device name (e.g. "ppp0") from the dictionary of |
| 51 | // configuration strings received from our PPP plugin. |
| 52 | static std::string GetInterfaceName( |
| 53 | const std::map<std::string, std::string> &configuration); |
| 54 | |
| 55 | private: |
| 56 | FRIEND_TEST(PPPDeviceTest, GetInterfaceName); |
| 57 | FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration); |
| 58 | |
mukesh agrawal | 4fef249 | 2013-08-01 16:03:59 -0700 | [diff] [blame] | 59 | static IPConfig::Properties ParseIPConfiguration( |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 60 | const std::string &link_name, |
mukesh agrawal | 4fef249 | 2013-08-01 16:03:59 -0700 | [diff] [blame] | 61 | const std::map<std::string, std::string> &configuration); |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(PPPDevice); |
| 64 | }; |
| 65 | |
| 66 | } // namespace shill |
| 67 | |
| 68 | #endif // SHILL_PPP_DEVICE_H_ |