summaryrefslogtreecommitdiff
path: root/src/libcharon/encoding
diff options
context:
space:
mode:
authorRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:29:19 +0100
committerRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:29:19 +0100
commit365e71f706b40c32173fa06c6feaac48c1527520 (patch)
tree54fa72a914d18c9430eaa54f3de4a2d4419198af /src/libcharon/encoding
parent5d7669b7b3563c50b3c86903e0a49373d597b8a0 (diff)
parent568905f488e63e28778f87ac0e38d845f45bae79 (diff)
downloadvyos-strongswan-365e71f706b40c32173fa06c6feaac48c1527520.tar.gz
vyos-strongswan-365e71f706b40c32173fa06c6feaac48c1527520.zip
Fixed merge, don't know why this didn't happen automatically - maybe a leftover from the svn->git conversion
Diffstat (limited to 'src/libcharon/encoding')
-rw-r--r--src/libcharon/encoding/generator.c113
-rw-r--r--src/libcharon/encoding/message.c216
-rw-r--r--src/libcharon/encoding/message.h54
-rw-r--r--src/libcharon/encoding/parser.c17
-rw-r--r--src/libcharon/encoding/payloads/auth_payload.c137
-rw-r--r--src/libcharon/encoding/payloads/auth_payload.h25
-rw-r--r--src/libcharon/encoding/payloads/cert_payload.c181
-rw-r--r--src/libcharon/encoding/payloads/cert_payload.h12
-rw-r--r--src/libcharon/encoding/payloads/certreq_payload.c131
-rw-r--r--src/libcharon/encoding/payloads/configuration_attribute.c94
-rw-r--r--src/libcharon/encoding/payloads/cp_payload.c138
-rw-r--r--src/libcharon/encoding/payloads/delete_payload.c19
-rw-r--r--src/libcharon/encoding/payloads/eap_payload.c18
-rw-r--r--src/libcharon/encoding/payloads/id_payload.c129
-rw-r--r--src/libcharon/encoding/payloads/id_payload.h9
-rw-r--r--src/libcharon/encoding/payloads/ike_header.c225
-rw-r--r--src/libcharon/encoding/payloads/ike_header.h34
-rw-r--r--src/libcharon/encoding/payloads/ke_payload.c133
-rw-r--r--src/libcharon/encoding/payloads/ke_payload.h12
-rw-r--r--src/libcharon/encoding/payloads/nonce_payload.c130
-rw-r--r--src/libcharon/encoding/payloads/notify_payload.c172
-rw-r--r--src/libcharon/encoding/payloads/payload.c77
-rw-r--r--src/libcharon/encoding/payloads/payload.h47
-rw-r--r--src/libcharon/encoding/payloads/proposal_substructure.c52
-rw-r--r--src/libcharon/encoding/payloads/proposal_substructure.h8
-rw-r--r--src/libcharon/encoding/payloads/sa_payload.c34
-rw-r--r--src/libcharon/encoding/payloads/sa_payload.h10
-rw-r--r--src/libcharon/encoding/payloads/traffic_selector_substructure.c124
-rw-r--r--src/libcharon/encoding/payloads/transform_attribute.c161
-rw-r--r--src/libcharon/encoding/payloads/transform_substructure.c203
-rw-r--r--src/libcharon/encoding/payloads/transform_substructure.h41
-rw-r--r--src/libcharon/encoding/payloads/ts_payload.c217
-rw-r--r--src/libcharon/encoding/payloads/ts_payload.h22
-rw-r--r--src/libcharon/encoding/payloads/unknown_payload.c137
-rw-r--r--src/libcharon/encoding/payloads/unknown_payload.h20
-rw-r--r--src/libcharon/encoding/payloads/vendor_id_payload.c106
-rw-r--r--src/libcharon/encoding/payloads/vendor_id_payload.h8
37 files changed, 3266 insertions, 0 deletions
diff --git a/src/libcharon/encoding/generator.c b/src/libcharon/encoding/generator.c
index 224f76fce..785f1430a 100644
--- a/src/libcharon/encoding/generator.c
+++ b/src/libcharon/encoding/generator.c
@@ -41,6 +41,10 @@
#include <encoding/payloads/cp_payload.h>
#include <encoding/payloads/configuration_attribute.h>
#include <encoding/payloads/eap_payload.h>
+<<<<<<< HEAD
+=======
+#include <encoding/payloads/unknown_payload.h>
+>>>>>>> upstream/4.5.1
/**
* Generating is done in a data buffer.
@@ -89,6 +93,7 @@ struct private_generator_t {
*/
void *data_struct;
+<<<<<<< HEAD
/*
* Last payload length position offset in the buffer.
*/
@@ -103,6 +108,12 @@ struct private_generator_t {
* Last SPI size.
*/
u_int8_t last_spi_size;
+=======
+ /**
+ * Offset of the header length field in the buffer.
+ */
+ u_int32_t header_length_offset;
+>>>>>>> upstream/4.5.1
/**
* Attribute format of the last generated transform attribute.
@@ -193,6 +204,7 @@ static void write_bytes_to_buffer(private_generator_t *this, void *bytes,
}
/**
+<<<<<<< HEAD
* 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,
@@ -220,6 +232,8 @@ static void write_bytes_to_buffer_at_offset(private_generator_t *this,
}
/**
+=======
+>>>>>>> upstream/4.5.1
* Generates a U_INT-Field type and writes it to buffer.
*/
static void generate_u_int_type(private_generator_t *this,
@@ -234,10 +248,19 @@ static void generate_u_int_type(private_generator_t *this,
number_of_bits = 4;
break;
case TS_TYPE:
+<<<<<<< HEAD
+=======
+ case RESERVED_BYTE:
+ case SPI_SIZE:
+>>>>>>> upstream/4.5.1
case U_INT_8:
number_of_bits = 8;
break;
case U_INT_16:
+<<<<<<< HEAD
+=======
+ case PAYLOAD_LENGTH:
+>>>>>>> upstream/4.5.1
case CONFIGURATION_ATTRIBUTE_LENGTH:
number_of_bits = 16;
break;
@@ -301,6 +324,11 @@ static void generate_u_int_type(private_generator_t *this,
break;
}
case TS_TYPE:
+<<<<<<< HEAD
+=======
+ case RESERVED_BYTE:
+ case SPI_SIZE:
+>>>>>>> upstream/4.5.1
case U_INT_8:
{
/* 8 bit values are written as they are */
@@ -338,6 +366,10 @@ static void generate_u_int_type(private_generator_t *this,
}
case U_INT_16:
+<<<<<<< HEAD
+=======
+ case PAYLOAD_LENGTH:
+>>>>>>> upstream/4.5.1
case CONFIGURATION_ATTRIBUTE_LENGTH:
{
u_int16_t val = htons(*((u_int16_t*)(this->data_struct + offset)));
@@ -371,6 +403,7 @@ static void generate_u_int_type(private_generator_t *this,
}
/**
+<<<<<<< HEAD
* Generate a reserved bit or byte
*/
static void generate_reserved_field(private_generator_t *this, int bits)
@@ -414,6 +447,8 @@ static void generate_reserved_field(private_generator_t *this, int bits)
}
/**
+=======
+>>>>>>> upstream/4.5.1
* Generate a FLAG filed
*/
static void generate_flag(private_generator_t *this, u_int32_t offset)
@@ -468,7 +503,11 @@ METHOD(generator_t, get_chunk, chunk_t,
{
chunk_t data;
+<<<<<<< HEAD
*lenpos = (u_int32_t*)(this->buffer + this->header_length_position_offset);
+=======
+ *lenpos = (u_int32_t*)(this->buffer + this->header_length_offset);
+>>>>>>> upstream/4.5.1
data = chunk_create(this->buffer, get_length(this));
DBG3(DBG_ENC, "generated data of this generator %B", &data);
return data;
@@ -484,8 +523,11 @@ METHOD(generator_t, generate_payload, void,
this->data_struct = payload;
payload_type = payload->get_type(payload);
+<<<<<<< HEAD
/* spi size has to get reseted */
this->last_spi_size = 0;
+=======
+>>>>>>> upstream/4.5.1
offset_start = this->out_position - this->buffer;
@@ -505,6 +547,7 @@ METHOD(generator_t, generate_payload, void,
case U_INT_8:
case U_INT_16:
case U_INT_32:
+<<<<<<< HEAD
case IKE_SPI:
case TS_TYPE:
case ATTRIBUTE_TYPE:
@@ -555,6 +598,27 @@ METHOD(generator_t, generate_payload, void,
generate_from_chunk(this, rules[i].offset);
break;
}
+=======
+ case PAYLOAD_LENGTH:
+ case IKE_SPI:
+ case RESERVED_BYTE:
+ case SPI_SIZE:
+ case TS_TYPE:
+ case ATTRIBUTE_TYPE:
+ case CONFIGURATION_ATTRIBUTE_LENGTH:
+ generate_u_int_type(this, rules[i].type, rules[i].offset);
+ break;
+ case RESERVED_BIT:
+ case FLAG:
+ generate_flag(this, rules[i].offset);
+ break;
+ case HEADER_LENGTH:
+ this->header_length_offset = get_offset(this);
+ generate_u_int_type(this, U_INT_32, rules[i].offset);
+ break;
+ case ADDRESS:
+ case SPI:
+>>>>>>> upstream/4.5.1
case KEY_EXCHANGE_DATA:
case NOTIFICATION_DATA:
case NONCE_DATA:
@@ -566,6 +630,7 @@ METHOD(generator_t, generate_payload, void,
case CONFIGURATION_ATTRIBUTE_VALUE:
case VID_DATA:
case EAP_DATA:
+<<<<<<< HEAD
{
u_int32_t payload_length_position_offset;
u_int16_t length_of_payload;
@@ -756,11 +821,39 @@ METHOD(generator_t, generate_payload, void,
}
case ATTRIBUTE_FORMAT:
{
+=======
+ case ENCRYPTED_DATA:
+ case UNKNOWN_DATA:
+ generate_from_chunk(this, rules[i].offset);
+ break;
+ case PROPOSALS:
+ case TRANSFORMS:
+ case TRANSFORM_ATTRIBUTES:
+ case CONFIGURATION_ATTRIBUTES:
+ case TRAFFIC_SELECTORS:
+ {
+ linked_list_t *proposals;
+ enumerator_t *enumerator;
+ payload_t *proposal;
+
+ proposals = *((linked_list_t **)
+ (this->data_struct + rules[i].offset));
+ enumerator = proposals->create_enumerator(proposals);
+ while (enumerator->enumerate(enumerator, &proposal))
+ {
+ generate_payload(this, proposal);
+ }
+ enumerator->destroy(enumerator);
+ break;
+ }
+ case ATTRIBUTE_FORMAT:
+>>>>>>> upstream/4.5.1
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;
+<<<<<<< HEAD
}
case ATTRIBUTE_LENGTH_OR_VALUE:
@@ -771,16 +864,33 @@ METHOD(generator_t, generate_payload, void,
/* this field hold the length of the attribute */
this->attribute_length =
*((u_int16_t *)(this->data_struct + rules[i].offset));
+=======
+ case ATTRIBUTE_LENGTH_OR_VALUE:
+ if (this->attribute_format)
+ {
+ generate_u_int_type(this, U_INT_16, rules[i].offset);
+>>>>>>> upstream/4.5.1
}
else
{
generate_u_int_type(this, U_INT_16, rules[i].offset);
+<<<<<<< HEAD
}
break;
}
case ATTRIBUTE_VALUE:
{
if (this->attribute_format == FALSE)
+=======
+ /* this field hold the length of the attribute */
+ this->attribute_length =
+ *((u_int16_t *)(this->data_struct + rules[i].offset));
+ }
+ break;
+ case ATTRIBUTE_VALUE:
+ {
+ if (!this->attribute_format)
+>>>>>>> upstream/4.5.1
{
DBG2(DBG_ENC, "attribute value has not fixed size");
/* the attribute value is generated */
@@ -788,6 +898,7 @@ METHOD(generator_t, generate_payload, void,
}
break;
}
+<<<<<<< HEAD
case TRAFFIC_SELECTORS:
{
u_int32_t payload_length_position_offset =
@@ -826,6 +937,8 @@ METHOD(generator_t, generate_payload, void,
generate_from_chunk(this, rules[i].offset);
break;
}
+=======
+>>>>>>> upstream/4.5.1
default:
DBG1(DBG_ENC, "field type %N is not supported",
encoding_type_names, rules[i].type);
diff --git a/src/libcharon/encoding/message.c b/src/libcharon/encoding/message.c
index d41ad4697..071424812 100644
--- a/src/libcharon/encoding/message.c
+++ b/src/libcharon/encoding/message.c
@@ -131,6 +131,10 @@ static payload_rule_t ike_sa_init_r_rules[] = {
{SECURITY_ASSOCIATION, 1, 1, FALSE, FALSE},
{KEY_EXCHANGE, 1, 1, FALSE, FALSE},
{NONCE, 1, 1, FALSE, FALSE},
+<<<<<<< HEAD
+=======
+ {CERTIFICATE_REQUEST, 1, 1, FALSE, FALSE},
+>>>>>>> upstream/4.5.1
{VENDOR_ID, 0, 10, FALSE, FALSE},
};
@@ -490,6 +494,24 @@ struct private_message_t {
bool is_request;
/**
+<<<<<<< HEAD
+=======
+ * Higher version supported?
+ */
+ bool version_flag;
+
+ /**
+ * Reserved bits in IKE header
+ */
+ bool reserved[5];
+
+ /**
+ * Sorting of message disabled?
+ */
+ bool sort_disabled;
+
+ /**
+>>>>>>> upstream/4.5.1
* Message ID of this message.
*/
u_int32_t message_id;
@@ -647,6 +669,7 @@ METHOD(message_t, get_request, bool,
return this->is_request;
}
+<<<<<<< HEAD
/**
* Is this message in an encoded form?
*/
@@ -659,6 +682,37 @@ static bool is_encoded(private_message_t *this)
return FALSE;
}
return TRUE;
+=======
+METHOD(message_t, set_version_flag, void,
+ private_message_t *this)
+{
+ this->version_flag = TRUE;
+}
+
+METHOD(message_t, get_reserved_header_bit, bool,
+ private_message_t *this, u_int nr)
+{
+ if (nr < countof(this->reserved))
+ {
+ return this->reserved[nr];
+ }
+ return FALSE;
+}
+
+METHOD(message_t, set_reserved_header_bit, void,
+ private_message_t *this, u_int nr)
+{
+ if (nr < countof(this->reserved))
+ {
+ this->reserved[nr] = TRUE;
+ }
+}
+
+METHOD(message_t, is_encoded, bool,
+ private_message_t *this)
+{
+ return this->packet->get_data(this->packet).ptr != NULL;
+>>>>>>> upstream/4.5.1
}
METHOD(message_t, add_payload, void,
@@ -732,6 +786,15 @@ METHOD(message_t, create_payload_enumerator, enumerator_t*,
return this->payloads->create_enumerator(this->payloads);
}
+<<<<<<< HEAD
+=======
+METHOD(message_t, remove_payload_at, void,
+ private_message_t *this, enumerator_t *enumerator)
+{
+ this->payloads->remove_at(this->payloads, enumerator);
+}
+
+>>>>>>> upstream/4.5.1
METHOD(message_t, get_payload, payload_t*,
private_message_t *this, payload_type_t type)
{
@@ -1001,6 +1064,15 @@ static encryption_payload_t* wrap_payloads(private_message_t *this)
return encryption;
}
+<<<<<<< HEAD
+=======
+METHOD(message_t, disable_sort, void,
+ private_message_t *this)
+{
+ this->sort_disabled = TRUE;
+}
+
+>>>>>>> upstream/4.5.1
METHOD(message_t, generate, status_t,
private_message_t *this, aead_t *aead, packet_t **packet)
{
@@ -1012,12 +1084,17 @@ METHOD(message_t, generate, status_t,
chunk_t chunk;
char str[256];
u_int32_t *lenpos;
+<<<<<<< HEAD
if (is_encoded(this))
{ /* already generated, return a new packet clone */
*packet = this->packet->clone(this->packet);
return SUCCESS;
}
+=======
+ bool *reserved;
+ int i;
+>>>>>>> upstream/4.5.1
if (this->exchange_type == EXCHANGE_TYPE_UNDEFINED)
{
@@ -1039,7 +1116,14 @@ METHOD(message_t, generate, status_t,
return NOT_SUPPORTED;
}
+<<<<<<< HEAD
order_payloads(this);
+=======
+ if (!this->sort_disabled)
+ {
+ order_payloads(this);
+ }
+>>>>>>> upstream/4.5.1
DBG1(DBG_ENC, "generating %s", get_string(this, str, sizeof(str)));
@@ -1053,9 +1137,18 @@ METHOD(message_t, generate, status_t,
}
ike_header = ike_header_create();
+<<<<<<< HEAD
ike_header->set_exchange_type(ike_header, this->exchange_type);
ike_header->set_message_id(ike_header, this->message_id);
ike_header->set_response_flag(ike_header, !this->is_request);
+=======
+ ike_header->set_maj_version(ike_header, this->major_version);
+ ike_header->set_min_version(ike_header, this->minor_version);
+ ike_header->set_exchange_type(ike_header, this->exchange_type);
+ ike_header->set_message_id(ike_header, this->message_id);
+ ike_header->set_response_flag(ike_header, !this->is_request);
+ ike_header->set_version_flag(ike_header, this->version_flag);
+>>>>>>> upstream/4.5.1
ike_header->set_initiator_flag(ike_header,
this->ike_sa_id->is_initiator(this->ike_sa_id));
ike_header->set_initiator_spi(ike_header,
@@ -1063,6 +1156,19 @@ METHOD(message_t, generate, status_t,
ike_header->set_responder_spi(ike_header,
this->ike_sa_id->get_responder_spi(this->ike_sa_id));
+<<<<<<< HEAD
+=======
+ for (i = 0; i < countof(this->reserved); i++)
+ {
+ reserved = payload_get_field(&ike_header->payload_interface,
+ RESERVED_BIT, i);
+ if (reserved)
+ {
+ *reserved = this->reserved[i];
+ }
+ }
+
+>>>>>>> upstream/4.5.1
generator = generator_create();
/* generate all payloads with proper next type */
@@ -1131,6 +1237,11 @@ METHOD(message_t, parse_header, status_t,
{
ike_header_t *ike_header;
status_t status;
+<<<<<<< HEAD
+=======
+ bool *reserved;
+ int i;
+>>>>>>> upstream/4.5.1
DBG2(DBG_ENC, "parsing header of message");
@@ -1165,7 +1276,19 @@ METHOD(message_t, parse_header, status_t,
this->minor_version = ike_header->get_min_version(ike_header);
this->first_payload = ike_header->payload_interface.get_next_type(
&ike_header->payload_interface);
+<<<<<<< HEAD
+=======
+ for (i = 0; i < countof(this->reserved); i++)
+ {
+ reserved = payload_get_field(&ike_header->payload_interface,
+ RESERVED_BIT, i);
+ if (reserved)
+ {
+ this->reserved[i] = *reserved;
+ }
+ }
+>>>>>>> upstream/4.5.1
DBG2(DBG_ENC, "parsed a %N %s", exchange_type_names, this->exchange_type,
this->is_request ? "request" : "response");
@@ -1182,6 +1305,34 @@ METHOD(message_t, parse_header, status_t,
}
/**
+<<<<<<< HEAD
+=======
+ * Check if a payload is for a mediation extension connectivity check
+ */
+static bool is_connectivity_check(private_message_t *this, payload_t *payload)
+{
+#ifdef ME
+ if (this->exchange_type == INFORMATIONAL &&
+ payload->get_type(payload) == NOTIFY)
+ {
+ notify_payload_t *notify = (notify_payload_t*)payload;
+
+ switch (notify->get_notify_type(notify))
+ {
+ case ME_CONNECTID:
+ case ME_ENDPOINT:
+ case ME_CONNECTAUTH:
+ return TRUE;
+ default:
+ break;
+ }
+ }
+#endif /* !ME */
+ return FALSE;
+}
+
+/**
+>>>>>>> upstream/4.5.1
* Decrypt payload from the encryption payload
*/
static status_t decrypt_payloads(private_message_t *this, aead_t *aead)
@@ -1252,14 +1403,23 @@ static status_t decrypt_payloads(private_message_t *this, aead_t *aead)
}
encryption->destroy(encryption);
}
+<<<<<<< HEAD
if (type != UNKNOWN_PAYLOAD && !was_encrypted)
+=======
+ if (payload_is_known(type) && !was_encrypted &&
+ !is_connectivity_check(this, payload))
+>>>>>>> upstream/4.5.1
{
rule = get_payload_rule(this, type);
if (!rule || rule->encrypted)
{
DBG1(DBG_ENC, "payload type %N was not encrypted",
payload_type_names, type);
+<<<<<<< HEAD
status = VERIFY_ERROR;
+=======
+ status = FAILED;
+>>>>>>> upstream/4.5.1
break;
}
}
@@ -1274,6 +1434,10 @@ static status_t decrypt_payloads(private_message_t *this, aead_t *aead)
*/
static status_t verify(private_message_t *this)
{
+<<<<<<< HEAD
+=======
+ bool complete = FALSE;
+>>>>>>> upstream/4.5.1
int i;
DBG2(DBG_ENC, "verifying message structure");
@@ -1291,6 +1455,7 @@ static status_t verify(private_message_t *this)
while (enumerator->enumerate(enumerator, &payload))
{
payload_type_t type;
+<<<<<<< HEAD
unknown_payload_t *unknown;
type = payload->get_type(payload);
@@ -1307,6 +1472,11 @@ static status_t verify(private_message_t *this)
}
}
else if (type == rule->type)
+=======
+
+ type = payload->get_type(payload);
+ if (type == rule->type)
+>>>>>>> upstream/4.5.1
{
found++;
DBG2(DBG_ENC, "found payload of type %N",
@@ -1323,15 +1493,25 @@ static status_t verify(private_message_t *this)
}
enumerator->destroy(enumerator);
+<<<<<<< HEAD
if (found < rule->min_occurence)
+=======
+ if (!complete && found < rule->min_occurence)
+>>>>>>> upstream/4.5.1
{
DBG1(DBG_ENC, "payload of type %N not occured %d times (%d)",
payload_type_names, rule->type, rule->min_occurence, found);
return VERIFY_ERROR;
}
+<<<<<<< HEAD
if (rule->sufficient)
{
return SUCCESS;
+=======
+ if (found && rule->sufficient)
+ {
+ complete = TRUE;
+>>>>>>> upstream/4.5.1
}
}
return SUCCESS;
@@ -1360,7 +1540,11 @@ METHOD(message_t, parse_body, status_t,
{
DBG1(DBG_ENC, "payload type %N could not be parsed",
payload_type_names, type);
+<<<<<<< HEAD
return PARSE_ERROR;
+=======
+ return this->exchange_type == IKE_SA_INIT ? PARSE_ERROR : FAILED;
+>>>>>>> upstream/4.5.1
}
DBG2(DBG_ENC, "verifying payload of type %N", payload_type_names, type);
@@ -1370,7 +1554,11 @@ METHOD(message_t, parse_body, status_t,
DBG1(DBG_ENC, "%N payload verification failed",
payload_type_names, type);
payload->destroy(payload);
+<<<<<<< HEAD
return VERIFY_ERROR;
+=======
+ return this->exchange_type == IKE_SA_INIT ? VERIFY_ERROR : FAILED;
+>>>>>>> upstream/4.5.1
}
DBG2(DBG_ENC, "%N payload verified. Adding to payload list",
@@ -1388,6 +1576,7 @@ METHOD(message_t, parse_body, status_t,
type = payload->get_next_type(payload);
}
+<<<<<<< HEAD
if (type == ENCRYPTED)
{
status = decrypt_payloads(this, aead);
@@ -1396,6 +1585,13 @@ METHOD(message_t, parse_body, status_t,
DBG1(DBG_ENC, "could not decrypt payloads");
return status;
}
+=======
+ status = decrypt_payloads(this, aead);
+ if (status != SUCCESS)
+ {
+ DBG1(DBG_ENC, "could not decrypt payloads");
+ return status;
+>>>>>>> upstream/4.5.1
}
status = verify(this);
@@ -1443,14 +1639,29 @@ message_t *message_create_from_packet(packet_t *packet)
.get_first_payload_type = _get_first_payload_type,
.set_request = _set_request,
.get_request = _get_request,
+<<<<<<< HEAD
+ .add_payload = _add_payload,
+ .add_notify = _add_notify,
+ .generate = _generate,
+=======
+ .set_version_flag = _set_version_flag,
+ .get_reserved_header_bit = _get_reserved_header_bit,
+ .set_reserved_header_bit = _set_reserved_header_bit,
.add_payload = _add_payload,
.add_notify = _add_notify,
+ .disable_sort = _disable_sort,
.generate = _generate,
+ .is_encoded = _is_encoded,
+>>>>>>> upstream/4.5.1
.set_source = _set_source,
.get_source = _get_source,
.set_destination = _set_destination,
.get_destination = _get_destination,
.create_payload_enumerator = _create_payload_enumerator,
+<<<<<<< HEAD
+=======
+ .remove_payload_at = _remove_payload_at,
+>>>>>>> upstream/4.5.1
.get_payload = _get_payload,
.get_notify = _get_notify,
.parse_header = _parse_header,
@@ -1459,6 +1670,11 @@ message_t *message_create_from_packet(packet_t *packet)
.get_packet_data = _get_packet_data,
.destroy = _destroy,
},
+<<<<<<< HEAD
+=======
+ .major_version = IKE_MAJOR_VERSION,
+ .minor_version = IKE_MINOR_VERSION,
+>>>>>>> upstream/4.5.1
.exchange_type = EXCHANGE_TYPE_UNDEFINED,
.is_request = TRUE,
.first_payload = NO_PAYLOAD,
diff --git a/src/libcharon/encoding/message.h b/src/libcharon/encoding/message.h
index 8c1cbcd09..dcc9b0577 100644
--- a/src/libcharon/encoding/message.h
+++ b/src/libcharon/encoding/message.h
@@ -154,6 +154,29 @@ struct message_t {
bool (*get_request) (message_t *this);
/**
+<<<<<<< HEAD
+=======
+ * Set the version flag in the IKE header.
+ */
+ void (*set_version_flag)(message_t *this);
+
+ /**
+ * Get a reserved bit in the IKE header.
+ *
+ * @param nr reserved bit to get in IKE header, 0-4
+ * @return TRUE if bit is set
+ */
+ bool (*get_reserved_header_bit)(message_t *this, u_int nr);
+
+ /**
+ * Set a reserved bit in the IKE header.
+ *
+ * @param nr reserved bit to set in IKE header, 0-4
+ */
+ void (*set_reserved_header_bit)(message_t *this, u_int nr);
+
+ /**
+>>>>>>> upstream/4.5.1
* Append a payload to the message.
*
* If the payload must be encrypted is not specified here. Encryption
@@ -181,6 +204,14 @@ struct message_t {
chunk_t data);
/**
+<<<<<<< HEAD
+=======
+ * Disable automatic payload sorting for this message.
+ */
+ void (*disable_sort)(message_t *this);
+
+ /**
+>>>>>>> upstream/4.5.1
* Parses header of message.
*
* Begins parisng of a message created via message_create_from_packet().
@@ -206,8 +237,11 @@ struct message_t {
* @param aead aead transform to verify/decrypt message
* @return
* - SUCCESS if parsing successful
+<<<<<<< HEAD
* - NOT_SUPPORTED if ciritcal unknown payloads found
* - NOT_SUPPORTED if message type is not supported!
+=======
+>>>>>>> upstream/4.5.1
* - PARSE_ERROR if message parsing failed
* - VERIFY_ERROR if message verification failed (bad syntax)
* - FAILED if integrity check failed
@@ -235,6 +269,16 @@ struct message_t {
status_t (*generate) (message_t *this, aead_t *aead, packet_t **packet);
/**
+<<<<<<< HEAD
+=======
+ * Check if the message has already been encoded using generate().
+ *
+ * @return TRUE if message has been encoded
+ */
+ bool (*is_encoded)(message_t *this);
+
+ /**
+>>>>>>> upstream/4.5.1
* Gets the source host informations.
*
* @warning Returned host_t object is not getting cloned,
@@ -282,6 +326,16 @@ struct message_t {
enumerator_t * (*create_payload_enumerator) (message_t *this);
/**
+<<<<<<< HEAD
+=======
+ * Remove the payload at the current enumerator position.
+ *
+ * @param enumerator enumerator created by create_payload_enumerator()
+ */
+ void (*remove_payload_at)(message_t *this, enumerator_t *enumerator);
+
+ /**
+>>>>>>> upstream/4.5.1
* Find a payload of a specific type.
*
* Returns the first occurance.
diff --git a/src/libcharon/encoding/parser.c b/src/libcharon/encoding/parser.c
index 9aa34b1bc..7a5ec8495 100644
--- a/src/libcharon/encoding/parser.c
+++ b/src/libcharon/encoding/parser.c
@@ -387,12 +387,15 @@ static status_t parse_payload(private_parser_t *this,
DBG3(DBG_ENC, "parsing payload from %b",
this->byte_pos, this->input_roof - this->byte_pos);
+<<<<<<< HEAD
if (pld->get_type(pld) == UNKNOWN_PAYLOAD)
{
DBG1(DBG_ENC, " payload type %d is unknown, handling as %N",
payload_type, payload_type_names, UNKNOWN_PAYLOAD);
}
+=======
+>>>>>>> upstream/4.5.1
/* base pointer for output, avoids casting in every rule */
output = pld;
@@ -415,6 +418,10 @@ static status_t parse_payload(private_parser_t *this,
break;
}
case U_INT_8:
+<<<<<<< HEAD
+=======
+ case RESERVED_BYTE:
+>>>>>>> upstream/4.5.1
{
if (!parse_uint8(this, rule_number, output + rule->offset))
{
@@ -433,6 +440,10 @@ static status_t parse_payload(private_parser_t *this,
break;
}
case U_INT_32:
+<<<<<<< HEAD
+=======
+ case HEADER_LENGTH:
+>>>>>>> upstream/4.5.1
{
if (!parse_uint32(this, rule_number, output + rule->offset))
{
@@ -451,6 +462,7 @@ static status_t parse_payload(private_parser_t *this,
break;
}
case RESERVED_BIT:
+<<<<<<< HEAD
{
if (!parse_bit(this, rule_number, NULL))
{
@@ -468,6 +480,8 @@ static status_t parse_payload(private_parser_t *this,
}
break;
}
+=======
+>>>>>>> upstream/4.5.1
case FLAG:
{
if (!parse_bit(this, rule_number, output + rule->offset))
@@ -493,6 +507,7 @@ static status_t parse_payload(private_parser_t *this,
}
break;
}
+<<<<<<< HEAD
case HEADER_LENGTH:
{
if (!parse_uint32(this, rule_number, output + rule->offset))
@@ -502,6 +517,8 @@ static status_t parse_payload(private_parser_t *this,
}
break;
}
+=======
+>>>>>>> upstream/4.5.1
case SPI_SIZE:
{
if (!parse_uint8(this, rule_number, output + rule->offset))
diff --git a/src/libcharon/encoding/payloads/auth_payload.c b/src/libcharon/encoding/payloads/auth_payload.c
index d31208abb..25a57511a 100644
--- a/src/libcharon/encoding/payloads/auth_payload.c
+++ b/src/libcharon/encoding/payloads/auth_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -18,7 +23,10 @@
#include <encoding/payloads/encodings.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_auth_payload_t private_auth_payload_t;
/**
@@ -43,6 +51,19 @@ struct private_auth_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved_bit[7];
+
+ /**
+ * Reserved bytes
+ */
+ u_int8_t reserved_byte[3];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -66,6 +87,7 @@ struct private_auth_payload_t {
*/
encoding_rule_t auth_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
+<<<<<<< HEAD
{ U_INT_8, offsetof(private_auth_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_auth_payload_t, critical) },
@@ -87,6 +109,29 @@ encoding_rule_t auth_payload_encodings[] = {
{ RESERVED_BYTE, 0 },
/* some auth data bytes, length is defined in PAYLOAD_LENGTH */
{ AUTH_DATA, offsetof(private_auth_payload_t, auth_data) }
+=======
+ { U_INT_8, offsetof(private_auth_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_auth_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[0]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[1]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[2]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[3]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[4]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[5]) },
+ { RESERVED_BIT, offsetof(private_auth_payload_t, reserved_bit[6]) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_auth_payload_t, payload_length) },
+ /* 1 Byte AUTH type*/
+ { U_INT_8, offsetof(private_auth_payload_t, auth_method) },
+ /* 3 reserved bytes */
+ { RESERVED_BYTE, offsetof(private_auth_payload_t, reserved_byte[0]) },
+ { RESERVED_BYTE, offsetof(private_auth_payload_t, reserved_byte[1]) },
+ { RESERVED_BYTE, offsetof(private_auth_payload_t, reserved_byte[2]) },
+ /* some auth data bytes, length is defined in PAYLOAD_LENGTH */
+ { AUTH_DATA, offsetof(private_auth_payload_t, auth_data) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -103,6 +148,7 @@ encoding_rule_t auth_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -131,10 +177,28 @@ static void get_encoding_rules(private_auth_payload_t *this, encoding_rule_t **r
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_auth_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_auth_payload_t *this)
+{
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_auth_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = auth_payload_encodings;
+ *rule_count = countof(auth_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_auth_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return AUTHENTICATION;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -147,26 +211,47 @@ static payload_type_t get_next_type(private_auth_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_auth_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_auth_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_auth_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_auth_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_auth_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of auth_payload_t.set_auth_method.
*/
static void set_auth_method (private_auth_payload_t *this, auth_method_t method)
+=======
+METHOD(auth_payload_t, set_auth_method, void,
+ private_auth_payload_t *this, auth_method_t method)
+>>>>>>> upstream/4.5.1
{
this->auth_method = method;
}
+<<<<<<< HEAD
/**
* Implementation of auth_payload_t.get_auth_method.
*/
@@ -222,6 +307,32 @@ static void destroy(private_auth_payload_t *this)
chunk_free(&(this->auth_data));
}
+=======
+METHOD(auth_payload_t, get_auth_method, auth_method_t,
+ private_auth_payload_t *this)
+{
+ return this->auth_method;
+}
+
+METHOD(auth_payload_t, set_data, void,
+ private_auth_payload_t *this, chunk_t data)
+{
+ free(this->auth_data.ptr);
+ this->auth_data = chunk_clone(data);
+ this->payload_length = AUTH_PAYLOAD_HEADER_LENGTH + this->auth_data.len;
+}
+
+METHOD(auth_payload_t, get_data, chunk_t,
+ private_auth_payload_t *this)
+{
+ return this->auth_data;
+}
+
+METHOD2(payload_t, auth_payload_t, destroy, void,
+ private_auth_payload_t *this)
+{
+ free(this->auth_data.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -230,6 +341,7 @@ static void destroy(private_auth_payload_t *this)
*/
auth_payload_t *auth_payload_create()
{
+<<<<<<< HEAD
private_auth_payload_t *this = malloc_thing(private_auth_payload_t);
/* interface functions */
@@ -256,4 +368,29 @@ auth_payload_t *auth_payload_create()
this->auth_data = chunk_empty;
return (&(this->public));
+=======
+ private_auth_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .set_auth_method = _set_auth_method,
+ .get_auth_method = _get_auth_method,
+ .set_data = _set_data,
+ .get_data = _get_data,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = AUTH_PAYLOAD_HEADER_LENGTH,
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/auth_payload.h b/src/libcharon/encoding/payloads/auth_payload.h
index 37ee149db..c28fc1e06 100644
--- a/src/libcharon/encoding/payloads/auth_payload.h
+++ b/src/libcharon/encoding/payloads/auth_payload.h
@@ -62,15 +62,20 @@ struct auth_payload_t {
/**
* Set the AUTH data.
*
+<<<<<<< HEAD
* Data gets cloned.
*
* @param data AUTH data as chunk_t
+=======
+ * @param data AUTH data as chunk_t, gets cloned
+>>>>>>> upstream/4.5.1
*/
void (*set_data) (auth_payload_t *this, chunk_t data);
/**
* Get the AUTH data.
*
+<<<<<<< HEAD
* Returned data are a copy of the internal one.
*
* @return AUTH data as chunk_t
@@ -85,6 +90,26 @@ struct auth_payload_t {
* @return AUTH data as chunk_t
*/
chunk_t (*get_data) (auth_payload_t *this);
+=======
+ * @return AUTH data as chunk_t, internal data
+ */
+ chunk_t (*get_data) (auth_payload_t *this);
+
+ /**
+ * Get the value of a reserved bit.
+ *
+ * @param nr number of the reserved bit, 0-6
+ * @return TRUE if bit was set, FALSE to clear
+ */
+ bool (*get_reserved_bit)(auth_payload_t *this, u_int nr);
+
+ /**
+ * Set one of the reserved bits.
+ *
+ * @param nr number of the reserved bit, 0-6
+ */
+ void (*set_reserved_bit)(auth_payload_t *this, u_int nr);
+>>>>>>> upstream/4.5.1
/**
* Destroys an auth_payload_t object.
diff --git a/src/libcharon/encoding/payloads/cert_payload.c b/src/libcharon/encoding/payloads/cert_payload.c
index 80239f654..6a28cd658 100644
--- a/src/libcharon/encoding/payloads/cert_payload.c
+++ b/src/libcharon/encoding/payloads/cert_payload.c
@@ -1,6 +1,11 @@
/*
* Copyright (C) 2008 Tobias Brunner
+<<<<<<< HEAD
* Copyright (C) 2005-2007 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -43,9 +48,15 @@ typedef struct private_cert_payload_t private_cert_payload_t;
/**
* Private data of an cert_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_cert_payload_t {
+=======
+ */
+struct private_cert_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public cert_payload_t interface.
*/
@@ -62,6 +73,14 @@ struct private_cert_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -91,6 +110,7 @@ struct private_cert_payload_t {
*/
encoding_rule_t cert_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
+<<<<<<< HEAD
{ U_INT_8, offsetof(private_cert_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_cert_payload_t, critical) },
@@ -102,12 +122,29 @@ encoding_rule_t cert_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ { U_INT_8, offsetof(private_cert_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_cert_payload_t, critical) },
+ /* 7 Bit reserved bits, nowhere stored */
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_cert_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_cert_payload_t, payload_length)},
/* 1 Byte CERT type*/
{ U_INT_8, offsetof(private_cert_payload_t, encoding) },
/* some cert data bytes, length is defined in PAYLOAD_LENGTH */
+<<<<<<< HEAD
{ CERT_DATA, offsetof(private_cert_payload_t, data) }
+=======
+ { CERT_DATA, offsetof(private_cert_payload_t, data) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -123,18 +160,29 @@ encoding_rule_t cert_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_cert_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_cert_payload_t *this)
+>>>>>>> upstream/4.5.1
{
if (this->encoding == ENC_X509_HASH_AND_URL ||
this->encoding == ENC_X509_HASH_AND_URL_BUNDLE)
{
+<<<<<<< HEAD
+=======
+ int i;
+
+>>>>>>> upstream/4.5.1
/* coarse verification of "Hash and URL" encoded certificates */
if (this->data.len <= 20)
{
DBG1(DBG_ENC, "invalid payload length for hash-and-url (%d), ignore",
+<<<<<<< HEAD
this->data.len);
this->invalid_hash_and_url = TRUE;
return SUCCESS;
@@ -142,6 +190,13 @@ static status_t verify(private_cert_payload_t *this)
int i = 20; /* skipping the hash */
for (; i < this->data.len; ++i)
+=======
+ this->data.len);
+ this->invalid_hash_and_url = TRUE;
+ return SUCCESS;
+ }
+ for (i = 20; i < this->data.len; ++i)
+>>>>>>> upstream/4.5.1
{
if (this->data.ptr[i] == '\0')
{
@@ -151,11 +206,16 @@ static status_t verify(private_cert_payload_t *this)
else if (!isprint(this->data.ptr[i]))
{
DBG1(DBG_ENC, "non printable characters in url of hash-and-url"
+<<<<<<< HEAD
" encoded certificate payload, ignore");
+=======
+ " encoded certificate payload, ignore");
+>>>>>>> upstream/4.5.1
this->invalid_hash_and_url = TRUE;
return SUCCESS;
}
}
+<<<<<<< HEAD
/* URL is not null terminated, correct that */
chunk_t data = chunk_alloc(this->data.len + 1);
@@ -163,10 +223,15 @@ static status_t verify(private_cert_payload_t *this)
data.ptr[this->data.len] = '\0';
chunk_free(&this->data);
this->data = data;
+=======
+ /* URL is not null terminated, correct that */
+ this->data = chunk_cat("mc", this->data, chunk_from_chars(0));
+>>>>>>> upstream/4.5.1
}
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of cert_payload_t.get_encoding_rules.
*/
@@ -181,42 +246,74 @@ static void get_encoding_rules(private_cert_payload_t *this,
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_cert_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_cert_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = cert_payload_encodings;
+ *rule_count = countof(cert_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_cert_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return CERTIFICATE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_cert_payload_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_cert_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->next_payload;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_cert_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, set_next_type, void,
+ private_cert_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_cert_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_cert_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of cert_payload_t.get_cert_encoding.
*/
static cert_encoding_t get_cert_encoding(private_cert_payload_t *this)
+=======
+METHOD(cert_payload_t, get_cert_encoding, cert_encoding_t,
+ private_cert_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->encoding;
}
+<<<<<<< HEAD
/**
* Implementation of cert_payload_t.get_cert.
*/
@@ -239,6 +336,35 @@ static chunk_t get_hash(private_cert_payload_t *this)
chunk_t hash = chunk_empty;
if ((this->encoding != ENC_X509_HASH_AND_URL &&
this->encoding != ENC_X509_HASH_AND_URL_BUNDLE) ||
+=======
+METHOD(cert_payload_t, get_cert, certificate_t*,
+ private_cert_payload_t *this)
+{
+ int type;
+
+ switch (this->encoding)
+ {
+ case ENC_X509_SIGNATURE:
+ type = CERT_X509;
+ break;
+ case ENC_CRL:
+ type = CERT_X509_CRL;
+ break;
+ default:
+ return NULL;
+ }
+ return lib->creds->create(lib->creds, CRED_CERTIFICATE, type,
+ BUILD_BLOB_ASN1_DER, this->data, BUILD_END);
+}
+
+METHOD(cert_payload_t, get_hash, chunk_t,
+ private_cert_payload_t *this)
+{
+ chunk_t hash = chunk_empty;
+
+ if ((this->encoding != ENC_X509_HASH_AND_URL &&
+ this->encoding != ENC_X509_HASH_AND_URL_BUNDLE) ||
+>>>>>>> upstream/4.5.1
this->invalid_hash_and_url)
{
return hash;
@@ -248,6 +374,7 @@ static chunk_t get_hash(private_cert_payload_t *this)
return hash;
}
+<<<<<<< HEAD
/**
* Implementation of cert_payload_t.get_url.
*/
@@ -255,6 +382,13 @@ static char *get_url(private_cert_payload_t *this)
{
if ((this->encoding != ENC_X509_HASH_AND_URL &&
this->encoding != ENC_X509_HASH_AND_URL_BUNDLE) ||
+=======
+METHOD(cert_payload_t, get_url, char*,
+ private_cert_payload_t *this)
+{
+ if ((this->encoding != ENC_X509_HASH_AND_URL &&
+ this->encoding != ENC_X509_HASH_AND_URL_BUNDLE) ||
+>>>>>>> upstream/4.5.1
this->invalid_hash_and_url)
{
return NULL;
@@ -262,12 +396,19 @@ static char *get_url(private_cert_payload_t *this)
return (char*)this->data.ptr + 20;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.destroy and cert_payload_t.destroy.
*/
static void destroy(private_cert_payload_t *this)
{
chunk_free(&this->data);
+=======
+METHOD2(payload_t, cert_payload_t, destroy, void,
+ private_cert_payload_t *this)
+{
+ free(this->data.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -276,6 +417,7 @@ static void destroy(private_cert_payload_t *this)
*/
cert_payload_t *cert_payload_create()
{
+<<<<<<< HEAD
private_cert_payload_t *this = malloc_thing(private_cert_payload_t);
this->public.payload_interface.verify = (status_t (*) (payload_t*))verify;
@@ -299,6 +441,30 @@ cert_payload_t *cert_payload_create()
this->encoding = 0;
this->invalid_hash_and_url = FALSE;
+=======
+ private_cert_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_cert = _get_cert,
+ .get_cert_encoding = _get_cert_encoding,
+ .get_hash = _get_hash,
+ .get_url = _get_url,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = CERT_PAYLOAD_HEADER_LENGTH,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
@@ -343,3 +509,18 @@ cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url)
return &this->public;
}
+<<<<<<< HEAD
+=======
+/*
+ * Described in header
+ */
+cert_payload_t *cert_payload_create_custom(cert_encoding_t type, chunk_t data)
+{
+ private_cert_payload_t *this = (private_cert_payload_t*)cert_payload_create();
+
+ this->encoding = type;
+ this->data = data;
+ this->payload_length = CERT_PAYLOAD_HEADER_LENGTH + this->data.len;
+ return &this->public;
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/cert_payload.h b/src/libcharon/encoding/payloads/cert_payload.h
index aa1c7bf5a..74d2b3cd2 100644
--- a/src/libcharon/encoding/payloads/cert_payload.h
+++ b/src/libcharon/encoding/payloads/cert_payload.h
@@ -134,4 +134,16 @@ cert_payload_t *cert_payload_create_from_cert(certificate_t *cert);
*/
cert_payload_t *cert_payload_create_from_hash_and_url(chunk_t hash, char *url);
+<<<<<<< HEAD
+=======
+/**
+ * Creates a custom certificate payload using type and associated data.
+ *
+ * @param type encoding type of certificate
+ * @param data associated data (gets owned)
+ * @return cert_payload_t object
+ */
+cert_payload_t *cert_payload_create_custom(cert_encoding_t type, chunk_t data);
+
+>>>>>>> upstream/4.5.1
#endif /** CERT_PAYLOAD_H_ @}*/
diff --git a/src/libcharon/encoding/payloads/certreq_payload.c b/src/libcharon/encoding/payloads/certreq_payload.c
index 9ff0bdde0..0c59fd66d 100644
--- a/src/libcharon/encoding/payloads/certreq_payload.c
+++ b/src/libcharon/encoding/payloads/certreq_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -22,14 +27,23 @@
#include "certreq_payload.h"
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_certreq_payload_t private_certreq_payload_t;
/**
* Private data of an certreq_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_certreq_payload_t {
+=======
+ */
+struct private_certreq_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public certreq_payload_t interface.
*/
@@ -46,6 +60,14 @@ struct private_certreq_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -66,6 +88,7 @@ struct private_certreq_payload_t {
*
* The defined offsets are the positions in a object of type
* private_certreq_payload_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t certreq_payload_encodings[] = {
@@ -81,6 +104,22 @@ encoding_rule_t certreq_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ */
+encoding_rule_t certreq_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_certreq_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_certreq_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_certreq_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_certreq_payload_t, payload_length) },
/* 1 Byte CERTREQ type*/
@@ -102,10 +141,15 @@ encoding_rule_t certreq_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_certreq_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_certreq_payload_t *this)
+>>>>>>> upstream/4.5.1
{
if (this->encoding == ENC_X509_SIGNATURE)
{
@@ -120,6 +164,7 @@ static status_t verify(private_certreq_payload_t *this)
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of certreq_payload_t.get_encoding_rules.
*/
@@ -133,10 +178,22 @@ static void get_encoding_rules(private_certreq_payload_t *this, encoding_rule_t
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_certreq_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_certreq_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = certreq_payload_encodings;
+ *rule_count = countof(certreq_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_certreq_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return CERTIFICATE_REQUEST;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -149,22 +206,42 @@ static payload_type_t get_next_type(private_certreq_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_certreq_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_certreq_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_certreq_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_certreq_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_certreq_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of certreq_payload_t.add_keyid.
*/
static void add_keyid(private_certreq_payload_t *this, chunk_t keyid)
+=======
+METHOD(certreq_payload_t, add_keyid, void,
+ private_certreq_payload_t *this, chunk_t keyid)
+>>>>>>> upstream/4.5.1
{
this->data = chunk_cat("mc", this->data, keyid);
this->payload_length += keyid.len;
@@ -181,10 +258,15 @@ struct keyid_enumerator_t {
u_char *pos;
};
+<<<<<<< HEAD
/**
* enumerate function for keyid_enumerator
*/
static bool keyid_enumerate(keyid_enumerator_t *this, chunk_t *chunk)
+=======
+METHOD(enumerator_t, keyid_enumerate, bool,
+ keyid_enumerator_t *this, chunk_t *chunk)
+>>>>>>> upstream/4.5.1
{
if (this->pos == NULL)
{
@@ -207,6 +289,7 @@ static bool keyid_enumerate(keyid_enumerator_t *this, chunk_t *chunk)
return FALSE;
}
+<<<<<<< HEAD
/**
* Implementation of certreq_payload_t.create_keyid_enumerator.
*/
@@ -224,6 +307,25 @@ static enumerator_t* create_keyid_enumerator(private_certreq_payload_t *this)
* Implementation of certreq_payload_t.get_cert_type.
*/
static certificate_type_t get_cert_type(private_certreq_payload_t *this)
+=======
+METHOD(certreq_payload_t, create_keyid_enumerator, enumerator_t*,
+ private_certreq_payload_t *this)
+{
+ keyid_enumerator_t *enumerator;
+
+ INIT(enumerator,
+ .public = {
+ .enumerate = (void*)_keyid_enumerate,
+ .destroy = (void*)free,
+ },
+ .full = this->data,
+ );
+ return &enumerator->public;
+}
+
+METHOD(certreq_payload_t, get_cert_type, certificate_type_t,
+ private_certreq_payload_t *this)
+>>>>>>> upstream/4.5.1
{
switch (this->encoding)
{
@@ -234,10 +336,15 @@ static certificate_type_t get_cert_type(private_certreq_payload_t *this)
}
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.destroy and certreq_payload_t.destroy.
*/
static void destroy(private_certreq_payload_t *this)
+=======
+METHOD2(payload_t, certreq_payload_t, destroy, void,
+ private_certreq_payload_t *this)
+>>>>>>> upstream/4.5.1
{
chunk_free(&this->data);
free(this);
@@ -248,6 +355,7 @@ static void destroy(private_certreq_payload_t *this)
*/
certreq_payload_t *certreq_payload_create()
{
+<<<<<<< HEAD
private_certreq_payload_t *this = malloc_thing(private_certreq_payload_t);
/* interface functions */
@@ -272,6 +380,29 @@ certreq_payload_t *certreq_payload_create()
this->data = chunk_empty;
this->encoding = 0;
+=======
+ private_certreq_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .create_keyid_enumerator = _create_keyid_enumerator,
+ .get_cert_type = _get_cert_type,
+ .add_keyid = _add_keyid,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = CERTREQ_PAYLOAD_HEADER_LENGTH,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
diff --git a/src/libcharon/encoding/payloads/configuration_attribute.c b/src/libcharon/encoding/payloads/configuration_attribute.c
index 9094fd44d..1ef8be800 100644
--- a/src/libcharon/encoding/payloads/configuration_attribute.c
+++ b/src/libcharon/encoding/payloads/configuration_attribute.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2009 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -22,20 +27,37 @@
#include <library.h>
#include <daemon.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_configuration_attribute_t private_configuration_attribute_t;
/**
* Private data of an configuration_attribute_t object.
+<<<<<<< HEAD
*
*/
struct private_configuration_attribute_t {
+=======
+ */
+struct private_configuration_attribute_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public configuration_attribute_t interface.
*/
configuration_attribute_t public;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bit
+ */
+ bool reserved;
+
+ /**
+>>>>>>> upstream/4.5.1
* Type of the attribute.
*/
u_int16_t type;
@@ -58,8 +80,13 @@ struct private_configuration_attribute_t {
* private_configuration_attribute_t.
*/
encoding_rule_t configuration_attribute_encodings[] = {
+<<<<<<< HEAD
{ RESERVED_BIT, 0 },
+=======
+ /* 1 reserved bit */
+ { RESERVED_BIT, offsetof(private_configuration_attribute_t, reserved)},
+>>>>>>> upstream/4.5.1
/* type of the attribute as 15 bit unsigned integer */
{ ATTRIBUTE_TYPE, offsetof(private_configuration_attribute_t, type) },
/* Length of attribute value */
@@ -80,10 +107,15 @@ encoding_rule_t configuration_attribute_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_configuration_attribute_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
bool failed = FALSE;
@@ -151,6 +183,7 @@ static status_t verify(private_configuration_attribute_t *this)
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_encoding_rules.
*/
@@ -165,18 +198,36 @@ static void get_encoding_rules(private_configuration_attribute_t *this,
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_configuration_attribute_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_configuration_attribute_t *this, encoding_rule_t **rules,
+ size_t *rule_count)
+{
+ *rules = configuration_attribute_encodings;
+ *rule_count = countof(configuration_attribute_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return CONFIGURATION_ATTRIBUTE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_configuration_attribute_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return NO_PAYLOAD;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.set_next_type.
*/
@@ -189,31 +240,55 @@ static void set_next_type(private_configuration_attribute_t *this,
* Implementation of configuration_attribute_t.get_length.
*/
static size_t get_length(private_configuration_attribute_t *this)
+=======
+METHOD(payload_t, set_next_type, void,
+ private_configuration_attribute_t *this, payload_type_t type)
+{
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return this->value.len + CONFIGURATION_ATTRIBUTE_HEADER_LENGTH;
}
+<<<<<<< HEAD
/**
* Implementation of configuration_attribute_t.get_type.
*/
static configuration_attribute_type_t get_configuration_attribute_type(
private_configuration_attribute_t *this)
+=======
+METHOD(configuration_attribute_t, get_cattr_type, configuration_attribute_type_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return this->type;
}
+<<<<<<< HEAD
/**
* Implementation of configuration_attribute_t.get_value.
*/
static chunk_t get_value(private_configuration_attribute_t *this)
+=======
+METHOD(configuration_attribute_t, get_value, chunk_t,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return this->value;
}
+<<<<<<< HEAD
/**
* Implementation of configuration_attribute_t.destroy and payload_t.destroy.
*/
static void destroy(private_configuration_attribute_t *this)
+=======
+METHOD2(payload_t, configuration_attribute_t, destroy, void,
+ private_configuration_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
free(this->value.ptr);
free(this);
@@ -226,6 +301,7 @@ configuration_attribute_t *configuration_attribute_create()
{
private_configuration_attribute_t *this;
+<<<<<<< HEAD
this = malloc_thing(private_configuration_attribute_t);
this->public.payload_interface.verify = (status_t(*)(payload_t *))verify;
this->public.payload_interface.get_encoding_rules = (void(*)(payload_t *, encoding_rule_t **, size_t *) )get_encoding_rules;
@@ -243,6 +319,24 @@ configuration_attribute_t *configuration_attribute_create()
this->value = chunk_empty;
this->length = 0;
+=======
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_value = _get_value,
+ .get_type = _get_cattr_type,
+ .destroy = _destroy,
+ },
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
diff --git a/src/libcharon/encoding/payloads/cp_payload.c b/src/libcharon/encoding/payloads/cp_payload.c
index f0a26eee2..d8779d27f 100644
--- a/src/libcharon/encoding/payloads/cp_payload.c
+++ b/src/libcharon/encoding/payloads/cp_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2009 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -32,9 +37,15 @@ typedef struct private_cp_payload_t private_cp_payload_t;
/**
* Private data of an cp_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_cp_payload_t {
+=======
+ */
+struct private_cp_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public cp_payload_t interface.
*/
@@ -51,6 +62,19 @@ struct private_cp_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved_bit[7];
+
+ /**
+ * Reserved bytes
+ */
+ u_int8_t reserved_byte[3];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -71,6 +95,7 @@ struct private_cp_payload_t {
*
* The defined offsets are the positions in a object of type
* private_cp_payload_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t cp_payload_encodings[] = {
@@ -95,6 +120,32 @@ encoding_rule_t cp_payload_encodings[] = {
{ RESERVED_BYTE,0 },
{ RESERVED_BYTE,0 },
{ CONFIGURATION_ATTRIBUTES, offsetof(private_cp_payload_t, attributes) }
+=======
+ */
+encoding_rule_t cp_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_cp_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_cp_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[0]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[1]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[2]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[3]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[4]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[5]) },
+ { RESERVED_BIT, offsetof(private_cp_payload_t, reserved_bit[6]) },
+ /* Length of the whole CP payload*/
+ { PAYLOAD_LENGTH, offsetof(private_cp_payload_t, payload_length) },
+ /* Proposals are stored in a proposal substructure,
+ offset points to a linked_list_t pointer */
+ { U_INT_8, offsetof(private_cp_payload_t, type) },
+ /* 3 reserved bytes */
+ { RESERVED_BYTE, offsetof(private_cp_payload_t, reserved_byte[0])},
+ { RESERVED_BYTE, offsetof(private_cp_payload_t, reserved_byte[1])},
+ { RESERVED_BYTE, offsetof(private_cp_payload_t, reserved_byte[2])},
+ { CONFIGURATION_ATTRIBUTES, offsetof(private_cp_payload_t, attributes) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -111,10 +162,15 @@ encoding_rule_t cp_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_cp_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
status_t status = SUCCESS;
enumerator_t *enumerator;
@@ -133,6 +189,7 @@ static status_t verify(private_cp_payload_t *this)
return status;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_encoding_rules.
*/
@@ -147,22 +204,43 @@ static void get_encoding_rules(private_cp_payload_t *this,
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_cp_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_cp_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = cp_payload_encodings;
+ *rule_count = countof(cp_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return CONFIGURATION;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_cp_payload_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->next_payload;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_cp_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, set_next_type, void,
+ private_cp_payload_t *this,payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
@@ -185,44 +263,69 @@ static void compute_length(private_cp_payload_t *this)
enumerator->destroy(enumerator);
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_cp_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of cp_payload_t.create_attribute_enumerator.
*/
static enumerator_t *create_attribute_enumerator(private_cp_payload_t *this)
+=======
+METHOD(cp_payload_t, create_attribute_enumerator, enumerator_t*,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->attributes->create_enumerator(this->attributes);
}
+<<<<<<< HEAD
/**
* Implementation of cp_payload_t.add_attribute.
*/
static void add_attribute(private_cp_payload_t *this,
configuration_attribute_t *attribute)
+=======
+METHOD(cp_payload_t, add_attribute, void,
+ private_cp_payload_t *this, configuration_attribute_t *attribute)
+>>>>>>> upstream/4.5.1
{
this->attributes->insert_last(this->attributes, attribute);
compute_length(this);
}
+<<<<<<< HEAD
/**
* Implementation of cp_payload_t.get_type.
*/
static config_type_t get_config_type(private_cp_payload_t *this)
+=======
+METHOD(cp_payload_t, get_config_type, config_type_t,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.destroy and cp_payload_t.destroy.
*/
static void destroy(private_cp_payload_t *this)
+=======
+METHOD2(payload_t, cp_payload_t, destroy, void,
+ private_cp_payload_t *this)
+>>>>>>> upstream/4.5.1
{
this->attributes->destroy_offset(this->attributes,
offsetof(configuration_attribute_t, destroy));
@@ -232,6 +335,7 @@ static void destroy(private_cp_payload_t *this)
/*
* Described in header.
*/
+<<<<<<< HEAD
cp_payload_t *cp_payload_create()
{
private_cp_payload_t *this = malloc_thing(private_cp_payload_t);
@@ -256,12 +360,40 @@ cp_payload_t *cp_payload_create()
this->attributes = linked_list_create();
this->type = CFG_REQUEST;
+=======
+cp_payload_t *cp_payload_create_type(config_type_t type)
+{
+ private_cp_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .create_attribute_enumerator = _create_attribute_enumerator,
+ .add_attribute = _add_attribute,
+ .get_type = _get_config_type,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = CP_PAYLOAD_HEADER_LENGTH,
+ .attributes = linked_list_create(),
+ .type = type,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
/*
* Described in header.
*/
+<<<<<<< HEAD
cp_payload_t *cp_payload_create_type(config_type_t type)
{
private_cp_payload_t *this = (private_cp_payload_t*)cp_payload_create();
@@ -271,3 +403,9 @@ cp_payload_t *cp_payload_create_type(config_type_t type)
return &this->public;
}
+=======
+cp_payload_t *cp_payload_create()
+{
+ return cp_payload_create_type(CFG_REQUEST);
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/delete_payload.c b/src/libcharon/encoding/payloads/delete_payload.c
index 5fc3b7c88..4e94ff417 100644
--- a/src/libcharon/encoding/payloads/delete_payload.c
+++ b/src/libcharon/encoding/payloads/delete_payload.c
@@ -43,6 +43,14 @@ struct private_delete_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -79,6 +87,7 @@ encoding_rule_t delete_payload_encodings[] = {
{ U_INT_8, offsetof(private_delete_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_delete_payload_t, critical) },
+<<<<<<< HEAD
/* 7 Bit reserved bits, nowhere stored */
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -87,6 +96,16 @@ encoding_rule_t delete_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_delete_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_delete_payload_t, payload_length) },
{ U_INT_8, offsetof(private_delete_payload_t, protocol_id) },
diff --git a/src/libcharon/encoding/payloads/eap_payload.c b/src/libcharon/encoding/payloads/eap_payload.c
index 21f34a642..8f5c8700a 100644
--- a/src/libcharon/encoding/payloads/eap_payload.c
+++ b/src/libcharon/encoding/payloads/eap_payload.c
@@ -43,6 +43,14 @@ struct private_eap_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -66,6 +74,7 @@ static encoding_rule_t eap_payload_encodings[] = {
/* the critical bit */
{ FLAG, offsetof(private_eap_payload_t, critical) },
/* 7 Bit reserved bits, nowhere stored */
+<<<<<<< HEAD
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -73,6 +82,15 @@ static encoding_rule_t eap_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_eap_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_eap_payload_t, payload_length) },
/* chunt to data, starting at "code" */
diff --git a/src/libcharon/encoding/payloads/id_payload.c b/src/libcharon/encoding/payloads/id_payload.c
index 4158c3e07..58250e766 100644
--- a/src/libcharon/encoding/payloads/id_payload.c
+++ b/src/libcharon/encoding/payloads/id_payload.c
@@ -1,6 +1,12 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2007 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ * Copyright (C) 2007 Tobias Brunner
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
*
* Hochschule fuer Technik Rapperswil
@@ -51,6 +57,19 @@ struct private_id_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved_bit[7];
+
+ /**
+ * Reserved bytes
+ */
+ u_int8_t reserved_byte[3];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -71,13 +90,17 @@ struct private_id_payload_t {
*
* The defined offsets are the positions in a object of type
* private_id_payload_t.
+<<<<<<< HEAD
*
+=======
+>>>>>>> upstream/4.5.1
*/
encoding_rule_t id_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
{ U_INT_8, offsetof(private_id_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_id_payload_t, critical) },
+<<<<<<< HEAD
/* 7 Bit reserved bits, nowhere stored */
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -86,16 +109,34 @@ encoding_rule_t id_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[0]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[1]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[2]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[3]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[4]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[5]) },
+ { RESERVED_BIT, offsetof(private_id_payload_t, reserved_bit[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_id_payload_t, payload_length) },
/* 1 Byte ID type*/
{ U_INT_8, offsetof(private_id_payload_t, id_type) },
/* 3 reserved bytes */
+<<<<<<< HEAD
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
/* some id data bytes, length is defined in PAYLOAD_LENGTH */
{ ID_DATA, offsetof(private_id_payload_t, id_data) }
+=======
+ { RESERVED_BYTE, offsetof(private_id_payload_t, reserved_byte[0])},
+ { RESERVED_BYTE, offsetof(private_id_payload_t, reserved_byte[1])},
+ { RESERVED_BYTE, offsetof(private_id_payload_t, reserved_byte[2])},
+ /* some id data bytes, length is defined in PAYLOAD_LENGTH */
+ { ID_DATA, offsetof(private_id_payload_t, id_data) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -112,6 +153,7 @@ encoding_rule_t id_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -121,11 +163,18 @@ static status_t verify(private_id_payload_t *this)
(this->id_type == 4) ||
((this->id_type >= 6) && (this->id_type <= 8)) ||
((this->id_type >= 12) && (this->id_type <= 200)))
+=======
+METHOD(payload_t, verify, status_t,
+ private_id_payload_t *this)
+{
+ if (this->id_type == 0 || this->id_type == 4)
+>>>>>>> upstream/4.5.1
{
/* reserved IDs */
DBG1(DBG_ENC, "received ID with reserved type %d", this->id_type);
return FAILED;
}
+<<<<<<< HEAD
return SUCCESS;
}
@@ -143,34 +192,64 @@ static void get_encoding_rules(private_id_payload_t *this, encoding_rule_t **rul
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_id_payload_t *this)
+=======
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_id_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = id_payload_encodings;
+ *rule_count = countof(id_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_id_payload_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->next_payload;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_id_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, set_next_type, void,
+ private_id_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_id_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of id_payload_t.set_type.
*/
@@ -242,6 +321,18 @@ static void destroy(private_id_payload_t *this)
{
chunk_free(&(this->id_data));
}
+=======
+METHOD(id_payload_t, get_identification, identification_t*,
+ private_id_payload_t *this)
+{
+ return identification_create_from_encoding(this->id_type, this->id_data);
+}
+
+METHOD2(payload_t, id_payload_t, destroy, void,
+ private_id_payload_t *this)
+{
+ free(this->id_data.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -250,6 +341,7 @@ static void destroy(private_id_payload_t *this)
*/
id_payload_t *id_payload_create(payload_type_t payload_type)
{
+<<<<<<< HEAD
private_id_payload_t *this = malloc_thing(private_id_payload_t);
/* interface functions */
@@ -279,15 +371,52 @@ id_payload_t *id_payload_create(payload_type_t payload_type)
this->payload_type = payload_type;
return (&(this->public));
+=======
+ private_id_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_identification = _get_identification,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = ID_PAYLOAD_HEADER_LENGTH,
+ .payload_type = payload_type,
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
/*
* Described in header.
*/
+<<<<<<< HEAD
id_payload_t *id_payload_create_from_identification(payload_type_t payload_type, identification_t *identification)
{
id_payload_t *this= id_payload_create(payload_type);
this->set_data(this,identification->get_encoding(identification));
this->set_id_type(this,identification->get_type(identification));
return this;
+=======
+id_payload_t *id_payload_create_from_identification(payload_type_t payload_type,
+ identification_t *id)
+{
+ private_id_payload_t *this;
+
+ this = (private_id_payload_t*)id_payload_create(payload_type);
+ this->id_data = chunk_clone(id->get_encoding(id));
+ this->id_type = id->get_type(id);
+ this->payload_length += this->id_data.len;
+
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/id_payload.h b/src/libcharon/encoding/payloads/id_payload.h
index 5502dc961..b5b9c5907 100644
--- a/src/libcharon/encoding/payloads/id_payload.h
+++ b/src/libcharon/encoding/payloads/id_payload.h
@@ -40,12 +40,17 @@ typedef struct id_payload_t id_payload_t;
* The ID payload format is described in RFC section 3.5.
*/
struct id_payload_t {
+<<<<<<< HEAD
+=======
+
+>>>>>>> upstream/4.5.1
/**
* The payload_t interface.
*/
payload_t payload_interface;
/**
+<<<<<<< HEAD
* Set the ID type.
*
* @param type Type of ID
@@ -91,6 +96,10 @@ struct id_payload_t {
*
* Returned object has to get destroyed by the caller.
*
+=======
+ * Creates an identification object of this id payload.
+ *
+>>>>>>> upstream/4.5.1
* @return identification_t object
*/
identification_t *(*get_identification) (id_payload_t *this);
diff --git a/src/libcharon/encoding/payloads/ike_header.c b/src/libcharon/encoding/payloads/ike_header.c
index 735f01304..1462b346b 100644
--- a/src/libcharon/encoding/payloads/ike_header.c
+++ b/src/libcharon/encoding/payloads/ike_header.c
@@ -84,6 +84,14 @@ struct private_ike_header_t {
} flags;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits of IKE header
+ */
+ bool reserved[5];
+
+ /**
+>>>>>>> upstream/4.5.1
* Associated Message-ID.
*/
u_int32_t message_id;
@@ -119,6 +127,7 @@ encoding_rule_t ike_header_encodings[] = {
/* 8 Byte SPI, stored in the field initiator_spi */
{ IKE_SPI, offsetof(private_ike_header_t, initiator_spi) },
/* 8 Byte SPI, stored in the field responder_spi */
+<<<<<<< HEAD
{ IKE_SPI, offsetof(private_ike_header_t, responder_spi) },
/* 1 Byte next payload type, stored in the field next_payload */
{ U_INT_8, offsetof(private_ike_header_t, next_payload) },
@@ -143,6 +152,32 @@ encoding_rule_t ike_header_encodings[] = {
{ U_INT_32, offsetof(private_ike_header_t, message_id) },
/* 4 Byte length fied, stored in the field length */
{ HEADER_LENGTH, offsetof(private_ike_header_t, length) }
+=======
+ { IKE_SPI, offsetof(private_ike_header_t, responder_spi) },
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_ike_header_t, next_payload) },
+ /* 4 Bit major version, stored in the field maj_version */
+ { U_INT_4, offsetof(private_ike_header_t, maj_version) },
+ /* 4 Bit minor version, stored in the field min_version */
+ { U_INT_4, offsetof(private_ike_header_t, min_version) },
+ /* 8 Bit for the exchange type */
+ { U_INT_8, offsetof(private_ike_header_t, exchange_type) },
+ /* 2 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_ike_header_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_ike_header_t, reserved[1]) },
+ /* 3 Bit flags, stored in the fields response, version and initiator */
+ { FLAG, offsetof(private_ike_header_t, flags.response) },
+ { FLAG, offsetof(private_ike_header_t, flags.version) },
+ { FLAG, offsetof(private_ike_header_t, flags.initiator) },
+ /* 3 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_ike_header_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_ike_header_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_ike_header_t, reserved[4]) },
+ /* 4 Byte message id, stored in the field message_id */
+ { U_INT_32, offsetof(private_ike_header_t, message_id) },
+ /* 4 Byte length fied, stored in the field length */
+ { HEADER_LENGTH,offsetof(private_ike_header_t, length) },
+>>>>>>> upstream/4.5.1
};
@@ -163,11 +198,16 @@ encoding_rule_t ike_header_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_ike_header_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
if ((this->exchange_type < IKE_SA_INIT) ||
((this->exchange_type > INFORMATIONAL)
@@ -179,7 +219,10 @@ static status_t verify(private_ike_header_t *this)
/* unsupported exchange type */
return FAILED;
}
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
if (this->initiator_spi == 0
#ifdef ME
/* we allow zero spi for INFORMATIONAL exchanges,
@@ -191,6 +234,7 @@ static status_t verify(private_ike_header_t *this)
/* initiator spi not set */
return FAILED;
}
+<<<<<<< HEAD
/* verification of version is not done in here */
@@ -208,131 +252,263 @@ static void set_next_type(payload_t *this,payload_type_t type)
* Implementation of ike_header_t.get_initiator_spi.
*/
static u_int64_t get_initiator_spi(private_ike_header_t *this)
+=======
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_ike_header_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = ike_header_encodings;
+ *rule_count = sizeof(ike_header_encodings) / sizeof(encoding_rule_t);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_ike_header_t *this)
+{
+ return HEADER;
+}
+
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_ike_header_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_ike_header_t *this, payload_type_t type)
+{
+ this->next_payload = type;
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_ike_header_t *this)
+{
+ return this->length;
+}
+
+METHOD(ike_header_t, get_initiator_spi, u_int64_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->initiator_spi;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_initiator_spi.
*/
static void set_initiator_spi(private_ike_header_t *this, u_int64_t initiator_spi)
+=======
+METHOD(ike_header_t, set_initiator_spi, void,
+ private_ike_header_t *this, u_int64_t initiator_spi)
+>>>>>>> upstream/4.5.1
{
this->initiator_spi = initiator_spi;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_responder_spi.
*/
static u_int64_t get_responder_spi(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, get_responder_spi, u_int64_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->responder_spi;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_responder_spi.
*/
static void set_responder_spi(private_ike_header_t *this, u_int64_t responder_spi)
+=======
+METHOD(ike_header_t, set_responder_spi, void,
+ private_ike_header_t *this, u_int64_t responder_spi)
+>>>>>>> upstream/4.5.1
{
this->responder_spi = responder_spi;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_maj_version.
*/
static u_int8_t get_maj_version(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, get_maj_version, u_int8_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->maj_version;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_min_version.
*/
static u_int8_t get_min_version(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, set_maj_version, void,
+ private_ike_header_t *this, u_int8_t major)
+{
+ this->maj_version = major;
+}
+
+METHOD(ike_header_t, get_min_version, u_int8_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->min_version;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_response_flag.
*/
static bool get_response_flag(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, set_min_version, void,
+ private_ike_header_t *this, u_int8_t minor)
+{
+ this->min_version = minor;
+}
+
+METHOD(ike_header_t, get_response_flag, bool,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->flags.response;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_response_flag.
*/
static void set_response_flag(private_ike_header_t *this, bool response)
+=======
+METHOD(ike_header_t, set_response_flag, void,
+ private_ike_header_t *this, bool response)
+>>>>>>> upstream/4.5.1
{
this->flags.response = response;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_version_flag.
*/
static bool get_version_flag(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, get_version_flag, bool,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->flags.version;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_initiator_flag.
*/
static bool get_initiator_flag(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, set_version_flag, void,
+ private_ike_header_t *this, bool version)
+{
+ this->flags.version = version;
+}
+
+METHOD(ike_header_t, get_initiator_flag, bool,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->flags.initiator;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_initiator_flag.
*/
static void set_initiator_flag(private_ike_header_t *this, bool initiator)
+=======
+METHOD(ike_header_t, set_initiator_flag, void,
+ private_ike_header_t *this, bool initiator)
+>>>>>>> upstream/4.5.1
{
this->flags.initiator = initiator;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.get_exchange_type.
*/
static u_int8_t get_exchange_type(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, get_exchange_type, u_int8_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->exchange_type;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_exchange_type.
*/
static void set_exchange_type(private_ike_header_t *this, u_int8_t exchange_type)
+=======
+METHOD(ike_header_t, set_exchange_type, void,
+ private_ike_header_t *this, u_int8_t exchange_type)
+>>>>>>> upstream/4.5.1
{
this->exchange_type = exchange_type;
}
+<<<<<<< HEAD
/**
* Implements ike_header_t's get_message_id function.
* See #ike_header_t.get_message_id for description.
*/
static u_int32_t get_message_id(private_ike_header_t *this)
+=======
+METHOD(ike_header_t, get_message_id, u_int32_t,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
return this->message_id;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.set_message_id.
*/
static void set_message_id(private_ike_header_t *this, u_int32_t message_id)
+=======
+METHOD(ike_header_t, set_message_id, void,
+ private_ike_header_t *this, u_int32_t message_id)
+>>>>>>> upstream/4.5.1
{
this->message_id = message_id;
}
+<<<<<<< HEAD
/**
* Implementation of ike_header_t.destroy and payload_t.destroy.
*/
static void destroy(ike_header_t *this)
+=======
+METHOD2(payload_t, ike_header_t, destroy, void,
+ private_ike_header_t *this)
+>>>>>>> upstream/4.5.1
{
free(this);
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_encoding_rules.
*/
@@ -366,11 +542,14 @@ static size_t get_length(payload_t *this)
return (((private_ike_header_t*)this)->length);
}
+=======
+>>>>>>> upstream/4.5.1
/*
* Described in header.
*/
ike_header_t *ike_header_create()
{
+<<<<<<< HEAD
private_ike_header_t *this = malloc_thing(private_ike_header_t);
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
@@ -412,4 +591,50 @@ ike_header_t *ike_header_create()
this->length = IKE_HEADER_LENGTH;
return (ike_header_t*)this;
+=======
+ private_ike_header_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_initiator_spi = _get_initiator_spi,
+ .set_initiator_spi = _set_initiator_spi,
+ .get_responder_spi = _get_responder_spi,
+ .set_responder_spi = _set_responder_spi,
+ .get_maj_version = _get_maj_version,
+ .set_maj_version = _set_maj_version,
+ .get_min_version = _get_min_version,
+ .set_min_version = _set_min_version,
+ .get_response_flag = _get_response_flag,
+ .set_response_flag = _set_response_flag,
+ .get_version_flag = _get_version_flag,
+ .set_version_flag = _set_version_flag,
+ .get_initiator_flag = _get_initiator_flag,
+ .set_initiator_flag = _set_initiator_flag,
+ .get_exchange_type = _get_exchange_type,
+ .set_exchange_type = _set_exchange_type,
+ .get_message_id = _get_message_id,
+ .set_message_id = _set_message_id,
+ .destroy = _destroy,
+ },
+ .maj_version = IKE_MAJOR_VERSION,
+ .min_version = IKE_MINOR_VERSION,
+ .exchange_type = EXCHANGE_TYPE_UNDEFINED,
+ .flags = {
+ .initiator = TRUE,
+ .version = HIGHER_VERSION_SUPPORTED_FLAG,
+ },
+ .length = IKE_HEADER_LENGTH,
+ );
+
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/ike_header.h b/src/libcharon/encoding/payloads/ike_header.h
index e63e8bf06..77e23efb7 100644
--- a/src/libcharon/encoding/payloads/ike_header.h
+++ b/src/libcharon/encoding/payloads/ike_header.h
@@ -143,6 +143,16 @@ struct ike_header_t {
u_int8_t (*get_maj_version) (ike_header_t *this);
/**
+<<<<<<< HEAD
+=======
+ * Set the major version.
+ *
+ * @param major major version
+ */
+ void (*set_maj_version) (ike_header_t *this, u_int8_t major);
+
+ /**
+>>>>>>> upstream/4.5.1
* Get the minor version.
*
* @return minor version
@@ -150,6 +160,16 @@ struct ike_header_t {
u_int8_t (*get_min_version) (ike_header_t *this);
/**
+<<<<<<< HEAD
+=======
+ * Set the minor version.
+ *
+ * @param minor minor version
+ */
+ void (*set_min_version) (ike_header_t *this, u_int8_t minor);
+
+ /**
+>>>>>>> upstream/4.5.1
* Get the response flag.
*
* @return response flag
@@ -162,6 +182,10 @@ struct ike_header_t {
* @param response response flag
*/
void (*set_response_flag) (ike_header_t *this, bool response);
+<<<<<<< HEAD
+=======
+
+>>>>>>> upstream/4.5.1
/**
* Get "higher version supported"-flag.
*
@@ -170,6 +194,16 @@ struct ike_header_t {
bool (*get_version_flag) (ike_header_t *this);
/**
+<<<<<<< HEAD
+=======
+ * Set the "higher version supported"-flag.
+ *
+ * @param version flag value
+ */
+ void (*set_version_flag)(ike_header_t *this, bool version);
+
+ /**
+>>>>>>> upstream/4.5.1
* Get the initiator flag.
*
* @return initiator flag
diff --git a/src/libcharon/encoding/payloads/ke_payload.c b/src/libcharon/encoding/payloads/ke_payload.c
index 1bc79f084..dd239b212 100644
--- a/src/libcharon/encoding/payloads/ke_payload.c
+++ b/src/libcharon/encoding/payloads/ke_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -20,14 +25,23 @@
#include <encoding/payloads/encodings.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_ke_payload_t private_ke_payload_t;
/**
* Private data of an ke_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_ke_payload_t {
+=======
+ */
+struct private_ke_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public ke_payload_t interface.
*/
@@ -44,6 +58,19 @@ struct private_ke_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved_bit[7];
+
+ /**
+ * Reserved bytes
+ */
+ u_int8_t reserved_byte[2];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -64,6 +91,7 @@ struct private_ke_payload_t {
*
* The defined offsets are the positions in a object of type
* private_ke_payload_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t ke_payload_encodings[] = {
@@ -85,6 +113,29 @@ encoding_rule_t ke_payload_encodings[] = {
{ U_INT_16, offsetof(private_ke_payload_t, dh_group_number) },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
+=======
+ */
+encoding_rule_t ke_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_ke_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_ke_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[0]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[1]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[2]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[3]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[4]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[5]) },
+ { RESERVED_BIT, offsetof(private_ke_payload_t, reserved_bit[6]) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_ke_payload_t, payload_length) },
+ /* DH Group number as 16 bit field*/
+ { U_INT_16, offsetof(private_ke_payload_t, dh_group_number) },
+ /* 2 reserved bytes */
+ { RESERVED_BYTE, offsetof(private_ke_payload_t, reserved_byte[0])},
+ { RESERVED_BYTE, offsetof(private_ke_payload_t, reserved_byte[1])},
+>>>>>>> upstream/4.5.1
/* Key Exchange Data is from variable size */
{ KEY_EXCHANGE_DATA, offsetof(private_ke_payload_t, key_exchange_data)}
};
@@ -103,6 +154,7 @@ encoding_rule_t ke_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -137,10 +189,28 @@ static void get_encoding_rules(private_ke_payload_t *this, encoding_rule_t **rul
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_ke_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_ke_payload_t *this)
+{
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_ke_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = ke_payload_encodings;
+ *rule_count = countof(ke_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_ke_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return KEY_EXCHANGE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -153,10 +223,21 @@ static payload_type_t get_next_type(private_ke_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_ke_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_ke_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_ke_payload_t *this,payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* recompute the length of the payload.
*/
@@ -210,16 +291,40 @@ static void set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchan
* Implementation of ke_payload_t.get_dh_group_number.
*/
static diffie_hellman_group_t get_dh_group_number(private_ke_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_ke_payload_t *this)
+{
+ return this->payload_length;
+}
+
+METHOD(ke_payload_t, get_key_exchange_data, chunk_t,
+ private_ke_payload_t *this)
+{
+ return this->key_exchange_data;
+}
+
+METHOD(ke_payload_t, get_dh_group_number, diffie_hellman_group_t,
+ private_ke_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->dh_group_number;
}
+<<<<<<< HEAD
/**
* Implementation of ke_payload_t.set_dh_group_number.
*/
static void set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group_t dh_group_number)
{
this->dh_group_number = dh_group_number;
+=======
+METHOD2(payload_t, ke_payload_t, destroy, void,
+ private_ke_payload_t *this)
+{
+ free(this->key_exchange_data.ptr);
+ free(this);
+>>>>>>> upstream/4.5.1
}
/*
@@ -227,6 +332,7 @@ static void set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group
*/
ke_payload_t *ke_payload_create()
{
+<<<<<<< HEAD
private_ke_payload_t *this = malloc_thing(private_ke_payload_t);
/* interface functions */
@@ -252,6 +358,29 @@ ke_payload_t *ke_payload_create()
this->key_exchange_data = chunk_empty;
this->dh_group_number = MODP_NONE;
+=======
+ private_ke_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_key_exchange_data = _get_key_exchange_data,
+ .get_dh_group_number = _get_dh_group_number,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = KE_PAYLOAD_HEADER_LENGTH,
+ .dh_group_number = MODP_NONE,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
@@ -264,7 +393,11 @@ ke_payload_t *ke_payload_create_from_diffie_hellman(diffie_hellman_t *dh)
dh->get_my_public_value(dh, &this->key_exchange_data);
this->dh_group_number = dh->get_dh_group(dh);
+<<<<<<< HEAD
compute_length(this);
+=======
+ this->payload_length = this->key_exchange_data.len + KE_PAYLOAD_HEADER_LENGTH;
+>>>>>>> upstream/4.5.1
return &this->public;
}
diff --git a/src/libcharon/encoding/payloads/ke_payload.h b/src/libcharon/encoding/payloads/ke_payload.h
index 3ca05009e..edf271add 100644
--- a/src/libcharon/encoding/payloads/ke_payload.h
+++ b/src/libcharon/encoding/payloads/ke_payload.h
@@ -47,15 +47,22 @@ struct ke_payload_t {
payload_t payload_interface;
/**
+<<<<<<< HEAD
* Returns the currently set key exchange data of this KE payload.
*
* @warning Returned data are not copied.
*
* @return chunk_t pointing to the value
+=======
+ * Returns the key exchange data of this KE payload.
+ *
+ * @return chunk_t pointing to internal data
+>>>>>>> upstream/4.5.1
*/
chunk_t (*get_key_exchange_data) (ke_payload_t *this);
/**
+<<<<<<< HEAD
* Sets the key exchange data of this KE payload.
*
* Value is getting copied.
@@ -65,6 +72,8 @@ struct ke_payload_t {
void (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
/**
+=======
+>>>>>>> upstream/4.5.1
* Gets the Diffie-Hellman Group Number of this KE payload.
*
* @return DH Group Number of this payload
@@ -72,6 +81,7 @@ struct ke_payload_t {
diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
/**
+<<<<<<< HEAD
* Sets the Diffie-Hellman Group Number of this KE payload.
*
* @param dh_group_number DH Group to set
@@ -80,6 +90,8 @@ struct ke_payload_t {
diffie_hellman_group_t dh_group_number);
/**
+=======
+>>>>>>> upstream/4.5.1
* Destroys an ke_payload_t object.
*/
void (*destroy) (ke_payload_t *this);
diff --git a/src/libcharon/encoding/payloads/nonce_payload.c b/src/libcharon/encoding/payloads/nonce_payload.c
index 4ad5ce9dd..ccaf60c09 100644
--- a/src/libcharon/encoding/payloads/nonce_payload.c
+++ b/src/libcharon/encoding/payloads/nonce_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -14,21 +19,33 @@
* for more details.
*/
+<<<<<<< HEAD
/* offsetof macro */
+=======
+>>>>>>> upstream/4.5.1
#include <stddef.h>
#include "nonce_payload.h"
#include <encoding/payloads/encodings.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_nonce_payload_t private_nonce_payload_t;
/**
* Private data of an nonce_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_nonce_payload_t {
+=======
+ */
+struct private_nonce_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public nonce_payload_t interface.
*/
@@ -45,6 +62,14 @@ struct private_nonce_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -60,6 +85,7 @@ struct private_nonce_payload_t {
*
* The defined offsets are the positions in a object of type
* private_nonce_payload_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t nonce_payload_encodings[] = {
@@ -79,6 +105,26 @@ encoding_rule_t nonce_payload_encodings[] = {
{ PAYLOAD_LENGTH, offsetof(private_nonce_payload_t, payload_length) },
/* some nonce bytes, lenth is defined in PAYLOAD_LENGTH */
{ NONCE_DATA, offsetof(private_nonce_payload_t, nonce) }
+=======
+ */
+encoding_rule_t nonce_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_nonce_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_nonce_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_nonce_payload_t, reserved[6]) },
+ /* Length of the whole nonce payload*/
+ { PAYLOAD_LENGTH, offsetof(private_nonce_payload_t, payload_length) },
+ /* some nonce bytes, lenth is defined in PAYLOAD_LENGTH */
+ { NONCE_DATA, offsetof(private_nonce_payload_t, nonce) },
+>>>>>>> upstream/4.5.1
};
/* 1 2 3
@@ -92,6 +138,7 @@ encoding_rule_t nonce_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -141,10 +188,32 @@ static void get_encoding_rules(private_nonce_payload_t *this, encoding_rule_t **
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_nonce_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_nonce_payload_t *this)
+{
+ if (this->nonce.len < 16 || this->nonce.len > 256)
+ {
+ return FAILED;
+ }
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_nonce_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = nonce_payload_encodings;
+ *rule_count = countof(nonce_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_nonce_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return NONCE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -157,10 +226,21 @@ static payload_type_t get_next_type(private_nonce_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_nonce_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_nonce_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_nonce_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* recompute the length of the payload.
*/
@@ -188,6 +268,31 @@ static void destroy(private_nonce_payload_t *this)
free(this->nonce.ptr);
}
+=======
+METHOD(payload_t, get_length, size_t,
+ private_nonce_payload_t *this)
+{
+ return this->payload_length;
+}
+
+METHOD(nonce_payload_t, set_nonce, void,
+ private_nonce_payload_t *this, chunk_t nonce)
+{
+ this->nonce = chunk_clone(nonce);
+ this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
+}
+
+METHOD(nonce_payload_t, get_nonce, chunk_t,
+ private_nonce_payload_t *this)
+{
+ return chunk_clone(this->nonce);
+}
+
+METHOD2(payload_t, nonce_payload_t, destroy, void,
+ private_nonce_payload_t *this)
+{
+ free(this->nonce.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -196,6 +301,7 @@ static void destroy(private_nonce_payload_t *this)
*/
nonce_payload_t *nonce_payload_create()
{
+<<<<<<< HEAD
private_nonce_payload_t *this = malloc_thing(private_nonce_payload_t);
/* interface functions */
@@ -223,3 +329,27 @@ nonce_payload_t *nonce_payload_create()
}
+=======
+ private_nonce_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .set_nonce = _set_nonce,
+ .get_nonce = _get_nonce,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = NONCE_PAYLOAD_HEADER_LENGTH,
+ );
+ return &this->public;
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/notify_payload.c b/src/libcharon/encoding/payloads/notify_payload.c
index a56fd1869..59668bb9d 100644
--- a/src/libcharon/encoding/payloads/notify_payload.c
+++ b/src/libcharon/encoding/payloads/notify_payload.c
@@ -1,7 +1,14 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2006-2008 Tobias Brunner
* Copyright (C) 2006 Daniel Roethlisberger
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ * Copyright (C) 2006-2008 Tobias Brunner
+ * Copyright (C) 2006 Daniel Roethlisberger
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -186,9 +193,15 @@ typedef struct private_notify_payload_t private_notify_payload_t;
/**
* Private data of an notify_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_notify_payload_t {
+=======
+ */
+struct private_notify_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public notify_payload_t interface.
*/
@@ -205,6 +218,14 @@ struct private_notify_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -240,7 +261,10 @@ struct private_notify_payload_t {
*
* The defined offsets are the positions in a object of type
* private_notify_payload_t.
+<<<<<<< HEAD
*
+=======
+>>>>>>> upstream/4.5.1
*/
encoding_rule_t notify_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
@@ -248,6 +272,7 @@ encoding_rule_t notify_payload_encodings[] = {
/* the critical bit */
{ FLAG, offsetof(private_notify_payload_t, critical) },
/* 7 Bit reserved bits, nowhere stored */
+<<<<<<< HEAD
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -255,6 +280,15 @@ encoding_rule_t notify_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_notify_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_notify_payload_t, payload_length) },
/* Protocol ID as 8 bit field*/
@@ -262,11 +296,19 @@ encoding_rule_t notify_payload_encodings[] = {
/* SPI Size as 8 bit field*/
{ SPI_SIZE, offsetof(private_notify_payload_t, spi_size) },
/* Notify message type as 16 bit field*/
+<<<<<<< HEAD
{ U_INT_16, offsetof(private_notify_payload_t, notify_type) },
/* SPI as variable length field*/
{ SPI, offsetof(private_notify_payload_t, spi) },
/* Key Exchange Data is from variable size */
{ NOTIFICATION_DATA, offsetof(private_notify_payload_t, notification_data) }
+=======
+ { U_INT_16, offsetof(private_notify_payload_t, notify_type) },
+ /* SPI as variable length field*/
+ { SPI, offsetof(private_notify_payload_t, spi) },
+ /* Key Exchange Data is from variable size */
+ { NOTIFICATION_DATA,offsetof(private_notify_payload_t, notification_data) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -287,10 +329,15 @@ encoding_rule_t notify_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_notify_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_notify_payload_t *this)
+>>>>>>> upstream/4.5.1
{
bool bad_length = FALSE;
@@ -404,6 +451,7 @@ static status_t verify(private_notify_payload_t *this)
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_encoding_rules.
*/
@@ -417,10 +465,22 @@ static void get_encoding_rules(private_notify_payload_t *this, encoding_rule_t *
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_notify_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_notify_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = notify_payload_encodings;
+ *rule_count = countof(notify_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_notify_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return NOTIFY;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -433,6 +493,16 @@ static payload_type_t get_next_type(private_notify_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_notify_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_notify_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_notify_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
@@ -443,6 +513,10 @@ static void set_next_type(private_notify_payload_t *this,payload_type_t type)
static void compute_length (private_notify_payload_t *this)
{
size_t length = NOTIFY_PAYLOAD_HEADER_LENGTH;
+<<<<<<< HEAD
+=======
+
+>>>>>>> upstream/4.5.1
if (this->notification_data.ptr != NULL)
{
length += this->notification_data.len;
@@ -454,6 +528,7 @@ static void compute_length (private_notify_payload_t *this)
this->payload_length = length;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
@@ -467,38 +542,68 @@ static size_t get_length(private_notify_payload_t *this)
* Implementation of notify_payload_t.get_protocol_id.
*/
static u_int8_t get_protocol_id(private_notify_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_notify_payload_t *this)
+{
+ return this->payload_length;
+}
+
+METHOD(notify_payload_t, get_protocol_id, u_int8_t,
+ private_notify_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->protocol_id;
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.set_protocol_id.
*/
static void set_protocol_id(private_notify_payload_t *this, u_int8_t protocol_id)
+=======
+METHOD(notify_payload_t, set_protocol_id, void,
+ private_notify_payload_t *this, u_int8_t protocol_id)
+>>>>>>> upstream/4.5.1
{
this->protocol_id = protocol_id;
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.get_notify_type.
*/
static notify_type_t get_notify_type(private_notify_payload_t *this)
+=======
+METHOD(notify_payload_t, get_notify_type, notify_type_t,
+ private_notify_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->notify_type;
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.set_notify_type.
*/
static void set_notify_type(private_notify_payload_t *this, u_int16_t notify_type)
+=======
+METHOD(notify_payload_t, set_notify_type, void,
+ private_notify_payload_t *this, notify_type_t notify_type)
+>>>>>>> upstream/4.5.1
{
this->notify_type = notify_type;
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.get_spi.
*/
static u_int32_t get_spi(private_notify_payload_t *this)
+=======
+METHOD(notify_payload_t, get_spi, u_int32_t,
+ private_notify_payload_t *this)
+>>>>>>> upstream/4.5.1
{
switch (this->protocol_id)
{
@@ -514,10 +619,15 @@ static u_int32_t get_spi(private_notify_payload_t *this)
return 0;
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.set_spi.
*/
static void set_spi(private_notify_payload_t *this, u_int32_t spi)
+=======
+METHOD(notify_payload_t, set_spi, void,
+ private_notify_payload_t *this, u_int32_t spi)
+>>>>>>> upstream/4.5.1
{
chunk_free(&this->spi);
switch (this->protocol_id)
@@ -534,6 +644,7 @@ static void set_spi(private_notify_payload_t *this, u_int32_t spi)
compute_length(this);
}
+<<<<<<< HEAD
/**
* Implementation of notify_payload_t.get_notification_data.
*/
@@ -565,6 +676,28 @@ static status_t destroy(private_notify_payload_t *this)
chunk_free(&this->spi);
free(this);
return SUCCESS;
+=======
+METHOD(notify_payload_t, get_notification_data, chunk_t,
+ private_notify_payload_t *this)
+{
+ return this->notification_data;
+}
+
+METHOD(notify_payload_t, set_notification_data, void,
+ private_notify_payload_t *this, chunk_t data)
+{
+ free(this->notification_data.ptr);
+ this->notification_data = chunk_clone(data);
+ compute_length(this);
+}
+
+METHOD2(payload_t, notify_payload_t, destroy, void,
+ private_notify_payload_t *this)
+{
+ free(this->notification_data.ptr);
+ free(this->spi.ptr);
+ free(this);
+>>>>>>> upstream/4.5.1
}
/*
@@ -572,6 +705,7 @@ static status_t destroy(private_notify_payload_t *this)
*/
notify_payload_t *notify_payload_create()
{
+<<<<<<< HEAD
private_notify_payload_t *this = malloc_thing(private_notify_payload_t);
/* interface functions */
@@ -606,18 +740,56 @@ notify_payload_t *notify_payload_create()
this->notification_data.ptr = NULL;
this->notification_data.len = 0;
+=======
+ private_notify_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_protocol_id = _get_protocol_id,
+ .set_protocol_id = _set_protocol_id,
+ .get_notify_type = _get_notify_type,
+ .set_notify_type = _set_notify_type,
+ .get_spi = _get_spi,
+ .set_spi = _set_spi,
+ .get_notification_data = _get_notification_data,
+ .set_notification_data = _set_notification_data,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = NOTIFY_PAYLOAD_HEADER_LENGTH,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
/*
* Described in header.
*/
+<<<<<<< HEAD
notify_payload_t *notify_payload_create_from_protocol_and_type(protocol_id_t protocol_id, notify_type_t notify_type)
{
notify_payload_t *notify = notify_payload_create();
notify->set_notify_type(notify,notify_type);
notify->set_protocol_id(notify,protocol_id);
+=======
+notify_payload_t *notify_payload_create_from_protocol_and_type(
+ protocol_id_t protocol_id, notify_type_t notify_type)
+{
+ notify_payload_t *notify = notify_payload_create();
+
+ notify->set_notify_type(notify, notify_type);
+ notify->set_protocol_id(notify, protocol_id);
+>>>>>>> upstream/4.5.1
return notify;
}
diff --git a/src/libcharon/encoding/payloads/payload.c b/src/libcharon/encoding/payloads/payload.c
index 1cee6d2aa..35d073240 100644
--- a/src/libcharon/encoding/payloads/payload.c
+++ b/src/libcharon/encoding/payloads/payload.c
@@ -59,25 +59,41 @@ ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, N
#ifdef ME
ENUM_NEXT(payload_type_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
"ID_PEER");
+<<<<<<< HEAD
ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
+=======
+ENUM_NEXT(payload_type_names, HEADER, CONFIGURATION_ATTRIBUTE, ID_PEER,
+>>>>>>> upstream/4.5.1
"HEADER",
"PROPOSAL_SUBSTRUCTURE",
"TRANSFORM_SUBSTRUCTURE",
"TRANSFORM_ATTRIBUTE",
"TRAFFIC_SELECTOR_SUBSTRUCTURE",
+<<<<<<< HEAD
"CONFIGURATION_ATTRIBUTE",
"UNKNOWN_PAYLOAD");
#else
ENUM_NEXT(payload_type_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
+=======
+ "CONFIGURATION_ATTRIBUTE");
+#else
+ENUM_NEXT(payload_type_names, HEADER, CONFIGURATION_ATTRIBUTE, EXTENSIBLE_AUTHENTICATION,
+>>>>>>> upstream/4.5.1
"HEADER",
"PROPOSAL_SUBSTRUCTURE",
"TRANSFORM_SUBSTRUCTURE",
"TRANSFORM_ATTRIBUTE",
"TRAFFIC_SELECTOR_SUBSTRUCTURE",
+<<<<<<< HEAD
"CONFIGURATION_ATTRIBUTE",
"UNKNOWN_PAYLOAD");
#endif /* ME */
ENUM_END(payload_type_names, UNKNOWN_PAYLOAD);
+=======
+ "CONFIGURATION_ATTRIBUTE");
+#endif /* ME */
+ENUM_END(payload_type_names, CONFIGURATION_ATTRIBUTE);
+>>>>>>> upstream/4.5.1
/* short forms of payload names */
ENUM_BEGIN(payload_type_short_names, NO_PAYLOAD, NO_PAYLOAD,
@@ -102,25 +118,41 @@ ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICAT
#ifdef ME
ENUM_NEXT(payload_type_short_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
"IDp");
+<<<<<<< HEAD
ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, ID_PEER,
+=======
+ENUM_NEXT(payload_type_short_names, HEADER, CONFIGURATION_ATTRIBUTE, ID_PEER,
+>>>>>>> upstream/4.5.1
"HDR",
"PROP",
"TRANS",
"TRANSATTR",
"TSSUB",
+<<<<<<< HEAD
"CPATTR",
"??");
#else
ENUM_NEXT(payload_type_short_names, HEADER, UNKNOWN_PAYLOAD, EXTENSIBLE_AUTHENTICATION,
+=======
+ "CPATTR");
+#else
+ENUM_NEXT(payload_type_short_names, HEADER, CONFIGURATION_ATTRIBUTE, EXTENSIBLE_AUTHENTICATION,
+>>>>>>> upstream/4.5.1
"HDR",
"PROP",
"TRANS",
"TRANSATTR",
"TSSUB",
+<<<<<<< HEAD
"CPATTR",
"??");
#endif /* ME */
ENUM_END(payload_type_short_names, UNKNOWN_PAYLOAD);
+=======
+ "CPATTR");
+#endif /* ME */
+ENUM_END(payload_type_short_names, CONFIGURATION_ATTRIBUTE);
+>>>>>>> upstream/4.5.1
/*
* see header
@@ -178,7 +210,52 @@ payload_t *payload_create(payload_type_t type)
case ENCRYPTED:
return (payload_t*)encryption_payload_create();
default:
+<<<<<<< HEAD
return (payload_t*)unknown_payload_create();
}
}
+=======
+ return (payload_t*)unknown_payload_create(type);
+ }
+}
+
+/**
+ * See header.
+ */
+bool payload_is_known(payload_type_t type)
+{
+ if (type == HEADER ||
+ (type >= SECURITY_ASSOCIATION && type <= EXTENSIBLE_AUTHENTICATION))
+ {
+ return TRUE;
+ }
+#ifdef ME
+ if (type == ID_PEER)
+ {
+ return TRUE;
+ }
+#endif
+ return FALSE;
+}
+
+/**
+ * See header.
+ */
+void* payload_get_field(payload_t *payload, encoding_type_t type, u_int skip)
+{
+ encoding_rule_t *rule;
+ size_t count;
+ int i;
+
+ payload->get_encoding_rules(payload, &rule, &count);
+ for (i = 0; i < count; i++)
+ {
+ if (rule[i].type == type && skip-- == 0)
+ {
+ return ((char*)payload) + rule[i].offset;
+ }
+ }
+ return NULL;
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/payload.h b/src/libcharon/encoding/payloads/payload.h
index 2e783cb30..68fbb01c0 100644
--- a/src/libcharon/encoding/payloads/payload.h
+++ b/src/libcharon/encoding/payloads/payload.h
@@ -137,7 +137,11 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle IKEv2-Header like a payload.
*/
+<<<<<<< HEAD
HEADER = 140,
+=======
+ HEADER = 256,
+>>>>>>> upstream/4.5.1
/**
* PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
@@ -145,7 +149,11 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle a proposal substructure like a payload.
*/
+<<<<<<< HEAD
PROPOSAL_SUBSTRUCTURE = 141,
+=======
+ PROPOSAL_SUBSTRUCTURE = 257,
+>>>>>>> upstream/4.5.1
/**
* TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
@@ -153,7 +161,11 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle a transform substructure like a payload.
*/
+<<<<<<< HEAD
TRANSFORM_SUBSTRUCTURE = 142,
+=======
+ TRANSFORM_SUBSTRUCTURE = 258,
+>>>>>>> upstream/4.5.1
/**
* TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
@@ -161,7 +173,11 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle a transform attribute like a payload.
*/
+<<<<<<< HEAD
TRANSFORM_ATTRIBUTE = 143,
+=======
+ TRANSFORM_ATTRIBUTE = 259,
+>>>>>>> upstream/4.5.1
/**
* TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
@@ -169,7 +185,11 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle a transform selector like a payload.
*/
+<<<<<<< HEAD
TRAFFIC_SELECTOR_SUBSTRUCTURE = 144,
+=======
+ TRAFFIC_SELECTOR_SUBSTRUCTURE = 260,
+>>>>>>> upstream/4.5.1
/**
* CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
@@ -177,6 +197,7 @@ enum payload_type_t{
* This payload type is not sent over wire and just
* used internally to handle a transform attribute like a payload.
*/
+<<<<<<< HEAD
CONFIGURATION_ATTRIBUTE = 145,
/**
@@ -189,6 +210,11 @@ enum payload_type_t{
};
+=======
+ CONFIGURATION_ATTRIBUTE = 261,
+};
+
+>>>>>>> upstream/4.5.1
/**
* enum names for payload_type_t.
*/
@@ -269,4 +295,25 @@ struct payload_t {
*/
payload_t *payload_create(payload_type_t type);
+<<<<<<< HEAD
+=======
+/**
+ * Check if a specific payload is implemented, or handled as unknown payload.
+ *
+ * @param type type of the payload to check
+ * @return FALSE if payload type handled as unknown payload
+ */
+bool payload_is_known(payload_type_t type);
+
+/**
+ * Get the value field in a payload using encoding rules.
+ *
+ * @param payload payload to look up a field
+ * @param type encoding rule type to look up
+ * @param skip number rules of type to skip, 0 to get first
+ * @return type specific value pointer, NULL if not found
+ */
+void* payload_get_field(payload_t *payload, encoding_type_t type, u_int skip);
+
+>>>>>>> upstream/4.5.1
#endif /** PAYLOAD_H_ @}*/
diff --git a/src/libcharon/encoding/payloads/proposal_substructure.c b/src/libcharon/encoding/payloads/proposal_substructure.c
index 985b03255..9272d1b63 100644
--- a/src/libcharon/encoding/payloads/proposal_substructure.c
+++ b/src/libcharon/encoding/payloads/proposal_substructure.c
@@ -47,6 +47,14 @@ struct private_proposal_substructure_t {
u_int8_t next_payload;
/**
+<<<<<<< HEAD
+=======
+ * reserved byte
+ */
+ u_int8_t reserved;
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t proposal_length;
@@ -91,8 +99,13 @@ struct private_proposal_substructure_t {
encoding_rule_t proposal_substructure_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
{ U_INT_8, offsetof(private_proposal_substructure_t, next_payload) },
+<<<<<<< HEAD
/* Reserved Byte is skipped */
{ RESERVED_BYTE, 0 },
+=======
+ /* 1 Reserved Byte */
+ { RESERVED_BYTE, offsetof(private_proposal_substructure_t, reserved) },
+>>>>>>> upstream/4.5.1
/* Length of the whole proposal substructure payload*/
{ PAYLOAD_LENGTH, offsetof(private_proposal_substructure_t, proposal_length) },
/* proposal number is a number of 8 bit */
@@ -213,6 +226,7 @@ METHOD(payload_t, set_next_type, void,
*/
static void compute_length(private_proposal_substructure_t *this)
{
+<<<<<<< HEAD
iterator_t *iterator;
payload_t *current_transform;
size_t transforms_count = 0;
@@ -229,12 +243,29 @@ static void compute_length(private_proposal_substructure_t *this)
length += this->spi.len;
this->transforms_count = transforms_count;
this->proposal_length = length;
+=======
+ enumerator_t *enumerator;
+ payload_t *transform;
+
+ this->transforms_count = 0;
+ this->proposal_length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH + this->spi.len;
+ enumerator = this->transforms->create_enumerator(this->transforms);
+ while (enumerator->enumerate(enumerator, &transform))
+ {
+ this->proposal_length += transform->get_length(transform);
+ this->transforms_count++;
+ }
+ enumerator->destroy(enumerator);
+>>>>>>> upstream/4.5.1
}
METHOD(payload_t, get_length, size_t,
private_proposal_substructure_t *this)
{
+<<<<<<< HEAD
compute_length(this);
+=======
+>>>>>>> upstream/4.5.1
return this->proposal_length;
}
@@ -342,6 +373,7 @@ METHOD(proposal_substructure_t, get_proposal, proposal_t*,
return proposal;
}
+<<<<<<< HEAD
METHOD(proposal_substructure_t, clone_, proposal_substructure_t*,
private_proposal_substructure_t *this)
{
@@ -368,6 +400,12 @@ METHOD(proposal_substructure_t, clone_, proposal_substructure_t*,
enumerator->destroy(enumerator);
return &clone->public;
+=======
+METHOD(proposal_substructure_t, create_substructure_enumerator, enumerator_t*,
+ private_proposal_substructure_t *this)
+{
+ return this->transforms->create_enumerator(this->transforms);
+>>>>>>> upstream/4.5.1
}
METHOD2(payload_t, proposal_substructure_t, destroy, void,
@@ -403,12 +441,22 @@ proposal_substructure_t *proposal_substructure_create()
.get_protocol_id = _get_protocol_id,
.set_is_last_proposal = _set_is_last_proposal,
.get_proposal = _get_proposal,
+<<<<<<< HEAD
.set_spi = _set_spi,
.get_spi = _get_spi,
.clone = _clone_,
.destroy = _destroy,
},
.next_payload = NO_PAYLOAD,
+=======
+ .create_substructure_enumerator = _create_substructure_enumerator,
+ .set_spi = _set_spi,
+ .get_spi = _get_spi,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .proposal_length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH,
+>>>>>>> upstream/4.5.1
.transforms = linked_list_create(),
);
@@ -500,6 +548,10 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(
}
this->proposal_number = proposal->get_number(proposal);
this->protocol_id = proposal->get_protocol(proposal);
+<<<<<<< HEAD
+=======
+ compute_length(this);
+>>>>>>> upstream/4.5.1
return &this->public;
}
diff --git a/src/libcharon/encoding/payloads/proposal_substructure.h b/src/libcharon/encoding/payloads/proposal_substructure.h
index 56e7184b6..a7ad97e1c 100644
--- a/src/libcharon/encoding/payloads/proposal_substructure.h
+++ b/src/libcharon/encoding/payloads/proposal_substructure.h
@@ -111,11 +111,19 @@ struct proposal_substructure_t {
proposal_t * (*get_proposal) (proposal_substructure_t *this);
/**
+<<<<<<< HEAD
* Clones an proposal_substructure_t object.
*
* @return cloned object
*/
proposal_substructure_t* (*clone) (proposal_substructure_t *this);
+=======
+ * Create an enumerator over transform substructures.
+ *
+ * @return enumerator over transform_substructure_t
+ */
+ enumerator_t* (*create_substructure_enumerator)(proposal_substructure_t *this);
+>>>>>>> upstream/4.5.1
/**
* Destroys an proposal_substructure_t object.
diff --git a/src/libcharon/encoding/payloads/sa_payload.c b/src/libcharon/encoding/payloads/sa_payload.c
index 4fbd4cac0..faa19b614 100644
--- a/src/libcharon/encoding/payloads/sa_payload.c
+++ b/src/libcharon/encoding/payloads/sa_payload.c
@@ -46,6 +46,14 @@ struct private_sa_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -68,6 +76,7 @@ encoding_rule_t sa_payload_encodings[] = {
/* the critical bit */
{ FLAG, offsetof(private_sa_payload_t, critical) },
/* 7 Bit reserved bits, nowhere stored */
+<<<<<<< HEAD
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
@@ -75,6 +84,15 @@ encoding_rule_t sa_payload_encodings[] = {
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
+=======
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_sa_payload_t, reserved[6]) },
+>>>>>>> upstream/4.5.1
/* Length of the whole SA payload*/
{ PAYLOAD_LENGTH, offsetof(private_sa_payload_t, payload_length) },
/* Proposals are stored in a proposal substructure,
@@ -185,7 +203,10 @@ static void compute_length(private_sa_payload_t *this)
METHOD(payload_t, get_length, size_t,
private_sa_payload_t *this)
{
+<<<<<<< HEAD
compute_length(this);
+=======
+>>>>>>> upstream/4.5.1
return this->payload_length;
}
@@ -258,6 +279,15 @@ METHOD(sa_payload_t, get_proposals, linked_list_t*,
return list;
}
+<<<<<<< HEAD
+=======
+METHOD(sa_payload_t, create_substructure_enumerator, enumerator_t*,
+ private_sa_payload_t *this)
+{
+ return this->proposals->create_enumerator(this->proposals);
+}
+
+>>>>>>> upstream/4.5.1
METHOD2(payload_t, sa_payload_t, destroy, void,
private_sa_payload_t *this)
{
@@ -286,6 +316,10 @@ sa_payload_t *sa_payload_create()
},
.add_proposal = _add_proposal,
.get_proposals = _get_proposals,
+<<<<<<< HEAD
+=======
+ .create_substructure_enumerator = _create_substructure_enumerator,
+>>>>>>> upstream/4.5.1
.destroy = _destroy,
},
.next_payload = NO_PAYLOAD,
diff --git a/src/libcharon/encoding/payloads/sa_payload.h b/src/libcharon/encoding/payloads/sa_payload.h
index 801a70738..fb0227016 100644
--- a/src/libcharon/encoding/payloads/sa_payload.h
+++ b/src/libcharon/encoding/payloads/sa_payload.h
@@ -61,6 +61,16 @@ struct sa_payload_t {
void (*add_proposal) (sa_payload_t *this, proposal_t *proposal);
/**
+<<<<<<< HEAD
+=======
+ * Create an enumerator over all proposal substructures.
+ *
+ * @return enumerator over proposal_substructure_t
+ */
+ enumerator_t* (*create_substructure_enumerator)(sa_payload_t *this);
+
+ /**
+>>>>>>> upstream/4.5.1
* Destroys an sa_payload_t object.
*/
void (*destroy) (sa_payload_t *this);
diff --git a/src/libcharon/encoding/payloads/traffic_selector_substructure.c b/src/libcharon/encoding/payloads/traffic_selector_substructure.c
index f24857591..f631714a2 100644
--- a/src/libcharon/encoding/payloads/traffic_selector_substructure.c
+++ b/src/libcharon/encoding/payloads/traffic_selector_substructure.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -19,14 +24,23 @@
#include <encoding/payloads/encodings.h>
#include <utils/linked_list.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_traffic_selector_substructure_t private_traffic_selector_substructure_t;
/**
* Private data of an traffic_selector_substructure_t object.
+<<<<<<< HEAD
*
*/
struct private_traffic_selector_substructure_t {
+=======
+ */
+struct private_traffic_selector_substructure_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public traffic_selector_substructure_t interface.
*/
@@ -73,6 +87,7 @@ struct private_traffic_selector_substructure_t {
*
* The defined offsets are the positions in a object of type
* private_traffic_selector_substructure_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t traffic_selector_substructure_encodings[] = {
@@ -91,6 +106,24 @@ encoding_rule_t traffic_selector_substructure_encodings[] = {
/* ending address is either 4 or 16 byte */
{ ADDRESS, offsetof(private_traffic_selector_substructure_t, ending_address) }
+=======
+ */
+encoding_rule_t traffic_selector_substructure_encodings[] = {
+ /* 1 Byte next ts type*/
+ { TS_TYPE, offsetof(private_traffic_selector_substructure_t, ts_type) },
+ /* 1 Byte IP protocol id*/
+ { U_INT_8, offsetof(private_traffic_selector_substructure_t, ip_protocol_id) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH,offsetof(private_traffic_selector_substructure_t, payload_length) },
+ /* 2 Byte start port*/
+ { U_INT_16, offsetof(private_traffic_selector_substructure_t, start_port) },
+ /* 2 Byte end port*/
+ { U_INT_16, offsetof(private_traffic_selector_substructure_t, end_port) },
+ /* starting address is either 4 or 16 byte */
+ { ADDRESS, offsetof(private_traffic_selector_substructure_t, starting_address) },
+ /* ending address is either 4 or 16 byte */
+ { ADDRESS, offsetof(private_traffic_selector_substructure_t, ending_address) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -111,10 +144,15 @@ encoding_rule_t traffic_selector_substructure_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_traffic_selector_substructure_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_traffic_selector_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
if (this->start_port > this->end_port)
{
@@ -152,6 +190,7 @@ static status_t verify(private_traffic_selector_substructure_t *this)
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of traffic_selector_substructure_t.get_encoding_rules.
*/
@@ -165,10 +204,23 @@ static void get_encoding_rules(private_traffic_selector_substructure_t *this, en
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_traffic_selector_substructure_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_traffic_selector_substructure_t *this, encoding_rule_t **rules,
+ size_t *rule_count)
+{
+ *rules = traffic_selector_substructure_encodings;
+ *rule_count = countof(traffic_selector_substructure_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_traffic_selector_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
return TRAFFIC_SELECTOR_SUBSTRUCTURE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -189,10 +241,26 @@ static void set_next_type(private_traffic_selector_substructure_t *this,payload_
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_traffic_selector_substructure_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_traffic_selector_substructure_t *this)
+{
+ return NO_PAYLOAD;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_traffic_selector_substructure_t *this,payload_type_t type)
+{
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_traffic_selector_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of traffic_selector_substructure_t.get_traffic_selector.
*/
@@ -218,6 +286,19 @@ void compute_length(private_traffic_selector_substructure_t *this)
* Implementation of payload_t.destroy and traffic_selector_substructure_t.destroy.
*/
static void destroy(private_traffic_selector_substructure_t *this)
+=======
+METHOD(traffic_selector_substructure_t, get_traffic_selector, traffic_selector_t*,
+ private_traffic_selector_substructure_t *this)
+{
+ return traffic_selector_create_from_bytes(
+ this->ip_protocol_id, this->ts_type,
+ this->starting_address, this->start_port,
+ this->ending_address, this->end_port);
+}
+
+METHOD2(payload_t, traffic_selector_substructure_t, destroy, void,
+ private_traffic_selector_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
free(this->starting_address.ptr);
free(this->ending_address.ptr);
@@ -229,6 +310,7 @@ static void destroy(private_traffic_selector_substructure_t *this)
*/
traffic_selector_substructure_t *traffic_selector_substructure_create()
{
+<<<<<<< HEAD
private_traffic_selector_substructure_t *this = malloc_thing(private_traffic_selector_substructure_t);
/* interface functions */
@@ -255,11 +337,35 @@ traffic_selector_substructure_t *traffic_selector_substructure_create()
this->ts_type = TS_IPV4_ADDR_RANGE;
return (&(this->public));
+=======
+ private_traffic_selector_substructure_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_traffic_selector = _get_traffic_selector,
+ .destroy = _destroy,
+ },
+ .payload_length = TRAFFIC_SELECTOR_HEADER_LENGTH,
+ /* must be set to be valid */
+ .ts_type = TS_IPV4_ADDR_RANGE,
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
/*
* Described in header
*/
+<<<<<<< HEAD
traffic_selector_substructure_t *traffic_selector_substructure_create_from_traffic_selector(traffic_selector_t *traffic_selector)
{
private_traffic_selector_substructure_t *this = (private_traffic_selector_substructure_t*)traffic_selector_substructure_create();
@@ -273,4 +379,22 @@ traffic_selector_substructure_t *traffic_selector_substructure_create_from_traff
compute_length(this);
return &(this->public);
+=======
+traffic_selector_substructure_t *traffic_selector_substructure_create_from_traffic_selector(
+ traffic_selector_t *ts)
+{
+ private_traffic_selector_substructure_t *this;
+
+ this = (private_traffic_selector_substructure_t*)traffic_selector_substructure_create();
+ this->ts_type = ts->get_type(ts);
+ this->ip_protocol_id = ts->get_protocol(ts);
+ this->start_port = ts->get_from_port(ts);
+ this->end_port = ts->get_to_port(ts);
+ this->starting_address = chunk_clone(ts->get_from_address(ts));
+ this->ending_address = chunk_clone(ts->get_to_address(ts));
+ this->payload_length = TRAFFIC_SELECTOR_HEADER_LENGTH +
+ this->ending_address.len + this->starting_address.len;
+
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/transform_attribute.c b/src/libcharon/encoding/payloads/transform_attribute.c
index 8bf2ddef4..7332b939b 100644
--- a/src/libcharon/encoding/payloads/transform_attribute.c
+++ b/src/libcharon/encoding/payloads/transform_attribute.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -26,9 +31,15 @@ typedef struct private_transform_attribute_t private_transform_attribute_t;
/**
* Private data of an transform_attribute_t object.
+<<<<<<< HEAD
*
*/
struct private_transform_attribute_t {
+=======
+ */
+struct private_transform_attribute_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public transform_attribute_t interface.
*/
@@ -70,7 +81,10 @@ ENUM_END(transform_attribute_type_name, KEY_LENGTH);
*
* The defined offsets are the positions in a object of type
* private_transform_attribute_t.
+<<<<<<< HEAD
*
+=======
+>>>>>>> upstream/4.5.1
*/
encoding_rule_t transform_attribute_encodings[] = {
/* Flag defining the format of this payload */
@@ -78,7 +92,11 @@ encoding_rule_t transform_attribute_encodings[] = {
/* type of the attribute as 15 bit unsigned integer */
{ ATTRIBUTE_TYPE, offsetof(private_transform_attribute_t, attribute_type) },
/* Length or value, depending on the attribute format flag */
+<<<<<<< HEAD
{ ATTRIBUTE_LENGTH_OR_VALUE, offsetof(private_transform_attribute_t, attribute_length_or_value) },
+=======
+ { ATTRIBUTE_LENGTH_OR_VALUE,offsetof(private_transform_attribute_t, attribute_length_or_value) },
+>>>>>>> upstream/4.5.1
/* Value of attribute if attribute format flag is zero */
{ ATTRIBUTE_VALUE, offsetof(private_transform_attribute_t, attribute_value) }
};
@@ -95,6 +113,7 @@ encoding_rule_t transform_attribute_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -121,10 +140,29 @@ static void get_encoding_rules(private_transform_attribute_t *this, encoding_rul
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_transform_attribute_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_transform_attribute_t *this)
+{
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_transform_attribute_t *this, encoding_rule_t **rules,
+ size_t *rule_count)
+{
+ *rules = transform_attribute_encodings;
+ *rule_count = countof(transform_attribute_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_transform_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return TRANSFORM_ATTRIBUTE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
@@ -173,10 +211,43 @@ static void set_value_chunk(private_transform_attribute_t *this, chunk_t value)
this->attribute_value.len = value.len;
this->attribute_length_or_value = value.len;
/* attribute has not a fixed length */
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_transform_attribute_t *this)
+{
+ return NO_PAYLOAD;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_transform_attribute_t *this, payload_type_t type)
+{
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_transform_attribute_t *this)
+{
+ if (this->attribute_format)
+ {
+ return 4;
+ }
+ return this->attribute_length_or_value + 4;
+}
+
+METHOD(transform_attribute_t, set_value_chunk, void,
+ private_transform_attribute_t *this, chunk_t value)
+{
+ chunk_free(&this->attribute_value);
+
+ if (value.len != 2)
+ {
+ this->attribute_value = chunk_clone(value);
+ this->attribute_length_or_value = value.len;
+>>>>>>> upstream/4.5.1
this->attribute_format = FALSE;
}
else
{
+<<<<<<< HEAD
memcpy(&(this->attribute_length_or_value),value.ptr,value.len);
}
}
@@ -222,27 +293,64 @@ static chunk_t get_value_chunk (private_transform_attribute_t *this)
* Implementation of transform_attribute_t.get_value.
*/
static u_int16_t get_value (private_transform_attribute_t *this)
+=======
+ memcpy(&this->attribute_length_or_value, value.ptr, value.len);
+ }
+}
+
+METHOD(transform_attribute_t, set_value, void,
+ private_transform_attribute_t *this, u_int16_t value)
+{
+ chunk_free(&this->attribute_value);
+ this->attribute_length_or_value = value;
+ this->attribute_format = TRUE;
+}
+
+METHOD(transform_attribute_t, get_value_chunk, chunk_t,
+ private_transform_attribute_t *this)
+{
+ if (this->attribute_format)
+ {
+ return chunk_from_thing(this->attribute_length_or_value);
+ }
+ return this->attribute_value;
+}
+
+METHOD(transform_attribute_t, get_value, u_int16_t,
+ private_transform_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return this->attribute_length_or_value;
}
+<<<<<<< HEAD
/**
* Implementation of transform_attribute_t.set_attribute_type.
*/
static void set_attribute_type (private_transform_attribute_t *this, u_int16_t type)
+=======
+METHOD(transform_attribute_t, set_attribute_type, void,
+ private_transform_attribute_t *this, u_int16_t type)
+>>>>>>> upstream/4.5.1
{
this->attribute_type = type & 0x7FFF;
}
+<<<<<<< HEAD
/**
* Implementation of transform_attribute_t.get_attribute_type.
*/
static u_int16_t get_attribute_type (private_transform_attribute_t *this)
+=======
+METHOD(transform_attribute_t, get_attribute_type, u_int16_t,
+ private_transform_attribute_t *this)
+>>>>>>> upstream/4.5.1
{
return this->attribute_type;
}
+<<<<<<< HEAD
/**
* Implementation of transform_attribute_t.clone.
*/
@@ -251,6 +359,14 @@ static transform_attribute_t * _clone(private_transform_attribute_t *this)
private_transform_attribute_t *new_clone;
new_clone = (private_transform_attribute_t *) transform_attribute_create();
+=======
+METHOD(transform_attribute_t, clone_, transform_attribute_t*,
+ private_transform_attribute_t *this)
+{
+ private_transform_attribute_t *new_clone;
+
+ new_clone = (private_transform_attribute_t *)transform_attribute_create();
+>>>>>>> upstream/4.5.1
new_clone->attribute_format = this->attribute_format;
new_clone->attribute_type = this->attribute_type;
@@ -258,6 +374,7 @@ static transform_attribute_t * _clone(private_transform_attribute_t *this)
if (!new_clone->attribute_format)
{
+<<<<<<< HEAD
new_clone->attribute_value.ptr = clalloc(this->attribute_value.ptr,this->attribute_value.len);
new_clone->attribute_value.len = this->attribute_value.len;
}
@@ -274,6 +391,17 @@ static void destroy(private_transform_attribute_t *this)
{
free(this->attribute_value.ptr);
}
+=======
+ new_clone->attribute_value = chunk_clone(this->attribute_value);
+ }
+ return &new_clone->public;
+}
+
+METHOD2(payload_t, transform_attribute_t, destroy, void,
+ private_transform_attribute_t *this)
+{
+ free(this->attribute_value.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -282,6 +410,7 @@ static void destroy(private_transform_attribute_t *this)
*/
transform_attribute_t *transform_attribute_create()
{
+<<<<<<< HEAD
private_transform_attribute_t *this = malloc_thing(private_transform_attribute_t);
/* payload interface */
@@ -311,6 +440,33 @@ transform_attribute_t *transform_attribute_create()
this->attribute_value.len = 0;
return (&(this->public));
+=======
+ private_transform_attribute_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .set_value_chunk = _set_value_chunk,
+ .set_value = _set_value,
+ .get_value_chunk = _get_value_chunk,
+ .get_value = _get_value,
+ .set_attribute_type = _set_attribute_type,
+ .get_attribute_type = _get_attribute_type,
+ .clone = _clone_,
+ .destroy = _destroy,
+ },
+ .attribute_format = TRUE,
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
/*
@@ -319,7 +475,12 @@ transform_attribute_t *transform_attribute_create()
transform_attribute_t *transform_attribute_create_key_length(u_int16_t key_length)
{
transform_attribute_t *attribute = transform_attribute_create();
+<<<<<<< HEAD
attribute->set_attribute_type(attribute,KEY_LENGTH);
attribute->set_value(attribute,key_length);
+=======
+ attribute->set_attribute_type(attribute, KEY_LENGTH);
+ attribute->set_value(attribute, key_length);
+>>>>>>> upstream/4.5.1
return attribute;
}
diff --git a/src/libcharon/encoding/payloads/transform_substructure.c b/src/libcharon/encoding/payloads/transform_substructure.c
index c94f6c1a2..fa711a7b5 100644
--- a/src/libcharon/encoding/payloads/transform_substructure.c
+++ b/src/libcharon/encoding/payloads/transform_substructure.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -24,14 +29,23 @@
#include <utils/linked_list.h>
#include <daemon.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_transform_substructure_t private_transform_substructure_t;
/**
* Private data of an transform_substructure_t object.
+<<<<<<< HEAD
*
*/
struct private_transform_substructure_t {
+=======
+ */
+struct private_transform_substructure_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public transform_substructure_t interface.
*/
@@ -41,14 +55,24 @@ struct private_transform_substructure_t {
* Next payload type.
*/
u_int8_t next_payload;
+<<<<<<< HEAD
+=======
+ /**
+ * Reserved bytes
+ */
+ u_int8_t reserved[2];
+>>>>>>> upstream/4.5.1
/**
* Length of this payload.
*/
u_int16_t transform_length;
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
/**
* Type of the transform.
*/
@@ -65,12 +89,16 @@ struct private_transform_substructure_t {
linked_list_t *attributes;
};
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
/**
* Encoding rules to parse or generate a Transform substructure.
*
* The defined offsets are the positions in a object of type
* private_transform_substructure_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t transform_substructure_encodings[] = {
@@ -89,6 +117,25 @@ encoding_rule_t transform_substructure_encodings[] = {
/* Attributes are stored in a transform attribute,
offset points to a linked_list_t pointer */
{ TRANSFORM_ATTRIBUTES, offsetof(private_transform_substructure_t, attributes) }
+=======
+ */
+encoding_rule_t transform_substructure_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_transform_substructure_t, next_payload) },
+ /* 1 Reserved Byte */
+ { RESERVED_BYTE, offsetof(private_transform_substructure_t, reserved[0]) },
+ /* Length of the whole transform substructure*/
+ { PAYLOAD_LENGTH, offsetof(private_transform_substructure_t, transform_length)},
+ /* transform type is a number of 8 bit */
+ { U_INT_8, offsetof(private_transform_substructure_t, transform_type) },
+ /* 1 Reserved Byte */
+ { RESERVED_BYTE, offsetof(private_transform_substructure_t, reserved[1]) },
+ /* tranform ID is a number of 8 bit */
+ { U_INT_16, offsetof(private_transform_substructure_t, transform_id) },
+ /* Attributes are stored in a transform attribute,
+ offset points to a linked_list_t pointer */
+ { TRANSFORM_ATTRIBUTES, offsetof(private_transform_substructure_t, attributes) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -105,6 +152,7 @@ encoding_rule_t transform_substructure_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
@@ -118,6 +166,17 @@ static status_t verify(private_transform_substructure_t *this)
if ((this->next_payload != NO_PAYLOAD) && (this->next_payload != 3))
{
/* must be 0 or 3 */
+=======
+METHOD(payload_t, verify, status_t,
+ private_transform_substructure_t *this)
+{
+ status_t status = SUCCESS;
+ enumerator_t *enumerator;
+ payload_t *attribute;
+
+ if (this->next_payload != NO_PAYLOAD && this->next_payload != 3)
+ {
+>>>>>>> upstream/4.5.1
DBG1(DBG_ENC, "inconsistent next payload");
return FAILED;
}
@@ -138,6 +197,7 @@ static status_t verify(private_transform_substructure_t *this)
return FAILED;
}
}
+<<<<<<< HEAD
iterator = this->attributes->create_iterator(this->attributes,TRUE);
while(iterator->iterate(iterator, (void**)&current_attributes))
@@ -149,11 +209,26 @@ static status_t verify(private_transform_substructure_t *this)
}
}
iterator->destroy(iterator);
+=======
+
+ enumerator = this->attributes->create_enumerator(this->attributes);
+ while (enumerator->enumerate(enumerator, &attribute))
+ {
+ status = attribute->verify(attribute);
+ if (status != SUCCESS)
+ {
+ DBG1(DBG_ENC, "TRANSFORM_ATTRIBUTE verification failed");
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+>>>>>>> upstream/4.5.1
/* proposal number is checked in SA payload */
return status;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_encoding_rules.
*/
@@ -167,16 +242,35 @@ static void get_encoding_rules(private_transform_substructure_t *this, encoding_
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_transform_substructure_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_transform_substructure_t *this, encoding_rule_t **rules,
+ size_t *rule_count)
+{
+ *rules = transform_substructure_encodings;
+ *rule_count = countof(transform_substructure_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_transform_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
return TRANSFORM_SUBSTRUCTURE;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_transform_substructure_t *this)
{
return (this->next_payload);
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_transform_substructure_t *this)
+{
+ return this->next_payload;
+>>>>>>> upstream/4.5.1
}
/**
@@ -184,6 +278,7 @@ static payload_type_t get_next_type(private_transform_substructure_t *this)
*/
static void compute_length (private_transform_substructure_t *this)
{
+<<<<<<< HEAD
iterator_t *iterator;
payload_t *current_attribute;
size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
@@ -259,10 +354,44 @@ static void set_transform_type (private_transform_substructure_t *this,u_int8_t
* Implementation of transform_substructure_t.get_transform_type.
*/
static u_int8_t get_transform_type (private_transform_substructure_t *this)
+=======
+ enumerator_t *enumerator;
+ payload_t *attribute;
+
+ this->transform_length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
+ enumerator = this->attributes->create_enumerator(this->attributes);
+ while (enumerator->enumerate(enumerator, &attribute))
+ {
+ this->transform_length += attribute->get_length(attribute);
+ }
+ enumerator->destroy(enumerator);
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_transform_substructure_t *this)
+{
+ return this->transform_length;
+}
+
+METHOD(transform_substructure_t, set_is_last_transform, void,
+ private_transform_substructure_t *this, bool is_last)
+{
+ this->next_payload = is_last ? 0: TRANSFORM_TYPE_VALUE;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_transform_substructure_t *this,payload_type_t type)
+{
+}
+
+METHOD(transform_substructure_t, get_transform_type, u_int8_t,
+ private_transform_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
return this->transform_type;
}
+<<<<<<< HEAD
/**
* Implementation of transform_substructure_t.set_transform_id.
*/
@@ -275,10 +404,15 @@ static void set_transform_id (private_transform_substructure_t *this,u_int16_t i
* Implementation of transform_substructure_t.get_transform_id.
*/
static u_int16_t get_transform_id (private_transform_substructure_t *this)
+=======
+METHOD(transform_substructure_t, get_transform_id, u_int16_t,
+ private_transform_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
return this->transform_id;
}
+<<<<<<< HEAD
/**
* Implementation of transform_substructure_t.clone.
*/
@@ -332,6 +466,30 @@ static status_t get_key_length(private_transform_substructure_t *this, u_int16_t
* Implementation of transform_substructure_t.destroy and payload_t.destroy.
*/
static void destroy(private_transform_substructure_t *this)
+=======
+METHOD(transform_substructure_t, get_key_length, status_t,
+ private_transform_substructure_t *this, u_int16_t *key_length)
+{
+ enumerator_t *enumerator;
+ transform_attribute_t *attribute;
+
+ enumerator = this->attributes->create_enumerator(this->attributes);
+ while (enumerator->enumerate(enumerator, &attribute))
+ {
+ if (attribute->get_attribute_type(attribute) == KEY_LENGTH)
+ {
+ *key_length = attribute->get_value(attribute);
+ enumerator->destroy(enumerator);
+ return SUCCESS;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return FAILED;
+}
+
+METHOD2(payload_t, transform_substructure_t, destroy, void,
+ private_transform_substructure_t *this)
+>>>>>>> upstream/4.5.1
{
this->attributes->destroy_offset(this->attributes,
offsetof(transform_attribute_t, destroy));
@@ -343,6 +501,7 @@ static void destroy(private_transform_substructure_t *this)
*/
transform_substructure_t *transform_substructure_create()
{
+<<<<<<< HEAD
private_transform_substructure_t *this = malloc_thing(private_transform_substructure_t);
/* payload interface */
@@ -375,12 +534,39 @@ transform_substructure_t *transform_substructure_create()
this->attributes = linked_list_create();
return (&(this->public));
+=======
+ private_transform_substructure_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .set_is_last_transform = _set_is_last_transform,
+ .get_transform_type = _get_transform_type,
+ .get_transform_id = _get_transform_id,
+ .get_key_length = _get_key_length,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .transform_length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH,
+ .attributes = linked_list_create(),
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
/*
* Described in header
*/
transform_substructure_t *transform_substructure_create_type(
+<<<<<<< HEAD
transform_type_t transform_type,
u_int16_t transform_id, u_int16_t key_length)
{
@@ -398,5 +584,22 @@ transform_substructure_t *transform_substructure_create_type(
}
return transform;
+=======
+ transform_type_t type, u_int16_t id, u_int16_t key_length)
+{
+ private_transform_substructure_t *this;
+
+ this = (private_transform_substructure_t*)transform_substructure_create();
+
+ this->transform_type = type;
+ this->transform_id = id;
+ if (key_length)
+ {
+ this->attributes->insert_last(this->attributes,
+ (void*)transform_attribute_create_key_length(key_length));
+ compute_length(this);
+ }
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/transform_substructure.h b/src/libcharon/encoding/payloads/transform_substructure.h
index 5d31f8c0a..2a60b65ba 100644
--- a/src/libcharon/encoding/payloads/transform_substructure.h
+++ b/src/libcharon/encoding/payloads/transform_substructure.h
@@ -34,7 +34,10 @@ typedef struct transform_substructure_t transform_substructure_t;
#include <crypto/crypters/crypter.h>
#include <config/proposal.h>
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
/**
* IKEv1 Value for a transform payload.
*/
@@ -45,19 +48,27 @@ typedef struct transform_substructure_t transform_substructure_t;
*/
#define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
/**
* Class representing an IKEv2- TRANSFORM SUBSTRUCTURE.
*
* The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
*/
struct transform_substructure_t {
+<<<<<<< HEAD
+=======
+
+>>>>>>> upstream/4.5.1
/**
* The payload_t interface.
*/
payload_t payload_interface;
/**
+<<<<<<< HEAD
* Creates an iterator of stored transform_attribute_t objects.
*
* When deleting an transform attribute using this iterator,
@@ -71,6 +82,8 @@ struct transform_substructure_t {
transform_substructure_t *this, bool forward);
/**
+=======
+>>>>>>> upstream/4.5.1
* Adds a transform_attribute_t object to this object.
*
* @param proposal transform_attribute_t object to add
@@ -89,6 +102,7 @@ struct transform_substructure_t {
void (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
/**
+<<<<<<< HEAD
* Checks if this is the last transform.
*
* @return TRUE if this is the last Transform, FALSE otherwise
@@ -103,6 +117,8 @@ struct transform_substructure_t {
void (*set_transform_type) (transform_substructure_t *this, u_int8_t type);
/**
+=======
+>>>>>>> upstream/4.5.1
* get transform type of the current transform.
*
* @return Transform type of current transform substructure.
@@ -110,6 +126,7 @@ struct transform_substructure_t {
u_int8_t (*get_transform_type) (transform_substructure_t *this);
/**
+<<<<<<< HEAD
* Sets transform id of the current transform substructure.
*
* @param id transform id to set
@@ -118,13 +135,20 @@ struct transform_substructure_t {
/**
* get transform id of the current transform.
+=======
+ * Get transform id of the current transform.
+>>>>>>> upstream/4.5.1
*
* @return Transform id of current transform substructure.
*/
u_int16_t (*get_transform_id) (transform_substructure_t *this);
/**
+<<<<<<< HEAD
* get transform id of the current transform.
+=======
+ * Get transform id of the current transform.
+>>>>>>> upstream/4.5.1
*
* @param key_length The key length is written to this location
* @return
@@ -136,6 +160,7 @@ struct transform_substructure_t {
u_int16_t *key_length);
/**
+<<<<<<< HEAD
* Clones an transform_substructure_t object.
*
* @return cloned transform_substructure_t object
@@ -143,6 +168,8 @@ struct transform_substructure_t {
transform_substructure_t* (*clone) (transform_substructure_t *this);
/**
+=======
+>>>>>>> upstream/4.5.1
* Destroys an transform_substructure_t object.
*/
void (*destroy) (transform_substructure_t *this);
@@ -151,13 +178,18 @@ struct transform_substructure_t {
/**
* Creates an empty transform_substructure_t object.
*
+<<<<<<< HEAD
* @return created transform_substructure_t object
+=======
+ * @return created transform_substructure_t object
+>>>>>>> upstream/4.5.1
*/
transform_substructure_t *transform_substructure_create(void);
/**
* Creates an empty transform_substructure_t object.
*
+<<<<<<< HEAD
* The key length is used for the transport types ENCRYPTION_ALGORITHM,
* PSEUDO_RANDOM_FUNCTION, INTEGRITY_ALGORITHM. For all
* other transport types the key_length parameter is not used
@@ -170,5 +202,14 @@ transform_substructure_t *transform_substructure_create(void);
transform_substructure_t *transform_substructure_create_type(
transform_type_t transform_type, u_int16_t transform_id,
u_int16_t key_length);
+=======
+ * @param type type of transform to create
+ * @param id transform id specifc for the transform type
+ * @param key_length key length for key lenght attribute, 0 to omit
+ * @return transform_substructure_t object
+ */
+transform_substructure_t *transform_substructure_create_type(
+ transform_type_t type, u_int16_t id, u_int16_t key_length);
+>>>>>>> upstream/4.5.1
#endif /** TRANSFORM_SUBSTRUCTURE_H_ @}*/
diff --git a/src/libcharon/encoding/payloads/ts_payload.c b/src/libcharon/encoding/payloads/ts_payload.c
index 6bf3e4293..db01b433f 100644
--- a/src/libcharon/encoding/payloads/ts_payload.c
+++ b/src/libcharon/encoding/payloads/ts_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2006 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -25,9 +30,15 @@ typedef struct private_ts_payload_t private_ts_payload_t;
/**
* Private data of an ts_payload_t object.
+<<<<<<< HEAD
*
*/
struct private_ts_payload_t {
+=======
+ */
+struct private_ts_payload_t {
+
+>>>>>>> upstream/4.5.1
/**
* Public ts_payload_t interface.
*/
@@ -49,6 +60,19 @@ struct private_ts_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * reserved bits
+ */
+ bool reserved_bit[7];
+
+ /**
+ * reserved bytes
+ */
+ bool reserved_byte[3];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -56,12 +80,20 @@ struct private_ts_payload_t {
/**
* Number of traffic selectors
*/
+<<<<<<< HEAD
u_int8_t number_of_traffic_selectors;
+=======
+ u_int8_t ts_num;
+>>>>>>> upstream/4.5.1
/**
* Contains the traffic selectors of type traffic_selector_substructure_t.
*/
+<<<<<<< HEAD
linked_list_t *traffic_selectors;
+=======
+ linked_list_t *substrs;
+>>>>>>> upstream/4.5.1
};
/**
@@ -69,6 +101,7 @@ struct private_ts_payload_t {
*
* The defined offsets are the positions in a object of type
* private_ts_payload_t.
+<<<<<<< HEAD
*
*/
encoding_rule_t ts_payload_encodings[] = {
@@ -94,6 +127,32 @@ encoding_rule_t ts_payload_encodings[] = {
{ RESERVED_BYTE, 0 },
/* some ts data bytes, length is defined in PAYLOAD_LENGTH */
{ TRAFFIC_SELECTORS, offsetof(private_ts_payload_t, traffic_selectors) }
+=======
+ */
+encoding_rule_t ts_payload_encodings[] = {
+ /* 1 Byte next payload type, stored in the field next_payload */
+ { U_INT_8, offsetof(private_ts_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_ts_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[0]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[1]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[2]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[3]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[4]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[5]) },
+ { RESERVED_BIT, offsetof(private_ts_payload_t, reserved_bit[6]) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_ts_payload_t, payload_length) },
+ /* 1 Byte TS type*/
+ { U_INT_8, offsetof(private_ts_payload_t, ts_num) },
+ /* 3 reserved bytes */
+ { RESERVED_BYTE, offsetof(private_ts_payload_t, reserved_byte[0])},
+ { RESERVED_BYTE, offsetof(private_ts_payload_t, reserved_byte[1])},
+ { RESERVED_BYTE, offsetof(private_ts_payload_t, reserved_byte[2])},
+ /* some ts data bytes, length is defined in PAYLOAD_LENGTH */
+ { TRAFFIC_SELECTORS,offsetof(private_ts_payload_t, substrs) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -110,6 +169,7 @@ encoding_rule_t ts_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -129,16 +189,38 @@ static status_t verify(private_ts_payload_t *this)
while(iterator->iterate(iterator, (void**)&current_traffic_selector))
{
status = current_traffic_selector->verify(current_traffic_selector);
+=======
+METHOD(payload_t, verify, status_t,
+ private_ts_payload_t *this)
+{
+ enumerator_t *enumerator;
+ payload_t *substr;
+ status_t status = SUCCESS;
+
+ if (this->ts_num != this->substrs->get_count(this->substrs))
+ {
+ return FAILED;
+ }
+ enumerator = this->substrs->create_enumerator(this->substrs);
+ while (enumerator->enumerate(enumerator, &substr))
+ {
+ status = substr->verify(substr);
+>>>>>>> upstream/4.5.1
if (status != SUCCESS)
{
break;
}
}
+<<<<<<< HEAD
iterator->destroy(iterator);
+=======
+ enumerator->destroy(enumerator);
+>>>>>>> upstream/4.5.1
return status;
}
+<<<<<<< HEAD
/**
* Implementation of ts_payload_t.get_encoding_rules.
*/
@@ -152,11 +234,23 @@ static void get_encoding_rules(private_ts_payload_t *this, encoding_rule_t **rul
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_ts_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_ts_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+{
+ *rules = ts_payload_encodings;
+ *rule_count = countof(ts_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_ts_payload_t *this)
+>>>>>>> upstream/4.5.1
{
if (this->is_initiator)
{
return TRAFFIC_SELECTOR_INITIATOR;
}
+<<<<<<< HEAD
else
{
return TRAFFIC_SELECTOR_RESPONDER;
@@ -175,6 +269,19 @@ static payload_type_t get_next_type(private_ts_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_ts_payload_t *this,payload_type_t type)
+=======
+ return TRAFFIC_SELECTOR_RESPONDER;
+}
+
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_ts_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_ts_payload_t *this,payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
@@ -182,6 +289,7 @@ static void set_next_type(private_ts_payload_t *this,payload_type_t type)
/**
* recompute the length of the payload.
*/
+<<<<<<< HEAD
static void compute_length (private_ts_payload_t *this)
{
iterator_t *iterator;
@@ -222,10 +330,43 @@ static bool get_initiator (private_ts_payload_t *this)
* Implementation of ts_payload_t.set_initiator.
*/
static void set_initiator (private_ts_payload_t *this,bool is_initiator)
+=======
+static void compute_length(private_ts_payload_t *this)
+{
+ enumerator_t *enumerator;
+ payload_t *subst;
+
+ this->payload_length = TS_PAYLOAD_HEADER_LENGTH;
+ this->ts_num = 0;
+ enumerator = this->substrs->create_enumerator(this->substrs);
+ while (enumerator->enumerate(enumerator, &subst))
+ {
+ this->payload_length += subst->get_length(subst);
+ this->ts_num++;
+ }
+ enumerator->destroy(enumerator);
+}
+
+METHOD(payload_t, get_length, size_t,
+ private_ts_payload_t *this)
+{
+ return this->payload_length;
+}
+
+METHOD(ts_payload_t, get_initiator, bool,
+ private_ts_payload_t *this)
+{
+ return this->is_initiator;
+}
+
+METHOD(ts_payload_t, set_initiator, void,
+ private_ts_payload_t *this,bool is_initiator)
+>>>>>>> upstream/4.5.1
{
this->is_initiator = is_initiator;
}
+<<<<<<< HEAD
/**
* Implementation of ts_payload_t.add_traffic_selector_substructure.
*/
@@ -271,6 +412,32 @@ static void destroy(private_ts_payload_t *this)
{
this->traffic_selectors->destroy_offset(this->traffic_selectors,
offsetof(payload_t, destroy));
+=======
+METHOD(ts_payload_t, get_traffic_selectors, linked_list_t*,
+ private_ts_payload_t *this)
+{
+ traffic_selector_t *ts;
+ enumerator_t *enumerator;
+ traffic_selector_substructure_t *subst;
+ linked_list_t *list;
+
+ list = linked_list_create();
+ enumerator = this->substrs->create_enumerator(this->substrs);
+ while (enumerator->enumerate(enumerator, &subst))
+ {
+ ts = subst->get_traffic_selector(subst);
+ list->insert_last(list, ts);
+ }
+ enumerator->destroy(enumerator);
+
+ return list;
+}
+
+METHOD2(payload_t, ts_payload_t, destroy, void,
+ private_ts_payload_t *this)
+{
+ this->substrs->destroy_offset(this->substrs, offsetof(payload_t, destroy));
+>>>>>>> upstream/4.5.1
free(this);
}
@@ -279,6 +446,7 @@ static void destroy(private_ts_payload_t *this)
*/
ts_payload_t *ts_payload_create(bool is_initiator)
{
+<<<<<<< HEAD
private_ts_payload_t *this = malloc_thing(private_ts_payload_t);
/* interface functions */
@@ -307,20 +475,56 @@ ts_payload_t *ts_payload_create(bool is_initiator)
this->traffic_selectors = linked_list_create();
return &(this->public);
+=======
+ private_ts_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_initiator = _get_initiator,
+ .set_initiator = _set_initiator,
+ .get_traffic_selectors = _get_traffic_selectors,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = TS_PAYLOAD_HEADER_LENGTH,
+ .is_initiator = is_initiator,
+ .substrs = linked_list_create(),
+ );
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
/*
* Described in header
*/
+<<<<<<< HEAD
ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked_list_t *traffic_selectors)
{
iterator_t *iterator;
traffic_selector_t *ts;
traffic_selector_substructure_t *ts_substructure;
+=======
+ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator,
+ linked_list_t *traffic_selectors)
+{
+ enumerator_t *enumerator;
+ traffic_selector_t *ts;
+ traffic_selector_substructure_t *subst;
+>>>>>>> upstream/4.5.1
private_ts_payload_t *this;
this = (private_ts_payload_t*)ts_payload_create(is_initiator);
+<<<<<<< HEAD
iterator = traffic_selectors->create_iterator(traffic_selectors, TRUE);
while (iterator->iterate(iterator, (void**)&ts))
{
@@ -332,3 +536,16 @@ ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked
return &(this->public);
}
+=======
+ enumerator = traffic_selectors->create_enumerator(traffic_selectors);
+ while (enumerator->enumerate(enumerator, &ts))
+ {
+ subst = traffic_selector_substructure_create_from_traffic_selector(ts);
+ this->substrs->insert_last(this->substrs, subst);
+ }
+ enumerator->destroy(enumerator);
+ compute_length(this);
+
+ return &this->public;
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/ts_payload.h b/src/libcharon/encoding/payloads/ts_payload.h
index d322ff1a8..eb39a5c1d 100644
--- a/src/libcharon/encoding/payloads/ts_payload.h
+++ b/src/libcharon/encoding/payloads/ts_payload.h
@@ -19,7 +19,10 @@
* @{ @ingroup payloads
*/
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
#ifndef TS_PAYLOAD_H_
#define TS_PAYLOAD_H_
@@ -36,13 +39,20 @@ typedef struct ts_payload_t ts_payload_t;
*/
#define TS_PAYLOAD_HEADER_LENGTH 8
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
/**
* Class representing an IKEv2 TS payload.
*
* The TS payload format is described in RFC section 3.13.
*/
struct ts_payload_t {
+<<<<<<< HEAD
+=======
+
+>>>>>>> upstream/4.5.1
/**
* The payload_t interface.
*/
@@ -67,6 +77,7 @@ struct ts_payload_t {
void (*set_initiator) (ts_payload_t *this,bool is_initiator);
/**
+<<<<<<< HEAD
* Adds a traffic_selector_substructure_t object to this object.
*
* @param traffic_selector traffic_selector_substructure_t object to add
@@ -88,6 +99,8 @@ struct ts_payload_t {
ts_payload_t *this, bool forward);
/**
+=======
+>>>>>>> upstream/4.5.1
* Get a list of nested traffic selectors as traffic_selector_t.
*
* Resulting list and its traffic selectors must be destroyed after usage
@@ -105,19 +118,28 @@ struct ts_payload_t {
/**
* Creates an empty ts_payload_t object.
*
+<<<<<<< HEAD
* @param is_initiator
* - TRUE if this payload is of type TSi
* - FALSE if this payload is of type TSr
* @return ts_payload_t object
+=======
+ * @param is_initiator TRUE for TSi, FALSE for TSr payload type
+ * @return ts_payload_t object
+>>>>>>> upstream/4.5.1
*/
ts_payload_t *ts_payload_create(bool is_initiator);
/**
* Creates ts_payload with a list of traffic_selector_t
*
+<<<<<<< HEAD
* @param is_initiator
* - TRUE if this payload is of type TSi
* - FALSE if this payload is of type TSr
+=======
+ * @param is_initiator TRUE for TSi, FALSE for TSr payload type
+>>>>>>> upstream/4.5.1
* @param traffic_selectors list of traffic selectors to include
* @return ts_payload_t object
*/
diff --git a/src/libcharon/encoding/payloads/unknown_payload.c b/src/libcharon/encoding/payloads/unknown_payload.c
index dd5547dc3..2f428ed06 100644
--- a/src/libcharon/encoding/payloads/unknown_payload.c
+++ b/src/libcharon/encoding/payloads/unknown_payload.c
@@ -18,8 +18,11 @@
#include "unknown_payload.h"
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/4.5.1
typedef struct private_unknown_payload_t private_unknown_payload_t;
/**
@@ -33,6 +36,14 @@ struct private_unknown_payload_t {
unknown_payload_t public;
/**
+<<<<<<< HEAD
+=======
+ * Type of this payload
+ */
+ payload_type_t type;
+
+ /**
+>>>>>>> upstream/4.5.1
* Next payload type.
*/
u_int8_t next_payload;
@@ -43,6 +54,14 @@ struct private_unknown_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -62,6 +81,7 @@ struct private_unknown_payload_t {
*/
encoding_rule_t unknown_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
+<<<<<<< HEAD
{ U_INT_8, offsetof(private_unknown_payload_t, next_payload)},
/* the critical bit */
{ FLAG, offsetof(private_unknown_payload_t, critical) },
@@ -77,6 +97,23 @@ encoding_rule_t unknown_payload_encodings[] = {
{ PAYLOAD_LENGTH, offsetof(private_unknown_payload_t, payload_length)},
/* some unknown data bytes, length is defined in PAYLOAD_LENGTH */
{ UNKNOWN_DATA, offsetof(private_unknown_payload_t, data) }
+=======
+ { U_INT_8, offsetof(private_unknown_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_unknown_payload_t, critical) },
+ /* 7 Bit reserved bits */
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_unknown_payload_t, reserved[6]) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_unknown_payload_t, payload_length) },
+ /* some unknown data bytes, length is defined in PAYLOAD_LENGTH */
+ { UNKNOWN_DATA, offsetof(private_unknown_payload_t, data) },
+>>>>>>> upstream/4.5.1
};
/*
@@ -91,6 +128,7 @@ encoding_rule_t unknown_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
@@ -104,11 +142,26 @@ static status_t verify(private_unknown_payload_t *this)
* Implementation of payload_t.get_encoding_rules.
*/
static void get_encoding_rules(private_unknown_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+=======
+METHOD(payload_t, verify, status_t,
+ private_unknown_payload_t *this)
+{
+ if (this->payload_length != UNKNOWN_PAYLOAD_HEADER_LENGTH + this->data.len)
+ {
+ return FAILED;
+ }
+ return SUCCESS;
+}
+
+METHOD(payload_t, get_encoding_rules, void,
+ private_unknown_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+>>>>>>> upstream/4.5.1
{
*rules = unknown_payload_encodings;
*rule_count = sizeof(unknown_payload_encodings) / sizeof(encoding_rule_t);
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_type.
*/
@@ -129,26 +182,53 @@ static payload_type_t get_next_type(private_unknown_payload_t *this)
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_unknown_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, get_payload_type, payload_type_t,
+ private_unknown_payload_t *this)
+{
+ return this->type;
+}
+
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_unknown_payload_t *this)
+{
+ return this->next_payload;
+}
+
+METHOD(payload_t, set_next_type, void,
+ private_unknown_payload_t *this,payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_unknown_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_unknown_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of unknown_payload_t.get_data.
*/
static bool is_critical(private_unknown_payload_t *this)
+=======
+METHOD(unknown_payload_t, is_critical, bool,
+ private_unknown_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->critical;
}
+<<<<<<< HEAD
/**
* Implementation of unknown_payload_t.get_data.
*/
@@ -167,12 +247,25 @@ static void destroy(private_unknown_payload_t *this)
chunk_free(&(this->data));
}
+=======
+METHOD(unknown_payload_t, get_data, chunk_t,
+ private_unknown_payload_t *this)
+{
+ return this->data;
+}
+
+METHOD2(payload_t, unknown_payload_t, destroy, void,
+ private_unknown_payload_t *this)
+{
+ free(this->data.ptr);
+>>>>>>> upstream/4.5.1
free(this);
}
/*
* Described in header
*/
+<<<<<<< HEAD
unknown_payload_t *unknown_payload_create()
{
private_unknown_payload_t *this = malloc_thing(private_unknown_payload_t);
@@ -198,4 +291,48 @@ unknown_payload_t *unknown_payload_create()
this->data = chunk_empty;
return (&(this->public));
+=======
+unknown_payload_t *unknown_payload_create(payload_type_t type)
+{
+ private_unknown_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_payload_type,
+ .destroy = _destroy,
+ },
+ .is_critical = _is_critical,
+ .get_data = _get_data,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = UNKNOWN_PAYLOAD_HEADER_LENGTH,
+ .type = type,
+ );
+
+ return &this->public;
+}
+
+
+/*
+ * Described in header
+ */
+unknown_payload_t *unknown_payload_create_data(payload_type_t type,
+ bool critical, chunk_t data)
+{
+ private_unknown_payload_t *this;
+
+ this = (private_unknown_payload_t*)unknown_payload_create(type);
+ this->data = data;
+ this->critical = critical;
+ this->payload_length = UNKNOWN_PAYLOAD_HEADER_LENGTH + data.len;
+
+ return &this->public;
+>>>>>>> upstream/4.5.1
}
diff --git a/src/libcharon/encoding/payloads/unknown_payload.h b/src/libcharon/encoding/payloads/unknown_payload.h
index c761ed2b6..b874f6dc3 100644
--- a/src/libcharon/encoding/payloads/unknown_payload.h
+++ b/src/libcharon/encoding/payloads/unknown_payload.h
@@ -70,10 +70,30 @@ struct unknown_payload_t {
};
/**
+<<<<<<< HEAD
* Creates an empty unknown_payload_t object.
*
* @return unknown_payload_t object
*/
unknown_payload_t *unknown_payload_create(void);
+=======
+ * Creates an empty unknown_payload_t.
+ *
+ * @param type of the payload
+ * @return unknown_payload_t object
+ */
+unknown_payload_t *unknown_payload_create(payload_type_t type);
+
+/**
+ * Create an unknown payload with data.
+ *
+ * @param type type of payload to create
+ * @param critical TRUE to set critical bit
+ * @param data data to set for this payload, gets owned by payload
+ * @return payload object
+ */
+unknown_payload_t *unknown_payload_create_data(payload_type_t type,
+ bool critical, chunk_t data);
+>>>>>>> upstream/4.5.1
#endif /** UNKNOWN_PAYLOAD_H_ @}*/
diff --git a/src/libcharon/encoding/payloads/vendor_id_payload.c b/src/libcharon/encoding/payloads/vendor_id_payload.c
index bf33d2418..d2295e4a2 100644
--- a/src/libcharon/encoding/payloads/vendor_id_payload.c
+++ b/src/libcharon/encoding/payloads/vendor_id_payload.c
@@ -1,5 +1,10 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2005-2009 Martin Willi
+=======
+ * Copyright (C) 2005-2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+>>>>>>> upstream/4.5.1
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -41,6 +46,14 @@ struct private_vendor_id_payload_t {
bool critical;
/**
+<<<<<<< HEAD
+=======
+ * Reserved bits
+ */
+ bool reserved[7];
+
+ /**
+>>>>>>> upstream/4.5.1
* Length of this payload.
*/
u_int16_t payload_length;
@@ -59,6 +72,7 @@ struct private_vendor_id_payload_t {
*/
encoding_rule_t vendor_id_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
+<<<<<<< HEAD
{ U_INT_8, offsetof(private_vendor_id_payload_t, next_payload) },
/* the critical bit */
{ FLAG, offsetof(private_vendor_id_payload_t, critical) },
@@ -74,6 +88,23 @@ encoding_rule_t vendor_id_payload_encodings[] = {
{ PAYLOAD_LENGTH, offsetof(private_vendor_id_payload_t, payload_length)},
/* some vendor_id data bytes, length is defined in PAYLOAD_LENGTH */
{ VID_DATA, offsetof(private_vendor_id_payload_t, data) }
+=======
+ { U_INT_8, offsetof(private_vendor_id_payload_t, next_payload) },
+ /* the critical bit */
+ { FLAG, offsetof(private_vendor_id_payload_t, critical) },
+ /* 7 Bit reserved bits, nowhere stored */
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[0]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[1]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[2]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[3]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[4]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[5]) },
+ { RESERVED_BIT, offsetof(private_vendor_id_payload_t, reserved[6]) },
+ /* Length of the whole payload*/
+ { PAYLOAD_LENGTH, offsetof(private_vendor_id_payload_t, payload_length)},
+ /* some vendor_id data bytes, length is defined in PAYLOAD_LENGTH */
+ { VID_DATA, offsetof(private_vendor_id_payload_t, data) }
+>>>>>>> upstream/4.5.1
};
/*
@@ -88,14 +119,20 @@ encoding_rule_t vendor_id_payload_encodings[] = {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+<<<<<<< HEAD
/**
* Implementation of payload_t.verify.
*/
static status_t verify(private_vendor_id_payload_t *this)
+=======
+METHOD(payload_t, verify, status_t,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return SUCCESS;
}
+<<<<<<< HEAD
/**
* Implementation of vendor_id_payload_t.get_encoding_rules.
*/
@@ -110,46 +147,83 @@ static void get_encoding_rules(private_vendor_id_payload_t *this,
* Implementation of payload_t.get_type.
*/
static payload_type_t get_payload_type(private_vendor_id_payload_t *this)
+=======
+METHOD(payload_t, get_encoding_rules, void,
+ private_vendor_id_payload_t *this, encoding_rule_t **rules,
+ size_t *rule_count)
+{
+ *rules = vendor_id_payload_encodings;
+ *rule_count = countof(vendor_id_payload_encodings);
+}
+
+METHOD(payload_t, get_type, payload_type_t,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return VENDOR_ID;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_vendor_id_payload_t *this)
+=======
+METHOD(payload_t, get_next_type, payload_type_t,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->next_payload;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.set_next_type.
*/
static void set_next_type(private_vendor_id_payload_t *this,payload_type_t type)
+=======
+METHOD(payload_t, set_next_type, void,
+ private_vendor_id_payload_t *this, payload_type_t type)
+>>>>>>> upstream/4.5.1
{
this->next_payload = type;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_vendor_id_payload_t *this)
+=======
+METHOD(payload_t, get_length, size_t,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->payload_length;
}
+<<<<<<< HEAD
/**
* Implementation of vendor_id_payload_t.get_data.
*/
static chunk_t get_data(private_vendor_id_payload_t *this)
+=======
+METHOD(vendor_id_payload_t, get_data, chunk_t,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
return this->data;
}
+<<<<<<< HEAD
/**
* Implementation of payload_t.destroy and vendor_id_payload_t.destroy.
*/
static void destroy(private_vendor_id_payload_t *this)
+=======
+METHOD2(payload_t, vendor_id_payload_t, destroy, void,
+ private_vendor_id_payload_t *this)
+>>>>>>> upstream/4.5.1
{
free(this->data.ptr);
free(this);
@@ -158,6 +232,7 @@ static void destroy(private_vendor_id_payload_t *this)
/*
* Described in header
*/
+<<<<<<< HEAD
vendor_id_payload_t *vendor_id_payload_create()
{
private_vendor_id_payload_t *this = malloc_thing(private_vendor_id_payload_t);
@@ -176,12 +251,37 @@ vendor_id_payload_t *vendor_id_payload_create()
this->payload_length = VENDOR_ID_PAYLOAD_HEADER_LENGTH;
this->data = chunk_empty;
+=======
+vendor_id_payload_t *vendor_id_payload_create_data(chunk_t data)
+{
+ private_vendor_id_payload_t *this;
+
+ INIT(this,
+ .public = {
+ .payload_interface = {
+ .verify = _verify,
+ .get_encoding_rules = _get_encoding_rules,
+ .get_length = _get_length,
+ .get_next_type = _get_next_type,
+ .set_next_type = _set_next_type,
+ .get_type = _get_type,
+ .destroy = _destroy,
+ },
+ .get_data = _get_data,
+ .destroy = _destroy,
+ },
+ .next_payload = NO_PAYLOAD,
+ .payload_length = VENDOR_ID_PAYLOAD_HEADER_LENGTH + data.len,
+ .data = data,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}
/*
* Described in header
*/
+<<<<<<< HEAD
vendor_id_payload_t *vendor_id_payload_create_data(chunk_t data)
{
private_vendor_id_payload_t *this;
@@ -193,3 +293,9 @@ vendor_id_payload_t *vendor_id_payload_create_data(chunk_t data)
return &this->public;
}
+=======
+vendor_id_payload_t *vendor_id_payload_create()
+{
+ return vendor_id_payload_create_data(chunk_empty);
+}
+>>>>>>> upstream/4.5.1
diff --git a/src/libcharon/encoding/payloads/vendor_id_payload.h b/src/libcharon/encoding/payloads/vendor_id_payload.h
index 241535cac..45cce985e 100644
--- a/src/libcharon/encoding/payloads/vendor_id_payload.h
+++ b/src/libcharon/encoding/payloads/vendor_id_payload.h
@@ -50,6 +50,14 @@ struct vendor_id_payload_t {
* @return VID data, pointing to an internal chunk_t
*/
chunk_t (*get_data)(vendor_id_payload_t *this);
+<<<<<<< HEAD
+=======
+
+ /**
+ * Destroy Vendor ID payload.
+ */
+ void (*destroy)(vendor_id_payload_t *this);
+>>>>>>> upstream/4.5.1
};
/**