2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 #include "delete_ike_sa_job.h"
21 typedef struct private_delete_ike_sa_job_t private_delete_ike_sa_job_t
;
24 * Private data of an delete_ike_sa_job_t Object
26 struct private_delete_ike_sa_job_t
{
28 * public delete_ike_sa_job_t interface
30 delete_ike_sa_job_t
public;
33 * ID of the ike_sa to delete
35 ike_sa_id_t
*ike_sa_id
;
38 * Should the IKE_SA be deleted if it is in ESTABLISHED state?
40 bool delete_if_established
;
44 METHOD(job_t
, destroy
, void,
45 private_delete_ike_sa_job_t
*this)
47 this->ike_sa_id
->destroy(this->ike_sa_id
);
51 METHOD(job_t
, execute
, void,
52 private_delete_ike_sa_job_t
*this)
56 ike_sa
= charon
->ike_sa_manager
->checkout(charon
->ike_sa_manager
,
60 if (ike_sa
->get_state(ike_sa
) == IKE_PASSIVE
)
62 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, ike_sa
);
65 if (this->delete_if_established
)
67 if (ike_sa
->delete(ike_sa
) == DESTROY_ME
)
69 charon
->ike_sa_manager
->checkin_and_destroy(
70 charon
->ike_sa_manager
, ike_sa
);
74 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, ike_sa
);
79 /* destroy only if not ESTABLISHED */
80 if (ike_sa
->get_state(ike_sa
) == IKE_ESTABLISHED
)
82 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, ike_sa
);
86 DBG1(DBG_JOB
, "deleting half open IKE_SA after timeout");
87 charon
->ike_sa_manager
->checkin_and_destroy(
88 charon
->ike_sa_manager
, ike_sa
);
98 delete_ike_sa_job_t
*delete_ike_sa_job_create(ike_sa_id_t
*ike_sa_id
,
99 bool delete_if_established
)
101 private_delete_ike_sa_job_t
*this;
110 .ike_sa_id
= ike_sa_id
->clone(ike_sa_id
),
111 .delete_if_established
= delete_if_established
,
114 return &(this->public);