summaryrefslogtreecommitdiff
path: root/src/libcharon/config/peer_cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/config/peer_cfg.c')
-rw-r--r--src/libcharon/config/peer_cfg.c89
1 files changed, 39 insertions, 50 deletions
diff --git a/src/libcharon/config/peer_cfg.c b/src/libcharon/config/peer_cfg.c
index d28a79507..6463c7a36 100644
--- a/src/libcharon/config/peer_cfg.c
+++ b/src/libcharon/config/peer_cfg.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2007-2015 Tobias Brunner
+ * Copyright (C) 2007-2016 Tobias Brunner
* Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2005 Jan Hutter
- * Hochschule fuer Technik Rapperswil
+ * HSR 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
@@ -88,7 +88,7 @@ struct private_peer_cfg_t {
/**
* number of tries after giving up if peer does not respond
*/
- u_int32_t keyingtries;
+ uint32_t keyingtries;
/**
* enable support for MOBIKE
@@ -108,32 +108,32 @@ struct private_peer_cfg_t {
/**
* Time before starting rekeying
*/
- u_int32_t rekey_time;
+ uint32_t rekey_time;
/**
* Time before starting reauthentication
*/
- u_int32_t reauth_time;
+ uint32_t reauth_time;
/**
* Time, which specifies the range of a random value subtracted from above.
*/
- u_int32_t jitter_time;
+ uint32_t jitter_time;
/**
* Delay before deleting a rekeying/reauthenticating SA
*/
- u_int32_t over_time;
+ uint32_t over_time;
/**
* DPD check intervall
*/
- u_int32_t dpd;
+ uint32_t dpd;
/**
* DPD timeout intervall (used for IKEv1 only)
*/
- u_int32_t dpd_timeout;
+ uint32_t dpd_timeout;
/**
* List of virtual IPs (host_t*) to request
@@ -455,13 +455,13 @@ METHOD(peer_cfg_t, get_unique_policy, unique_policy_t,
return this->unique;
}
-METHOD(peer_cfg_t, get_keyingtries, u_int32_t,
+METHOD(peer_cfg_t, get_keyingtries, uint32_t,
private_peer_cfg_t *this)
{
return this->keyingtries;
}
-METHOD(peer_cfg_t, get_rekey_time, u_int32_t,
+METHOD(peer_cfg_t, get_rekey_time, uint32_t,
private_peer_cfg_t *this, bool jitter)
{
if (this->rekey_time == 0)
@@ -475,7 +475,7 @@ METHOD(peer_cfg_t, get_rekey_time, u_int32_t,
return this->rekey_time - (random() % this->jitter_time);
}
-METHOD(peer_cfg_t, get_reauth_time, u_int32_t,
+METHOD(peer_cfg_t, get_reauth_time, uint32_t,
private_peer_cfg_t *this, bool jitter)
{
if (this->reauth_time == 0)
@@ -489,7 +489,7 @@ METHOD(peer_cfg_t, get_reauth_time, u_int32_t,
return this->reauth_time - (random() % this->jitter_time);
}
-METHOD(peer_cfg_t, get_over_time, u_int32_t,
+METHOD(peer_cfg_t, get_over_time, uint32_t,
private_peer_cfg_t *this)
{
return this->over_time;
@@ -513,13 +513,13 @@ METHOD(peer_cfg_t, use_pull_mode, bool,
return this->pull_mode;
}
-METHOD(peer_cfg_t, get_dpd, u_int32_t,
+METHOD(peer_cfg_t, get_dpd, uint32_t,
private_peer_cfg_t *this)
{
return this->dpd;
}
-METHOD(peer_cfg_t, get_dpd_timeout, u_int32_t,
+METHOD(peer_cfg_t, get_dpd_timeout, uint32_t,
private_peer_cfg_t *this)
{
return this->dpd_timeout;
@@ -724,29 +724,22 @@ METHOD(peer_cfg_t, destroy, void,
/*
* Described in header-file
*/
-peer_cfg_t *peer_cfg_create(char *name,
- ike_cfg_t *ike_cfg, cert_policy_t cert_policy,
- unique_policy_t unique, u_int32_t keyingtries,
- u_int32_t rekey_time, u_int32_t reauth_time,
- u_int32_t jitter_time, u_int32_t over_time,
- bool mobike, bool aggressive, bool pull_mode,
- u_int32_t dpd, u_int32_t dpd_timeout,
- bool mediation, peer_cfg_t *mediated_by,
- identification_t *peer_id)
+peer_cfg_t *peer_cfg_create(char *name, ike_cfg_t *ike_cfg,
+ peer_cfg_create_t *data)
{
private_peer_cfg_t *this;
- if (rekey_time && jitter_time > rekey_time)
+ if (data->rekey_time && data->jitter_time > data->rekey_time)
{
- jitter_time = rekey_time;
+ data->jitter_time = data->rekey_time;
}
- if (reauth_time && jitter_time > reauth_time)
+ if (data->reauth_time && data->jitter_time > data->reauth_time)
{
- jitter_time = reauth_time;
+ data->jitter_time = data->reauth_time;
}
- if (dpd && dpd_timeout && dpd > dpd_timeout)
+ if (data->dpd && data->dpd_timeout && data->dpd > data->dpd_timeout)
{
- dpd_timeout = dpd;
+ data->dpd_timeout = data->dpd;
}
INIT(this,
@@ -789,33 +782,29 @@ peer_cfg_t *peer_cfg_create(char *name,
.ike_cfg = ike_cfg,
.child_cfgs = linked_list_create(),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
- .cert_policy = cert_policy,
- .unique = unique,
- .keyingtries = keyingtries,
- .rekey_time = rekey_time,
- .reauth_time = reauth_time,
- .jitter_time = jitter_time,
- .over_time = over_time,
- .use_mobike = mobike,
- .aggressive = aggressive,
- .pull_mode = pull_mode,
- .dpd = dpd,
- .dpd_timeout = dpd_timeout,
+ .cert_policy = data->cert_policy,
+ .unique = data->unique,
+ .keyingtries = data->keyingtries,
+ .rekey_time = data->rekey_time,
+ .reauth_time = data->reauth_time,
+ .jitter_time = data->jitter_time,
+ .over_time = data->over_time,
+ .use_mobike = !data->no_mobike,
+ .aggressive = data->aggressive,
+ .pull_mode = !data->push_mode,
+ .dpd = data->dpd,
+ .dpd_timeout = data->dpd_timeout,
.vips = linked_list_create(),
.pools = linked_list_create(),
.local_auth = linked_list_create(),
.remote_auth = linked_list_create(),
.refcount = 1,
- );
-
#ifdef ME
- this->mediation = mediation;
- this->mediated_by = mediated_by;
- this->peer_id = peer_id;
-#else /* ME */
- DESTROY_IF(mediated_by);
- DESTROY_IF(peer_id);
+ .mediation = data->mediation,
+ .mediated_by = data->mediated_by,
+ .peer_id = data->peer_id,
#endif /* ME */
+ );
return &this->public;
}