peer-cfg: Use struct to pass data to constructor
This commit is contained in:
committed by
Andreas Steffen
parent
8a00a8452d
commit
2ba5dadb12
@@ -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
|
||||
@@ -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, uint32_t keyingtries,
|
||||
uint32_t rekey_time, uint32_t reauth_time,
|
||||
uint32_t jitter_time, uint32_t over_time,
|
||||
bool mobike, bool aggressive, bool pull_mode,
|
||||
uint32_t dpd, uint32_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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -26,6 +26,7 @@
|
||||
typedef enum cert_policy_t cert_policy_t;
|
||||
typedef enum unique_policy_t unique_policy_t;
|
||||
typedef struct peer_cfg_t peer_cfg_t;
|
||||
typedef struct peer_cfg_create_t peer_cfg_create_t;
|
||||
|
||||
#include <library.h>
|
||||
#include <utils/identification.h>
|
||||
@@ -366,43 +367,53 @@ struct peer_cfg_t {
|
||||
void (*destroy) (peer_cfg_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Data passed to the constructor of a peer_cfg_t object.
|
||||
*/
|
||||
struct peer_cfg_create_t {
|
||||
/** Whether to send a certificate payload */
|
||||
cert_policy_t cert_policy;
|
||||
/** Uniqueness of an IKE_SA */
|
||||
unique_policy_t unique;
|
||||
/** How many keying tries should be done before giving up */
|
||||
uint32_t keyingtries;
|
||||
/** Timeout in seconds before starting rekeying */
|
||||
uint32_t rekey_time;
|
||||
/** Timeout in seconds before starting reauthentication */
|
||||
uint32_t reauth_time;
|
||||
/** Time range in seconds to randomly subtract from rekey/reauth time */
|
||||
uint32_t jitter_time;
|
||||
/** Maximum overtime in seconds before closing a rekeying/reauth SA */
|
||||
uint32_t over_time;
|
||||
/** Disable MOBIKE (RFC4555) */
|
||||
bool no_mobike;
|
||||
/** Use/accept aggressive mode with IKEv1 */
|
||||
bool aggressive;
|
||||
/** TRUE to use modeconfig push, FALSE for pull */
|
||||
bool push_mode;
|
||||
/** DPD check interval, 0 to disable */
|
||||
uint32_t dpd;
|
||||
/** DPD timeout interval (IKEv1 only), if 0 default applies */
|
||||
uint32_t dpd_timeout;
|
||||
#ifdef ME
|
||||
/** TRUE if this is a mediation connection */
|
||||
bool mediation;
|
||||
/** peer_cfg_t of the mediation connection to mediate through (adopted) */
|
||||
peer_cfg_t *mediated_by;
|
||||
/** ID that identifies our peer at the mediation server (adopted) */
|
||||
identification_t *peer_id;
|
||||
#endif /* ME */
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a configuration object for IKE_AUTH and later.
|
||||
*
|
||||
* name-string gets cloned, ID's not.
|
||||
* Virtual IPs are used if they are != NULL. A %any host means the virtual
|
||||
* IP should be obtained from the other peer.
|
||||
* Lifetimes are in seconds. To prevent to peers to start rekeying at the
|
||||
* same time, a jitter may be specified. Rekeying of an SA starts at
|
||||
* (rekeylifetime - random(0, jitter)).
|
||||
*
|
||||
* @param name name of the peer_cfg
|
||||
* @param ike_cfg IKE config to use when acting as initiator
|
||||
* @param cert_policy should we send a certificate payload?
|
||||
* @param unique uniqueness of an IKE_SA
|
||||
* @param keyingtries how many keying tries should be done before giving up
|
||||
* @param rekey_time timeout before starting rekeying
|
||||
* @param reauth_time timeout before starting reauthentication
|
||||
* @param jitter_time timerange to randomly subtract from rekey/reauth time
|
||||
* @param over_time maximum overtime before closing a rekeying/reauth SA
|
||||
* @param mobike use MOBIKE (RFC4555) if peer supports it
|
||||
* @param aggressive use/accept aggressive mode with IKEv1
|
||||
* @param pull_mode TRUE to use modeconfig pull, FALSE for push
|
||||
* @param dpd DPD check interval, 0 to disable
|
||||
* @param dpd_timeout DPD timeout interval (IKEv1 only), if 0 default applies
|
||||
* @param mediation TRUE if this is a mediation connection
|
||||
* @param mediated_by peer_cfg_t of the mediation connection to mediate through
|
||||
* @param peer_id ID that identifies our peer at the mediation server
|
||||
* @param name name of the peer_cfg (cloned)
|
||||
* @param ike_cfg IKE config to use when acting as initiator (adopted)
|
||||
* @param data data for this peer_cfg
|
||||
* @return peer_cfg_t object
|
||||
*/
|
||||
peer_cfg_t *peer_cfg_create(char *name,
|
||||
ike_cfg_t *ike_cfg, cert_policy_t cert_policy,
|
||||
unique_policy_t unique, uint32_t keyingtries,
|
||||
uint32_t rekey_time, uint32_t reauth_time,
|
||||
uint32_t jitter_time, uint32_t over_time,
|
||||
bool mobike, bool aggressive, bool pull_mode,
|
||||
uint32_t dpd, uint32_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);
|
||||
|
||||
#endif /** PEER_CFG_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user