]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libcharon/processing/jobs/send_dpd_job.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / processing / jobs / send_dpd_job.c
1 /*
2 * Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
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>.
10 *
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
14 * for more details.
15 */
16
17 #include <stdlib.h>
18
19 #include "send_dpd_job.h"
20
21 #include <sa/ike_sa.h>
22 #include <daemon.h>
23
24
25 typedef struct private_send_dpd_job_t private_send_dpd_job_t;
26
27 /**
28 * Private data of an send_dpd_job_t Object
29 */
30 struct private_send_dpd_job_t {
31 /**
32 * public send_dpd_job_t interface
33 */
34 send_dpd_job_t public;
35
36 /**
37 * ID of the IKE_SA which the message belongs to.
38 */
39 ike_sa_id_t *ike_sa_id;
40 };
41
42 METHOD(job_t, destroy, void,
43 private_send_dpd_job_t *this)
44 {
45 this->ike_sa_id->destroy(this->ike_sa_id);
46 free(this);
47 }
48
49 METHOD(job_t, execute, job_requeue_t,
50 private_send_dpd_job_t *this)
51 {
52 ike_sa_t *ike_sa;
53
54 ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
55 this->ike_sa_id);
56 if (ike_sa)
57 {
58 if (ike_sa->send_dpd(ike_sa) == DESTROY_ME)
59 {
60 charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, ike_sa);
61 }
62 else
63 {
64 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
65 }
66 }
67 return JOB_REQUEUE_NONE;
68 }
69
70 METHOD(job_t, get_priority, job_priority_t,
71 private_send_dpd_job_t *this)
72 {
73 return JOB_PRIO_HIGH;
74 }
75
76 /*
77 * Described in header
78 */
79 send_dpd_job_t *send_dpd_job_create(ike_sa_id_t *ike_sa_id)
80 {
81 private_send_dpd_job_t *this;
82
83 INIT(this,
84 .public = {
85 .job_interface = {
86 .execute = _execute,
87 .get_priority = _get_priority,
88 .destroy = _destroy,
89 },
90 },
91 .ike_sa_id = ike_sa_id->clone(ike_sa_id),
92 );
93
94 return &this->public;
95 }