OLD | NEW |
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef _VPN_MANAGER_L2TP_MANAGER_H_ | 5 #ifndef _VPN_MANAGER_L2TP_MANAGER_H_ |
6 #define _VPN_MANAGER_L2TP_MANAGER_H_ | 6 #define _VPN_MANAGER_L2TP_MANAGER_H_ |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "gtest/gtest_prod.h" // for FRIEND_TEST | 11 #include "gtest/gtest_prod.h" // for FRIEND_TEST |
12 #include "vpn-manager/service_manager.h" | 12 #include "vpn-manager/service_manager.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 class Process; | 15 class Process; |
16 } | 16 } |
17 | 17 |
18 // Manages the L2TP daemon. This manager orchestrates configuring and | 18 // Manages the L2TP daemon. This manager orchestrates configuring and |
19 // launching the L2TP daemon, initiating the L2TP connection, and | 19 // launching the L2TP daemon, initiating the L2TP connection, and |
20 // detecting when PPP has been set up. It also sends user credentials | 20 // detecting when PPP has been set up. It also sends user credentials |
21 // to PPP through the L2TP control fifo unless the user has specified | 21 // to PPP through the L2TP control fifo unless the user has specified |
22 // a PPP plugin should be used, which it will defer to. Current | 22 // a PPP plugin should be used, which it will defer to. Current |
23 // implementation assumes a connection that has been stopped will not | 23 // implementation assumes a connection that has been stopped will not |
24 // be started again with the same object. | 24 // be started again with the same object. |
25 class L2tpManager : public ServiceManager { | 25 class L2tpManager : public ServiceManager { |
26 public: | 26 public: |
27 L2tpManager(); | 27 L2tpManager(); |
28 | 28 |
29 // Initialize the object using |remote_address|. Returns false if | 29 // Initialize the object using |remote_host|. Returns false if |
30 // an illegal set of parameters has been given. Has no side effects | 30 // an illegal set of parameters has been given. Has no side effects |
31 // other than setting up the object. | 31 // other than setting up the object. |
32 bool Initialize(const std::string& remote_address); | 32 bool Initialize(const std::string& remote_host); |
33 | 33 |
34 virtual bool Start(); | 34 virtual bool Start(); |
35 virtual void Stop(); | 35 virtual void Stop(); |
36 virtual int Poll(); | 36 virtual int Poll(); |
37 virtual void ProcessOutput(); | 37 virtual void ProcessOutput(); |
38 virtual bool IsChild(pid_t pid); | 38 virtual bool IsChild(pid_t pid); |
39 | 39 |
40 // Returns the stderr output file descriptor of our child process. | 40 // Returns the stderr output file descriptor of our child process. |
41 int output_fd() const { return output_fd_; } | 41 int output_fd() const { return output_fd_; } |
42 | 42 |
(...skipping 15 matching lines...) Expand all Loading... |
58 std::string FormatPppdConfiguration(); | 58 std::string FormatPppdConfiguration(); |
59 bool Initiate(); | 59 bool Initiate(); |
60 bool Terminate(); | 60 bool Terminate(); |
61 | 61 |
62 // Has the L2TP connection been initiated yet. | 62 // Has the L2TP connection been initiated yet. |
63 bool was_initiated_; | 63 bool was_initiated_; |
64 // l2tp daemon stderr pipe file descriptor. | 64 // l2tp daemon stderr pipe file descriptor. |
65 int output_fd_; | 65 int output_fd_; |
66 // Start time of the l2tp daemon. | 66 // Start time of the l2tp daemon. |
67 base::TimeTicks start_ticks_; | 67 base::TimeTicks start_ticks_; |
68 // Remote address for L2TP connection. | 68 // Remote host for L2TP connection. |
69 std::string remote_address_; | 69 std::string remote_host_; |
70 // Last partial line read from output_fd_. | 70 // Last partial line read from output_fd_. |
71 std::string partial_output_line_; | 71 std::string partial_output_line_; |
72 // Path to a file whose existence indicates the ppp device is up. | 72 // Path to a file whose existence indicates the ppp device is up. |
73 FilePath ppp_interface_path_; | 73 FilePath ppp_interface_path_; |
74 // Path to l2tp daemon's control file. | 74 // Path to l2tp daemon's control file. |
75 FilePath l2tpd_control_path_; | 75 FilePath l2tpd_control_path_; |
76 // Running l2tp process. | 76 // Running l2tp process. |
77 scoped_ptr<chromeos::Process> l2tpd_; | 77 scoped_ptr<chromeos::Process> l2tpd_; |
78 }; | 78 }; |
79 | 79 |
80 #endif // _VPN_MANAGER_L2TP_MANAGER_H_ | 80 #endif // _VPN_MANAGER_L2TP_MANAGER_H_ |
OLD | NEW |