2006-05-31 14:23:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Martin Willi
|
|
|
|
* 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 <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* 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 "rekey_child_sa_job.h"
|
|
|
|
|
|
|
|
#include <daemon.h>
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct private_rekey_child_sa_job_t private_rekey_child_sa_job_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data of an rekey_child_sa_job_t object.
|
|
|
|
*/
|
|
|
|
struct private_rekey_child_sa_job_t {
|
|
|
|
/**
|
|
|
|
* Public rekey_child_sa_job_t interface.
|
|
|
|
*/
|
|
|
|
rekey_child_sa_job_t public;
|
|
|
|
|
2006-07-21 13:31:53 +00:00
|
|
|
/**
|
|
|
|
* reqid of the child to rekey
|
|
|
|
*/
|
|
|
|
u_int32_t reqid;
|
|
|
|
|
2006-05-31 14:23:15 +00:00
|
|
|
/**
|
2006-07-07 07:04:07 +00:00
|
|
|
* protocol of the CHILD_SA (ESP/AH)
|
2006-05-31 14:23:15 +00:00
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
protocol_id_t protocol;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* inbound SPI of the CHILD_SA
|
|
|
|
*/
|
|
|
|
u_int32_t spi;
|
2006-05-31 14:23:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2007-06-11 10:57:19 +00:00
|
|
|
* Implementation of job_t.destroy.
|
2006-05-31 14:23:15 +00:00
|
|
|
*/
|
2007-06-11 10:57:19 +00:00
|
|
|
static void destroy(private_rekey_child_sa_job_t *this)
|
2006-05-31 14:23:15 +00:00
|
|
|
{
|
2007-06-11 10:57:19 +00:00
|
|
|
free(this);
|
2006-05-31 14:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of job_t.execute.
|
|
|
|
*/
|
2007-06-11 10:57:19 +00:00
|
|
|
static void execute(private_rekey_child_sa_job_t *this)
|
2006-05-31 14:23:15 +00:00
|
|
|
{
|
|
|
|
ike_sa_t *ike_sa;
|
|
|
|
|
2007-02-28 14:04:36 +00:00
|
|
|
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
|
|
|
|
this->reqid, TRUE);
|
2006-07-21 13:31:53 +00:00
|
|
|
if (ike_sa == NULL)
|
2006-05-31 14:23:15 +00:00
|
|
|
{
|
2006-10-26 09:46:56 +00:00
|
|
|
DBG2(DBG_JOB, "CHILD_SA with reqid %d not found for rekeying",
|
2006-10-18 11:46:13 +00:00
|
|
|
this->reqid);
|
2006-05-31 14:23:15 +00:00
|
|
|
}
|
2007-06-11 10:57:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ike_sa->rekey_child_sa(ike_sa, this->protocol, this->spi);
|
|
|
|
charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
|
|
|
|
}
|
|
|
|
destroy(this);
|
2006-05-31 14:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Described in header
|
|
|
|
*/
|
2006-07-21 13:31:53 +00:00
|
|
|
rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
|
|
|
|
protocol_id_t protocol,
|
|
|
|
u_int32_t spi)
|
2006-05-31 14:23:15 +00:00
|
|
|
{
|
|
|
|
private_rekey_child_sa_job_t *this = malloc_thing(private_rekey_child_sa_job_t);
|
|
|
|
|
|
|
|
/* interface functions */
|
2007-06-11 10:57:19 +00:00
|
|
|
this->public.job_interface.execute = (void (*) (job_t *)) execute;
|
2006-05-31 14:23:15 +00:00
|
|
|
this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
|
|
|
|
|
|
|
|
/* private variables */
|
2006-07-21 13:31:53 +00:00
|
|
|
this->reqid = reqid;
|
2006-07-07 07:04:07 +00:00
|
|
|
this->protocol = protocol;
|
|
|
|
this->spi = spi;
|
2006-05-31 14:23:15 +00:00
|
|
|
|
2007-06-11 10:57:19 +00:00
|
|
|
return &this->public;
|
2006-05-31 14:23:15 +00:00
|
|
|
}
|