#include "proposal.h"
#include <daemon.h>
-#include <collections/linked_list.h>
+#include <collections/array.h>
#include <utils/identification.h>
#include <crypto/transform.h>
/**
* Priority ordered list of transforms, as entry_t
*/
- linked_list_t *transforms;
+ array_t *transforms;
/**
* senders SPI
private_proposal_t *this, transform_type_t type,
u_int16_t alg, u_int16_t key_size)
{
- entry_t *entry;
-
- INIT(entry,
+ entry_t entry = {
.type = type,
.alg = alg,
.key_size = key_size,
- );
+ };
- this->transforms->insert_last(this->transforms, entry);
+ array_insert(this->transforms, ARRAY_TAIL, &entry);
}
/**
private_proposal_t *this, transform_type_t type)
{
return enumerator_create_filter(
- this->transforms->create_enumerator(this->transforms),
+ array_create_enumerator(this->transforms),
(void*)alg_filter, (void*)(uintptr_t)type, NULL);
}
enumerator_t *enumerator;
entry_t *entry;
- enumerator = this->transforms->create_enumerator(this->transforms);
+ enumerator = array_create_enumerator(this->transforms);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->type == DIFFIE_HELLMAN_GROUP &&
entry->alg != keep)
{
- this->transforms->remove_at(this->transforms, enumerator);
- free(entry);
+ array_remove_at(this->transforms, enumerator);
}
}
enumerator->destroy(enumerator);
{
private_proposal_t *clone;
enumerator_t *enumerator;
- entry_t *current, *entry;
+ entry_t *entry;
clone = (private_proposal_t*)proposal_create(this->protocol, 0);
- enumerator = this->transforms->create_enumerator(this->transforms);
- while (enumerator->enumerate(enumerator, ¤t))
+ enumerator = array_create_enumerator(this->transforms);
+ while (enumerator->enumerate(enumerator, &entry))
{
- INIT(entry,
- .type = current->type,
- .alg = current->alg,
- .key_size = current->key_size,
- );
- clone->transforms->insert_last(clone->transforms, entry);
+ array_insert(clone->transforms, ARRAY_TAIL, entry);
}
enumerator->destroy(enumerator);
{
/* if all encryption algorithms in the proposal are AEADs,
* we MUST NOT propose any integrity algorithms */
- e = this->transforms->create_enumerator(this->transforms);
+ e = array_create_enumerator(this->transforms);
while (e->enumerate(e, &entry))
{
if (entry->type == INTEGRITY_ALGORITHM)
{
- this->transforms->remove_at(this->transforms, e);
- free(entry);
+ array_remove_at(this->transforms, e);
}
}
e->destroy(e);
}
e->destroy(e);
}
+
+ array_compress(this->transforms);
}
/**
METHOD(proposal_t, destroy, void,
private_proposal_t *this)
{
- this->transforms->destroy_function(this->transforms, free);
+ array_destroy(this->transforms);
free(this);
}
},
.protocol = protocol,
.number = number,
- .transforms = linked_list_create(),
+ .transforms = array_create(sizeof(entry_t), 0),
);
return &this->public;