/src/strongswan/src/libcharon/processing/jobs/retransmit_job.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2005-2007 Martin Willi |
3 | | * Copyright (C) 2005 Jan Hutter |
4 | | * |
5 | | * Copyright (C) secunet Security Networks AG |
6 | | * |
7 | | * This program is free software; you can redistribute it and/or modify it |
8 | | * under the terms of the GNU General Public License as published by the |
9 | | * Free Software Foundation; either version 2 of the License, or (at your |
10 | | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. |
11 | | * |
12 | | * This program is distributed in the hope that it will be useful, but |
13 | | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | | * for more details. |
16 | | */ |
17 | | |
18 | | #include "retransmit_job.h" |
19 | | |
20 | | #include <daemon.h> |
21 | | |
22 | | typedef struct private_retransmit_job_t private_retransmit_job_t; |
23 | | |
24 | | /** |
25 | | * Private data of an retransmit_job_t Object. |
26 | | */ |
27 | | struct private_retransmit_job_t { |
28 | | /** |
29 | | * Public retransmit_job_t interface. |
30 | | */ |
31 | | retransmit_job_t public; |
32 | | |
33 | | /** |
34 | | * Message ID of the request to resend. |
35 | | */ |
36 | | uint32_t message_id; |
37 | | |
38 | | /** |
39 | | * ID of the IKE_SA which the message belongs to. |
40 | | */ |
41 | | ike_sa_id_t *ike_sa_id; |
42 | | }; |
43 | | |
44 | | METHOD(job_t, destroy, void, |
45 | | private_retransmit_job_t *this) |
46 | 0 | { |
47 | 0 | this->ike_sa_id->destroy(this->ike_sa_id); |
48 | 0 | free(this); |
49 | 0 | } |
50 | | |
51 | | METHOD(job_t, execute, job_requeue_t, |
52 | | private_retransmit_job_t *this) |
53 | 0 | { |
54 | 0 | ike_sa_t *ike_sa; |
55 | |
|
56 | 0 | ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, |
57 | 0 | this->ike_sa_id); |
58 | 0 | if (ike_sa) |
59 | 0 | { |
60 | 0 | if (ike_sa->retransmit(ike_sa, this->message_id) == DESTROY_ME) |
61 | 0 | { |
62 | | /* retransmitted to many times, giving up */ |
63 | 0 | charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, |
64 | 0 | ike_sa); |
65 | 0 | } |
66 | 0 | else |
67 | 0 | { |
68 | 0 | charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); |
69 | 0 | } |
70 | 0 | } |
71 | 0 | return JOB_REQUEUE_NONE; |
72 | 0 | } |
73 | | |
74 | | METHOD(job_t, get_priority, job_priority_t, |
75 | | private_retransmit_job_t *this) |
76 | 0 | { |
77 | 0 | return JOB_PRIO_HIGH; |
78 | 0 | } |
79 | | |
80 | | /* |
81 | | * Described in header. |
82 | | */ |
83 | | retransmit_job_t *retransmit_job_create(uint32_t message_id,ike_sa_id_t *ike_sa_id) |
84 | 0 | { |
85 | 0 | private_retransmit_job_t *this; |
86 | |
|
87 | 0 | INIT(this, |
88 | 0 | .public = { |
89 | 0 | .job_interface = { |
90 | 0 | .execute = _execute, |
91 | 0 | .get_priority = _get_priority, |
92 | 0 | .destroy = _destroy, |
93 | 0 | }, |
94 | 0 | }, |
95 | 0 | .message_id = message_id, |
96 | 0 | .ike_sa_id = ike_sa_id->clone(ike_sa_id), |
97 | 0 | ); |
98 | |
|
99 | 0 | return &this->public; |
100 | 0 | } |