diff options
Diffstat (limited to 'Source/charon/config')
-rw-r--r-- | Source/charon/config/configuration_manager.c | 31 | ||||
-rw-r--r-- | Source/charon/config/configuration_manager.h | 27 |
2 files changed, 52 insertions, 6 deletions
diff --git a/Source/charon/config/configuration_manager.c b/Source/charon/config/configuration_manager.c index f3c3cd4cc..2f7fc099f 100644 --- a/Source/charon/config/configuration_manager.c +++ b/Source/charon/config/configuration_manager.c @@ -123,6 +123,17 @@ struct private_configuration_manager_t { * Assigned logger object. */ logger_t *logger; + + + /** + * Max number of retransmitted requests. + */ + u_int32_t max_retransmit_count; + + /** + * First retransmit timeout in ms. + */ + u_int32_t first_retransmit_timeout; /** * Load default configuration @@ -457,6 +468,21 @@ static void add_new_configuration (private_configuration_manager_t *this, char * this->configurations->insert_first(this->configurations,configuration_entry_create(name,init_config,sa_config)); } +static status_t get_retransmit_timeout (private_configuration_manager_t *this, u_int32_t retransmit_count, u_int32_t *timeout) +{ + if ((retransmit_count > this->max_retransmit_count) && (this->max_retransmit_count != 0)) + { + return FAILED; + } + + /** + * TODO implement a good retransmit policy + */ + *timeout = this->first_retransmit_timeout * (retransmit_count + 1); + + return SUCCESS; +} + /** * Implementation of configuration_manager_t.destroy. */ @@ -499,7 +525,7 @@ static void destroy(private_configuration_manager_t *this) /* * Described in header-file */ -configuration_manager_t *configuration_manager_create() +configuration_manager_t *configuration_manager_create(u_int32_t first_retransmit_timeout,u_int32_t max_retransmit_count) { private_configuration_manager_t *this = allocator_alloc_thing(private_configuration_manager_t); @@ -509,6 +535,7 @@ configuration_manager_t *configuration_manager_create() this->public.get_init_config_for_host = (status_t (*) (configuration_manager_t *, host_t *, host_t *,init_config_t **)) get_init_config_for_host; this->public.get_sa_config_for_name =(status_t (*) (configuration_manager_t *, char *, sa_config_t **)) get_sa_config_for_name; this->public.get_sa_config_for_init_config_and_id =(status_t (*) (configuration_manager_t *, init_config_t *, identification_t *, identification_t *,sa_config_t **)) get_sa_config_for_init_config_and_id; + this->public.get_retransmit_timeout = (status_t (*) (configuration_manager_t *, u_int32_t retransmit_count, u_int32_t *timeout))get_retransmit_timeout; /* private functions */ this->load_default_config = load_default_config; @@ -519,6 +546,8 @@ configuration_manager_t *configuration_manager_create() this->configurations = linked_list_create(); this->sa_configs = linked_list_create(); this->init_configs = linked_list_create(); + this->max_retransmit_count = max_retransmit_count; + this->first_retransmit_timeout = first_retransmit_timeout; this->load_default_config(this); diff --git a/Source/charon/config/configuration_manager.h b/Source/charon/config/configuration_manager.h index 9cc6a313b..bc6c6e81f 100644 --- a/Source/charon/config/configuration_manager.h +++ b/Source/charon/config/configuration_manager.h @@ -39,7 +39,7 @@ typedef struct configuration_manager_t configuration_manager_t; struct configuration_manager_t { /** - * Gets the configuration information needed for IKE_SA_INIT exchange + * Get the configuration information needed for IKE_SA_INIT exchange * for a specific configuration name. * * The returned init_config_t object MUST NOT be destroyed cause it's the original one. @@ -55,7 +55,7 @@ struct configuration_manager_t { status_t (*get_init_config_for_name) (configuration_manager_t *this, char *name, init_config_t **init_config); /** - * Gets the configuration information needed for IKE_SA_INIT exchange + * Get the configuration information needed for IKE_SA_INIT exchange * for specific host informations. * * The returned init_config_t object MUST NOT be destroyed cause it's the original one. @@ -72,7 +72,7 @@ struct configuration_manager_t { status_t (*get_init_config_for_host) (configuration_manager_t *this, host_t *my_host, host_t *other_host,init_config_t **init_config); /** - * Gets the configuration information needed after IKE_SA_INIT exchange. + * Get the configuration information needed after IKE_SA_INIT exchange. * * The returned sa_config_t object MUST not be destroyed cause it's the original one. * @@ -87,7 +87,7 @@ struct configuration_manager_t { status_t (*get_sa_config_for_name) (configuration_manager_t *this, char *name, sa_config_t **sa_config); /** - * Gets the configuration information needed after IKE_SA_INIT exchange + * Get the configuration information needed after IKE_SA_INIT exchange * for specific init_config_t and ID data. * * The returned sa_config_t object MUST NOT be destroyed cause it's the original one. @@ -105,6 +105,21 @@ struct configuration_manager_t { status_t (*get_sa_config_for_init_config_and_id) (configuration_manager_t *this, init_config_t *init_config, identification_t *other_id, identification_t *my_id,sa_config_t **sa_config); /** + * Get the retransmit timeout. + * + * The timeout values are managed by the configuration manager. + * + * @param this calling object + * @param retransmit_count number of times a message was allready retransmitted + * @param[out] timeout the new retransmit timeout in milliseconds + * + * @return + * - FAILED if the message should not be resent again + * - SUCCESS + */ + status_t (*get_retransmit_timeout) (configuration_manager_t *this, u_int32_t retransmit_count, u_int32_t *timeout); + + /** * Destroys configuration manager * * @@ -118,12 +133,14 @@ struct configuration_manager_t { /** * Creates the mighty configuration manager * + * @param first_retransmit_timeout first retransmit timeout in milliseconds + * @param max_retransmit_count max number of retransmitted requests (0 for infinite) * @return * - pointer to created manager object if succeeded * - NULL if memory allocation failed * * @ingroup config */ -configuration_manager_t *configuration_manager_create(); +configuration_manager_t *configuration_manager_create(u_int32_t first_retransmit_timeout,u_int32_t max_retransmit_count); #endif /*CONFIGURATION_MANAGER_H_*/ |