Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: l2tp_manager.h

Issue 6508016: vpn-manager: Add l2tp/ipsec vpn manager (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vpn-manager.git@master
Patch Set: Add line combining Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: l2tp_manager.h
diff --git a/l2tp_manager.h b/l2tp_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..136ccdca5729e451604061a69e3ad83a7e8468b4
--- /dev/null
+++ b/l2tp_manager.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef _VPN_MANAGER_L2TP_MANAGER_H_
+#define _VPN_MANAGER_L2TP_MANAGER_H_
+
+#include "base/file_util.h"
+#include "base/scoped_ptr.h"
+#include "base/time.h"
+#include "gtest/gtest_prod.h" // for FRIEND_TEST
+
+#include "vpn-manager/service_manager.h"
+
+namespace chromeos {
+class Process;
+}
+
+// Manages the L2TP daemon. This manager orchestrates configuring and
+// launching the L2TP daemon, initiating the L2TP connection, and
+// detecting when PPP has been set up. It also sends user credentials
+// to PPP through the L2TP control fifo unless the user has specified
+// a PPP plugin should be used, which it will defer to. Current
+// implementation assumes a connection that has been stopped will not
+// be started again with the same object.
+class L2tpManager : public ServiceManager {
+ public:
+ L2tpManager();
+
+ // Initialize the object using |remote|. Returns false if an illegal
+ // set of parameters has been given. Has no side effects other than
+ // setting up the object.
+ bool Initialize(const std::string& remote);
+
+ virtual bool Start();
+ virtual void Stop();
+ virtual int Poll();
+ virtual void ProcessOutput();
+ virtual bool IsChild(pid_t pid);
+
+ // Returns the stderr output file descriptor of our child process.
+ int output_fd() const { return output_fd_; }
+
+ protected:
+ friend class L2tpManagerTest;
+ FRIEND_TEST(L2tpManagerTest, FormatL2tpdConfiguration);
+ FRIEND_TEST(L2tpManagerTest, FormatPppdConfiguration);
+ FRIEND_TEST(L2tpManagerTest, Initiate);
+ FRIEND_TEST(L2tpManagerTest, PollInitiateConnection);
+ FRIEND_TEST(L2tpManagerTest, PollNothingIfRunning);
+ FRIEND_TEST(L2tpManagerTest, PollTimeoutWaitingForControl);
+ FRIEND_TEST(L2tpManagerTest, PollTimeoutWaitingForUp);
+ FRIEND_TEST(L2tpManagerTest, PollTransitionToUp);
+ FRIEND_TEST(L2tpManagerTest, PollWaitIfNotUpYet);
+ FRIEND_TEST(L2tpManagerTest, Start);
+ FRIEND_TEST(L2tpManagerTest, Terminate);
+
+ std::string FormatL2tpdConfiguration(const std::string& ppp_config_path);
+ std::string FormatPppdConfiguration();
+ bool Initiate();
+ bool Terminate();
+
+ // Has the L2TP connection been initiated yet.
+ bool was_initiated_;
+ // l2tp daemon stderr pipe file descriptor.
+ int output_fd_;
+ // Start time of the l2tp daemon.
+ base::TimeTicks start_ticks_;
+ // Remote IP for L2TP connection.
+ std::string remote_;
+ // Last partial line read from output_fd_.
+ std::string partial_output_line_;
+ // Path to a file whose existence indicates the ppp device is up.
+ FilePath ppp_interface_path_;
+ // Path to l2tp daemon's control file.
+ FilePath l2tpd_control_path_;
+ // Running l2tp process.
+ scoped_ptr<chromeos::Process> l2tpd_;
+};
+
+#endif // _VPN_MANAGER_L2TP_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698