cleaned up apidoc

added some comments
removed configuration.[ch], as it does not make sense like it is
This commit is contained in:
Martin Willi
2007-04-11 07:20:39 +00:00
parent 2ed8cee162
commit 3b138b8422
27 changed files with 219 additions and 374 deletions
+6 -2
View File
@@ -6,7 +6,7 @@
*/
/*
* Copyright (C) 2006 Martin Willi
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -34,8 +34,12 @@ typedef struct backend_t backend_t;
/**
* @brief The interface for a configuration backend.
*
* A configuration backend is registered in the cfg_store. It does the actual
* configuration lookup for the method it implements. See cfg_store_t for
* more information.
*
* @b Constructors:
* - implementations constructor, such as local_backend_create()
* - none, use implementations of backend_t.
*
* @ingroup backends
*/
+1 -1
View File
@@ -84,7 +84,7 @@ struct local_backend_t {
*
* @return local_backend instance.
*
* @ingroup config
* @ingroup backends
*/
local_backend_t *local_backend_create(void);
+14 -21
View File
@@ -40,29 +40,22 @@ typedef struct cfg_store_t cfg_store_t;
* access all this backends by a single call, this class wraps multiple
* backends behind a single object.
* Backends may be registered and unregister at runtime dynamically.
*
* +---------+ +---------+ +--------------+ |
* | | | | +--------------+ | |
* | |----->| config | +--------------+ |-+ <==|==> IPC
* | | | |------>| backends |-+ |
* | daemon |----->| | +--------------+ |
* | core | +---------+ |
* | | |
* | | +---------+ +--------------+ |
* | |<-----| | +--------------+ | |
* | | | control-| +--------------+ |-+ <==|==> IPC
* | |<-----| ler |------>| controllers |-+ |
* | | | | +--------------+ |
* +---------+ +---------+ |
*
* The daemon core only knows the simple and single cfg_store interface.
* The cfg_store wraps two kind of objects, backends and trustchains.
* If the daemon needs something, it asks the cfg_store. cfg_store
* asks all of its backends if they can fullfil the request.
*
* @verbatim
+---------+ +-----------+ +--------------+ |
| | | | +--------------+ | |
| daemon |----->| cfg_store | +--------------+ |-+ <==|==> IPC
| core | | |---->| backends |-+ |
| |----->| | +--------------+ |
| | | | |
+---------+ +-----------+ |
@endverbatim
* Configuration lookup is done only when acting as responder. For initating
* the corresponding controller is responsible to get a config to initiate.
*
* @b Constructors:
* - stroke_create()
* - cfg_store_create()
*
* @ingroup config
*/
+8 -7
View File
@@ -36,7 +36,7 @@ typedef struct child_cfg_t child_cfg_t;
*
* These are equal to those defined in XFRM, so don't change.
*
* @ingroup child_cfg
* @ingroup config
*/
enum mode_t {
/** transport mode, no inner address */
@@ -57,14 +57,16 @@ extern enum_name_t *mode_names;
*
* After creation, proposals and traffic selectors may be added to the config.
* A child_cfg object is referenced multiple times, and is not thread save.
* Reading from the object is save, adding things is not allowed when other
* Reading from the object is save, adding things is not allowed while other
* threads may access the object.
* A reference counter handles the number of references hold to this config.
*
* @see peer_cfg_t to get an overview over the configurations.
*
* @b Constructors:
* - child_cfg_create()
*
* @ingroup child_cfg
* @ingroup config
*/
struct child_cfg_t {
@@ -229,11 +231,10 @@ struct child_cfg_t {
* @param mode mode to propose for CHILD_SA, transport, tunnel or BEET
* @return child_cfg_t object
*
* @ingroup child_cfg
* @ingroup config
*/
child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime,
u_int32_t rekeytime, u_int32_t jitter,
char *updown, bool hostaccess,
mode_t mode);
u_int32_t rekeytime, u_int32_t jitter,
char *updown, bool hostaccess, mode_t mode);
#endif /* CHILD_CFG_H_ */
-162
View File
@@ -1,162 +0,0 @@
/**
* @file configuration.c
*
* @brief Implementation of configuration_t.
*
*/
/*
* Copyright (C) 2006 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <stdlib.h>
#include <math.h>
#include "configuration.h"
#include <library.h>
/**
* Timeout in milliseconds after that a half open IKE_SA gets deleted.
*/
#define HALF_OPEN_IKE_SA_TIMEOUT 30000
/**
* Retransmission uses a backoff algorithm. The timeout is calculated using
* TIMEOUT * (BASE ** try).
* When try reaches TRIES, retransmission is given up.
*
* Using an initial TIMEOUT of 4s, a BASE of 1.8, and 5 TRIES gives us:
*
* | relative | absolute
* ---------------------------------------------------------
* 4s * (1.8 ** (0 % 5)) = 4s 4s
* 4s * (1.8 ** (1 % 5)) = 7s 11s
* 4s * (1.8 ** (2 % 5)) = 13s 24s
* 4s * (1.8 ** (3 % 5)) = 23s 47s
* 4s * (1.8 ** (4 % 5)) = 42s 89s
* 4s * (1.8 ** (5 % 5)) = 76s 165s
*
* The peer is considered dead after 2min 45s when no reply comes in.
*/
/**
* First retransmit timeout in milliseconds.
* Timeout value is increasing in each retransmit round.
*/
#define RETRANSMIT_TIMEOUT 4000
/**
* Base which is raised to the power of the retransmission count.
*/
#define RETRANSMIT_BASE 1.8
/**
* Number of retransmits done in a retransmit sequence
*/
#define RETRANSMIT_TRIES 5
/**
* Keepalive interval in seconds.
*/
#define KEEPALIVE_INTERVAL 20
/**
* retry interval in seconds.
*/
#define RETRY_INTERVAL 30
/**
* jitter to user for retrying
*/
#define RETRY_JITTER 20
typedef struct private_configuration_t private_configuration_t;
/**
* Private data of an configuration_t object.
*/
struct private_configuration_t {
/**
* Public part of configuration_t object.
*/
configuration_t public;
};
/**
* Implementation of configuration_t.get_retransmit_timeout.
*/
static u_int32_t get_retransmit_timeout (private_configuration_t *this,
u_int32_t retransmit_count)
{
if (retransmit_count > RETRANSMIT_TRIES)
{
/* give up */
return 0;
}
return (u_int32_t)
(RETRANSMIT_TIMEOUT * pow(RETRANSMIT_BASE, retransmit_count));
}
/**
* Implementation of configuration_t.get_half_open_ike_sa_timeout.
*/
static u_int32_t get_half_open_ike_sa_timeout (private_configuration_t *this)
{
return HALF_OPEN_IKE_SA_TIMEOUT;
}
/**
* Implementation of configuration_t.get_keepalive_interval.
*/
static u_int32_t get_keepalive_interval (private_configuration_t *this)
{
return KEEPALIVE_INTERVAL;
}
/**
* Implementation of configuration_t.get_retry_interval.
*/
static u_int32_t get_retry_interval (private_configuration_t *this)
{
return RETRY_INTERVAL - (random() % RETRY_JITTER);
}
/**
* Implementation of configuration_t.destroy.
*/
static void destroy(private_configuration_t *this)
{
free(this);
}
/*
* Described in header-file
*/
configuration_t *configuration_create()
{
private_configuration_t *this = malloc_thing(private_configuration_t);
/* public functions */
this->public.destroy = (void(*)(configuration_t*))destroy;
this->public.get_retransmit_timeout = (u_int32_t (*) (configuration_t*,u_int32_t))get_retransmit_timeout;
this->public.get_half_open_ike_sa_timeout = (u_int32_t (*) (configuration_t*)) get_half_open_ike_sa_timeout;
this->public.get_keepalive_interval = (u_int32_t (*) (configuration_t*)) get_keepalive_interval;
this->public.get_retry_interval = (u_int32_t (*) (configuration_t*)) get_retry_interval;
return (&this->public);
}
-102
View File
@@ -1,102 +0,0 @@
/**
* @file configuration.h
*
* @brief Interface configuration_t.
*
*/
/*
* Copyright (C) 2006 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_
typedef struct configuration_t configuration_t;
#include <library.h>
/**
* @brief The interface for various daemon related configs.
*
* @b Constructors:
* - configuration_create()
*
* @ingroup config
*/
struct configuration_t {
/**
* @brief Returns the retransmit timeout.
*
* A return value of zero means the request should not be
* retransmitted again.
*
* @param this calling object
* @param retransmitted number of times a message was retransmitted so far
* @return time in milliseconds, when to do next retransmit
*/
u_int32_t (*get_retransmit_timeout) (configuration_t *this,
u_int32_t retransmitted);
/**
* @brief Returns the timeout for an half open IKE_SA in ms.
*
* Half open means that the IKE_SA is still on a not established state
*
* @param this calling object
* @return timeout in milliseconds (ms)
*/
u_int32_t (*get_half_open_ike_sa_timeout) (configuration_t *this);
/**
* @brief Returns the keepalive interval in s.
*
* The keepalive interval defines the idle time after which a
* NAT keepalive packet should be sent.
*
* @param this calling object
* @return interval in s
*/
u_int32_t (*get_keepalive_interval) (configuration_t *this);
/**
* @brief Returns the interval to retry a failed action again.
*
* In some situations, the protocol may be in a state where processing
* is not possible and an action must be retried (e.g. rekeying).
*
* @param this calling object
* @return interval in s
*/
u_int32_t (*get_retry_interval) (configuration_t *this);
/**
* @brief Destroys a configuration_t object.
*
* @param this calling object
*/
void (*destroy) (configuration_t *this);
};
/**
* @brief Creates a configuration backend.
*
* @return static_configuration_t object
*
* @ingroup config
*/
configuration_t *configuration_create(void);
#endif /*CONFIGURATION_H_*/
+3 -1
View File
@@ -36,10 +36,12 @@ typedef struct ike_cfg_t ike_cfg_t;
/**
* @brief An ike_cfg_t defines the rules to set up an IKE_SA.
*
* @see peer_cfg_t to get an overview over the configurations.
*
* @b Constructors:
* - ike_cfg_create()
*
* @ingroup ike_cfg
* @ingroup config
*/
struct ike_cfg_t {
+18 -2
View File
@@ -69,7 +69,7 @@ extern enum_name_t *cert_policy_names;
*
* These values are the same as in pluto/starter, so do not modify them!
*
* @ingroup peer_cfg
* @ingroup config
*/
enum dpd_action_t {
/** DPD disabled */
@@ -90,10 +90,26 @@ extern enum_name_t *dpd_action_names;
/**
* @brief Configuration of a peer, specified by IDs.
*
* The peer config defines a connection between two given IDs. It contains
* exactly one ike_cfg_t, which is use for initiation. Additionally, it contains
* multiple child_cfg_t defining which CHILD_SAs are allowed for this peer.
* @verbatim
+-------------------+ +---------------+
+---------------+ | peer_cfg | +---------------+ |
| ike_cfg | +-------------------+ | child_cfg | |
+---------------+ | - ids | +---------------+ |
| - hosts | 1 1 | - cas | 1 n | - proposals | |
| - proposals |<------| - auth info |-------->| - traffic sel | |
| - ... | | - dpd config | | - ... |-+
+---------------+ | - ... | +---------------+
+-------------------+
@endverbatim
*
* @b Constructors:
* - peer_cfg_create()
*
* @ingroup peer_cfg
* @ingroup config
*/
struct peer_cfg_t {
+2
View File
@@ -102,6 +102,8 @@ extern enum_name_t *extended_sequence_numbers_names;
/**
* Struct used to store different kinds of algorithms. The internal
* lists of algorithms contain such structures.
*
* @ingroup config
*/
struct algorithm_t {
/**