(no commit message)
[strongswan.git] / src / charon / queues / jobs / retransmit_request_job.c
1 /**
2 * @file retransmit_request_job.c
3 *
4 * @brief Implementation of retransmit_request_job_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include "retransmit_request_job.h"
24
25
26
27
28 typedef struct private_retransmit_request_job_t private_retransmit_request_job_t;
29
30 /**
31 * Private data of an retransmit_request_job_t Object.
32 */
33 struct private_retransmit_request_job_t {
34 /**
35 * Public retransmit_request_job_t interface.
36 */
37 retransmit_request_job_t public;
38
39 /**
40 * Message ID of the request to resend.
41 */
42 u_int32_t message_id;
43
44 /**
45 * ID of the IKE_SA which the message belongs to.
46 */
47 ike_sa_id_t *ike_sa_id;
48
49 /**
50 * Number of times a request was retransmitted
51 */
52 u_int32_t retransmit_count;
53 };
54
55
56 /**
57 * Implements job_t.get_type.
58 */
59 static job_type_t get_type(private_retransmit_request_job_t *this)
60 {
61 return RETRANSMIT_REQUEST;
62 }
63
64 /**
65 * Implements retransmit_request_job_t.get_ike_sa_id.
66 */
67 static ike_sa_id_t *get_ike_sa_id(private_retransmit_request_job_t *this)
68 {
69 return this->ike_sa_id;
70 }
71
72 /**
73 * Implements retransmit_request_job_t.get_retransmit_count.
74 */
75 static u_int32_t get_retransmit_count(private_retransmit_request_job_t *this)
76 {
77 return this->retransmit_count;
78 }
79
80 /**
81 * Implements retransmit_request_job_t.increase_retransmit_count.
82 */
83 static void increase_retransmit_count(private_retransmit_request_job_t *this)
84 {
85 this->retransmit_count++;
86 }
87
88 /**
89 * Implements retransmit_request_job_t.get_message_id.
90 */
91 static u_int32_t get_message_id(private_retransmit_request_job_t *this)
92 {
93 return this->message_id;
94 }
95
96
97 /**
98 * Implements job_t.destroy.
99 */
100 static void destroy(private_retransmit_request_job_t *this)
101 {
102 this->ike_sa_id->destroy(this->ike_sa_id);
103 free(this);
104 }
105
106 /*
107 * Described in header.
108 */
109 retransmit_request_job_t *retransmit_request_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa_id)
110 {
111 private_retransmit_request_job_t *this = malloc_thing(private_retransmit_request_job_t);
112
113 /* interface functions */
114 this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
115 /* same as destroy */
116 this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy;
117 this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
118
119 /* public functions */
120 this->public.get_ike_sa_id = (ike_sa_id_t * (*)(retransmit_request_job_t *)) get_ike_sa_id;
121 this->public.get_message_id = (u_int32_t (*)(retransmit_request_job_t *)) get_message_id;
122 this->public.destroy = (void (*)(retransmit_request_job_t *)) destroy;
123 this->public.get_retransmit_count = (u_int32_t (*)(retransmit_request_job_t *)) get_retransmit_count;
124 this->public.increase_retransmit_count = (void (*)(retransmit_request_job_t *)) increase_retransmit_count;
125
126 /* private variables */
127 this->message_id = message_id;
128 this->retransmit_count = 0;
129 this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
130
131 return &(this->public);
132 }