From 2e210e3ef5e798dd194318c5a8a8a24271684dd3 Mon Sep 17 00:00:00 2001 From: Clavister OpenSource Date: Tue, 29 Nov 2011 09:24:29 +0100 Subject: [PATCH] IKEv1 XAuth: Added a job to call the initiate_xauth method of ike_sa after the completion of the current set of tasks is complete. --- src/libcharon/Makefile.am | 1 + src/libcharon/processing/jobs/initiate_xauth_job.c | 85 ++++++++++++++++++++++ src/libcharon/processing/jobs/initiate_xauth_job.h | 49 +++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 src/libcharon/processing/jobs/initiate_xauth_job.c create mode 100644 src/libcharon/processing/jobs/initiate_xauth_job.h diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am index 6f3151a..5387749 100644 --- a/src/libcharon/Makefile.am +++ b/src/libcharon/Makefile.am @@ -57,6 +57,7 @@ processing/jobs/start_action_job.c processing/jobs/start_action_job.h \ processing/jobs/roam_job.c processing/jobs/roam_job.h \ processing/jobs/update_sa_job.c processing/jobs/update_sa_job.h \ processing/jobs/inactivity_job.c processing/jobs/inactivity_job.h \ +processing/jobs/initiate_xauth_job.c processing/jobs/initiate_xauth_job.h \ sa/authenticators/authenticator.c sa/authenticators/authenticator.h \ sa/authenticators/eap_authenticator.c sa/authenticators/eap_authenticator.h \ sa/authenticators/eap/eap_method.c sa/authenticators/eap/eap_method.h \ diff --git a/src/libcharon/processing/jobs/initiate_xauth_job.c b/src/libcharon/processing/jobs/initiate_xauth_job.c new file mode 100644 index 0000000..0ec12df --- /dev/null +++ b/src/libcharon/processing/jobs/initiate_xauth_job.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2007-2008 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "initiate_xauth_job.h" + +#include +#include + + +typedef struct private_initiate_xauth_job_t private_initiate_xauth_job_t; + +/** + * Private data of an initiate_xauth_job_t Object + */ +struct private_initiate_xauth_job_t { + /** + * public initiate_xauth_job_t interface + */ + initiate_xauth_job_t public; + + /** + * ID of the IKE_SA of the mediated connection. + */ + ike_sa_id_t *ike_sa_id; +}; + +METHOD(job_t, destroy, void, + private_initiate_xauth_job_t *this) +{ + DESTROY_IF(this->ike_sa_id); + free(this); +} + +METHOD(job_t, initiate, void, + private_initiate_xauth_job_t *this) +{ + ike_sa_t *ike_sa; + + ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, + this->ike_sa_id); + if (ike_sa) + { + DBG1(DBG_IKE, "INITIATING XAUTH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + ike_sa->initiate_xauth(ike_sa); + charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); + } + destroy(this); +} + +METHOD(job_t, get_priority, job_priority_t, + private_initiate_xauth_job_t *this) +{ + return JOB_PRIO_MEDIUM; +} + +/** + * Creates an empty job + */ +initiate_xauth_job_t *initiate_xauth_job_create(ike_sa_id_t *ike_sa_id) +{ + private_initiate_xauth_job_t *this; + INIT(this, + .public = { + .job_interface = { + .get_priority = _get_priority, + .destroy = _destroy, + .execute = _initiate, + }, + }, + .ike_sa_id = ike_sa_id->clone(ike_sa_id), + ); + return &this->public; +} diff --git a/src/libcharon/processing/jobs/initiate_xauth_job.h b/src/libcharon/processing/jobs/initiate_xauth_job.h new file mode 100644 index 0000000..9027141 --- /dev/null +++ b/src/libcharon/processing/jobs/initiate_xauth_job.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007-2008 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup initiate_xauth_job initiate_xauth_job + * @{ @ingroup cjobs + */ + +#ifndef INITIATE_XAUTH_JOB_H_ +#define INITIATE_XAUTH_JOB_H_ + +typedef struct initiate_xauth_job_t initiate_xauth_job_t; + +#include +#include + +/** + * Class representing a INITIATE_XAUTH Job. + * + * This job will an XAuth authentication exchange. + */ +struct initiate_xauth_job_t { + /** + * implements job_t interface + */ + job_t job_interface; +}; + +/** + * Creates a job of type INITIATE_XAUTH. + * + * @param ike_sa_id_t identification of the ike_sa as ike_sa_id_t object (gets cloned) + * @return job object + */ +initiate_xauth_job_t *initiate_xauth_job_create(ike_sa_id_t *ike_sa_id); + +#endif /** INITIATE_XAUTH_JOB_H_ @}*/ -- 2.7.4