2 * @file retransmit_request_job.c
4 * @brief Implementation of retransmit_request_job_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
23 #include "retransmit_request_job.h"
28 typedef struct private_retransmit_request_job_t private_retransmit_request_job_t
;
31 * Private data of an retransmit_request_job_t Object.
33 struct private_retransmit_request_job_t
{
35 * Public retransmit_request_job_t interface.
37 retransmit_request_job_t
public;
40 * Message ID of the request to resend.
45 * ID of the IKE_SA which the message belongs to.
47 ike_sa_id_t
*ike_sa_id
;
50 * Number of times a request was retransmitted
52 u_int32_t retransmit_count
;
57 * Implements job_t.get_type.
59 static job_type_t
get_type(private_retransmit_request_job_t
*this)
61 return RETRANSMIT_REQUEST
;
65 * Implements retransmit_request_job_t.get_ike_sa_id.
67 static ike_sa_id_t
*get_ike_sa_id(private_retransmit_request_job_t
*this)
69 return this->ike_sa_id
;
73 * Implements retransmit_request_job_t.get_retransmit_count.
75 static u_int32_t
get_retransmit_count(private_retransmit_request_job_t
*this)
77 return this->retransmit_count
;
81 * Implements retransmit_request_job_t.increase_retransmit_count.
83 static void increase_retransmit_count(private_retransmit_request_job_t
*this)
85 this->retransmit_count
++;
89 * Implements retransmit_request_job_t.get_message_id.
91 static u_int32_t
get_message_id(private_retransmit_request_job_t
*this)
93 return this->message_id
;
98 * Implements job_t.destroy.
100 static void destroy(private_retransmit_request_job_t
*this)
102 this->ike_sa_id
->destroy(this->ike_sa_id
);
107 * Described in header.
109 retransmit_request_job_t
*retransmit_request_job_create(u_int32_t message_id
,ike_sa_id_t
*ike_sa_id
)
111 private_retransmit_request_job_t
*this = malloc_thing(private_retransmit_request_job_t
);
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
;
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
;
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
);
131 return &(this->public);