summaryrefslogtreecommitdiff
path: root/src/charon/processing/jobs/initiate_mediation_job.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:42:46 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:42:46 +0000
commitde6b12502cdf42d5d92118f1c0e38dc31becf7c5 (patch)
tree0edac9c79f5a43e01913dd7f71c7abc487e5727b /src/charon/processing/jobs/initiate_mediation_job.c
parent172642669d4a23e17f1ed411fbc8629dcaa5fb46 (diff)
downloadvyos-strongswan-de6b12502cdf42d5d92118f1c0e38dc31becf7c5.tar.gz
vyos-strongswan-de6b12502cdf42d5d92118f1c0e38dc31becf7c5.zip
Updated to new upstream release. interfaces Patch is not from upstream.
Diffstat (limited to 'src/charon/processing/jobs/initiate_mediation_job.c')
-rw-r--r--src/charon/processing/jobs/initiate_mediation_job.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/charon/processing/jobs/initiate_mediation_job.c b/src/charon/processing/jobs/initiate_mediation_job.c
index 157d84341..ffe8755e2 100644
--- a/src/charon/processing/jobs/initiate_mediation_job.c
+++ b/src/charon/processing/jobs/initiate_mediation_job.c
@@ -29,12 +29,12 @@ struct private_initiate_mediation_job_t {
* public initiate_mediation_job_t interface
*/
initiate_mediation_job_t public;
-
+
/**
* ID of the IKE_SA of the mediated connection.
*/
ike_sa_id_t *mediated_sa_id;
-
+
/**
* ID of the IKE_SA of the mediation connection.
*/
@@ -68,26 +68,27 @@ static bool initiate_callback(private_initiate_mediation_job_t *this,
/**
* Implementation of job_t.execute.
- */
+ */
static void initiate(private_initiate_mediation_job_t *this)
{
ike_sa_t *mediated_sa, *mediation_sa;
peer_cfg_t *mediated_cfg, *mediation_cfg;
enumerator_t *enumerator;
auth_cfg_t *auth_cfg;
-
+
mediated_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
this->mediated_sa_id);
if (mediated_sa)
{
+ DBG1(DBG_IKE, "initiating mediation connection");
mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
- mediated_cfg->get_ref(mediated_cfg);
-
+ mediated_cfg->get_ref(mediated_cfg);
+
charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
-
+
mediation_cfg = mediated_cfg->get_mediated_by(mediated_cfg);
mediation_cfg->get_ref(mediation_cfg);
-
+
enumerator = mediation_cfg->create_auth_cfg_enumerator(mediation_cfg,
TRUE);
if (!enumerator->enumerate(enumerator, &auth_cfg) ||
@@ -99,7 +100,8 @@ static void initiate(private_initiate_mediation_job_t *this)
destroy(this);
return;
}
-
+ enumerator->destroy(enumerator);
+
if (charon->connect_manager->check_and_register(charon->connect_manager,
auth_cfg->get(auth_cfg, AUTH_RULE_IDENTITY),
mediated_cfg->get_peer_id(mediated_cfg),
@@ -107,7 +109,7 @@ static void initiate(private_initiate_mediation_job_t *this)
{
mediated_cfg->destroy(mediated_cfg);
mediation_cfg->destroy(mediation_cfg);
-
+
mediated_sa = charon->ike_sa_manager->checkout(
charon->ike_sa_manager, this->mediated_sa_id);
if (mediated_sa)
@@ -121,7 +123,7 @@ static void initiate(private_initiate_mediation_job_t *this)
return;
}
/* we need an additional reference because initiate consumes one */
- mediation_cfg->get_ref(mediation_cfg);
+ mediation_cfg->get_ref(mediation_cfg);
if (charon->controller->initiate(charon->controller, mediation_cfg,
NULL, (controller_cb_t)initiate_callback, this) != SUCCESS)
@@ -142,8 +144,7 @@ static void initiate(private_initiate_mediation_job_t *this)
mediation_cfg->destroy(mediation_cfg);
mediation_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
- this->mediation_sa_id);
-
+ this->mediation_sa_id);
if (mediation_sa)
{
if (mediation_sa->initiate_mediation(mediation_sa,
@@ -163,10 +164,9 @@ static void initiate(private_initiate_mediation_job_t *this)
destroy(this);
return;
}
-
- charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediation_sa);
+ charon->ike_sa_manager->checkin(charon->ike_sa_manager,
+ mediation_sa);
}
-
mediated_cfg->destroy(mediated_cfg);
}
destroy(this);
@@ -174,44 +174,50 @@ static void initiate(private_initiate_mediation_job_t *this)
/**
* Implementation of job_t.execute.
- */
+ */
static void reinitiate(private_initiate_mediation_job_t *this)
{
ike_sa_t *mediated_sa, *mediation_sa;
peer_cfg_t *mediated_cfg;
-
+
mediated_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
- this->mediated_sa_id);
+ this->mediated_sa_id);
if (mediated_sa)
{
mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
mediated_cfg->get_ref(mediated_cfg);
charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
-
+
mediation_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
- this->mediation_sa_id);
+ this->mediation_sa_id);
if (mediation_sa)
{
- if (mediation_sa->initiate_mediation(mediation_sa, mediated_cfg) != SUCCESS)
+ if (mediation_sa->initiate_mediation(mediation_sa,
+ mediated_cfg) != SUCCESS)
{
DBG1(DBG_JOB, "initiating mediated connection '%s' failed",
- mediated_cfg->get_name(mediated_cfg));
+ mediated_cfg->get_name(mediated_cfg));
mediated_cfg->destroy(mediated_cfg);
- charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, mediation_sa);
+ charon->ike_sa_manager->checkin_and_destroy(
+ charon->ike_sa_manager,
+ mediation_sa);
mediated_sa = charon->ike_sa_manager->checkout(
- charon->ike_sa_manager, this->mediated_sa_id);
+ charon->ike_sa_manager,
+ this->mediated_sa_id);
if (mediated_sa)
{
DBG1(DBG_IKE, "establishing mediation connection failed");
charon->ike_sa_manager->checkin_and_destroy(
- charon->ike_sa_manager, mediated_sa);
+ charon->ike_sa_manager,
+ mediated_sa);
}
destroy(this);
return;
}
- charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediation_sa);
+ charon->ike_sa_manager->checkin(charon->ike_sa_manager,
+ mediation_sa);
}
-
+
mediated_cfg->destroy(mediated_cfg);
}
destroy(this);
@@ -223,10 +229,10 @@ static void reinitiate(private_initiate_mediation_job_t *this)
static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
{
private_initiate_mediation_job_t *this = malloc_thing(private_initiate_mediation_job_t);
-
+
/* interface functions */
this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-
+
/* private variables */
this->mediation_sa_id = NULL;
this->mediated_sa_id = NULL;
@@ -240,9 +246,9 @@ static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
initiate_mediation_job_t *initiate_mediation_job_create(ike_sa_id_t *ike_sa_id)
{
private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
-
+
this->public.job_interface.execute = (void (*) (job_t *)) initiate;
-
+
this->mediated_sa_id = ike_sa_id->clone(ike_sa_id);
return &this->public;
@@ -255,11 +261,11 @@ initiate_mediation_job_t *reinitiate_mediation_job_create(ike_sa_id_t *mediation
ike_sa_id_t *mediated_sa_id)
{
private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
-
+
this->public.job_interface.execute = (void (*) (job_t *)) reinitiate;
-
+
this->mediation_sa_id = mediation_sa_id->clone(mediation_sa_id);
this->mediated_sa_id = mediated_sa_id->clone(mediated_sa_id);
-
- return &this->public;
+
+ return &this->public;
}