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:
Tobias Brunner
2019-10-24 17:43:21 +02:00
parent 3187293e3d
commit a2cb2c9cc8
13 changed files with 84 additions and 37 deletions
+7 -5
View File
@@ -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, &current))
{
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);
+2 -2
View File
@@ -310,7 +310,7 @@ METHOD(ike_cfg_t, get_proposals, linked_list_t*,
enumerator = this->proposals->create_enumerator(this->proposals);
while (enumerator->enumerate(enumerator, &current))
{
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;