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 #include <poll.h> | 5 #include <poll.h> |
6 #include <signal.h> | 6 #include <signal.h> |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
15 #include "chromeos/process.h" | 15 #include "chromeos/process.h" |
16 #include "chromeos/syslog_logging.h" | 16 #include "chromeos/syslog_logging.h" |
17 #include "gflags/gflags.h" | 17 #include "gflags/gflags.h" |
18 #include "vpn-manager/ipsec_manager.h" | 18 #include "vpn-manager/ipsec_manager.h" |
19 #include "vpn-manager/l2tp_manager.h" | 19 #include "vpn-manager/l2tp_manager.h" |
20 | 20 |
21 #pragma GCC diagnostic ignored "-Wstrict-aliasing" | 21 #pragma GCC diagnostic ignored "-Wstrict-aliasing" |
22 DEFINE_string(client_cert_file, "", "File with IPsec client certificate"); | 22 DEFINE_string(client_cert_file, "", "File with IPsec client certificate"); |
23 DEFINE_string(client_key_file, "", "File with IPsec client private key"); | 23 DEFINE_string(client_key_file, "", "File with IPsec client private key"); |
24 DEFINE_string(psk_file, "", "File with IPsec pre-shared key"); | 24 DEFINE_string(psk_file, "", "File with IPsec pre-shared key"); |
25 DEFINE_string(remote_address, "", "VPN server address"); | 25 DEFINE_string(remote_host, "", "VPN server hostname"); |
26 DEFINE_string(server_ca_file, "", "File with IPsec server CA"); | 26 DEFINE_string(server_ca_file, "", "File with IPsec server CA"); |
27 #pragma GCC diagnostic error "-Wstrict-aliasing" | 27 #pragma GCC diagnostic error "-Wstrict-aliasing" |
28 | 28 |
29 // True if a signal has requested termination. | 29 // True if a signal has requested termination. |
30 static bool s_terminate_request = false; | 30 static bool s_terminate_request = false; |
31 | 31 |
32 void HandleSignal(int sig_num) { | 32 void HandleSignal(int sig_num) { |
33 LOG(INFO) << "Caught signal " << sig_num; | 33 LOG(INFO) << "Caught signal " << sig_num; |
34 switch(sig_num) { | 34 switch(sig_num) { |
35 case SIGTERM: | 35 case SIGTERM: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 chromeos::InitLog(log_flags); | 104 chromeos::InitLog(log_flags); |
105 chromeos::OpenLog("l2tpipsec_vpn", true); | 105 chromeos::OpenLog("l2tpipsec_vpn", true); |
106 IpsecManager ipsec; | 106 IpsecManager ipsec; |
107 L2tpManager l2tp; | 107 L2tpManager l2tp; |
108 | 108 |
109 LockDownUmask(); | 109 LockDownUmask(); |
110 | 110 |
111 ServiceManager::InitializeDirectories(&temp_dir); | 111 ServiceManager::InitializeDirectories(&temp_dir); |
112 | 112 |
113 if (!ipsec.Initialize(1, | 113 if (!ipsec.Initialize(1, |
114 FLAGS_remote_address, | 114 FLAGS_remote_host, |
115 FLAGS_psk_file, | 115 FLAGS_psk_file, |
116 FLAGS_server_ca_file, | 116 FLAGS_server_ca_file, |
117 FLAGS_client_key_file, | 117 FLAGS_client_key_file, |
118 FLAGS_client_cert_file)) { | 118 FLAGS_client_cert_file)) { |
119 return 1; | 119 return 1; |
120 } | 120 } |
121 if (!l2tp.Initialize(FLAGS_remote_address)) { | 121 if (!l2tp.Initialize(FLAGS_remote_host)) { |
122 return 1; | 122 return 1; |
123 } | 123 } |
124 ServiceManager::SetLayerOrder(&ipsec, &l2tp); | 124 ServiceManager::SetLayerOrder(&ipsec, &l2tp); |
125 | 125 |
126 InstallSignalHandlers(); | 126 InstallSignalHandlers(); |
127 CHECK(ipsec.Start()) << "Unable to start IPsec layer"; | 127 CHECK(ipsec.Start()) << "Unable to start IPsec layer"; |
128 | 128 |
129 RunEventLoop(&ipsec, &l2tp); | 129 RunEventLoop(&ipsec, &l2tp); |
130 | 130 |
131 LOG(INFO) << "Shutting down..."; | 131 LOG(INFO) << "Shutting down..."; |
132 l2tp.Stop(); | 132 l2tp.Stop(); |
133 return 0; | 133 return 0; |
134 } | 134 } |
OLD | NEW |