diff options
author | Timo Teräs <timo.teras@iki.fi> | 2015-09-21 13:41:58 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2017-11-20 10:45:02 +0200 |
commit | ea546194df7e5d181cdfc1b236e21f973080be51 (patch) | |
tree | f9b401bfa8405f99f58159cc73eed25e22cf7bd1 /src/libcharon/control/controller.c | |
parent | 1d669ed02aca9e797db9fbca3eb1198dc19c292e (diff) | |
download | strongswan-ea546194df7e5d181cdfc1b236e21f973080be51.tar.bz2 strongswan-ea546194df7e5d181cdfc1b236e21f973080be51.tar.xz |
charon: add optional source and remote overrides for initiate
This introduces support for specifying optional IKE SA specific
source and remote address for child sa initiation. This allows
to initiate wildcard connection for known address via vici.
In addition this allows impler implementation of trap-any patches
and is a prerequisite for dmvpn support.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Diffstat (limited to 'src/libcharon/control/controller.c')
-rw-r--r-- | src/libcharon/control/controller.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/libcharon/control/controller.c b/src/libcharon/control/controller.c index 44a4d0aa8..88c04b16c 100644 --- a/src/libcharon/control/controller.c +++ b/src/libcharon/control/controller.c @@ -15,6 +15,28 @@ * for more details. */ +/* + * Copyright (C) 2014 Timo Teräs <timo.teras@iki.fi> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include "controller.h" #include <sys/types.h> @@ -103,6 +125,16 @@ struct interface_listener_t { ike_sa_t *ike_sa; /** + * Our host hint. + */ + host_t *my_host; + + /** + * Other host hint. + */ + host_t *other_host; + + /** * unique ID, used for various methods */ uint32_t id; @@ -402,9 +434,14 @@ METHOD(job_t, initiate_execute, job_requeue_t, ike_sa_t *ike_sa; interface_listener_t *listener = &job->listener; peer_cfg_t *peer_cfg = listener->peer_cfg; + host_t *my_host = listener->my_host; + host_t *other_host = listener->other_host; ike_sa = charon->ike_sa_manager->checkout_by_config(charon->ike_sa_manager, - peer_cfg); + peer_cfg, my_host, other_host); + DESTROY_IF(my_host); + DESTROY_IF(other_host); + if (!ike_sa) { listener->child_cfg->destroy(listener->child_cfg); @@ -413,6 +450,7 @@ METHOD(job_t, initiate_execute, job_requeue_t, listener_done(listener); return JOB_REQUEUE_NONE; } + listener->lock->lock(listener->lock); listener->ike_sa = ike_sa; listener->lock->unlock(listener->lock); @@ -485,6 +523,7 @@ METHOD(job_t, initiate_execute, job_requeue_t, METHOD(controller_t, initiate, status_t, private_controller_t *this, peer_cfg_t *peer_cfg, child_cfg_t *child_cfg, + host_t *my_host, host_t *other_host, controller_cb_t callback, void *param, u_int timeout, bool limits) { interface_job_t *job; @@ -507,6 +546,8 @@ METHOD(controller_t, initiate, status_t, .status = FAILED, .child_cfg = child_cfg, .peer_cfg = peer_cfg, + .my_host = my_host ? my_host->clone(my_host) : NULL, + .other_host = other_host ? other_host->clone(other_host) : NULL, .lock = spinlock_create(), .limits = limits, }, |