diff options
Diffstat (limited to 'src/libcharon/sa/tasks')
-rw-r--r-- | src/libcharon/sa/tasks/ike_config.c | 23 | ||||
-rw-r--r-- | src/libcharon/sa/tasks/xauth_request.c | 26 |
2 files changed, 24 insertions, 25 deletions
diff --git a/src/libcharon/sa/tasks/ike_config.c b/src/libcharon/sa/tasks/ike_config.c index 6623730d1..332af465b 100644 --- a/src/libcharon/sa/tasks/ike_config.c +++ b/src/libcharon/sa/tasks/ike_config.c @@ -98,7 +98,8 @@ static configuration_attribute_t *build_vip(host_t *vip) chunk = chunk_cata("cc", chunk, prefix); } } - return configuration_attribute_create_value(type, chunk); + return configuration_attribute_create_chunk(CONFIGURATION_ATTRIBUTE, + type, chunk); } /** @@ -128,11 +129,11 @@ static void handle_attribute(private_ike_config_t *this, /* and pass it to the handle function */ handler = hydra->attributes->handle(hydra->attributes, this->ike_sa->get_other_id(this->ike_sa), handler, - ca->get_type(ca), ca->get_value(ca)); + ca->get_type(ca), ca->get_chunk(ca)); if (handler) { this->ike_sa->add_configuration_attribute(this->ike_sa, - handler, ca->get_type(ca), ca->get_value(ca)); + handler, ca->get_type(ca), ca->get_chunk(ca)); } } @@ -153,7 +154,7 @@ static void process_attribute(private_ike_config_t *this, /* fall */ case INTERNAL_IP6_ADDRESS: { - addr = ca->get_value(ca); + addr = ca->get_chunk(ca); if (addr.len == 0) { ip = host_create_any(family); @@ -252,7 +253,7 @@ METHOD(task_t, build_i, status_t, } if (vip) { - cp = cp_payload_create_type(CFG_REQUEST); + cp = cp_payload_create_type(CONFIGURATION, CFG_REQUEST); cp->add_attribute(cp, build_vip(vip)); } @@ -266,10 +267,11 @@ METHOD(task_t, build_i, status_t, /* create configuration attribute */ DBG2(DBG_IKE, "building %N attribute", configuration_attribute_type_names, type); - ca = configuration_attribute_create_value(type, data); + ca = configuration_attribute_create_chunk(CONFIGURATION_ATTRIBUTE, + type, data); if (!cp) { - cp = cp_payload_create_type(CFG_REQUEST); + cp = cp_payload_create_type(CONFIGURATION, CFG_REQUEST); } cp->add_attribute(cp, ca); @@ -335,7 +337,7 @@ METHOD(task_t, build_r, status_t, DBG1(DBG_IKE, "assigning virtual IP %H to peer '%Y'", vip, id); this->ike_sa->set_virtual_ip(this->ike_sa, FALSE, vip); - cp = cp_payload_create_type(CFG_REPLY); + cp = cp_payload_create_type(CONFIGURATION, CFG_REPLY); cp->add_attribute(cp, build_vip(vip)); } @@ -346,12 +348,13 @@ METHOD(task_t, build_r, status_t, { if (!cp) { - cp = cp_payload_create_type(CFG_REPLY); + cp = cp_payload_create_type(CONFIGURATION, CFG_REPLY); } DBG2(DBG_IKE, "building %N attribute", configuration_attribute_type_names, type); cp->add_attribute(cp, - configuration_attribute_create_value(type, value)); + configuration_attribute_create_chunk(CONFIGURATION_ATTRIBUTE, + type, value)); } enumerator->destroy(enumerator); diff --git a/src/libcharon/sa/tasks/xauth_request.c b/src/libcharon/sa/tasks/xauth_request.c index a50d0fb43..60914beef 100644 --- a/src/libcharon/sa/tasks/xauth_request.c +++ b/src/libcharon/sa/tasks/xauth_request.c @@ -3,8 +3,7 @@ #include <daemon.h> #include <hydra.h> -#include <encoding/payloads/attribute_payload_v1.h> -#include <encoding/payloads/data_attribute_v1.h> +#include <encoding/payloads/cp_payload.h> #include <encoding/payloads/hash_payload.h> #include <encoding/generator.h> @@ -61,10 +60,9 @@ static void process_payloads(private_xauth_request_t *this, message_t *message) METHOD(task_t, build_i, status_t, private_xauth_request_t *this, message_t *message) { - attribute_payload_v1_t *ap = NULL; + cp_payload_t *cp; chunk_t chunk = chunk_empty; - data_attribute_v1_t *da = NULL; - hash_payload_t *hash_payload = NULL; + hash_payload_t *hash_payload; generator_t *generator; chunk_t attr_chunk; chunk_t mid_chunk; @@ -76,13 +74,11 @@ METHOD(task_t, build_i, status_t, DBG1(DBG_IKE, "BUILDING XAUTH REQUEST PACKET"); /* TODO1: Create ATTR payload */ - ap = attribute_payload_v1_create(); - - da = data_attribute_v1_create_value(XAUTH_USER_NAME, chunk); - ap->add_attribute(ap, da); - - da = data_attribute_v1_create_value(XAUTH_USER_PASSWORD, chunk); - ap->add_attribute(ap, da); + cp = cp_payload_create(CONFIGURATION_V1); + cp->add_attribute(cp, configuration_attribute_create_chunk( + CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_NAME, chunk)); + cp->add_attribute(cp, configuration_attribute_create_chunk( + CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_PASSWORD, chunk)); /* Create HASH payload */ hash_payload = hash_payload_create(); @@ -90,8 +86,8 @@ METHOD(task_t, build_i, status_t, /* Calculate the chunk for the ATTR payload */ generator = generator_create(); - ap->payload_interface.set_next_type(&ap->payload_interface, NO_PAYLOAD); - generator->generate_payload(generator, (payload_t *)ap); + cp->payload_interface.set_next_type(&cp->payload_interface, NO_PAYLOAD); + generator->generate_payload(generator, (payload_t *)cp); attr_chunk = generator->get_chunk(generator, &lenpos); /* Get the message ID in network order */ @@ -102,7 +98,7 @@ METHOD(task_t, build_i, status_t, hash_in = chunk_cat("cc", mid_chunk, attr_chunk); message->add_payload(message, (payload_t *)hash_payload); - message->add_payload(message, (payload_t *)ap); + message->add_payload(message, (payload_t *)cp); return NEED_MORE; } |