2 * @file configuration.c
4 * @brief Implementation of configuration_t.
9 * Copyright (C) 2006 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
25 #include "configuration.h"
30 * First retransmit timeout in milliseconds.
31 * Timeout value is increasing in each retransmit round.
33 #define RETRANSMIT_TIMEOUT 3000
36 * Timeout in milliseconds after that a half open IKE_SA gets deleted.
38 #define HALF_OPEN_IKE_SA_TIMEOUT 30000
41 * Max retransmit count.
42 * 0 for infinite. The max time a half open IKE_SA is alive is set by
45 #define MAX_RETRANSMIT_COUNT 0
48 typedef struct private_configuration_t private_configuration_t
;
51 * Private data of an configuration_t object.
53 struct private_configuration_t
{
56 * Public part of configuration_t object.
58 configuration_t
public;
63 * Implementation of configuration_t.get_retransmit_timeout.
65 static status_t
get_retransmit_timeout (private_configuration_t
*this, u_int32_t retransmit_count
, u_int32_t
*timeout
)
67 int new_timeout
= RETRANSMIT_TIMEOUT
, i
;
68 if (retransmit_count
> MAX_RETRANSMIT_COUNT
&& MAX_RETRANSMIT_COUNT
!= 0)
73 for (i
= 0; i
< retransmit_count
; i
++)
78 *timeout
= new_timeout
;
84 * Implementation of configuration_t.get_half_open_ike_sa_timeout.
86 static u_int32_t
get_half_open_ike_sa_timeout (private_configuration_t
*this)
88 return HALF_OPEN_IKE_SA_TIMEOUT
;
92 * Implementation of configuration_t.destroy.
94 static void destroy(private_configuration_t
*this)
100 * Described in header-file
102 configuration_t
*configuration_create()
104 private_configuration_t
*this = malloc_thing(private_configuration_t
);
106 /* public functions */
107 this->public.destroy
= (void(*)(configuration_t
*))destroy
;
108 this->public.get_retransmit_timeout
= (status_t (*) (configuration_t
*, u_int32_t retransmit_count
, u_int32_t
*timeout
))get_retransmit_timeout
;
109 this->public.get_half_open_ike_sa_timeout
= (u_int32_t (*) (configuration_t
*)) get_half_open_ike_sa_timeout
;
111 return (&this->public);