2 * Copyright (C) 2012 Martin Willi
3 * Copyright (C) 2012 revosec AG
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "dpd_timeout_job.h"
20 #include <sa/ike_sa.h>
24 typedef struct private_dpd_timeout_job_t private_dpd_timeout_job_t
;
29 struct private_dpd_timeout_job_t
{
32 * public dpd_timeout_job_t interface
34 dpd_timeout_job_t
public;
39 ike_sa_id_t
*ike_sa_id
;
42 * Timestamp of first DPD check
47 METHOD(job_t
, destroy
, void,
48 private_dpd_timeout_job_t
*this)
50 this->ike_sa_id
->destroy(this->ike_sa_id
);
54 METHOD(job_t
, execute
, void,
55 private_dpd_timeout_job_t
*this)
59 ike_sa
= charon
->ike_sa_manager
->checkout(charon
->ike_sa_manager
,
63 /* check if no incoming packet during timeout, reestalish SA */
64 if (ike_sa
->get_statistic(ike_sa
, STAT_INBOUND
) < this->check
)
66 DBG1(DBG_JOB
, "DPD check timed out, enforcing DPD action");
67 if (ike_sa
->reestablish(ike_sa
) == SUCCESS
)
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 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, ike_sa
);
85 METHOD(job_t
, get_priority
, job_priority_t
,
86 private_dpd_timeout_job_t
*this)
94 dpd_timeout_job_t
*dpd_timeout_job_create(ike_sa_id_t
*ike_sa_id
)
96 private_dpd_timeout_job_t
*this;
102 .get_priority
= _get_priority
,
106 .ike_sa_id
= ike_sa_id
->clone(ike_sa_id
),
107 .check
= time_monotonic(NULL
),
110 return &this->public;