summaryrefslogtreecommitdiff
path: root/src/conftest/hooks
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2014-07-11 07:23:31 +0200
committerYves-Alexis Perez <corsac@debian.org>2014-07-11 07:23:31 +0200
commit81c63b0eed39432878f78727f60a1e7499645199 (patch)
tree82387d8fecd1c20788fd8bd784a9b0bde091fb6b /src/conftest/hooks
parentc5ebfc7b9c16551fe825dc1d79c3f7e2f096f6c9 (diff)
downloadvyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.tar.gz
vyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.zip
Imported Upstream version 5.2.0
Diffstat (limited to 'src/conftest/hooks')
-rw-r--r--src/conftest/hooks/add_notify.c5
-rw-r--r--src/conftest/hooks/add_payload.c3
-rw-r--r--src/conftest/hooks/custom_proposal.c5
-rw-r--r--src/conftest/hooks/force_cookie.c2
-rw-r--r--src/conftest/hooks/ike_auth_fill.c2
-rw-r--r--src/conftest/hooks/log_id.c4
-rw-r--r--src/conftest/hooks/log_ke.c2
-rw-r--r--src/conftest/hooks/log_proposals.c2
-rw-r--r--src/conftest/hooks/log_ts.c4
-rw-r--r--src/conftest/hooks/pretend_auth.c18
-rw-r--r--src/conftest/hooks/rebuild_auth.c6
-rw-r--r--src/conftest/hooks/set_critical.c3
-rw-r--r--src/conftest/hooks/set_length.c3
-rw-r--r--src/conftest/hooks/set_proposal_number.c2
-rw-r--r--src/conftest/hooks/set_reserved.c13
-rw-r--r--src/conftest/hooks/unencrypted_notify.c5
-rw-r--r--src/conftest/hooks/unsort_message.c3
17 files changed, 37 insertions, 45 deletions
diff --git a/src/conftest/hooks/add_notify.c b/src/conftest/hooks/add_notify.c
index 9611cad6c..73a9b1a80 100644
--- a/src/conftest/hooks/add_notify.c
+++ b/src/conftest/hooks/add_notify.c
@@ -73,8 +73,7 @@ METHOD(listener_t, message, bool,
type = atoi(this->type);
if (!type)
{
- type = enum_from_name(notify_type_names, this->type);
- if (type == -1)
+ if (!enum_from_name(notify_type_names, this->type, &type))
{
DBG1(DBG_CFG, "unknown notify: '%s', skipped", this->type);
return TRUE;
@@ -89,7 +88,7 @@ METHOD(listener_t, message, bool,
{
data = chunk_clone(chunk_create(this->data, strlen(this->data)));
}
- notify = notify_payload_create_from_protocol_and_type(NOTIFY,
+ notify = notify_payload_create_from_protocol_and_type(PLV2_NOTIFY,
this->esp ? PROTO_ESP : PROTO_IKE, type);
notify->set_spi(notify, this->spi);
if (data.len)
diff --git a/src/conftest/hooks/add_payload.c b/src/conftest/hooks/add_payload.c
index 2903bb20f..cb5be1aef 100644
--- a/src/conftest/hooks/add_payload.c
+++ b/src/conftest/hooks/add_payload.c
@@ -77,8 +77,7 @@ METHOD(listener_t, message, bool,
type = atoi(this->type);
if (!type)
{
- type = enum_from_name(payload_type_short_names, this->type);
- if (type == -1)
+ if (!enum_from_name(payload_type_short_names, this->type, &type))
{
DBG1(DBG_CFG, "unknown payload: '%s', skipped", this->type);
return TRUE;
diff --git a/src/conftest/hooks/custom_proposal.c b/src/conftest/hooks/custom_proposal.c
index 38d4286c4..ee4404575 100644
--- a/src/conftest/hooks/custom_proposal.c
+++ b/src/conftest/hooks/custom_proposal.c
@@ -79,8 +79,7 @@ static linked_list_t* load_proposals(private_custom_proposal_t *this,
type = strtoul(key, &end, 10);
if (end == key || errno)
{
- type = enum_from_name(transform_type_names, key);
- if (type == -1)
+ if (!enum_from_name(transform_type_names, key, &type))
{
DBG1(DBG_CFG, "unknown transform: '%s', skipped", key);
continue;
@@ -125,7 +124,7 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == SECURITY_ASSOCIATION)
+ if (payload->get_type(payload) == PLV2_SECURITY_ASSOCIATION)
{
old = (sa_payload_t*)payload;
message->remove_payload_at(message, enumerator);
diff --git a/src/conftest/hooks/force_cookie.c b/src/conftest/hooks/force_cookie.c
index 1b044db14..6be516cf4 100644
--- a/src/conftest/hooks/force_cookie.c
+++ b/src/conftest/hooks/force_cookie.c
@@ -44,7 +44,7 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == NOTIFY)
+ if (payload->get_type(payload) == PLV2_NOTIFY)
{
notify_payload_t *notify = (notify_payload_t*)payload;
chunk_t data;
diff --git a/src/conftest/hooks/ike_auth_fill.c b/src/conftest/hooks/ike_auth_fill.c
index 09590d4f3..5cdd5be38 100644
--- a/src/conftest/hooks/ike_auth_fill.c
+++ b/src/conftest/hooks/ike_auth_fill.c
@@ -108,7 +108,7 @@ METHOD(listener_t, message, bool,
diff = this->bytes - size - CERT_PAYLOAD_HEADER_LENGTH;
data = chunk_alloc(diff);
memset(data.ptr, 0x12, data.len);
- pld = cert_payload_create_custom(CERTIFICATE, 201, data);
+ pld = cert_payload_create_custom(PLV2_CERTIFICATE, 201, data);
message->add_payload(message, &pld->payload_interface);
DBG1(DBG_CFG, "inserting %d dummy bytes certificate payload", diff);
}
diff --git a/src/conftest/hooks/log_id.c b/src/conftest/hooks/log_id.c
index 07dd6a44e..f47372fa7 100644
--- a/src/conftest/hooks/log_id.c
+++ b/src/conftest/hooks/log_id.c
@@ -45,8 +45,8 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == ID_INITIATOR ||
- payload->get_type(payload) == ID_RESPONDER)
+ if (payload->get_type(payload) == PLV2_ID_INITIATOR ||
+ payload->get_type(payload) == PLV2_ID_RESPONDER)
{
id_payload = (id_payload_t*)payload;
id = id_payload->get_identification(id_payload);
diff --git a/src/conftest/hooks/log_ke.c b/src/conftest/hooks/log_ke.c
index 710482326..66aa4a65e 100644
--- a/src/conftest/hooks/log_ke.c
+++ b/src/conftest/hooks/log_ke.c
@@ -43,7 +43,7 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == KEY_EXCHANGE)
+ if (payload->get_type(payload) == PLV2_KEY_EXCHANGE)
{
ke = (ke_payload_t*)payload;
DBG1(DBG_CFG, "received DH group %N",
diff --git a/src/conftest/hooks/log_proposals.c b/src/conftest/hooks/log_proposals.c
index 347b83209..c0d458eae 100644
--- a/src/conftest/hooks/log_proposals.c
+++ b/src/conftest/hooks/log_proposals.c
@@ -45,7 +45,7 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == SECURITY_ASSOCIATION)
+ if (payload->get_type(payload) == PLV2_SECURITY_ASSOCIATION)
{
sa = (sa_payload_t*)payload;
list = sa->get_proposals(sa);
diff --git a/src/conftest/hooks/log_ts.c b/src/conftest/hooks/log_ts.c
index f212efa12..79c59b89a 100644
--- a/src/conftest/hooks/log_ts.c
+++ b/src/conftest/hooks/log_ts.c
@@ -43,8 +43,8 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == TRAFFIC_SELECTOR_INITIATOR ||
- payload->get_type(payload) == TRAFFIC_SELECTOR_RESPONDER)
+ if (payload->get_type(payload) == PLV2_TS_INITIATOR ||
+ payload->get_type(payload) == PLV2_TS_RESPONDER)
{
ts = (ts_payload_t*)payload;
host_t *from, *to;
diff --git a/src/conftest/hooks/pretend_auth.c b/src/conftest/hooks/pretend_auth.c
index 4166afc79..54957b048 100644
--- a/src/conftest/hooks/pretend_auth.c
+++ b/src/conftest/hooks/pretend_auth.c
@@ -79,7 +79,7 @@ static void process_init_request(private_pretend_auth_t *this,
{
nonce_payload_t *nonce;
- nonce = (nonce_payload_t*)message->get_payload(message, NONCE);
+ nonce = (nonce_payload_t*)message->get_payload(message, PLV2_NONCE);
if (nonce)
{
free(this->nonce.ptr);
@@ -98,13 +98,13 @@ static void process_auth_request(private_pretend_auth_t *this,
ts_payload_t *tsi, *tsr;
linked_list_t *proposals;
- id = (id_payload_t*)message->get_payload(message, ID_RESPONDER);
+ id = (id_payload_t*)message->get_payload(message, PLV2_ID_RESPONDER);
if (id)
{
this->id->destroy(this->id);
this->id = id->get_identification(id);
}
- sa = (sa_payload_t*)message->get_payload(message, SECURITY_ASSOCIATION);
+ sa = (sa_payload_t*)message->get_payload(message, PLV2_SECURITY_ASSOCIATION);
if (sa)
{
proposals = sa->get_proposals(sa);
@@ -116,13 +116,13 @@ static void process_auth_request(private_pretend_auth_t *this,
proposals->destroy_offset(proposals, offsetof(proposal_t, destroy));
}
tsi = (ts_payload_t*)message->get_payload(message,
- TRAFFIC_SELECTOR_INITIATOR);
+ PLV2_TS_INITIATOR);
if (tsi)
{
this->tsi = tsi->get_traffic_selectors(tsi);
}
tsr = (ts_payload_t*)message->get_payload(message,
- TRAFFIC_SELECTOR_RESPONDER);
+ PLV2_TS_RESPONDER);
if (tsr)
{
this->tsr = tsr->get_traffic_selectors(tsr);
@@ -154,7 +154,7 @@ static void build_certs(private_pretend_auth_t *this,
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
if (cert)
{
- payload = cert_payload_create_from_cert(CERTIFICATE, cert);
+ payload = cert_payload_create_from_cert(PLV2_CERTIFICATE, cert);
if (payload)
{
DBG1(DBG_IKE, "pretending end entity cert \"%Y\"",
@@ -167,7 +167,7 @@ static void build_certs(private_pretend_auth_t *this,
{
if (type == AUTH_RULE_IM_CERT)
{
- payload = cert_payload_create_from_cert(CERTIFICATE, cert);
+ payload = cert_payload_create_from_cert(PLV2_CERTIFICATE, cert);
if (payload)
{
DBG1(DBG_IKE, "pretending issuer cert \"%Y\"",
@@ -276,7 +276,7 @@ static void process_auth_response(private_pretend_auth_t *this,
{
notify_payload_t *notify = (notify_payload_t*)payload;
- if (payload->get_type(payload) != NOTIFY ||
+ if (payload->get_type(payload) != PLV2_NOTIFY ||
notify->get_notify_type(notify) != AUTHENTICATION_FAILED)
{
DBG1(DBG_CFG, "no %N notify found, disabling AUTH pretending",
@@ -295,7 +295,7 @@ static void process_auth_response(private_pretend_auth_t *this,
return;
}
message->add_payload(message, (payload_t*)
- id_payload_create_from_identification(ID_RESPONDER, this->id));
+ id_payload_create_from_identification(PLV2_ID_RESPONDER, this->id));
if (this->proposal)
{
message->add_payload(message, (payload_t*)
diff --git a/src/conftest/hooks/rebuild_auth.c b/src/conftest/hooks/rebuild_auth.c
index b7e6f22e7..bc2f00071 100644
--- a/src/conftest/hooks/rebuild_auth.c
+++ b/src/conftest/hooks/rebuild_auth.c
@@ -70,7 +70,7 @@ static bool rebuild_auth(private_rebuild_auth_t *this, ike_sa_t *ike_sa,
u_int32_t *lenpos;
payload = message->get_payload(message,
- message->get_request(message) ? ID_INITIATOR : ID_RESPONDER);
+ message->get_request(message) ? PLV2_ID_INITIATOR : PLV2_ID_RESPONDER);
if (!payload)
{
DBG1(DBG_CFG, "ID payload not found to rebuild AUTH");
@@ -160,7 +160,7 @@ static bool rebuild_auth(private_rebuild_auth_t *this, ike_sa_t *ike_sa,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == AUTHENTICATION)
+ if (payload->get_type(payload) == PLV2_AUTH)
{
message->remove_payload_at(message, enumerator);
payload->destroy(payload);
@@ -191,7 +191,7 @@ METHOD(listener_t, message, bool,
{
nonce_payload_t *nonce;
- nonce = (nonce_payload_t*)message->get_payload(message, NONCE);
+ nonce = (nonce_payload_t*)message->get_payload(message, PLV2_NONCE);
if (nonce)
{
free(this->nonce.ptr);
diff --git a/src/conftest/hooks/set_critical.c b/src/conftest/hooks/set_critical.c
index 8ec84e13d..15c313c51 100644
--- a/src/conftest/hooks/set_critical.c
+++ b/src/conftest/hooks/set_critical.c
@@ -65,8 +65,7 @@ METHOD(listener_t, message, bool,
type = atoi(name);
if (!type)
{
- type = enum_from_name(payload_type_short_names, name);
- if (type == -1)
+ if (!enum_from_name(payload_type_short_names, name, &type))
{
DBG1(DBG_CFG, "invalid payload name '%s'", name);
break;
diff --git a/src/conftest/hooks/set_length.c b/src/conftest/hooks/set_length.c
index c1a867a99..b1a1a4723 100644
--- a/src/conftest/hooks/set_length.c
+++ b/src/conftest/hooks/set_length.c
@@ -63,8 +63,7 @@ METHOD(listener_t, message, bool,
type = atoi(this->type);
if (!type)
{
- type = enum_from_name(payload_type_short_names, this->type);
- if (type == -1)
+ if (!enum_from_name(payload_type_short_names, this->type, &type))
{
DBG1(DBG_CFG, "unknown payload: '%s', skipped", this->type);
return TRUE;
diff --git a/src/conftest/hooks/set_proposal_number.c b/src/conftest/hooks/set_proposal_number.c
index 0cc3cfc63..4e572d608 100644
--- a/src/conftest/hooks/set_proposal_number.c
+++ b/src/conftest/hooks/set_proposal_number.c
@@ -85,7 +85,7 @@ METHOD(listener_t, message, bool,
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
- if (payload->get_type(payload) == SECURITY_ASSOCIATION)
+ if (payload->get_type(payload) == PLV2_SECURITY_ASSOCIATION)
{
sa = (sa_payload_t*)payload;
list = sa->get_proposals(sa);
diff --git a/src/conftest/hooks/set_reserved.c b/src/conftest/hooks/set_reserved.c
index d1a4a977b..488e8df1c 100644
--- a/src/conftest/hooks/set_reserved.c
+++ b/src/conftest/hooks/set_reserved.c
@@ -55,7 +55,7 @@ static void set_bit(private_set_reserved_t *this, message_t *message,
payload_t *payload;
bool *bit;
- if (type == HEADER)
+ if (type == PL_HEADER)
{
message->set_reserved_header_bit(message, nr);
DBG1(DBG_CFG, "setting reserved bit %d of %N",
@@ -91,7 +91,7 @@ static void set_byte(private_set_reserved_t *this, message_t *message,
payload_t *payload;
u_int8_t *byte;
- if (type == TRANSFORM_SUBSTRUCTURE || type == PROPOSAL_SUBSTRUCTURE)
+ if (type == PLV2_TRANSFORM_SUBSTRUCTURE || type == PLV2_PROPOSAL_SUBSTRUCTURE)
{
enumerator_t *transforms, *proposals;
transform_substructure_t *transform;
@@ -101,13 +101,13 @@ static void set_byte(private_set_reserved_t *this, message_t *message,
payloads = message->create_payload_enumerator(message);
while (payloads->enumerate(payloads, &payload))
{
- if (payload->get_type(payload) == SECURITY_ASSOCIATION)
+ if (payload->get_type(payload) == PLV2_SECURITY_ASSOCIATION)
{
sa = (sa_payload_t*)payload;
proposals = sa->create_substructure_enumerator(sa);
while (proposals->enumerate(proposals, &proposal))
{
- if (type == PROPOSAL_SUBSTRUCTURE)
+ if (type == PLV2_PROPOSAL_SUBSTRUCTURE)
{
byte = payload_get_field(&proposal->payload_interface,
RESERVED_BYTE, nr);
@@ -118,7 +118,7 @@ static void set_byte(private_set_reserved_t *this, message_t *message,
*byte = byteval;
}
}
- else if (type == TRANSFORM_SUBSTRUCTURE)
+ else if (type == PLV2_TRANSFORM_SUBSTRUCTURE)
{
transforms = proposal->create_substructure_enumerator(
proposal);
@@ -181,8 +181,7 @@ METHOD(listener_t, message, bool,
type = atoi(name);
if (!type)
{
- type = enum_from_name(payload_type_short_names, name);
- if (type == -1)
+ if (!enum_from_name(payload_type_short_names, name, &type))
{
DBG1(DBG_CFG, "invalid payload name '%s'", name);
break;
diff --git a/src/conftest/hooks/unencrypted_notify.c b/src/conftest/hooks/unencrypted_notify.c
index f4c35725c..2a7498527 100644
--- a/src/conftest/hooks/unencrypted_notify.c
+++ b/src/conftest/hooks/unencrypted_notify.c
@@ -68,8 +68,7 @@ METHOD(listener_t, ike_updown, bool,
type = atoi(this->type);
if (!type)
{
- type = enum_from_name(notify_type_names, this->type);
- if (type == -1)
+ if (!enum_from_name(notify_type_names, this->type, &type))
{
DBG1(DBG_CFG, "unknown notify: '%s', skipped", this->type);
return TRUE;
@@ -84,7 +83,7 @@ METHOD(listener_t, ike_updown, bool,
{
data = chunk_clone(chunk_create(this->data, strlen(this->data)));
}
- notify = notify_payload_create_from_protocol_and_type(NOTIFY,
+ notify = notify_payload_create_from_protocol_and_type(PLV2_NOTIFY,
this->esp ? PROTO_ESP : PROTO_IKE, type);
notify->set_spi(notify, this->spi);
if (data.len)
diff --git a/src/conftest/hooks/unsort_message.c b/src/conftest/hooks/unsort_message.c
index 1b2b302af..399d2932a 100644
--- a/src/conftest/hooks/unsort_message.c
+++ b/src/conftest/hooks/unsort_message.c
@@ -69,8 +69,7 @@ METHOD(listener_t, message, bool,
order = enumerator_create_token(this->order, ", ", " ");
while (order->enumerate(order, &name))
{
- type = enum_from_name(payload_type_short_names, name);
- if (type != -1)
+ if (enum_from_name(payload_type_short_names, name, &type))
{
enumerator = list->create_enumerator(list);
while (enumerator->enumerate(enumerator, &payload))