/*
- * Copyright (C) 2012-2017 Tobias Brunner
+ * Copyright (C) 2012-2019 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return proposals;
}
+METHOD(ike_cfg_t, has_proposal, bool,
+ private_ike_cfg_t *this, proposal_t *match, bool private)
+{
+ enumerator_t *enumerator;
+ proposal_t *proposal;
+
+ enumerator = this->proposals->create_enumerator(this->proposals);
+ while (enumerator->enumerate(enumerator, &proposal))
+ {
+ if (proposal->matches(proposal, match, private))
+ {
+ enumerator->destroy(enumerator);
+ return TRUE;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return FALSE;
+}
+
METHOD(ike_cfg_t, select_proposal, proposal_t*,
private_ike_cfg_t *this, linked_list_t *proposals, bool private,
bool prefer_self)
{
DBG2(DBG_CFG, "received proposals: %#P", proposals);
DBG2(DBG_CFG, "configured proposals: %#P", this->proposals);
- DBG2(DBG_CFG, "selected proposal: %P", selected);
+ DBG1(DBG_CFG, "selected proposal: %P", selected);
break;
}
}
host = host_create_from_string(str, 0);
if (host && addr->ip_equals(addr, host))
{
+ host->destroy(host);
found = TRUE;
break;
}
return found;
}
-/**
- * Described in header.
+/*
+ * Described in header
*/
-ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap,
- char *me, uint16_t my_port,
- char *other, uint16_t other_port,
- fragmentation_t fragmentation, uint8_t dscp)
+ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data)
{
private_ike_cfg_t *this;
.add_proposal = _add_proposal,
.get_proposals = _get_proposals,
.select_proposal = _select_proposal,
+ .has_proposal = _has_proposal,
.get_dh_group = _get_dh_group,
.equals = _equals,
.get_ref = _get_ref,
.destroy = _destroy,
},
.refcount = 1,
- .version = version,
- .certreq = certreq,
- .force_encap = force_encap,
- .fragmentation = fragmentation,
- .me = strdup(me),
+ .version = data->version,
+ .certreq = !data->no_certreq,
+ .force_encap = data->force_encap,
+ .fragmentation = data->fragmentation,
+ .me = strdup(data->local),
.my_ranges = linked_list_create(),
.my_hosts = linked_list_create(),
- .other = strdup(other),
+ .other = strdup(data->remote),
.other_ranges = linked_list_create(),
.other_hosts = linked_list_create(),
- .my_port = my_port,
- .other_port = other_port,
- .dscp = dscp,
+ .my_port = data->local_port,
+ .other_port = data->remote_port,
+ .dscp = data->dscp,
.proposals = linked_list_create(),
);
- parse_addresses(me, this->my_hosts, this->my_ranges);
- parse_addresses(other, this->other_hosts, this->other_ranges);
+ parse_addresses(data->local, this->my_hosts, this->my_ranges);
+ parse_addresses(data->remote, this->other_hosts, this->other_ranges);
return &this->public;
}