Removed strayed code fragment
[strongswan.git] / src / charon / processing / jobs / send_keepalive_job.c
1 /*
2 * Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include <stdlib.h>
17
18 #include "send_keepalive_job.h"
19
20 #include <sa/ike_sa.h>
21 #include <daemon.h>
22
23
24 typedef struct private_send_keepalive_job_t private_send_keepalive_job_t;
25
26 /**
27 * Private data of an send_keepalive_job_t Object
28 */
29 struct private_send_keepalive_job_t {
30 /**
31 * public send_keepalive_job_t interface
32 */
33 send_keepalive_job_t public;
34
35 /**
36 * ID of the IKE_SA which the message belongs to.
37 */
38 ike_sa_id_t *ike_sa_id;
39 };
40
41 /**
42 * Implements job_t.destroy.
43 */
44 static void destroy(private_send_keepalive_job_t *this)
45 {
46 this->ike_sa_id->destroy(this->ike_sa_id);
47 free(this);
48 }
49
50 /**
51 * Implementation of job_t.execute.
52 */
53 static void execute(private_send_keepalive_job_t *this)
54 {
55 ike_sa_t *ike_sa;
56
57 ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
58 this->ike_sa_id);
59 if (ike_sa)
60 {
61 ike_sa->send_keepalive(ike_sa);
62 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
63 }
64 destroy(this);
65 }
66
67 /*
68 * Described in header
69 */
70 send_keepalive_job_t *send_keepalive_job_create(ike_sa_id_t *ike_sa_id)
71 {
72 private_send_keepalive_job_t *this = malloc_thing(private_send_keepalive_job_t);
73
74 /* interface functions */
75 this->public.job_interface.execute = (void (*) (job_t *)) execute;
76 this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
77
78 /* private variables */
79 this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
80
81 return &this->public;
82 }