peer-cfg: Use struct to pass data to constructor

This commit is contained in:
Tobias Brunner
2016-04-09 16:51:01 +02:00
committed by Andreas Steffen
parent 8a00a8452d
commit 2ba5dadb12
16 changed files with 266 additions and 200 deletions
+24 -6
View File
@@ -300,6 +300,7 @@ static ike_cfg_t* get_ike_cfg_by_id(private_sql_config_t *this, int id)
return ike_cfg;
}
#ifdef ME
/**
* Query a peer config by its id
*/
@@ -332,6 +333,7 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id)
}
return peer_cfg;
}
#endif /* ME */
/**
* Check if the two IDs match (the first one is optional)
@@ -363,7 +365,7 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
&mediation, &mediated_by, &p_type, &p_data))
{
identification_t *local_id, *remote_id, *peer_id = NULL;
peer_cfg_t *peer_cfg, *mediated_cfg;
peer_cfg_t *peer_cfg, *mediated_cfg = NULL;
ike_cfg_t *ike;
host_t *vip = NULL;
auth_cfg_t *auth;
@@ -377,22 +379,38 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
continue;
}
ike = get_ike_cfg_by_id(this, ike_cfg);
#ifdef ME
mediated_cfg = mediated_by ? get_peer_cfg_by_id(this, mediated_by) : NULL;
if (p_type)
{
peer_id = identification_create_from_encoding(p_type, p_data);
}
#endif
if (virtual)
{
vip = host_create_from_string(virtual, 0);
}
if (ike)
{
peer_cfg = peer_cfg_create(
name, ike, cert_policy, uniqueid,
keyingtries, rekeytime, reauthtime, jitter, overtime,
mobike, FALSE, TRUE, dpd_delay, 0,
mediation, mediated_cfg, peer_id);
peer_cfg_create_t peer = {
.cert_policy = cert_policy,
.unique = uniqueid,
.keyingtries = keyingtries,
.rekey_time = rekeytime,
.reauth_time = reauthtime,
.jitter_time = jitter,
.over_time = overtime,
.no_mobike = !mobike,
.dpd = dpd_delay,
#ifdef ME
.mediation = mediation,
.mediated_by = mediated_cfg,
.peer_id = peer_id,
#endif /* ME */
};
peer_cfg = peer_cfg_create(name, ike, &peer);
if (vip)
{
peer_cfg->add_virtual_ip(peer_cfg, vip);