proposal: Add selection flags to clone() method
This avoids having to call strip_dh() in child_cfg_t::get_proposals(). It also inverts the ALLOW_PRIVATE flag (i.e. makes it SKIP_PRIVATE) so nothing has to be supplied to clone complete proposals.
This commit is contained in:
@@ -209,16 +209,18 @@ METHOD(child_cfg_t, get_proposals, linked_list_t*,
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
proposal_t *current;
|
||||
proposal_selection_flag_t flags = 0;
|
||||
linked_list_t *proposals = linked_list_create();
|
||||
|
||||
if (strip_dh)
|
||||
{
|
||||
flags |= PROPOSAL_SKIP_DH;
|
||||
}
|
||||
|
||||
enumerator = this->proposals->create_enumerator(this->proposals);
|
||||
while (enumerator->enumerate(enumerator, ¤t))
|
||||
{
|
||||
current = current->clone(current);
|
||||
if (strip_dh)
|
||||
{
|
||||
current->strip_dh(current, MODP_NONE);
|
||||
}
|
||||
current = current->clone(current, flags);
|
||||
if (proposals->find_first(proposals, match_proposal, NULL, current))
|
||||
{
|
||||
current->destroy(current);
|
||||
|
||||
@@ -310,7 +310,7 @@ METHOD(ike_cfg_t, get_proposals, linked_list_t*,
|
||||
enumerator = this->proposals->create_enumerator(this->proposals);
|
||||
while (enumerator->enumerate(enumerator, ¤t))
|
||||
{
|
||||
current = current->clone(current);
|
||||
current = current->clone(current, 0);
|
||||
proposals->insert_last(proposals, current);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
@@ -330,7 +330,7 @@ METHOD(ike_cfg_t, has_proposal, bool,
|
||||
while (enumerator->enumerate(enumerator, &proposal))
|
||||
{
|
||||
if (proposal->matches(proposal, match,
|
||||
private ? PROPOSAL_ALLOW_PRIVATE : 0))
|
||||
private ? 0 : PROPOSAL_SKIP_PRIVATE))
|
||||
{
|
||||
enumerator->destroy(enumerator);
|
||||
return TRUE;
|
||||
|
||||
@@ -749,7 +749,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
|
||||
ike.local_port = charon->socket->get_port(charon->socket, FALSE);
|
||||
}
|
||||
ike_cfg = ike_cfg_create(&ike);
|
||||
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
|
||||
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal, 0));
|
||||
peer_cfg = peer_cfg_create("load-test", ike_cfg, &peer);
|
||||
|
||||
if (this->vip)
|
||||
@@ -784,7 +784,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
|
||||
}
|
||||
|
||||
child_cfg = child_cfg_create("load-test", &child);
|
||||
child_cfg->add_proposal(child_cfg, this->esp->clone(this->esp));
|
||||
child_cfg->add_proposal(child_cfg, this->esp->clone(this->esp, 0));
|
||||
|
||||
if (num)
|
||||
{ /* initiator */
|
||||
|
||||
@@ -429,7 +429,7 @@ METHOD(child_sa_t, get_proposal, proposal_t*,
|
||||
METHOD(child_sa_t, set_proposal, void,
|
||||
private_child_sa_t *this, proposal_t *proposal)
|
||||
{
|
||||
this->proposal = proposal->clone(proposal);
|
||||
this->proposal = proposal->clone(proposal, 0);
|
||||
}
|
||||
|
||||
METHOD(child_sa_t, create_ts_enumerator, enumerator_t*,
|
||||
|
||||
@@ -610,7 +610,7 @@ METHOD(ike_sa_t, set_proposal, void,
|
||||
private_ike_sa_t *this, proposal_t *proposal)
|
||||
{
|
||||
DESTROY_IF(this->proposal);
|
||||
this->proposal = proposal->clone(proposal);
|
||||
this->proposal = proposal->clone(proposal, 0);
|
||||
}
|
||||
|
||||
METHOD(ike_sa_t, set_message_id, void,
|
||||
|
||||
@@ -374,7 +374,7 @@ METHOD(task_t, process_r, status_t,
|
||||
id_payload_t *id_payload;
|
||||
identification_t *id;
|
||||
linked_list_t *list;
|
||||
proposal_selection_flag_t flags = 0;
|
||||
proposal_selection_flag_t flags = PROPOSAL_SKIP_PRIVATE;
|
||||
uint16_t group;
|
||||
|
||||
this->ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
|
||||
|
||||
@@ -386,9 +386,9 @@ METHOD(task_t, process_r, status_t,
|
||||
}
|
||||
|
||||
list = sa_payload->get_proposals(sa_payload);
|
||||
if (this->ike_sa->supports_extension(this->ike_sa , EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
if (!lib->settings->get_bool(lib->settings,
|
||||
"%s.prefer_configured_proposals", TRUE, lib->ns))
|
||||
@@ -640,9 +640,9 @@ METHOD(task_t, process_i, status_t,
|
||||
return send_notify(this, INVALID_PAYLOAD_TYPE);
|
||||
}
|
||||
list = sa_payload->get_proposals(sa_payload);
|
||||
if (this->ike_sa->supports_extension(this->ike_sa , EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
this->proposal = this->ike_cfg->select_proposal(this->ike_cfg,
|
||||
list, flags);
|
||||
|
||||
@@ -1132,9 +1132,9 @@ METHOD(task_t, process_r, status_t,
|
||||
DESTROY_IF(list);
|
||||
list = sa_payload->get_proposals(sa_payload);
|
||||
}
|
||||
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
if (!lib->settings->get_bool(lib->settings,
|
||||
"%s.prefer_configured_proposals", TRUE, lib->ns))
|
||||
@@ -1370,9 +1370,9 @@ METHOD(task_t, process_i, status_t,
|
||||
DESTROY_IF(list);
|
||||
list = sa_payload->get_proposals(sa_payload);
|
||||
}
|
||||
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
this->proposal = this->config->select_proposal(this->config, list,
|
||||
flags);
|
||||
|
||||
@@ -564,9 +564,9 @@ static status_t select_and_install(private_child_create_t *this,
|
||||
{
|
||||
flags |= PROPOSAL_SKIP_DH;
|
||||
}
|
||||
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
if (!lib->settings->get_bool(lib->settings,
|
||||
"%s.prefer_configured_proposals", TRUE, lib->ns))
|
||||
|
||||
@@ -458,9 +458,9 @@ static void process_sa_payload(private_ike_init_t *this, message_t *message,
|
||||
ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
|
||||
|
||||
proposal_list = sa_payload->get_proposals(sa_payload);
|
||||
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
|
||||
{
|
||||
flags |= PROPOSAL_ALLOW_PRIVATE;
|
||||
flags |= PROPOSAL_SKIP_PRIVATE;
|
||||
}
|
||||
if (!lib->settings->get_bool(lib->settings,
|
||||
"%s.prefer_configured_proposals", TRUE, lib->ns))
|
||||
|
||||
Reference in New Issue
Block a user