transform->get_transform_id(transform), key_length);
}
-METHOD(proposal_substructure_t, get_proposal, proposal_t*,
- private_proposal_substructure_t *this)
+METHOD(proposal_substructure_t, get_proposals, void,
+ private_proposal_substructure_t *this, linked_list_t *proposals)
{
transform_substructure_t *transform;
enumerator_t *enumerator;
- proposal_t *proposal;
+ proposal_t *proposal = NULL;
+ u_int64_t spi = 0;
- proposal = proposal_create(this->protocol_id, this->proposal_number);
+ switch (this->spi.len)
+ {
+ case 4:
+ spi = *((u_int32_t*)this->spi.ptr);
+ break;
+ case 8:
+ spi = *((u_int64_t*)this->spi.ptr);
+ break;
+ default:
+ break;
+ }
enumerator = this->transforms->create_enumerator(this->transforms);
while (enumerator->enumerate(enumerator, &transform))
{
+ if (!proposal)
+ {
+ proposal = proposal_create(this->protocol_id, this->proposal_number);
+ proposal->set_spi(proposal, spi);
+ proposals->insert_last(proposals, proposal);
+ }
if (this->type == PROPOSAL_SUBSTRUCTURE)
{
add_to_proposal_v2(proposal, transform);
default:
break;
}
- /* TODO-IKEv1: We currently accept the first set of transforms
- * in a substructure only. We need to return multiple proposals,
- * but this messes up proposal numbering, as we don't support
- * transform numbering. */
- break;
+ /* create a new proposal for each transform in IKEv1 */
+ proposal = NULL;
}
}
enumerator->destroy(enumerator);
-
- switch (this->spi.len)
- {
- case 4:
- proposal->set_spi(proposal, *((u_int32_t*)this->spi.ptr));
- break;
- case 8:
- proposal->set_spi(proposal, *((u_int64_t*)this->spi.ptr));
- break;
- default:
- break;
- }
- return proposal;
}
METHOD(proposal_substructure_t, create_substructure_enumerator, enumerator_t*,
.set_protocol_id = _set_protocol_id,
.get_protocol_id = _get_protocol_id,
.set_is_last_proposal = _set_is_last_proposal,
- .get_proposal = _get_proposal,
+ .get_proposals = _get_proposals,
.create_substructure_enumerator = _create_substructure_enumerator,
.set_spi = _set_spi,
.get_spi = _get_spi,
int ignore_struct_number = 0;
enumerator_t *enumerator;
proposal_substructure_t *substruct;
- linked_list_t *list;
proposal_t *proposal;
+ linked_list_t *list;
if (this->type == SECURITY_ASSOCIATION_V1)
{ /* IKEv1 proposals start with 0 */
if (ignore_struct_number < struct_number)
{
/* remove an already added, if first of series */
- list->remove_last(list, (void**)&proposal);
- proposal->destroy(proposal);
+ if (list->remove_last(list, (void**)&proposal) == SUCCESS)
+ {
+ proposal->destroy(proposal);
+ }
ignore_struct_number = struct_number;
}
continue;
}
struct_number++;
- proposal = substruct->get_proposal(substruct);
- if (proposal)
- {
- list->insert_last(list, proposal);
- }
+ substruct->get_proposals(substruct, list);
}
enumerator->destroy(enumerator);
return list;