proposal: Use flags to select/match proposals

During proposal selection with ike/child_cfgs a couple of boolean
variables can be set (e.g. private, prefer_self, strip_dh). To simplify
the addition of new parameters, these functions now use a set of flags
instead of indiviual boolean values.

Signed-off-by: Thomas Egerer <[email protected]>
This commit is contained in:
Thomas Egerer
2019-10-24 17:22:53 +02:00
committed by Tobias Brunner
parent 8346db09dd
commit f930b732c4
12 changed files with 130 additions and 86 deletions
+15 -5
View File
@@ -544,7 +544,7 @@ static status_t select_and_install(private_child_create_t *this,
chunk_t integ_i = chunk_empty, integ_r = chunk_empty;
linked_list_t *my_ts, *other_ts;
host_t *me, *other;
bool private, prefer_configured;
proposal_selection_flag_t flags = 0;
if (this->proposals == NULL)
{
@@ -560,11 +560,21 @@ static status_t select_and_install(private_child_create_t *this,
me = this->ike_sa->get_my_host(this->ike_sa);
other = this->ike_sa->get_other_host(this->ike_sa);
private = this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN);
prefer_configured = lib->settings->get_bool(lib->settings,
"%s.prefer_configured_proposals", TRUE, lib->ns);
if (no_dh)
{
flags |= PROPOSAL_STRIP_DH;
}
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
{
flags |= PROPOSAL_ALLOW_PRIVATE;
}
if (lib->settings->get_bool(lib->settings, "%s.prefer_configured_proposals",
TRUE, lib->ns))
{
flags |= PROPOSAL_PREFER_CONFIGURED;
}
this->proposal = this->config->select_proposal(this->config,
this->proposals, no_dh, private, prefer_configured);
this->proposals, flags);
if (this->proposal == NULL)
{
DBG1(DBG_IKE, "no acceptable proposal found");
+12 -8
View File
@@ -453,17 +453,21 @@ static void process_sa_payload(private_ike_init_t *this, message_t *message,
enumerator_t *enumerator;
linked_list_t *proposal_list;
host_t *me, *other;
bool private, prefer_configured;
proposal_selection_flag_t flags = 0;
ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
proposal_list = sa_payload->get_proposals(sa_payload);
private = this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN);
prefer_configured = lib->settings->get_bool(lib->settings,
"%s.prefer_configured_proposals", TRUE, lib->ns);
this->proposal = ike_cfg->select_proposal(ike_cfg, proposal_list, private,
prefer_configured);
if (this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN))
{
flags |= PROPOSAL_ALLOW_PRIVATE;
}
if (lib->settings->get_bool(lib->settings, "%s.prefer_configured_proposals",
TRUE, lib->ns))
{
flags |= PROPOSAL_PREFER_CONFIGURED;
}
this->proposal = ike_cfg->select_proposal(ike_cfg, proposal_list, flags);
if (!this->proposal)
{
if (!this->initiator && !this->old_sa)
@@ -481,7 +485,7 @@ static void process_sa_payload(private_ike_init_t *this, message_t *message,
DBG1(DBG_IKE, "no matching proposal found, trying alternative "
"config");
this->proposal = cfg->select_proposal(cfg, proposal_list,
private, prefer_configured);
flags);
if (this->proposal)
{
alt_cfg = cfg->get_ref(cfg);