From 60356f3375da67375e48691bb1d732c02d1681a1 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Wed, 18 Oct 2006 11:46:13 +0000 Subject: introduced new logging subsystem using bus: passive listeners can register on the bus active listeners wait for signals actively multiplexing allows multiple listeners to receive debug signals a lot more... --- .../encoding/payloads/transform_substructure.c | 69 ++++++++-------------- 1 file changed, 25 insertions(+), 44 deletions(-) (limited to 'src/charon/encoding/payloads/transform_substructure.c') diff --git a/src/charon/encoding/payloads/transform_substructure.c b/src/charon/encoding/payloads/transform_substructure.c index e24191814..59e335a74 100644 --- a/src/charon/encoding/payloads/transform_substructure.c +++ b/src/charon/encoding/payloads/transform_substructure.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include typedef struct private_transform_substructure_t private_transform_substructure_t; @@ -70,18 +70,6 @@ struct private_transform_substructure_t { * Transforms Attributes are stored in a linked_list_t. */ linked_list_t *attributes; - - /** - * assigned logger - */ - logger_t *logger; - - /** - * @brief Computes the length of this substructure. - * - * @param this calling private_transform_substructure_t object - */ - void (*compute_length) (private_transform_substructure_t *this); }; @@ -136,7 +124,7 @@ static status_t verify(private_transform_substructure_t *this) if ((this->next_payload != NO_PAYLOAD) && (this->next_payload != 3)) { /* must be 0 or 3 */ - this->logger->log(this->logger, ERROR, "inconsistent next payload"); + DBG1(SIG_DBG_ENC, "inconsistent next payload"); return FAILED; } @@ -152,8 +140,7 @@ static status_t verify(private_transform_substructure_t *this) break; default: { - this->logger->log(this->logger, ERROR, "invalid transform type: %d", - this->transform_type); + DBG1(SIG_DBG_ENC, "invalid transform type: %d", this->transform_type); return FAILED; } } @@ -167,8 +154,7 @@ static status_t verify(private_transform_substructure_t *this) status = current_attributes->verify(current_attributes); if (status != SUCCESS) { - this->logger->log(this->logger, ERROR, - "TRANSFORM_ATTRIBUTE verification failed"); + DBG1(SIG_DBG_ENC, "TRANSFORM_ATTRIBUTE verification failed"); } } iterator->destroy(iterator); @@ -202,13 +188,31 @@ static payload_type_t get_next_type(private_transform_substructure_t *this) return (this->next_payload); } +/** + * recompute the length of the payload. + */ +static void compute_length (private_transform_substructure_t *this) +{ + iterator_t *iterator; + size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH; + iterator = this->attributes->create_iterator(this->attributes,TRUE); + while (iterator->has_next(iterator)) + { + payload_t * current_attribute; + iterator->current(iterator,(void **) ¤t_attribute); + length += current_attribute->get_length(current_attribute); + } + iterator->destroy(iterator); + + this->transform_length = length; +} + /** * Implementation of payload_t.get_length. */ static size_t get_length(private_transform_substructure_t *this) { - this->compute_length(this); - + compute_length(this); return this->transform_length; } @@ -226,7 +230,7 @@ static iterator_t *create_transform_attribute_iterator (private_transform_substr static void add_transform_attribute (private_transform_substructure_t *this,transform_attribute_t *attribute) { this->attributes->insert_last(this->attributes,(void *) attribute); - this->compute_length(this); + compute_length(this); } /** @@ -284,25 +288,6 @@ static u_int16_t get_transform_id (private_transform_substructure_t *this) return this->transform_id; } -/** - * Implementation of private_transform_substructure_t.compute_length. - */ -static void compute_length (private_transform_substructure_t *this) -{ - iterator_t *iterator; - size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH; - iterator = this->attributes->create_iterator(this->attributes,TRUE); - while (iterator->has_next(iterator)) - { - payload_t * current_attribute; - iterator->current(iterator,(void **) ¤t_attribute); - length += current_attribute->get_length(current_attribute); - } - iterator->destroy(iterator); - - this->transform_length = length; -} - /** * Implementation of transform_substructure_t.clone. */ @@ -410,16 +395,12 @@ transform_substructure_t *transform_substructure_create() this->public.clone = (transform_substructure_t* (*) (transform_substructure_t *)) clone_; this->public.destroy = (void (*) (transform_substructure_t *)) destroy; - /* private functions */ - this->compute_length = compute_length; - /* set default values of the fields */ this->next_payload = NO_PAYLOAD; this->transform_length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH; this->transform_id = 0; this->transform_type = 0; this->attributes = linked_list_create(); - this->logger = logger_manager->get_logger(logger_manager, PAYLOAD); return (&(this->public)); } -- cgit v1.2.3