summaryrefslogtreecommitdiff
path: root/src/charon/encoding
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2009-03-01 10:48:08 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2009-03-01 10:48:08 +0000
commita6f902baed7abb17a1a9c014e01bb100077f8198 (patch)
tree82114e22e251e9260d9a712f1232e52e1ef494e3 /src/charon/encoding
parent1450c9df799b0870477f6e63357f4bcb63537f4f (diff)
downloadvyos-strongswan-a6f902baed7abb17a1a9c014e01bb100077f8198.tar.gz
vyos-strongswan-a6f902baed7abb17a1a9c014e01bb100077f8198.zip
- Updated to new upstream revision.
Diffstat (limited to 'src/charon/encoding')
-rw-r--r--src/charon/encoding/generator.c428
-rw-r--r--src/charon/encoding/generator.h6
-rw-r--r--src/charon/encoding/parser.c250
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.c7
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.h7
-rw-r--r--src/charon/encoding/payloads/nonce_payload.h4
-rw-r--r--src/charon/encoding/payloads/notify_payload.c18
-rw-r--r--src/charon/encoding/payloads/notify_payload.h5
-rw-r--r--src/charon/encoding/payloads/payload.h4
9 files changed, 234 insertions, 495 deletions
diff --git a/src/charon/encoding/generator.c b/src/charon/encoding/generator.c
index 3b68af84e..dea4f0e21 100644
--- a/src/charon/encoding/generator.c
+++ b/src/charon/encoding/generator.c
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: generator.c 3589 2008-03-13 14:14:44Z martin $
+ * $Id: generator.c 4702 2008-11-26 10:42:54Z martin $
*/
#include <stdlib.h>
@@ -56,125 +56,6 @@ struct private_generator_t {
* Public part of a generator_t object.
*/
generator_t public;
-
- /**
- * Generates a U_INT-Field type and writes it to buffer.
- *
- * @param this private_generator_t object
- * @param int_type type of U_INT field (U_INT_4, U_INT_8, etc.)
- * ATTRIBUTE_TYPE is also generated in this function
- * @param offset offset of value in data struct
- * @param generator_contexts generator_contexts_t object where the context is written or read from
- * @return
- * - SUCCESS
- * - FAILED if allignment is wrong
- */
- void (*generate_u_int_type) (private_generator_t *this,encoding_type_t int_type,u_int32_t offset);
-
- /**
- * Get size of current buffer in bytes.
- *
- * @param this private_generator_t object
- * @return Size of buffer in bytes
- */
- size_t (*get_current_buffer_size) (private_generator_t *this);
-
- /**
- * Get free space of current buffer in bytes.
- *
- * @param this private_generator_t object
- * @return space in buffer in bytes
- */
- size_t (*get_current_buffer_space) (private_generator_t *this);
-
- /**
- * Get length of data in buffer (in bytes).
- *
- * @param this private_generator_t object
- * @return length of data in bytes
- */
- size_t (*get_current_data_length) (private_generator_t *this);
-
- /**
- * Get current offset in buffer (in bytes).
- *
- * @param this private_generator_t object
- * @return offset in bytes
- */
- u_int32_t (*get_current_buffer_offset) (private_generator_t *this);
-
- /**
- * Generates a RESERVED BIT field or a RESERVED BYTE field and writes
- * it to the buffer.
- *
- * @param this private_generator_t object
- * @param generator_contexts generator_contexts_t object where the context is written or read from
- * @param bits number of bits to generate
- */
- void (*generate_reserved_field) (private_generator_t *this,int bits);
-
- /**
- * Generates a FLAG field.
- *
- * @param this private_generator_t object
- * @param generator_contexts generator_contexts_t object where the context is written or read from
- * @param offset offset of flag value in data struct
- */
- void (*generate_flag) (private_generator_t *this,u_int32_t offset);
-
- /**
- * Writes the current buffer content into a chunk_t.
- *
- * Memory of specific chunk_t gets allocated.
- *
- * @param this calling private_generator_t object
- * @param data pointer of chunk_t to write to
- */
- void (*write_chunk) (private_generator_t *this,chunk_t *data);
-
- /**
- * Generates a bytestream from a chunk_t.
- *
- * @param this private_generator_t object
- * @param offset offset of chunk_t value in data struct
- */
- void (*generate_from_chunk) (private_generator_t *this,u_int32_t offset);
-
- /**
- * Makes sure enough space is available in buffer to store amount of bits.
- *
- * If buffer is to small to hold the specific amount of bits it
- * is increased using reallocation function of allocator.
- *
- * @param this calling private_generator_t object
- * @param bits number of bits to make available in buffer
- */
- void (*make_space_available) (private_generator_t *this,size_t bits);
-
- /**
- * Writes a specific amount of byte into the buffer.
- *
- * If buffer is to small to hold the specific amount of bytes it
- * is increased.
- *
- * @param this calling private_generator_t object
- * @param bytes pointer to bytes to write
- * @param number_of_bytes number of bytes to write into buffer
- */
- void (*write_bytes_to_buffer) (private_generator_t *this,void * bytes,size_t number_of_bytes);
-
-
- /**
- * Writes a specific amount of byte into the buffer at a specific offset.
- *
- * @warning buffer size is not check to hold the data if offset is to large.
- *
- * @param this calling private_generator_t object
- * @param bytes pointer to bytes to write
- * @param number_of_bytes number of bytes to write into buffer
- * @param offset offset to write the data into
- */
- void (*write_bytes_to_buffer_at_offset) (private_generator_t *this,void * bytes,size_t number_of_bytes,u_int32_t offset);
/**
* Buffer used to generate the data into.
@@ -232,43 +113,116 @@ struct private_generator_t {
};
/**
- * Implementation of private_generator_t.get_current_buffer_size.
+ * Get size of current buffer in bytes.
*/
-static size_t get_current_buffer_size (private_generator_t *this)
+static size_t get_current_buffer_size(private_generator_t *this)
{
- return ((this->roof_position) - (this->buffer));
+ return this->roof_position - this->buffer;
}
/**
- * Implementation of private_generator_t.get_current_buffer_space.
+ * Get free space of current buffer in bytes.
*/
-static size_t get_current_buffer_space (private_generator_t *this)
+static size_t get_current_buffer_space(private_generator_t *this)
{
- /* we know, one byte more */
- size_t space = (this->roof_position) - (this->out_position);
- return (space);
+ return this->roof_position - this->out_position;
}
/**
- * Implementation of private_generator_t.get_current_data_length.
+ * Get length of data in buffer (in bytes).
*/
-static size_t get_current_data_length (private_generator_t *this)
+static size_t get_current_data_length(private_generator_t *this)
{
- return (this->out_position - this->buffer);
+ return this->out_position - this->buffer;
}
/**
- * Implementation of private_generator_t.get_current_buffer_offset.
+ * Get current offset in buffer (in bytes).
*/
-static u_int32_t get_current_buffer_offset (private_generator_t *this)
+static u_int32_t get_current_buffer_offset(private_generator_t *this)
{
- return (this->out_position - this->buffer);
+ return this->out_position - this->buffer;
}
/**
- * Implementation of private_generator_t.generate_u_int_type.
+ * Makes sure enough space is available in buffer to store amount of bits.
*/
-static void generate_u_int_type (private_generator_t *this,encoding_type_t int_type,u_int32_t offset)
+static void make_space_available (private_generator_t *this, size_t bits)
+{
+ while ((get_current_buffer_space(this) * 8 - this->current_bit) < bits)
+ {
+ /* must increase buffer */
+ size_t old_buffer_size = get_current_buffer_size(this);
+ size_t new_buffer_size = old_buffer_size + GENERATOR_DATA_BUFFER_INCREASE_VALUE;
+ size_t out_position_offset = ((this->out_position) - (this->buffer));
+
+ DBG2(DBG_ENC, "increased gen buffer from %d to %d byte",
+ old_buffer_size, new_buffer_size);
+
+ /* Reallocate space for new buffer */
+ this->buffer = realloc(this->buffer,new_buffer_size);
+
+ this->out_position = (this->buffer + out_position_offset);
+ this->roof_position = (this->buffer + new_buffer_size);
+ }
+}
+
+/**
+ * Writes a specific amount of byte into the buffer.
+ */
+static void write_bytes_to_buffer(private_generator_t *this, void * bytes,
+ size_t number_of_bytes)
+{
+ int i;
+ u_int8_t *read_position = (u_int8_t *) bytes;
+
+ make_space_available(this, number_of_bytes * 8);
+
+ for (i = 0; i < number_of_bytes; i++)
+ {
+ *(this->out_position) = *(read_position);
+ read_position++;
+ this->out_position++;
+ }
+}
+
+/**
+ * Writes a specific amount of byte into the buffer at a specific offset.
+ */
+static void write_bytes_to_buffer_at_offset (private_generator_t *this,
+ void *bytes, size_t number_of_bytes, u_int32_t offset)
+{
+ int i;
+ u_int8_t *read_position = (u_int8_t *) bytes;
+ u_int8_t *write_position;
+ u_int32_t free_space_after_offset = get_current_buffer_size(this) - offset;
+
+ /* check first if enough space for new data is available */
+ if (number_of_bytes > free_space_after_offset)
+ {
+ make_space_available(this, (number_of_bytes - free_space_after_offset) * 8);
+ }
+
+ write_position = this->buffer + offset;
+ for (i = 0; i < number_of_bytes; i++)
+ {
+ *write_position = *read_position;
+ read_position++;
+ write_position++;
+ }
+}
+
+/**
+ * Generates a U_INT-Field type and writes it to buffer.
+ *
+ * @param this private_generator_t object
+ * @param int_type type of U_INT field (U_INT_4, U_INT_8, etc.)
+ * ATTRIBUTE_TYPE is also generated in this function
+ * @param offset offset of value in data struct
+ * @param generator_contexts generator_contexts_t object where the context is written or read from
+ */
+static void generate_u_int_type(private_generator_t *this,
+ encoding_type_t int_type,u_int32_t offset)
{
size_t number_of_bits = 0;
@@ -316,7 +270,7 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
}
/* make sure enough space is available in buffer */
- this->make_space_available(this,number_of_bits);
+ make_space_available(this, number_of_bits);
/* now handle each u int type differently */
switch (int_type)
{
@@ -386,7 +340,7 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
int16_val = htons(int16_val);
DBG3(DBG_ENC, " => %d", int16_val);
/* write bytes to buffer (set bit is overwritten)*/
- this->write_bytes_to_buffer(this,&int16_val,sizeof(u_int16_t));
+ write_bytes_to_buffer(this, &int16_val, sizeof(u_int16_t));
this->current_bit = 0;
break;
@@ -396,14 +350,14 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
{
u_int16_t int16_val = htons(*((u_int16_t*)(this->data_struct + offset)));
DBG3(DBG_ENC, " => %b", (void*)&int16_val, sizeof(int16_val));
- this->write_bytes_to_buffer(this,&int16_val,sizeof(u_int16_t));
+ write_bytes_to_buffer(this, &int16_val, sizeof(u_int16_t));
break;
}
case U_INT_32:
{
u_int32_t int32_val = htonl(*((u_int32_t*)(this->data_struct + offset)));
DBG3(DBG_ENC, " => %b", (void*)&int32_val, sizeof(int32_val));
- this->write_bytes_to_buffer(this,&int32_val,sizeof(u_int32_t));
+ write_bytes_to_buffer(this, &int32_val, sizeof(u_int32_t));
break;
}
case U_INT_64:
@@ -415,15 +369,15 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
(void*)&int32_val_low, sizeof(int32_val_low),
(void*)&int32_val_high, sizeof(int32_val_high));
/* TODO add support for big endian machines */
- this->write_bytes_to_buffer(this,&int32_val_high,sizeof(u_int32_t));
- this->write_bytes_to_buffer(this,&int32_val_low,sizeof(u_int32_t));
+ write_bytes_to_buffer(this, &int32_val_high, sizeof(u_int32_t));
+ write_bytes_to_buffer(this, &int32_val_low, sizeof(u_int32_t));
break;
}
case IKE_SPI:
{
/* 64 bit are written as they come :-) */
- this->write_bytes_to_buffer(this,(this->data_struct + offset),sizeof(u_int64_t));
+ write_bytes_to_buffer(this, this->data_struct + offset, sizeof(u_int64_t));
DBG3(DBG_ENC, " => %b", (void*)(this->data_struct + offset), sizeof(u_int64_t));
break;
}
@@ -437,9 +391,9 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
}
/**
- * Implementation of private_generator_t.generate_reserved_field.
+ * Generate a reserved bit or byte
*/
-static void generate_reserved_field(private_generator_t *this,int bits)
+static void generate_reserved_field(private_generator_t *this, int bits)
{
/* only one bit or 8 bit fields are supported */
if ((bits != 1) && (bits != 8))
@@ -448,7 +402,7 @@ static void generate_reserved_field(private_generator_t *this,int bits)
return ;
}
/* make sure enough space is available in buffer */
- this->make_space_available(this,bits);
+ make_space_available(this, bits);
if (bits == 1)
{
@@ -460,8 +414,6 @@ static void generate_reserved_field(private_generator_t *this,int bits)
/* memory must be zero */
*(this->out_position) = 0x00;
}
-
-
this->current_bit++;
if (this->current_bit >= 8)
{
@@ -484,9 +436,9 @@ static void generate_reserved_field(private_generator_t *this,int bits)
}
/**
- * Implementation of private_generator_t.generate_flag.
+ * Generate a FLAG filed
*/
-static void generate_flag (private_generator_t *this,u_int32_t offset)
+static void generate_flag(private_generator_t *this, u_int32_t offset)
{
/* value of current flag */
u_int8_t flag_value;
@@ -499,7 +451,7 @@ static void generate_flag (private_generator_t *this,u_int32_t offset)
flag = (flag_value << (7 - this->current_bit));
/* make sure one bit is available in buffer */
- this->make_space_available(this,1);
+ make_space_available(this, 1);
if (this->current_bit == 0)
{
/* memory must be zero */
@@ -520,9 +472,9 @@ static void generate_flag (private_generator_t *this,u_int32_t offset)
}
/**
- * Implementation of private_generator_t.generate_from_chunk.
+ * Generates a bytestream from a chunk_t.
*/
-static void generate_from_chunk (private_generator_t *this,u_int32_t offset)
+static void generate_from_chunk(private_generator_t *this, u_int32_t offset)
{
if (this->current_bit != 0)
{
@@ -536,73 +488,7 @@ static void generate_from_chunk (private_generator_t *this,u_int32_t offset)
DBG3(DBG_ENC, " => %B", attribute_value);
/* use write_bytes_to_buffer function to do the job */
- this->write_bytes_to_buffer(this,attribute_value->ptr,attribute_value->len);
-}
-
-/**
- * Implementation of private_generator_t.make_space_available.
- */
-static void make_space_available (private_generator_t *this, size_t bits)
-{
- while (((this->get_current_buffer_space(this) * 8) - this->current_bit) < bits)
- {
- /* must increase buffer */
- size_t old_buffer_size = this->get_current_buffer_size(this);
- size_t new_buffer_size = old_buffer_size + GENERATOR_DATA_BUFFER_INCREASE_VALUE;
- size_t out_position_offset = ((this->out_position) - (this->buffer));
-
- DBG2(DBG_ENC, "increased gen buffer from %d to %d byte",
- old_buffer_size, new_buffer_size);
-
- /* Reallocate space for new buffer */
- this->buffer = realloc(this->buffer,new_buffer_size);
-
- this->out_position = (this->buffer + out_position_offset);
- this->roof_position = (this->buffer + new_buffer_size);
- }
-}
-
-/**
- * Implementation of private_generator_t.write_bytes_to_buffer.
- */
-static void write_bytes_to_buffer (private_generator_t *this,void * bytes, size_t number_of_bytes)
-{
- int i;
- u_int8_t *read_position = (u_int8_t *) bytes;
-
- this->make_space_available(this,number_of_bytes * 8);
-
- for (i = 0; i < number_of_bytes; i++)
- {
- *(this->out_position) = *(read_position);
- read_position++;
- this->out_position++;
- }
-}
-
-/**
- * Implementation of private_generator_t.write_bytes_to_buffer_at_offset.
- */
-static void write_bytes_to_buffer_at_offset (private_generator_t *this,void * bytes,size_t number_of_bytes,u_int32_t offset)
-{
- int i;
- u_int8_t *read_position = (u_int8_t *) bytes;
- u_int8_t *write_position;
- u_int32_t free_space_after_offset = (this->get_current_buffer_size(this) - offset);
-
- /* check first if enough space for new data is available */
- if (number_of_bytes > free_space_after_offset)
- {
- this->make_space_available(this,(number_of_bytes - free_space_after_offset) * 8);
- }
-
- write_position = this->buffer + offset;
- for (i = 0; i < number_of_bytes; i++)
- {
- *(write_position) = *(read_position);
- read_position++;
- write_position++;
- }
+ write_bytes_to_buffer(this, attribute_value->ptr, attribute_value->len);
}
/**
@@ -610,14 +496,15 @@ static void write_bytes_to_buffer_at_offset (private_generator_t *this,void * by
*/
static void write_to_chunk (private_generator_t *this,chunk_t *data)
{
- size_t data_length = this->get_current_data_length(this);
+ size_t data_length = get_current_data_length(this);
u_int32_t header_length_field = data_length;
/* write length into header length field */
if (this->header_length_position_offset > 0)
{
u_int32_t int32_val = htonl(header_length_field);
- this->write_bytes_to_buffer_at_offset(this,&int32_val,sizeof(u_int32_t),this->header_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int32_val, sizeof(u_int32_t),
+ this->header_length_position_offset);
}
if (this->current_bit > 0)
@@ -660,7 +547,6 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
i, encoding_type_names, rules[i].type);
switch (rules[i].type)
{
- /* all u int values, IKE_SPI,TS_TYPE and ATTRIBUTE_TYPE are generated in generate_u_int_type */
case U_INT_4:
case U_INT_8:
case U_INT_16:
@@ -671,56 +557,56 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
case ATTRIBUTE_TYPE:
case CONFIGURATION_ATTRIBUTE_LENGTH:
{
- this->generate_u_int_type(this,rules[i].type,rules[i].offset);
+ generate_u_int_type(this, rules[i].type,rules[i].offset);
break;
}
case RESERVED_BIT:
{
- this->generate_reserved_field(this,1);
+ generate_reserved_field(this, 1);
break;
}
case RESERVED_BYTE:
{
- this->generate_reserved_field(this,8);
+ generate_reserved_field(this, 8);
break;
}
case FLAG:
{
- this->generate_flag(this,rules[i].offset);
+ generate_flag(this, rules[i].offset);
break;
}
case PAYLOAD_LENGTH:
{
/* position of payload lenght field is temporary stored */
- this->last_payload_length_position_offset = this->get_current_buffer_offset(this);
+ this->last_payload_length_position_offset = get_current_buffer_offset(this);
/* payload length is generated like an U_INT_16 */
- this->generate_u_int_type(this,U_INT_16,rules[i].offset);
+ generate_u_int_type(this, U_INT_16,rules[i].offset);
break;
}
case HEADER_LENGTH:
{
/* position of header length field is temporary stored */
- this->header_length_position_offset = this->get_current_buffer_offset(this);
+ this->header_length_position_offset = get_current_buffer_offset(this);
/* header length is generated like an U_INT_32 */
- this->generate_u_int_type(this,U_INT_32,rules[i].offset);
+ generate_u_int_type(this ,U_INT_32, rules[i].offset);
break;
}
case SPI_SIZE:
/* spi size is handled as 8 bit unsigned integer */
- this->generate_u_int_type(this,U_INT_8,rules[i].offset);
+ generate_u_int_type(this, U_INT_8, rules[i].offset);
/* last spi size is temporary stored */
this->last_spi_size = *((u_int8_t *)(this->data_struct + rules[i].offset));
break;
case ADDRESS:
{
/* the Address value is generated from chunk */
- this->generate_from_chunk(this,rules[i].offset);
+ generate_from_chunk(this, rules[i].offset);
break;
}
case SPI:
{
/* the SPI value is generated from chunk */
- this->generate_from_chunk(this,rules[i].offset);
+ generate_from_chunk(this, rules[i].offset);
break;
}
case KEY_EXCHANGE_DATA:
@@ -780,16 +666,17 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
}
/* the data value is generated from chunk */
- this->generate_from_chunk(this,rules[i].offset);
-
+ generate_from_chunk(this, rules[i].offset);
+
payload_length_position_offset = this->last_payload_length_position_offset;
/* Length of payload is calculated */
length_of_payload = header_length + ((chunk_t *)(this->data_struct + rules[i].offset))->len;
-
+
length_in_network_order = htons(length_of_payload);
- this->write_bytes_to_buffer_at_offset(this,&length_in_network_order,sizeof(u_int16_t),payload_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &length_in_network_order,
+ sizeof(u_int16_t),payload_length_position_offset);
break;
}
case PROPOSALS:
@@ -812,9 +699,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
u_int32_t before_generate_position_offset;
u_int32_t after_generate_position_offset;
- before_generate_position_offset = this->get_current_buffer_offset(this);
+ before_generate_position_offset = get_current_buffer_offset(this);
this->public.generate_payload(&(this->public),current_proposal);
- after_generate_position_offset = this->get_current_buffer_offset(this);
+ after_generate_position_offset = get_current_buffer_offset(this);
/* increase size of transform */
length_of_sa_payload += (after_generate_position_offset - before_generate_position_offset);
@@ -822,7 +709,8 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator->destroy(iterator);
int16_val = htons(length_of_sa_payload);
- this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int16_val,
+ sizeof(u_int16_t),payload_length_position_offset);
break;
}
case TRANSFORMS:
@@ -842,9 +730,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
u_int32_t before_generate_position_offset;
u_int32_t after_generate_position_offset;
- before_generate_position_offset = this->get_current_buffer_offset(this);
+ before_generate_position_offset = get_current_buffer_offset(this);
this->public.generate_payload(&(this->public),current_transform);
- after_generate_position_offset = this->get_current_buffer_offset(this);
+ after_generate_position_offset = get_current_buffer_offset(this);
/* increase size of transform */
length_of_proposal += (after_generate_position_offset - before_generate_position_offset);
@@ -853,7 +741,8 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator->destroy(iterator);
int16_val = htons(length_of_proposal);
- this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int16_val,
+ sizeof(u_int16_t), payload_length_position_offset);
break;
}
@@ -874,9 +763,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
u_int32_t before_generate_position_offset;
u_int32_t after_generate_position_offset;
- before_generate_position_offset = this->get_current_buffer_offset(this);
+ before_generate_position_offset = get_current_buffer_offset(this);
this->public.generate_payload(&(this->public),current_attribute);
- after_generate_position_offset = this->get_current_buffer_offset(this);
+ after_generate_position_offset = get_current_buffer_offset(this);
/* increase size of transform */
length_of_transform += (after_generate_position_offset - before_generate_position_offset);
@@ -885,7 +774,8 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator->destroy(iterator);
int16_val = htons(length_of_transform);
- this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),transform_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int16_val,
+ sizeof(u_int16_t),transform_length_position_offset);
break;
}
@@ -906,9 +796,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
u_int32_t before_generate_position_offset;
u_int32_t after_generate_position_offset;
- before_generate_position_offset = this->get_current_buffer_offset(this);
+ before_generate_position_offset = get_current_buffer_offset(this);
this->public.generate_payload(&(this->public),current_attribute);
- after_generate_position_offset = this->get_current_buffer_offset(this);
+ after_generate_position_offset = get_current_buffer_offset(this);
/* increase size of transform */
length_of_configurations += (after_generate_position_offset - before_generate_position_offset);
@@ -917,13 +807,14 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator->destroy(iterator);
int16_val = htons(length_of_configurations);
- this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),configurations_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int16_val,
+ sizeof(u_int16_t),configurations_length_position_offset);
break;
}
case ATTRIBUTE_FORMAT:
{
- this->generate_flag(this,rules[i].offset);
+ generate_flag(this, rules[i].offset);
/* Attribute format is a flag which is stored in context*/
this->attribute_format = *((bool *) (this->data_struct + rules[i].offset));
break;
@@ -933,13 +824,13 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
{
if (this->attribute_format == FALSE)
{
- this->generate_u_int_type(this,U_INT_16,rules[i].offset);
+ generate_u_int_type(this, U_INT_16, rules[i].offset);
/* this field hold the length of the attribute */
this->attribute_length = *((u_int16_t *)(this->data_struct + rules[i].offset));
}
else
{
- this->generate_u_int_type(this,U_INT_16,rules[i].offset);
+ generate_u_int_type(this, U_INT_16, rules[i].offset);
}
break;
}
@@ -949,7 +840,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
{
DBG2(DBG_ENC, "attribute value has not fixed size");
/* the attribute value is generated */
- this->generate_from_chunk(this,rules[i].offset);
+ generate_from_chunk(this, rules[i].offset);
}
break;
}
@@ -973,9 +864,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
u_int32_t before_generate_position_offset;
u_int32_t after_generate_position_offset;
- before_generate_position_offset = this->get_current_buffer_offset(this);
+ before_generate_position_offset = get_current_buffer_offset(this);
this->public.generate_payload(&(this->public),current_traffic_selector_substructure);
- after_generate_position_offset = this->get_current_buffer_offset(this);
+ after_generate_position_offset = get_current_buffer_offset(this);
/* increase size of transform */
length_of_ts_payload += (after_generate_position_offset - before_generate_position_offset);
@@ -983,13 +874,14 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator->destroy(iterator);
int16_val = htons(length_of_ts_payload);
- this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset);
+ write_bytes_to_buffer_at_offset(this, &int16_val,
+ sizeof(u_int16_t),payload_length_position_offset);
break;
}
case ENCRYPTED_DATA:
{
- this->generate_from_chunk(this, rules[i].offset);
+ generate_from_chunk(this, rules[i].offset);
break;
}
default:
@@ -1028,24 +920,9 @@ generator_t *generator_create()
this->public.destroy = (void(*)(generator_t*)) destroy;
this->public.write_to_chunk = (void (*) (generator_t *,chunk_t *)) write_to_chunk;
-
- /* initiate private functions */
- this->get_current_buffer_size = get_current_buffer_size;
- this->get_current_buffer_space = get_current_buffer_space;
- this->get_current_data_length = get_current_data_length;
- this->get_current_buffer_offset = get_current_buffer_offset;
- this->generate_u_int_type = generate_u_int_type;
- this->generate_reserved_field = generate_reserved_field;
- this->generate_flag = generate_flag;
- this->generate_from_chunk = generate_from_chunk;
- this->make_space_available = make_space_available;
- this->write_bytes_to_buffer = write_bytes_to_buffer;
- this->write_bytes_to_buffer_at_offset = write_bytes_to_buffer_at_offset;
-
-
/* allocate memory for buffer */
this->buffer = malloc(GENERATOR_DATA_BUFFER_SIZE);
-
+
/* initiate private variables */
this->out_position = this->buffer;
this->roof_position = this->buffer + GENERATOR_DATA_BUFFER_SIZE;
@@ -1053,6 +930,7 @@ generator_t *generator_create()
this->current_bit = 0;
this->last_payload_length_position_offset = 0;
this->header_length_position_offset = 0;
-
+
return &(this->public);
}
+
diff --git a/src/charon/encoding/generator.h b/src/charon/encoding/generator.h
index b6f2af2cb..d1d3522d0 100644
--- a/src/charon/encoding/generator.h
+++ b/src/charon/encoding/generator.h
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: generator.h 3589 2008-03-13 14:14:44Z martin $
+ * $Id: generator.h 4702 2008-11-26 10:42:54Z martin $
*/
/**
@@ -32,12 +32,12 @@ typedef struct generator_t generator_t;
/**
* Generating is done in a data buffer.
- * This is thehe start size of this buffer in bytes.
+ * This is the start size of this buffer in bytes.
*/
#define GENERATOR_DATA_BUFFER_SIZE 500
/**
- * Number of bytes to increase the buffer, if it is to small.
+ * Number of bytes to increase the buffer, if it is too small.
*/
#define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
diff --git a/src/charon/encoding/parser.c b/src/charon/encoding/parser.c
index 1b03aacb2..396054810 100644
--- a/src/charon/encoding/parser.c
+++ b/src/charon/encoding/parser.c
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: parser.c 4010 2008-05-23 18:23:17Z martin $
+ * $Id: parser.c 4703 2008-11-26 10:54:08Z martin $
*/
#include <stdlib.h>
@@ -62,147 +62,6 @@ struct private_parser_t {
parser_t public;
/**
- * Parse a 4-Bit unsigned integer from the current parsing position.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint4) (private_parser_t *this, int rule_number, u_int8_t *output_pos);
-
- /**
- * Parse a 8-Bit unsigned integer from the current parsing position.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint8) (private_parser_t *this, int rule_number, u_int8_t *output_pos);
-
- /**
- * Parse a 15-Bit unsigned integer from the current parsing position.
- *
- * This is a special case used for ATTRIBUTE_TYPE.
- * Big-/Little-endian conversion is done here.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint15) (private_parser_t *this, int rule_number, u_int16_t *output_pos);
-
- /**
- * Parse a 16-Bit unsigned integer from the current parsing position.
- *
- * Big-/Little-endian conversion is done here.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint16) (private_parser_t *this, int rule_number, u_int16_t *output_pos);
-
- /**
- * Parse a 32-Bit unsigned integer from the current parsing position.
- *
- * Big-/Little-endian conversion is done here.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint32) (private_parser_t *this, int rule_number, u_int32_t *output_pos);
-
- /**
- * Parse a 64-Bit unsigned integer from the current parsing position.
- *
- * @todo add support for big-endian machines.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_uint64) (private_parser_t *this, int rule_number, u_int64_t *output_pos);
-
- /**
- * Parse a given amount of bytes and writes them to a specific location
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @param bytes number of bytes to parse
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_bytes) (private_parser_t *this, int rule_number, u_int8_t *output_pos,size_t bytes);
-
- /**
- * Parse a single Bit from the current parsing position
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer where to write the parsed result
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_bit) (private_parser_t *this, int rule_number, bool *output_pos);
-
- /**
- * Parse substructures in a list
- *
- * This function calls the parser recursively to parse contained substructures
- * in a linked_list_t. The list must already be created. Payload defines
- * the type of the substructures. parsing is continued until the specified length
- * is completely parsed.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer of a linked_list where substructures are added
- * @param payload_type type of the contained substructures to parse
- * @param length number of bytes to parse in this list
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_list) (private_parser_t *this, int rule_number, linked_list_t **output_pos, payload_type_t payload_ype, size_t length);
-
- /**
- * Parse data from current parsing position in a chunk.
- *
- * This function clones length number of bytes to output_pos, without
- * modifiyng them. Space will be allocated and must be freed by caller.
- *
- * @param this parser_t object
- * @param rule_number number of current rule
- * @param[out] output_pos pointer of a chunk which will point to the allocated data
- * @param length number of bytes to clone
- * @return
- * - SUCCESS or
- * - PARSE_ERROR when not successful
- */
- status_t (*parse_chunk) (private_parser_t *this, int rule_number, chunk_t *output_pos, size_t length);
-
- /**
* Current bit for reading in input data.
*/
u_int8_t bit_pos;
@@ -229,7 +88,7 @@ struct private_parser_t {
};
/**
- * Implementation of private_parser_t.parse_uint4.
+ * Parse a 4-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint4(private_parser_t *this, int rule_number, u_int8_t *output_pos)
{
@@ -274,7 +133,7 @@ static status_t parse_uint4(private_parser_t *this, int rule_number, u_int8_t *o
}
/**
- * Implementation of private_parser_t.parse_uint8.
+ * Parse a 8-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint8(private_parser_t *this, int rule_number, u_int8_t *output_pos)
{
@@ -304,7 +163,7 @@ static status_t parse_uint8(private_parser_t *this, int rule_number, u_int8_t *o
}
/**
- * Implementation of private_parser_t.parse_uint15.
+ * Parse a 15-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint15(private_parser_t *this, int rule_number, u_int16_t *output_pos)
{
@@ -333,7 +192,7 @@ static status_t parse_uint15(private_parser_t *this, int rule_number, u_int16_t
}
/**
- * Implementation of private_parser_t.parse_uint16.
+ * Parse a 16-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint16(private_parser_t *this, int rule_number, u_int16_t *output_pos)
{
@@ -361,7 +220,7 @@ static status_t parse_uint16(private_parser_t *this, int rule_number, u_int16_t
return SUCCESS;
}
/**
- * Implementation of private_parser_t.parse_uint32.
+ * Parse a 32-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint32(private_parser_t *this, int rule_number, u_int32_t *output_pos)
{
@@ -390,7 +249,7 @@ static status_t parse_uint32(private_parser_t *this, int rule_number, u_int32_t
}
/**
- * Implementation of private_parser_t.parse_uint64.
+ * Parse a 64-Bit unsigned integer from the current parsing position.
*/
static status_t parse_uint64(private_parser_t *this, int rule_number, u_int64_t *output_pos)
{
@@ -421,7 +280,7 @@ static status_t parse_uint64(private_parser_t *this, int rule_number, u_int64_t
}
/**
- * Implementation of private_parser_t.parse_bytes.
+ * Parse a given amount of bytes and writes them to a specific location
*/
static status_t parse_bytes (private_parser_t *this, int rule_number, u_int8_t *output_pos,size_t bytes)
{
@@ -451,7 +310,7 @@ static status_t parse_bytes (private_parser_t *this, int rule_number, u_int8_t *
}
/**
- * Implementation of private_parser_t.parse_bit.
+ * Parse a single Bit from the current parsing position
*/
static status_t parse_bit(private_parser_t *this, int rule_number, bool *output_pos)
{
@@ -486,7 +345,7 @@ static status_t parse_bit(private_parser_t *this, int rule_number, bool *output_
}
/**
- * Implementation of private_parser_t.parse_list.
+ * Parse substructures in a list.
*/
static status_t parse_list(private_parser_t *this, int rule_number, linked_list_t **output_pos, payload_type_t payload_type, size_t length)
{
@@ -528,7 +387,7 @@ static status_t parse_list(private_parser_t *this, int rule_number, linked_list_
}
/**
- * Implementation of private_parser_t.parse_chunk.
+ * Parse data from current parsing position in a chunk.
*/
static status_t parse_chunk(private_parser_t *this, int rule_number, chunk_t *output_pos, size_t length)
{
@@ -598,7 +457,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
{
case U_INT_4:
{
- if (this->parse_uint4(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint4(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -607,7 +466,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case U_INT_8:
{
- if (this->parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -616,7 +475,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case U_INT_16:
{
- if (this->parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -625,7 +484,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case U_INT_32:
{
- if (this->parse_uint32(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint32(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -634,7 +493,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case U_INT_64:
{
- if (this->parse_uint64(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint64(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -643,7 +502,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case IKE_SPI:
{
- if (this->parse_bytes(this, rule_number, output + rule->offset,8) != SUCCESS)
+ if (parse_bytes(this, rule_number, output + rule->offset,8) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -652,7 +511,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case RESERVED_BIT:
{
- if (this->parse_bit(this, rule_number, NULL) != SUCCESS)
+ if (parse_bit(this, rule_number, NULL) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -661,7 +520,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case RESERVED_BYTE:
{
- if (this->parse_uint8(this, rule_number, NULL) != SUCCESS)
+ if (parse_uint8(this, rule_number, NULL) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -670,7 +529,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case FLAG:
{
- if (this->parse_bit(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_bit(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -679,7 +538,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case PAYLOAD_LENGTH:
{
- if (this->parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -694,7 +553,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case HEADER_LENGTH:
{
- if (this->parse_uint32(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint32(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -703,7 +562,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case SPI_SIZE:
{
- if (this->parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -713,7 +572,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case SPI:
{
- if (this->parse_chunk(this, rule_number, output + rule->offset, spi_size) != SUCCESS)
+ if (parse_chunk(this, rule_number, output + rule->offset, spi_size) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -723,7 +582,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case PROPOSALS:
{
if (payload_length < SA_PAYLOAD_HEADER_LENGTH ||
- this->parse_list(this, rule_number, output + rule->offset, PROPOSAL_SUBSTRUCTURE,
+ parse_list(this, rule_number, output + rule->offset, PROPOSAL_SUBSTRUCTURE,
payload_length - SA_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -734,7 +593,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case TRANSFORMS:
{
if (payload_length < spi_size + PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH ||
- this->parse_list(this, rule_number, output + rule->offset, TRANSFORM_SUBSTRUCTURE,
+ parse_list(this, rule_number, output + rule->offset, TRANSFORM_SUBSTRUCTURE,
payload_length - spi_size - PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -745,7 +604,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case TRANSFORM_ATTRIBUTES:
{
if (payload_length < TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH ||
- this->parse_list(this, rule_number, output + rule->offset, TRANSFORM_ATTRIBUTE,
+ parse_list(this, rule_number, output + rule->offset, TRANSFORM_ATTRIBUTE,
payload_length - TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -756,7 +615,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case CONFIGURATION_ATTRIBUTES:
{
if (payload_length < CP_PAYLOAD_HEADER_LENGTH ||
- this->parse_list(this, rule_number, output + rule->offset, CONFIGURATION_ATTRIBUTE,
+ parse_list(this, rule_number, output + rule->offset, CONFIGURATION_ATTRIBUTE,
payload_length - CP_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -766,7 +625,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case ATTRIBUTE_FORMAT:
{
- if (this->parse_bit(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_bit(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -776,7 +635,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case ATTRIBUTE_TYPE:
{
- if (this->parse_uint15(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint15(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -786,7 +645,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case CONFIGURATION_ATTRIBUTE_LENGTH:
{
- if (this->parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -796,7 +655,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case ATTRIBUTE_LENGTH_OR_VALUE:
{
- if (this->parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint16(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -808,7 +667,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
{
if (attribute_format == FALSE)
{
- if (this->parse_chunk(this, rule_number, output + rule->offset, attribute_length) != SUCCESS)
+ if (parse_chunk(this, rule_number, output + rule->offset, attribute_length) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -819,7 +678,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case NONCE_DATA:
{
if (payload_length < NONCE_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - NONCE_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -830,7 +689,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case ID_DATA:
{
if (payload_length < ID_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - ID_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -841,7 +700,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case AUTH_DATA:
{
if (payload_length < AUTH_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - AUTH_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -852,7 +711,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case CERT_DATA:
{
if (payload_length < CERT_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - CERT_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -863,7 +722,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case CERTREQ_DATA:
{
if (payload_length < CERTREQ_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - CERTREQ_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -874,7 +733,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case EAP_DATA:
{
if (payload_length < EAP_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - EAP_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -885,7 +744,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case SPIS:
{
if (payload_length < DELETE_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - DELETE_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -896,7 +755,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case VID_DATA:
{
if (payload_length < VENDOR_ID_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - VENDOR_ID_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -907,7 +766,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case CONFIGURATION_ATTRIBUTE_VALUE:
{
size_t data_length = attribute_length;
- if (this->parse_chunk(this, rule_number, output + rule->offset, data_length) != SUCCESS)
+ if (parse_chunk(this, rule_number, output + rule->offset, data_length) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -917,7 +776,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case KEY_EXCHANGE_DATA:
{
if (payload_length < KE_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - KE_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -928,7 +787,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case NOTIFICATION_DATA:
{
if (payload_length < NOTIFY_PAYLOAD_HEADER_LENGTH + spi_size ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - NOTIFY_PAYLOAD_HEADER_LENGTH - spi_size) != SUCCESS)
{
pld->destroy(pld);
@@ -939,7 +798,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case ENCRYPTED_DATA:
{
if (payload_length < ENCRYPTION_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - ENCRYPTION_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -949,7 +808,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
}
case TS_TYPE:
{
- if (this->parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
+ if (parse_uint8(this, rule_number, output + rule->offset) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -960,7 +819,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case ADDRESS:
{
size_t address_length = (ts_type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
- if (this->parse_chunk(this, rule_number, output + rule->offset,address_length) != SUCCESS)
+ if (parse_chunk(this, rule_number, output + rule->offset,address_length) != SUCCESS)
{
pld->destroy(pld);
return PARSE_ERROR;
@@ -970,7 +829,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case TRAFFIC_SELECTORS:
{
if (payload_length < TS_PAYLOAD_HEADER_LENGTH ||
- this->parse_list(this, rule_number, output + rule->offset, TRAFFIC_SELECTOR_SUBSTRUCTURE,
+ parse_list(this, rule_number, output + rule->offset, TRAFFIC_SELECTOR_SUBSTRUCTURE,
payload_length - TS_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -981,7 +840,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
case UNKNOWN_DATA:
{
if (payload_length < UNKNOWN_PAYLOAD_HEADER_LENGTH ||
- this->parse_chunk(this, rule_number, output + rule->offset,
+ parse_chunk(this, rule_number, output + rule->offset,
payload_length - UNKNOWN_PAYLOAD_HEADER_LENGTH) != SUCCESS)
{
pld->destroy(pld);
@@ -1045,17 +904,6 @@ parser_t *parser_create(chunk_t data)
this->public.get_remaining_byte_count = (int (*) (parser_t *))get_remaining_byte_count;
this->public.destroy = (void(*)(parser_t*)) destroy;
- this->parse_uint4 = parse_uint4;
- this->parse_uint8 = parse_uint8;
- this->parse_uint15 = parse_uint15;
- this->parse_uint16 = parse_uint16;
- this->parse_uint32 = parse_uint32;
- this->parse_uint64 = parse_uint64;
- this->parse_bytes = parse_bytes;
- this->parse_bit = parse_bit;
- this->parse_list = parse_list;
- this->parse_chunk = parse_chunk;
-
this->input = data.ptr;
this->byte_pos = data.ptr;
this->bit_pos = 0;
diff --git a/src/charon/encoding/payloads/configuration_attribute.c b/src/charon/encoding/payloads/configuration_attribute.c
index 6b1cbffb4..ad8177e1f 100644
--- a/src/charon/encoding/payloads/configuration_attribute.c
+++ b/src/charon/encoding/payloads/configuration_attribute.c
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: configuration_attribute.c 3589 2008-03-13 14:14:44Z martin $
+ * $Id: configuration_attribute.c 4844 2009-01-20 22:55:13Z andreas $
*/
#include <stddef.h>
@@ -69,7 +69,10 @@ ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP6_DNS, INTERNAL_IP6_SUB
"INTERNAL_IP4_SUBNET",
"SUPPORTED_ATTRIBUTES",
"INTERNAL_IP6_SUBNET");
-ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SUBNET);
+ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_SUBNET,
+ "INTERNAL_IP4_SERVER",
+ "INTERNAL_IP6_SERVER");
+ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
/**
* Encoding rules to parse or generate a configuration attribute.
diff --git a/src/charon/encoding/payloads/configuration_attribute.h b/src/charon/encoding/payloads/configuration_attribute.h
index ade837107..4c8673a26 100644
--- a/src/charon/encoding/payloads/configuration_attribute.h
+++ b/src/charon/encoding/payloads/configuration_attribute.h
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: configuration_attribute.h 3589 2008-03-13 14:14:44Z martin $
+ * $Id: configuration_attribute.h 4844 2009-01-20 22:55:13Z andreas $
*/
/**
@@ -53,7 +53,10 @@ enum configuration_attribute_type_t {
INTERNAL_IP6_DHCP = 12,
INTERNAL_IP4_SUBNET = 13,
SUPPORTED_ATTRIBUTES = 14,
- INTERNAL_IP6_SUBNET = 15
+ INTERNAL_IP6_SUBNET = 15,
+ /* proprietary Microsoft attributes */
+ INTERNAL_IP4_SERVER = 23456,
+ INTERNAL_IP6_SERVER = 23457
};
/**
diff --git a/src/charon/encoding/payloads/nonce_payload.h b/src/charon/encoding/payloads/nonce_payload.h
index f1679834e..f1e49491d 100644
--- a/src/charon/encoding/payloads/nonce_payload.h
+++ b/src/charon/encoding/payloads/nonce_payload.h
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: nonce_payload.h 3589 2008-03-13 14:14:44Z martin $
+ * $Id: nonce_payload.h 4819 2008-12-31 08:58:49Z martin $
*/
/**
@@ -32,7 +32,7 @@ typedef struct nonce_payload_t nonce_payload_t;
/**
* Nonce size in bytes for nonces sending to other peer.
*/
-#define NONCE_SIZE 16
+#define NONCE_SIZE 32
/**
* Length of a nonce payload without a nonce in bytes.
diff --git a/src/charon/encoding/payloads/notify_payload.c b/src/charon/encoding/payloads/notify_payload.c
index defb0b98a..a4377c275 100644
--- a/src/charon/encoding/payloads/notify_payload.c
+++ b/src/charon/encoding/payloads/notify_payload.c
@@ -15,7 +15,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: notify_payload.c 3920 2008-05-08 16:19:11Z tobias $
+ * $Id: notify_payload.c 4842 2009-01-19 12:32:42Z andreas $
*/
#include <stddef.h>
@@ -54,7 +54,7 @@ ENUM_NEXT(notify_type_names, SINGLE_PAIR_REQUIRED, UNEXPECTED_NAT_DETECTED, AUTH
"UNEXPECTED_NAT_DETECTED");
ENUM_NEXT(notify_type_names, ME_CONNECT_FAILED, ME_CONNECT_FAILED, UNEXPECTED_NAT_DETECTED,
"ME_CONNECT_FAILED");
-ENUM_NEXT(notify_type_names, INITIAL_CONTACT, AUTH_LIFETIME, ME_CONNECT_FAILED,
+ENUM_NEXT(notify_type_names, INITIAL_CONTACT, ANOTHER_AUTH_FOLLOWS, ME_CONNECT_FAILED,
"INITIAL_CONTACT",
"SET_WINDOW_SIZE",
"ADDITIONAL_TS_POSSIBLE",
@@ -74,8 +74,10 @@ ENUM_NEXT(notify_type_names, INITIAL_CONTACT, AUTH_LIFETIME, ME_CONNECT_FAILED,
"UPDATE_SA_ADDRESSES",
"COOKIE2",
"NO_NATS_ALLOWED",
- "AUTH_LIFETIME");
-ENUM_NEXT(notify_type_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, AUTH_LIFETIME,
+ "AUTH_LIFETIME",
+ "MULTIPLE_AUTH_SUPPORTED",
+ "ANOTHER_AUTH_FOLLOWS");
+ENUM_NEXT(notify_type_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, ANOTHER_AUTH_FOLLOWS,
"EAP_ONLY_AUTHENTICATION");
ENUM_NEXT(notify_type_names, USE_BEET_MODE, USE_BEET_MODE, EAP_ONLY_AUTHENTICATION,
"USE_BEET_MODE");
@@ -118,7 +120,7 @@ ENUM_NEXT(notify_type_short_names, SINGLE_PAIR_REQUIRED, UNEXPECTED_NAT_DETECTED
"UNEXPECT_NAT");
ENUM_NEXT(notify_type_short_names, ME_CONNECT_FAILED, ME_CONNECT_FAILED, UNEXPECTED_NAT_DETECTED,
"ME_CONN_FAIL");
-ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT, AUTH_LIFETIME, ME_CONNECT_FAILED,
+ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT, ANOTHER_AUTH_FOLLOWS, ME_CONNECT_FAILED,
"INIT_CONTACT",
"SET_WINSIZE",
"ADD_TS_POSS",
@@ -138,8 +140,10 @@ ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT, AUTH_LIFETIME, ME_CONNECT_FA
"UPD_SA_ADDR",
"COOKIE2",
"NO_NATS",
- "AUTH_LFT");
-ENUM_NEXT(notify_type_short_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, AUTH_LIFETIME,
+ "AUTH_LFT",
+ "MULT_AUTH",
+ "AUTH_FOLLOWS");
+ENUM_NEXT(notify_type_short_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, ANOTHER_AUTH_FOLLOWS,
"EAP_ONLY");
ENUM_NEXT(notify_type_short_names, USE_BEET_MODE, USE_BEET_MODE, EAP_ONLY_AUTHENTICATION,
"BEET_MODE");
diff --git a/src/charon/encoding/payloads/notify_payload.h b/src/charon/encoding/payloads/notify_payload.h
index f4a3bf27c..6ee137543 100644
--- a/src/charon/encoding/payloads/notify_payload.h
+++ b/src/charon/encoding/payloads/notify_payload.h
@@ -15,7 +15,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: notify_payload.h 3670 2008-03-27 09:54:09Z tobias $
+ * $Id: notify_payload.h 4842 2009-01-19 12:32:42Z andreas $
*/
/**
@@ -89,6 +89,9 @@ enum notify_type_t {
NO_NATS_ALLOWED = 16402,
/* repeated authentication extension, RFC4478 */
AUTH_LIFETIME = 16403,
+ /* multiple authentication exchanges, RFC 4739 */
+ MULTIPLE_AUTH_SUPPORTED = 16404,
+ ANOTHER_AUTH_FOLLOWS = 16405,
/* draft-eronen-ipsec-ikev2-eap-auth, not assigned by IANA yet */
EAP_ONLY_AUTHENTICATION = 40960,
/* BEET mode, not even a draft yet. private use */
diff --git a/src/charon/encoding/payloads/payload.h b/src/charon/encoding/payloads/payload.h
index abc79259a..7a19cc76c 100644
--- a/src/charon/encoding/payloads/payload.h
+++ b/src/charon/encoding/payloads/payload.h
@@ -14,7 +14,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: payload.h 3666 2008-03-26 18:40:19Z tobias $
+ * $Id: payload.h 4875 2009-02-17 17:14:15Z tobias $
*/
/**
@@ -86,7 +86,7 @@ enum payload_type_t{
NONCE = 40,
/**
- * Notif paylaod (N).
+ * Notify paylaod (N).
*/
NOTIFY = 41,