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
+7 -10
View File
@@ -436,15 +436,14 @@ static status_t send_dpd(private_ike_sa_t *this)
static void send_keepalive(private_ike_sa_t *this)
{
send_keepalive_job_t *job;
time_t last_out, now, diff, interval;
time_t last_out, now, diff;
last_out = get_use_time(this, FALSE);
now = time(NULL);
diff = now - last_out;
interval = charon->configuration->get_keepalive_interval(charon->configuration);
if (diff >= interval)
if (diff >= KEEPALIVE_INTERVAL)
{
packet_t *packet;
chunk_t data;
@@ -462,7 +461,7 @@ static void send_keepalive(private_ike_sa_t *this)
}
job = send_keepalive_job_create(this->ike_sa_id);
charon->event_queue->add_relative(charon->event_queue, (job_t*)job,
(interval - diff) * 1000);
(KEEPALIVE_INTERVAL - diff) * 1000);
}
/**
@@ -526,9 +525,8 @@ static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
{
/* delete may fail if a packet gets lost, so set a timeout */
job_t *job = (job_t*)delete_ike_sa_job_create(this->ike_sa_id, TRUE);
charon->event_queue->add_relative(charon->event_queue, job,
charon->configuration->get_half_open_ike_sa_timeout(
charon->configuration));
charon->event_queue->add_relative(charon->event_queue, job,
HALF_OPEN_IKE_SA_TIMEOUT);
break;
}
default:
@@ -747,10 +745,9 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
/* add a timeout if peer does not establish it completely */
job = (job_t*)delete_ike_sa_job_create(this->ike_sa_id, FALSE);
charon->event_queue->add_relative(charon->event_queue, job,
charon->configuration->get_half_open_ike_sa_timeout(
charon->configuration));
HALF_OPEN_IKE_SA_TIMEOUT);
}
/* check if message is trustworthy, and update host information */
if (this->state == IKE_CREATED ||
message->get_exchange_type(message) != IKE_SA_INIT)
+29 -1
View File
@@ -34,7 +34,6 @@ typedef struct ike_sa_t ike_sa_t;
#include <sa/ike_sa_id.h>
#include <sa/child_sa.h>
#include <sa/tasks/task.h>
#include <config/configuration.h>
#include <utils/randomizer.h>
#include <crypto/prfs/prf.h>
#include <crypto/crypters/crypter.h>
@@ -42,6 +41,35 @@ typedef struct ike_sa_t ike_sa_t;
#include <config/peer_cfg.h>
#include <config/ike_cfg.h>
/**
* Timeout in milliseconds after that a half open IKE_SA gets deleted.
*
* @ingroup sa
*/
#define HALF_OPEN_IKE_SA_TIMEOUT 30000
/**
* Interval to send keepalives when NATed, in seconds.
*
* @ingroup sa
*/
#define KEEPALIVE_INTERVAL 20
/**
* After which time rekeying should be retried if it failed, in seconds.
*
* @ingroup sa
*/
#define RETRY_INTERVAL 30
/**
* Jitter to subtract from RETRY_INTERVAL to randomize rekey retry.
*
* @ingroup sa
*/
#define RETRY_JITTER 20
/**
* @brief State of an IKE_SA.
*
+8 -3
View File
@@ -22,6 +22,8 @@
#include "task_manager.h"
#include <math.h>
#include <daemon.h>
#include <sa/tasks/ike_init.h>
#include <sa/tasks/ike_natd.h>
@@ -210,9 +212,12 @@ static status_t retransmit(private_task_manager_t *this, u_int32_t message_id)
u_int32_t timeout;
job_t *job;
timeout = charon->configuration->get_retransmit_timeout(
charon->configuration, this->initiating.retransmitted);
if (timeout == 0)
if (this->initiating.retransmitted <= RETRANSMIT_TRIES)
{
timeout = (u_int32_t)(RETRANSMIT_TIMEOUT *
pow(RETRANSMIT_BASE, this->initiating.retransmitted));
}
else
{
DBG1(DBG_IKE, "giving up after %d retransmits",
this->initiating.retransmitted - 1);
+40
View File
@@ -30,6 +30,28 @@ typedef struct task_manager_t task_manager_t;
#include <sa/ike_sa.h>
#include <sa/tasks/task.h>
/**
* First retransmit timeout in milliseconds.
*
* @ingroup sa
*/
#define RETRANSMIT_TIMEOUT 4000
/**
* Base which is raised to the power of the retransmission try.
*
* @ingroup sa
*/
#define RETRANSMIT_BASE 1.8
/**
* Number of retransmits done before giving up.
*
* @ingroup sa
*/
#define RETRANSMIT_TRIES 5
/**
* @brief The task manager, juggles task and handles message exchanges.
*
@@ -43,6 +65,24 @@ typedef struct task_manager_t task_manager_t;
* For the initial IKE_SA setup, several tasks are queued: One for the
* unauthenticated IKE_SA setup, one for authentication, one for CHILD_SA setup
* and maybe one for virtual IP assignement.
* The task manager is also responsible for retransmission. It uses a backoff
* algorithm. The timeout is calculated using
* RETRANSMIT_TIMEOUT * (RETRANSMIT_BASE ** try).
* When try reaches RETRANSMIT_TRIES, retransmission is given up.
*
* Using an initial TIMEOUT of 4s, a BASE of 1.8, and 5 TRIES gives us:
* @verbatim
| relative | absolute
---------------------------------------------------------
4s * (1.8 ** 0) = 4s 4s
4s * (1.8 ** 1) = 7s 11s
4s * (1.8 ** 2) = 13s 24s
4s * (1.8 ** 3) = 23s 47s
4s * (1.8 ** 4) = 42s 89s
4s * (1.8 ** 5) = 76s 165s
@endberbatim
* The peer is considered dead after 2min 45s when no reply comes in.
*
* @b Constructors:
* - task_manager_create()
+2 -2
View File
@@ -192,8 +192,8 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
this->collision->get_type(this->collision) == CHILD_DELETE))
{
job_t *job;
u_int32_t retry = charon->configuration->get_retry_interval(
charon->configuration);
u_int32_t retry = RETRY_INTERVAL - (random() % RETRY_JITTER);
job = (job_t*)rekey_child_sa_job_create(
this->child_sa->get_reqid(this->child_sa),
this->child_sa->get_protocol(this->child_sa),
+1 -2
View File
@@ -169,8 +169,7 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
this->collision->get_type(this->collision) == IKE_DELETE))
{
job_t *job;
u_int32_t retry = charon->configuration->get_retry_interval(
charon->configuration);
u_int32_t retry = RETRY_INTERVAL - (random() % RETRY_JITTER);
job = (job_t*)rekey_ike_sa_job_create(
this->ike_sa->get_id(this->ike_sa), FALSE);
DBG1(DBG_IKE, "IKE_SA rekeying failed, "