Removed strayed code fragment
[strongswan.git] / src / charon / processing / jobs / retransmit_job.c
1 /*
2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
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 "retransmit_job.h"
18
19 #include <daemon.h>
20
21 typedef struct private_retransmit_job_t private_retransmit_job_t;
22
23 /**
24 * Private data of an retransmit_job_t Object.
25 */
26 struct private_retransmit_job_t {
27 /**
28 * Public retransmit_job_t interface.
29 */
30 retransmit_job_t public;
31
32 /**
33 * Message ID of the request to resend.
34 */
35 u_int32_t message_id;
36
37 /**
38 * ID of the IKE_SA which the message belongs to.
39 */
40 ike_sa_id_t *ike_sa_id;
41 };
42
43 /**
44 * Implements job_t.destroy.
45 */
46 static void destroy(private_retransmit_job_t *this)
47 {
48 this->ike_sa_id->destroy(this->ike_sa_id);
49 free(this);
50 }
51
52 /**
53 * Implementation of job_t.execute.
54 */
55 static void execute(private_retransmit_job_t *this)
56 {
57 ike_sa_t *ike_sa;
58
59 ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
60 this->ike_sa_id);
61 if (ike_sa)
62 {
63 if (ike_sa->retransmit(ike_sa, this->message_id) == DESTROY_ME)
64 {
65 /* retransmitted to many times, giving up */
66 charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,
67 ike_sa);
68 }
69 else
70 {
71 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
72 }
73 }
74 destroy(this);
75 }
76
77 /*
78 * Described in header.
79 */
80 retransmit_job_t *retransmit_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa_id)
81 {
82 private_retransmit_job_t *this = malloc_thing(private_retransmit_job_t);
83
84 /* interface functions */
85 this->public.job_interface.execute = (void (*) (job_t *)) execute;
86 this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
87
88 /* private variables */
89 this->message_id = message_id;
90 this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
91
92 return &this->public;
93 }