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 | |
| 8 | #include <base/basictypes.h> |
| 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"; |
| 26 | static const char kPPPReasonConnect[] = "connect"; |
| 27 | static const char kPPPReasonDisconnect[] = "disconnect"; |
| 28 | |
| 29 | class PPPDevice : public VirtualDevice { |
| 30 | public: |
| 31 | static const char kDaemonPath[]; |
| 32 | static const char kPluginPath[]; |
| 33 | |
| 34 | PPPDevice(ControlInterface *control, |
| 35 | EventDispatcher *dispatcher, |
| 36 | Metrics *metrics, |
| 37 | Manager *manager, |
| 38 | const std::string &link_name, |
| 39 | int interface_index); |
| 40 | virtual ~PPPDevice(); |
| 41 | |
| 42 | // Set IPConfig for this device, based on the dictionary of |
| 43 | // configuration strings received from our PPP plugin. |
| 44 | virtual void UpdateIPConfigFromPPP( |
| 45 | const std::map<std::string, std::string> &configuration, |
| 46 | bool blackhole_ipv6); |
| 47 | |
| 48 | // Get the network device name (e.g. "ppp0") from the dictionary of |
| 49 | // configuration strings received from our PPP plugin. |
| 50 | static std::string GetInterfaceName( |
| 51 | const std::map<std::string, std::string> &configuration); |
| 52 | |
| 53 | private: |
| 54 | FRIEND_TEST(PPPDeviceTest, GetInterfaceName); |
| 55 | FRIEND_TEST(PPPDeviceTest, ParseIPConfiguration); |
| 56 | |
| 57 | static void ParseIPConfiguration( |
| 58 | const std::string &link_name, |
| 59 | const std::map<std::string, std::string> &configuration, |
| 60 | IPConfig::Properties *properties); |
| 61 | |
| 62 | DISALLOW_COPY_AND_ASSIGN(PPPDevice); |
| 63 | }; |
| 64 | |
| 65 | } // namespace shill |
| 66 | |
| 67 | #endif // SHILL_PPP_DEVICE_H_ |