generator: Make pointer to length field optional

Only useful if we generate an IKE header.
This commit is contained in:
Tobias Brunner 2019-08-20 14:53:16 +02:00 committed by Andreas Steffen
parent 5e0b9a04ee
commit 96e6371b98
2 changed files with 6 additions and 4 deletions

View File

@ -431,7 +431,10 @@ METHOD(generator_t, get_chunk, chunk_t,
{
chunk_t data;
*lenpos = (uint32_t*)(this->buffer + this->header_length_offset);
if (lenpos)
{
*lenpos = (uint32_t*)(this->buffer + this->header_length_offset);
}
data = chunk_create(this->buffer, get_length(this));
if (this->debug)
{

View File

@ -2089,7 +2089,6 @@ METHOD(message_t, fragment, status_t,
host_t *src, *dst;
chunk_t data;
status_t status;
uint32_t *lenpos;
size_t len;
src = this->packet->get_source(this->packet);
@ -2126,7 +2125,7 @@ METHOD(message_t, fragment, status_t,
DESTROY_IF(generator);
return status;
}
data = generator->get_chunk(generator, &lenpos);
data = generator->get_chunk(generator, NULL);
len = data.len + (encrypted ? encrypted->get_length(encrypted) : 0);
}
@ -2182,7 +2181,7 @@ METHOD(message_t, fragment, status_t,
}
next = encrypted->payload_interface.get_next_type((payload_t*)encrypted);
encrypted->generate_payloads(encrypted, generator);
data = generator->get_chunk(generator, &lenpos);
data = generator->get_chunk(generator, NULL);
if (!is_encoded(this))
{
encrypted->destroy(encrypted);