blob: c01f7aec2dda260de56e071fff03fcda081e0487 [file] [log] [blame]
Darin Petkov7476a262012-04-12 16:30:46 +02001// Copyright (c) 2012 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#include "shill/l2tp_ipsec_driver.h"
6
Darin Petkovf7ef50a2012-04-16 20:54:31 +02007#include <base/file_util.h>
Darin Petkov209e6292012-04-20 11:33:32 +02008#include <base/string_util.h>
Darin Petkov7476a262012-04-12 16:30:46 +02009#include <chromeos/dbus/service_constants.h>
10
Darin Petkovf8046b82012-04-24 16:29:23 +020011#include "shill/device_info.h"
Darin Petkovf7ef50a2012-04-16 20:54:31 +020012#include "shill/error.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070013#include "shill/logging.h"
Darin Petkovf7ef50a2012-04-16 20:54:31 +020014#include "shill/manager.h"
15#include "shill/nss.h"
Darin Petkov5a850472012-06-06 15:44:24 +020016#include "shill/process_killer.h"
Darin Petkovf8046b82012-04-24 16:29:23 +020017#include "shill/vpn.h"
Darin Petkov209e6292012-04-20 11:33:32 +020018#include "shill/vpn_service.h"
Darin Petkovf7ef50a2012-04-16 20:54:31 +020019
Darin Petkov5a850472012-06-06 15:44:24 +020020using base::Closure;
Darin Petkov209e6292012-04-20 11:33:32 +020021using std::map;
Darin Petkov7476a262012-04-12 16:30:46 +020022using std::string;
Darin Petkovf7ef50a2012-04-16 20:54:31 +020023using std::vector;
Darin Petkov7476a262012-04-12 16:30:46 +020024
25namespace shill {
26
Darin Petkovf7ef50a2012-04-16 20:54:31 +020027namespace {
28const char kL2TPIPSecIPSecTimeoutProperty[] = "L2TPIPsec.IPsecTimeout";
29const char kL2TPIPSecLeftProtoPortProperty[] = "L2TPIPsec.LeftProtoPort";
30const char kL2TPIPSecLengthBitProperty[] = "L2TPIPsec.LengthBit";
31const char kL2TPIPSecPFSProperty[] = "L2TPIPsec.PFS";
32const char kL2TPIPSecRefusePapProperty[] = "L2TPIPsec.RefusePap";
33const char kL2TPIPSecRekeyProperty[] = "L2TPIPsec.Rekey";
34const char kL2TPIPSecRequireAuthProperty[] = "L2TPIPsec.RequireAuth";
35const char kL2TPIPSecRequireChapProperty[] = "L2TPIPsec.RequireChap";
36const char kL2TPIPSecRightProtoPortProperty[] = "L2TPIPsec.RightProtoPort";
37} // namespace
38
39// static
Darin Petkov95f317f2012-10-22 13:37:43 +020040const char L2TPIPSecDriver::kPPPDPlugin[] = SHIMDIR "/shill-pppd-plugin.so";
Darin Petkovd4325392012-04-23 15:48:22 +020041// static
Darin Petkov209e6292012-04-20 11:33:32 +020042const char L2TPIPSecDriver::kL2TPIPSecVPNPath[] = "/usr/sbin/l2tpipsec_vpn";
Darin Petkovd4325392012-04-23 15:48:22 +020043// static
44const VPNDriver::Property L2TPIPSecDriver::kProperties[] = {
Darin Petkova56bf972012-10-09 12:27:32 +020045 { flimflam::kL2tpIpsecAuthenticationType, 0 },
Darin Petkovd4325392012-04-23 15:48:22 +020046 { flimflam::kL2tpIpsecCaCertNssProperty, 0 },
47 { flimflam::kL2tpIpsecClientCertIdProperty, 0 },
48 { flimflam::kL2tpIpsecClientCertSlotProperty, 0 },
Darin Petkova56bf972012-10-09 12:27:32 +020049 { flimflam::kL2tpIpsecIkeVersion, 0 },
Darin Petkov02236552012-06-11 13:15:19 +020050 { flimflam::kL2tpIpsecPasswordProperty,
51 Property::kCredential | Property::kWriteOnly },
Darin Petkovcb715292012-04-25 13:04:37 +020052 { flimflam::kL2tpIpsecPinProperty, Property::kCredential },
53 { flimflam::kL2tpIpsecPskProperty, Property::kCredential },
Darin Petkovd4325392012-04-23 15:48:22 +020054 { flimflam::kL2tpIpsecUserProperty, 0 },
Darin Petkov2c773c22012-04-26 12:54:11 +020055 { flimflam::kProviderHostProperty, 0 },
56 { flimflam::kProviderNameProperty, 0 },
57 { flimflam::kProviderTypeProperty, 0 },
Darin Petkovd4325392012-04-23 15:48:22 +020058 { kL2TPIPSecIPSecTimeoutProperty, 0 },
59 { kL2TPIPSecLeftProtoPortProperty, 0 },
60 { kL2TPIPSecLengthBitProperty, 0 },
61 { kL2TPIPSecPFSProperty, 0 },
62 { kL2TPIPSecRefusePapProperty, 0 },
63 { kL2TPIPSecRekeyProperty, 0 },
64 { kL2TPIPSecRequireAuthProperty, 0 },
65 { kL2TPIPSecRequireChapProperty, 0 },
66 { kL2TPIPSecRightProtoPortProperty, 0 },
67};
Darin Petkovf7ef50a2012-04-16 20:54:31 +020068
Darin Petkov209e6292012-04-20 11:33:32 +020069L2TPIPSecDriver::L2TPIPSecDriver(ControlInterface *control,
Darin Petkovf8046b82012-04-24 16:29:23 +020070 EventDispatcher *dispatcher,
71 Metrics *metrics,
Darin Petkov209e6292012-04-20 11:33:32 +020072 Manager *manager,
Darin Petkovf8046b82012-04-24 16:29:23 +020073 DeviceInfo *device_info,
Darin Petkov209e6292012-04-20 11:33:32 +020074 GLib *glib)
Darin Petkov602303f2012-06-06 12:15:59 +020075 : VPNDriver(dispatcher, manager, kProperties, arraysize(kProperties)),
Darin Petkovb451d6e2012-04-23 11:56:41 +020076 control_(control),
Darin Petkovf8046b82012-04-24 16:29:23 +020077 metrics_(metrics),
78 device_info_(device_info),
Darin Petkov209e6292012-04-20 11:33:32 +020079 glib_(glib),
80 nss_(NSS::GetInstance()),
Darin Petkov5a850472012-06-06 15:44:24 +020081 process_killer_(ProcessKiller::GetInstance()),
Darin Petkov209e6292012-04-20 11:33:32 +020082 pid_(0),
83 child_watch_tag_(0) {}
Darin Petkov7476a262012-04-12 16:30:46 +020084
Darin Petkov209e6292012-04-20 11:33:32 +020085L2TPIPSecDriver::~L2TPIPSecDriver() {
86 Cleanup(Service::kStateIdle);
87}
Darin Petkov7476a262012-04-12 16:30:46 +020088
89bool L2TPIPSecDriver::ClaimInterface(const string &link_name,
90 int interface_index) {
Darin Petkovf8f970a2012-09-03 11:32:55 +020091 // TODO(petkov): crosbug.com/29970.
Darin Petkov7476a262012-04-12 16:30:46 +020092 NOTIMPLEMENTED();
93 return false;
94}
95
96void L2TPIPSecDriver::Connect(const VPNServiceRefPtr &service, Error *error) {
Darin Petkov602303f2012-06-06 12:15:59 +020097 StartConnectTimeout();
Darin Petkov209e6292012-04-20 11:33:32 +020098 service_ = service;
99 service_->SetState(Service::kStateConfiguring);
100 rpc_task_.reset(new RPCTask(control_, this));
101 if (!SpawnL2TPIPSecVPN(error)) {
102 Cleanup(Service::kStateFailure);
103 }
Darin Petkov7476a262012-04-12 16:30:46 +0200104}
105
106void L2TPIPSecDriver::Disconnect() {
Darin Petkova0e645e2012-04-25 11:38:59 +0200107 SLOG(VPN, 2) << __func__;
108 Cleanup(Service::kStateIdle);
Darin Petkov7476a262012-04-12 16:30:46 +0200109}
110
Darin Petkov5eb05422012-05-11 15:45:25 +0200111void L2TPIPSecDriver::OnConnectionDisconnected() {
Darin Petkov602303f2012-06-06 12:15:59 +0200112 LOG(ERROR) << "VPN connection disconnected.";
Darin Petkov5eb05422012-05-11 15:45:25 +0200113 Cleanup(Service::kStateFailure);
114}
115
Darin Petkov7476a262012-04-12 16:30:46 +0200116string L2TPIPSecDriver::GetProviderType() const {
117 return flimflam::kProviderL2tpIpsec;
118}
119
Darin Petkov209e6292012-04-20 11:33:32 +0200120void L2TPIPSecDriver::Cleanup(Service::ConnectState state) {
121 SLOG(VPN, 2) << __func__
122 << "(" << Service::ConnectStateToString(state) << ")";
Darin Petkov602303f2012-06-06 12:15:59 +0200123 StopConnectTimeout();
Darin Petkov0e9735d2012-04-24 12:33:45 +0200124 DeletePSKFile();
Darin Petkov209e6292012-04-20 11:33:32 +0200125 if (child_watch_tag_) {
126 glib_->SourceRemove(child_watch_tag_);
127 child_watch_tag_ = 0;
Darin Petkov209e6292012-04-20 11:33:32 +0200128 }
129 if (pid_) {
Darin Petkov5a850472012-06-06 15:44:24 +0200130 process_killer_->Kill(pid_, Closure());
Darin Petkov209e6292012-04-20 11:33:32 +0200131 pid_ = 0;
132 }
Darin Petkovf8046b82012-04-24 16:29:23 +0200133 if (device_) {
134 device_->OnDisconnected();
135 device_->SetEnabled(false);
136 device_ = NULL;
137 }
Darin Petkov209e6292012-04-20 11:33:32 +0200138 rpc_task_.reset();
139 if (service_) {
140 service_->SetState(state);
141 service_ = NULL;
142 }
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200143}
144
Darin Petkov0e9735d2012-04-24 12:33:45 +0200145void L2TPIPSecDriver::DeletePSKFile() {
146 if (!psk_file_.empty()) {
147 file_util::Delete(psk_file_, false);
148 psk_file_.clear();
149 }
150}
151
Darin Petkov209e6292012-04-20 11:33:32 +0200152bool L2TPIPSecDriver::SpawnL2TPIPSecVPN(Error *error) {
153 SLOG(VPN, 2) << __func__;
154
155 vector<string> options;
156 if (!InitOptions(&options, error)) {
157 return false;
158 }
159 SLOG(VPN, 2) << "L2TP/IPSec VPN process options: "
160 << JoinString(options, ' ');
161
162 // TODO(petkov): This code needs to be abstracted away in a separate external
163 // process module (crosbug.com/27131).
164 vector<char *> process_args;
165 process_args.push_back(const_cast<char *>(kL2TPIPSecVPNPath));
166 for (vector<string>::const_iterator it = options.begin();
167 it != options.end(); ++it) {
168 process_args.push_back(const_cast<char *>(it->c_str()));
169 }
170 process_args.push_back(NULL);
171
172 vector<string> environment;
173 InitEnvironment(&environment);
174
175 vector<char *> process_env;
176 for (vector<string>::const_iterator it = environment.begin();
177 it != environment.end(); ++it) {
178 process_env.push_back(const_cast<char *>(it->c_str()));
179 }
180 process_env.push_back(NULL);
181
182 CHECK(!pid_);
183 // Redirect all l2tp/ipsec output to stderr.
184 int stderr_fd = fileno(stderr);
185 if (!glib_->SpawnAsyncWithPipesCWD(process_args.data(),
186 process_env.data(),
187 G_SPAWN_DO_NOT_REAP_CHILD,
188 NULL,
189 NULL,
190 &pid_,
191 NULL,
192 &stderr_fd,
193 &stderr_fd,
194 NULL)) {
195 Error::PopulateAndLog(error, Error::kInternalError,
196 string("Unable to spawn: ") + process_args[0]);
197 return false;
198 }
199 CHECK(!child_watch_tag_);
200 child_watch_tag_ = glib_->ChildWatchAdd(pid_, OnL2TPIPSecVPNDied, this);
201 return true;
202}
203
204void L2TPIPSecDriver::InitEnvironment(vector<string> *environment) {
Darin Petkov95f317f2012-10-22 13:37:43 +0200205 environment->push_back(string(kRPCTaskServiceVariable) + "=" +
206 rpc_task_->GetRpcConnectionIdentifier());
207 environment->push_back(string(kRPCTaskPathVariable) + "=" +
208 rpc_task_->GetRpcIdentifier());
Darin Petkov209e6292012-04-20 11:33:32 +0200209}
210
211bool L2TPIPSecDriver::InitOptions(vector<string> *options, Error *error) {
Darin Petkov01c66042012-04-26 11:10:45 +0200212 string vpnhost = args()->LookupString(flimflam::kProviderHostProperty, "");
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200213 if (vpnhost.empty()) {
214 Error::PopulateAndLog(
215 error, Error::kInvalidArguments, "VPN host not specified.");
Darin Petkov209e6292012-04-20 11:33:32 +0200216 return false;
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200217 }
218
219 if (!InitPSKOptions(options, error)) {
Darin Petkov209e6292012-04-20 11:33:32 +0200220 return false;
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200221 }
222
223 options->push_back("--remote_host");
224 options->push_back(vpnhost);
225 options->push_back("--pppd_plugin");
226 options->push_back(kPPPDPlugin);
227 // Disable pppd from configuring IP addresses, routes, DNS.
228 options->push_back("--nosystemconfig");
229
230 InitNSSOptions(options);
231
232 AppendValueOption(flimflam::kL2tpIpsecClientCertIdProperty,
233 "--client_cert_id", options);
234 AppendValueOption(flimflam::kL2tpIpsecClientCertSlotProperty,
235 "--client_cert_slot", options);
236 AppendValueOption(flimflam::kL2tpIpsecPinProperty, "--user_pin", options);
237 AppendValueOption(flimflam::kL2tpIpsecUserProperty, "--user", options);
238 AppendValueOption(kL2TPIPSecIPSecTimeoutProperty, "--ipsec_timeout", options);
239 AppendValueOption(kL2TPIPSecLeftProtoPortProperty,
240 "--leftprotoport", options);
241 AppendFlag(kL2TPIPSecPFSProperty, "--pfs", "--nopfs", options);
242 AppendFlag(kL2TPIPSecRekeyProperty, "--rekey", "--norekey", options);
243 AppendValueOption(kL2TPIPSecRightProtoPortProperty,
244 "--rightprotoport", options);
245 AppendFlag(kL2TPIPSecRequireChapProperty,
246 "--require_chap", "--norequire_chap", options);
247 AppendFlag(kL2TPIPSecRefusePapProperty,
248 "--refuse_pap", "--norefuse_pap", options);
249 AppendFlag(kL2TPIPSecRequireAuthProperty,
250 "--require_authentication", "--norequire_authentication", options);
251 AppendFlag(kL2TPIPSecLengthBitProperty,
252 "--length_bit", "--nolength_bit", options);
Darin Petkov209e6292012-04-20 11:33:32 +0200253 if (SLOG_IS_ON(VPN, 0)) {
254 options->push_back("--debug");
255 }
256 return true;
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200257}
258
259bool L2TPIPSecDriver::InitPSKOptions(vector<string> *options, Error *error) {
Darin Petkov01c66042012-04-26 11:10:45 +0200260 string psk = args()->LookupString(flimflam::kL2tpIpsecPskProperty, "");
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200261 if (!psk.empty()) {
262 if (!file_util::CreateTemporaryFileInDir(
Darin Petkov0e9735d2012-04-24 12:33:45 +0200263 manager()->run_path(), &psk_file_) ||
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200264 chmod(psk_file_.value().c_str(), S_IRUSR | S_IWUSR) ||
265 file_util::WriteFile(psk_file_, psk.data(), psk.size()) !=
266 static_cast<int>(psk.size())) {
267 Error::PopulateAndLog(
268 error, Error::kInternalError, "Unable to setup psk file.");
269 return false;
270 }
271 options->push_back("--psk_file");
272 options->push_back(psk_file_.value());
273 }
274 return true;
275}
276
277void L2TPIPSecDriver::InitNSSOptions(vector<string> *options) {
278 string ca_cert =
Darin Petkov01c66042012-04-26 11:10:45 +0200279 args()->LookupString(flimflam::kL2tpIpsecCaCertNssProperty, "");
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200280 if (!ca_cert.empty()) {
Darin Petkov01c66042012-04-26 11:10:45 +0200281 const string &vpnhost = args()->GetString(flimflam::kProviderHostProperty);
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200282 vector<char> id(vpnhost.begin(), vpnhost.end());
283 FilePath certfile = nss_->GetDERCertfile(ca_cert, id);
284 if (certfile.empty()) {
285 LOG(ERROR) << "Unable to extract certificate: " << ca_cert;
286 } else {
287 options->push_back("--server_ca_file");
288 options->push_back(certfile.value());
289 }
290 }
291}
292
293bool L2TPIPSecDriver::AppendValueOption(
294 const string &property, const string &option, vector<string> *options) {
Darin Petkov01c66042012-04-26 11:10:45 +0200295 string value = args()->LookupString(property, "");
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200296 if (!value.empty()) {
297 options->push_back(option);
298 options->push_back(value);
299 return true;
300 }
301 return false;
302}
303
304bool L2TPIPSecDriver::AppendFlag(const string &property,
305 const string &true_option,
306 const string &false_option,
307 vector<string> *options) {
Darin Petkov01c66042012-04-26 11:10:45 +0200308 string value = args()->LookupString(property, "");
Darin Petkovf7ef50a2012-04-16 20:54:31 +0200309 if (!value.empty()) {
310 options->push_back(value == "true" ? true_option : false_option);
311 return true;
312 }
313 return false;
314}
315
Darin Petkov209e6292012-04-20 11:33:32 +0200316// static
317void L2TPIPSecDriver::OnL2TPIPSecVPNDied(GPid pid, gint status, gpointer data) {
318 SLOG(VPN, 2) << __func__ << "(" << pid << ", " << status << ")";
319 L2TPIPSecDriver *me = reinterpret_cast<L2TPIPSecDriver *>(data);
320 me->child_watch_tag_ = 0;
321 CHECK_EQ(pid, me->pid_);
Darin Petkov5a850472012-06-06 15:44:24 +0200322 me->pid_ = 0;
Darin Petkov209e6292012-04-20 11:33:32 +0200323 me->Cleanup(Service::kStateFailure);
324 // TODO(petkov): Figure if we need to restart the connection.
325}
326
327void L2TPIPSecDriver::GetLogin(string *user, string *password) {
Darin Petkov602303f2012-06-06 12:15:59 +0200328 LOG(INFO) << "Login requested.";
Darin Petkov209e6292012-04-20 11:33:32 +0200329 string user_property =
Darin Petkov01c66042012-04-26 11:10:45 +0200330 args()->LookupString(flimflam::kL2tpIpsecUserProperty, "");
Darin Petkov209e6292012-04-20 11:33:32 +0200331 if (user_property.empty()) {
332 LOG(ERROR) << "User not set.";
333 return;
334 }
335 string password_property =
Darin Petkov01c66042012-04-26 11:10:45 +0200336 args()->LookupString(flimflam::kL2tpIpsecPasswordProperty, "");
Darin Petkov209e6292012-04-20 11:33:32 +0200337 if (password_property.empty()) {
338 LOG(ERROR) << "Password not set.";
339 return;
340 }
341 *user = user_property;
342 *password = password_property;
343}
344
Darin Petkov0e9735d2012-04-24 12:33:45 +0200345void L2TPIPSecDriver::ParseIPConfiguration(
346 const map<string, string> &configuration,
347 IPConfig::Properties *properties,
348 string *interface_name) {
349 properties->address_family = IPAddress::kFamilyIPv4;
350 properties->subnet_prefix = IPAddress::GetMaxPrefixLength(
351 properties->address_family);
352 for (map<string, string>::const_iterator it = configuration.begin();
353 it != configuration.end(); ++it) {
354 const string &key = it->first;
355 const string &value = it->second;
356 SLOG(VPN, 2) << "Processing: " << key << " -> " << value;
Darin Petkov95f317f2012-10-22 13:37:43 +0200357 if (key == kL2TPIPSecInternalIP4Address) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200358 properties->address = value;
Darin Petkov95f317f2012-10-22 13:37:43 +0200359 } else if (key == kL2TPIPSecExternalIP4Address) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200360 properties->peer_address = value;
Darin Petkov95f317f2012-10-22 13:37:43 +0200361 } else if (key == kL2TPIPSecGatewayAddress) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200362 properties->gateway = value;
Darin Petkov95f317f2012-10-22 13:37:43 +0200363 } else if (key == kL2TPIPSecDNS1) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200364 properties->dns_servers.insert(properties->dns_servers.begin(), value);
Darin Petkov95f317f2012-10-22 13:37:43 +0200365 } else if (key == kL2TPIPSecDNS2) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200366 properties->dns_servers.push_back(value);
Darin Petkov95f317f2012-10-22 13:37:43 +0200367 } else if (key == kL2TPIPSecInterfaceName) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200368 *interface_name = value;
Darin Petkov95f317f2012-10-22 13:37:43 +0200369 } else if (key == kL2TPIPSecLNSAddress) {
Darin Petkov0e9735d2012-04-24 12:33:45 +0200370 properties->trusted_ip = value;
371 } else {
372 SLOG(VPN, 2) << "Key ignored.";
373 }
374 }
Ben Chana0163122012-09-25 15:10:52 -0700375
376 // There is no IPv6 support for L2TP/IPsec VPN at this moment, so create a
377 // blackhole route for IPv6 traffic after establishing a IPv4 VPN.
378 // TODO(benchan): Generalize this when IPv6 support is added.
379 properties->blackhole_ipv6 = true;
Darin Petkov0e9735d2012-04-24 12:33:45 +0200380}
381
Darin Petkov209e6292012-04-20 11:33:32 +0200382void L2TPIPSecDriver::Notify(
383 const string &reason, const map<string, string> &dict) {
Darin Petkov602303f2012-06-06 12:15:59 +0200384 LOG(INFO) << "IP configuration received: " << reason;
Darin Petkov0e9735d2012-04-24 12:33:45 +0200385
Darin Petkov95f317f2012-10-22 13:37:43 +0200386 if (reason != kL2TPIPSecReasonConnect) {
Darin Petkova0e645e2012-04-25 11:38:59 +0200387 device_->OnDisconnected();
Darin Petkov0e9735d2012-04-24 12:33:45 +0200388 return;
389 }
390
Darin Petkovf8046b82012-04-24 16:29:23 +0200391 DeletePSKFile();
392
Darin Petkov0e9735d2012-04-24 12:33:45 +0200393 IPConfig::Properties properties;
394 string interface_name;
395 ParseIPConfiguration(dict, &properties, &interface_name);
Darin Petkovf8046b82012-04-24 16:29:23 +0200396
397 int interface_index = device_info_->GetIndex(interface_name);
398 if (interface_index < 0) {
399 // TODO(petkov): Consider handling the race when the RTNL notification about
400 // the new PPP device has not been received yet. We can keep the IP
Darin Petkovf8f970a2012-09-03 11:32:55 +0200401 // configuration and apply it when ClaimInterface is
402 // invoked. crosbug.com/29970.
Darin Petkovf8046b82012-04-24 16:29:23 +0200403 NOTIMPLEMENTED() << ": No device info for " << interface_name << ".";
404 return;
405 }
406
407 if (!device_) {
Darin Petkov602303f2012-06-06 12:15:59 +0200408 device_ = new VPN(control_, dispatcher(), metrics_, manager(),
Darin Petkovf8046b82012-04-24 16:29:23 +0200409 interface_name, interface_index);
410 }
411 device_->SetEnabled(true);
412 device_->SelectService(service_);
Darin Petkovf8046b82012-04-24 16:29:23 +0200413 device_->UpdateIPConfig(properties);
Darin Petkov602303f2012-06-06 12:15:59 +0200414 StopConnectTimeout();
Darin Petkov209e6292012-04-20 11:33:32 +0200415}
416
Darin Petkovb536a742012-04-26 11:31:28 +0200417KeyValueStore L2TPIPSecDriver::GetProvider(Error *error) {
418 SLOG(VPN, 2) << __func__;
419 KeyValueStore props = VPNDriver::GetProvider(error);
420 props.SetBool(flimflam::kPassphraseRequiredProperty,
421 args()->LookupString(
422 flimflam::kL2tpIpsecPasswordProperty, "").empty());
423 props.SetBool(flimflam::kL2tpIpsecPskRequiredProperty,
424 args()->LookupString(
425 flimflam::kL2tpIpsecPskProperty, "").empty());
426 return props;
427}
428
Darin Petkov7476a262012-04-12 16:30:46 +0200429} // namespace shill