peer-cfg: Use struct to pass data to constructor
This commit is contained in:
committed by
Andreas Steffen
parent
8a00a8452d
commit
2ba5dadb12
@@ -616,12 +616,17 @@ static mem_pool_t *create_pool_range(char *str)
|
||||
static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
|
||||
stroke_msg_t *msg, ike_cfg_t *ike_cfg)
|
||||
{
|
||||
identification_t *peer_id = NULL;
|
||||
peer_cfg_t *mediated_by = NULL;
|
||||
unique_policy_t unique;
|
||||
uint32_t rekey = 0, reauth = 0, over, jitter;
|
||||
peer_cfg_t *peer_cfg;
|
||||
auth_cfg_t *auth_cfg;
|
||||
peer_cfg_create_t peer = {
|
||||
.cert_policy = msg->add_conn.me.sendcert,
|
||||
.keyingtries = msg->add_conn.rekey.tries,
|
||||
.no_mobike = !msg->add_conn.mobike,
|
||||
.aggressive = msg->add_conn.aggressive,
|
||||
.push_mode = msg->add_conn.pushmode,
|
||||
.dpd = msg->add_conn.dpd.delay,
|
||||
.dpd_timeout = msg->add_conn.dpd.timeout,
|
||||
};
|
||||
|
||||
#ifdef ME
|
||||
if (msg->add_conn.ikeme.mediation && msg->add_conn.ikeme.mediated_by)
|
||||
@@ -633,14 +638,17 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
|
||||
|
||||
if (msg->add_conn.ikeme.mediation)
|
||||
{
|
||||
peer.mediation = TRUE;
|
||||
/* force unique connections for mediation connections */
|
||||
msg->add_conn.unique = 1;
|
||||
}
|
||||
|
||||
if (msg->add_conn.ikeme.mediated_by)
|
||||
{
|
||||
mediated_by = charon->backends->get_peer_cfg_by_name(charon->backends,
|
||||
msg->add_conn.ikeme.mediated_by);
|
||||
peer_cfg_t *mediated_by;
|
||||
|
||||
mediated_by = charon->backends->get_peer_cfg_by_name(
|
||||
charon->backends, msg->add_conn.ikeme.mediated_by);
|
||||
if (!mediated_by)
|
||||
{
|
||||
DBG1(DBG_CFG, "mediation connection '%s' not found, aborting",
|
||||
@@ -655,58 +663,55 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
|
||||
mediated_by->destroy(mediated_by);
|
||||
return NULL;
|
||||
}
|
||||
peer.mediated_by = mediated_by;
|
||||
if (msg->add_conn.ikeme.peerid)
|
||||
{
|
||||
peer_id = identification_create_from_string(msg->add_conn.ikeme.peerid);
|
||||
peer.peer_id = identification_create_from_string(
|
||||
msg->add_conn.ikeme.peerid);
|
||||
}
|
||||
else if (msg->add_conn.other.id)
|
||||
{
|
||||
peer_id = identification_create_from_string(msg->add_conn.other.id);
|
||||
peer.peer_id = identification_create_from_string(
|
||||
msg->add_conn.other.id);
|
||||
}
|
||||
}
|
||||
#endif /* ME */
|
||||
|
||||
jitter = msg->add_conn.rekey.margin * msg->add_conn.rekey.fuzz / 100;
|
||||
over = msg->add_conn.rekey.margin;
|
||||
peer.jitter_time = msg->add_conn.rekey.margin * msg->add_conn.rekey.fuzz / 100;
|
||||
peer.over_time = msg->add_conn.rekey.margin;
|
||||
if (msg->add_conn.rekey.reauth)
|
||||
{
|
||||
reauth = msg->add_conn.rekey.ike_lifetime - over;
|
||||
peer.reauth_time = msg->add_conn.rekey.ike_lifetime - peer.over_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
rekey = msg->add_conn.rekey.ike_lifetime - over;
|
||||
peer.rekey_time = msg->add_conn.rekey.ike_lifetime - peer.over_time;
|
||||
}
|
||||
switch (msg->add_conn.unique)
|
||||
{
|
||||
case 1: /* yes */
|
||||
case 2: /* replace */
|
||||
unique = UNIQUE_REPLACE;
|
||||
peer.unique = UNIQUE_REPLACE;
|
||||
break;
|
||||
case 3: /* keep */
|
||||
unique = UNIQUE_KEEP;
|
||||
peer.unique = UNIQUE_KEEP;
|
||||
break;
|
||||
case 4: /* never */
|
||||
unique = UNIQUE_NEVER;
|
||||
peer.unique = UNIQUE_NEVER;
|
||||
break;
|
||||
default: /* no */
|
||||
unique = UNIQUE_NO;
|
||||
peer.unique = UNIQUE_NO;
|
||||
break;
|
||||
}
|
||||
if (msg->add_conn.dpd.action == 0)
|
||||
{ /* dpdaction=none disables DPD */
|
||||
msg->add_conn.dpd.delay = 0;
|
||||
peer.dpd = 0;
|
||||
}
|
||||
|
||||
/* other.sourceip is managed in stroke_attributes. If it is set, we define
|
||||
* the pool name as the connection name, which the attribute provider
|
||||
* uses to serve pool addresses. */
|
||||
peer_cfg = peer_cfg_create(msg->add_conn.name, ike_cfg,
|
||||
msg->add_conn.me.sendcert, unique,
|
||||
msg->add_conn.rekey.tries, rekey, reauth, jitter, over,
|
||||
msg->add_conn.mobike, msg->add_conn.aggressive,
|
||||
msg->add_conn.pushmode == 0,
|
||||
msg->add_conn.dpd.delay, msg->add_conn.dpd.timeout,
|
||||
msg->add_conn.ikeme.mediation, mediated_by, peer_id);
|
||||
peer_cfg = peer_cfg_create(msg->add_conn.name, ike_cfg, &peer);
|
||||
|
||||
if (msg->add_conn.other.sourceip)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user