diff options
Diffstat (limited to 'Source/charon')
-rw-r--r-- | Source/charon/configuration.c | 78 | ||||
-rw-r--r-- | Source/charon/configuration.h | 58 | ||||
-rw-r--r-- | Source/charon/daemon.c | 10 | ||||
-rw-r--r-- | Source/charon/generator.c | 54 | ||||
-rw-r--r-- | Source/charon/ike_sa.c | 8 | ||||
-rw-r--r-- | Source/charon/ike_sa_manager.c | 6 | ||||
-rw-r--r-- | Source/charon/message.c | 8 | ||||
-rw-r--r-- | Source/charon/parser.c | 4 | ||||
-rw-r--r-- | Source/charon/thread_pool.c | 26 | ||||
-rw-r--r-- | Source/charon/utils/logger.h | 34 |
10 files changed, 83 insertions, 203 deletions
diff --git a/Source/charon/configuration.c b/Source/charon/configuration.c deleted file mode 100644 index 8c960ebe9..000000000 --- a/Source/charon/configuration.c +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file configuration.c - * - * @brief Configuration class used to store IKE_SA-configurations. - * - * Object of this type represents a configuration for an IKE_SA and its child_sa's. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <stdlib.h> - -#include "configuration.h" - -#include "types.h" -#include "utils/allocator.h" - -/** - * Private data of an configuration_t object - */ -typedef struct private_configuration_s private_configuration_t; - -struct private_configuration_s { - - /** - * Public part of a configuration_t object - */ - configuration_t public; - - - /* Private values */ -}; - -/** - * Implements function destroy of configuration_t. - * See #configuration_s.destroy for description. - */ -static status_t destroy (private_configuration_t *this) -{ - if (this == NULL) - { - return FAILED; - } - allocator_free(this); - return SUCCESS; -} - -/* - * Described in header-file - */ -configuration_t * configuration_create() -{ - private_configuration_t *this = allocator_alloc_thing(private_configuration_t); - if (this == NULL) - { - return NULL; - } - - /* public functions */ - this->public.destroy = (status_t(*)(configuration_t*))destroy; - - - return (&this->public); -} diff --git a/Source/charon/configuration.h b/Source/charon/configuration.h deleted file mode 100644 index 9f54e91e0..000000000 --- a/Source/charon/configuration.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file configuration.h - * - * @brief Configuration class used to store IKE_SA-configurations. - * - * Object of this type represents a configuration for an IKE_SA and its child_sa's. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef CONFIGURATION_H_ -#define CONFIGURATION_H_ - -#include "types.h" - -/** - * @brief This class is used to represent an IKE_SA-configuration. - * - */ -typedef struct configuration_s configuration_t; - -struct configuration_s { - - /** - * @brief Destroys a configuration_t object - * - * @param this configuration_t object - * @return - * - SUCCESS if succeeded - * - FAILED when NULL pointer given - */ - status_t (*destroy) (configuration_t *this); -}; - -/** - * Creates an configuration_t object - * - * @return - * - pointer to created configuration_t object if succeeded - * - NULL if memory allocation failed - */ -configuration_t *configuration_create(); - -#endif /*CONFIGURATION_H_*/ diff --git a/Source/charon/daemon.c b/Source/charon/daemon.c index c79696c07..559b478cf 100644 --- a/Source/charon/daemon.c +++ b/Source/charon/daemon.c @@ -100,7 +100,7 @@ int main() register_signals(); /* logger_manager is created first */ - global_logger_manager = logger_manager_create(ALL); + global_logger_manager = logger_manager_create(FULL); if (global_logger_manager == NULL) { printf("could not create logger manager"); @@ -150,7 +150,7 @@ int main() } - logger->log(logger,CONTROL_MORE,"going to wait for exit signal"); + logger->log(logger,CONTROL|MORE,"going to wait for exit signal"); /* go and handle signals*/ main_loop(); @@ -354,10 +354,10 @@ static void destroy_and_exit(int exit_code) destroy_globals(); /* logger is destroyed */ - logger->log(logger,CONTROL_MORE,"destroy logger"); + logger->log(logger,CONTROL|MORE,"destroy logger"); global_logger_manager->destroy_logger(global_logger_manager,logger); - logger->log(logger,CONTROL_MORE,"destroy logger_manager"); - logger->log(logger,CONTROL_MORE,"------------------------------------"); + logger->log(logger,CONTROL|MORE,"destroy logger_manager"); + logger->log(logger,CONTROL|MORE,"------------------------------------"); if (global_logger_manager != NULL) { global_logger_manager->destroy(global_logger_manager); diff --git a/Source/charon/generator.c b/Source/charon/generator.c index 091c46278..92afae68d 100644 --- a/Source/charon/generator.c +++ b/Source/charon/generator.c @@ -328,7 +328,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i /* U_INT Types of multiple then 8 bits must be aligned */ if (((number_of_bits % 8) == 0) && (this->current_bit != 0)) { - this->logger->log(this->logger,CONTROL_MORE,"U_INT Type %s is not 8 Bit aligned", mapping_find(encoding_type_m,int_type)); + this->logger->log(this->logger,CONTROL|MORE,"U_INT Type %s is not 8 Bit aligned", mapping_find(encoding_type_m,int_type)); /* current bit has to be zero for values multiple of 8 bits */ return FAILED; } @@ -368,7 +368,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i } else { - this->logger->log(this->logger,CONTROL_MORE,"U_INT_4 Type is not 4 Bit aligned"); + this->logger->log(this->logger,CONTROL|MORE,"U_INT_4 Type is not 4 Bit aligned"); /* 4 Bit integers must have a 4 bit alignment */ return FAILED; }; @@ -387,7 +387,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i /* attribute type must not change first bit uf current byte ! */ if (this->current_bit != 1) { - this->logger->log(this->logger,CONTROL_MORE,"ATTRIBUTE FORMAT flag is not set"); + this->logger->log(this->logger,CONTROL|MORE,"ATTRIBUTE FORMAT flag is not set"); /* first bit has to be set! */ return FAILED; } @@ -429,7 +429,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i } default: - this->logger->log(this->logger,CONTROL_MORE,"U_INT Type %s is not supported", mapping_find(encoding_type_m,int_type)); + this->logger->log(this->logger,CONTROL|MORE,"U_INT Type %s is not supported", mapping_find(encoding_type_m,int_type)); return FAILED; } return SUCCESS; @@ -446,7 +446,7 @@ static status_t generate_reserved_field (private_generator_t *this,int bits) /* only one bit or 8 bit fields are supported */ if ((bits != 1) && (bits != 8)) { - this->logger->log(this->logger,CONTROL_MORE,"Reserved field of %d bits cannot be generated",bits); + this->logger->log(this->logger,CONTROL|MORE,"Reserved field of %d bits cannot be generated",bits); return FAILED; } /* make sure enough space is available in buffer */ @@ -480,7 +480,7 @@ static status_t generate_reserved_field (private_generator_t *this,int bits) /* one byte processing*/ if (this->current_bit > 0) { - this->logger->log(this->logger,CONTROL_MORE,"Reserved field cannot be written cause allignement of current bit is %d",this->current_bit); + this->logger->log(this->logger,CONTROL|MORE,"Reserved field cannot be written cause allignement of current bit is %d",this->current_bit); return FAILED; } *(this->out_position) = 0x00; @@ -540,7 +540,7 @@ static status_t generate_from_chunk (private_generator_t *this,u_int32_t offset) { if (this->current_bit != 0) { - this->logger->log(this->logger,CONTROL_MORE,"Chunks can only be taken if bits are alligned in buffer"); + this->logger->log(this->logger,CONTROL|MORE,"Chunks can only be taken if bits are alligned in buffer"); return FAILED; } /* position in buffer */ @@ -565,13 +565,13 @@ static status_t make_space_available (private_generator_t *this, size_t bits) size_t new_buffer_size = old_buffer_size + GENERATOR_DATA_BUFFER_INCREASE_VALUE; size_t out_position_offset = ((this->out_position) - (this->buffer)); - this->logger->log(this->logger,CONTROL_MORE,"Gen-Buffer is increased from %d to %d byte",old_buffer_size,new_buffer_size); + this->logger->log(this->logger,CONTROL|MORE,"Gen-Buffer is increased from %d to %d byte",old_buffer_size,new_buffer_size); /* Reallocate space for new buffer */ new_buffer = allocator_realloc(this->buffer,new_buffer_size); if (new_buffer == NULL) { - this->logger->log(this->logger,CONTROL_MORE,"Fatal error: Reallocation of buffer failed!!!"); + this->logger->log(this->logger,CONTROL|MORE,"Fatal error: Reallocation of buffer failed!!!"); return OUT_OF_RES; } @@ -658,7 +658,7 @@ static status_t write_to_chunk (private_generator_t *this,chunk_t *data) if (data->ptr == NULL) { data->len = 0; - this->logger->log(this->logger,CONTROL_MORE,"OUT OF Ressources to wrote data to chunk!!!!!"); + this->logger->log(this->logger,CONTROL|MORE,"OUT OF Ressources to wrote data to chunk!!!!!"); return OUT_OF_RES; } memcpy(data->ptr,this->buffer,data_length); @@ -754,7 +754,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->generate_from_chunk(this,rules[i].offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write key exchange data from chunk"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write key exchange data from chunk"); return status; } @@ -766,7 +766,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write payload length into buffer"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write payload length into buffer"); return status; } break; @@ -777,7 +777,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->generate_from_chunk(this,rules[i].offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write notification data from chunk"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write notification data from chunk"); return status; } @@ -790,7 +790,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write payload length into buffer"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write payload length into buffer"); return status; } break; @@ -801,7 +801,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->generate_from_chunk(this,rules[i].offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write nonce data from chunk"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write nonce data from chunk"); return status; } @@ -813,7 +813,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) status = this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write payload length into buffer"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write payload length into buffer"); return status; } break; @@ -828,14 +828,14 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) /* proposals are stored in a linked list and so accessed */ linked_list_t *proposals = *((linked_list_t **)(this->data_struct + rules[i].offset)); - this->logger->log(this->logger,CONTROL_MORE,"Generate Proposals"); + this->logger->log(this->logger,CONTROL|MORE,"Generate Proposals"); linked_list_iterator_t *iterator; /* create forward iterator */ status = proposals->create_iterator(proposals,&iterator,TRUE); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could not iterator of proposals"); + this->logger->log(this->logger,CONTROL|MORE,"Could not iterator of proposals"); return status; } /* every proposal is processed (iterative call )*/ @@ -864,13 +864,13 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) length_of_sa_payload += (after_generate_position_offset - before_generate_position_offset); } iterator->destroy(iterator); - this->logger->log(this->logger,CONTROL_MORE,"Length of Payload is %d, offset is %d",length_of_sa_payload,payload_length_position_offset); + this->logger->log(this->logger,CONTROL|MORE,"Length of Payload is %d, offset is %d",length_of_sa_payload,payload_length_position_offset); int16_val = htons(length_of_sa_payload); status = this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); if (status != SUCCESS) { - this->logger->log(this->logger,CONTROL_MORE,"Could no write payload length into buffer"); + this->logger->log(this->logger,CONTROL|MORE,"Could no write payload length into buffer"); return status; } break; @@ -885,7 +885,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) linked_list_t *transforms = *((linked_list_t **)(this->data_struct + rules[i].offset)); linked_list_iterator_t *iterator; - this->logger->log(this->logger,CONTROL_MORE,"Generate Transforms"); + this->logger->log(this->logger,CONTROL|MORE,"Generate Transforms"); /* create forward iterator */ status = transforms->create_iterator(transforms,&iterator,TRUE); @@ -921,7 +921,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) iterator->destroy(iterator); - this->logger->log(this->logger,CONTROL_MORE,"Length of Transform is %d, offset is %d",length_of_proposal,payload_length_position_offset); + this->logger->log(this->logger,CONTROL|MORE,"Length of Transform is %d, offset is %d",length_of_proposal,payload_length_position_offset); int16_val = htons(length_of_proposal); this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); @@ -930,7 +930,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) } case TRANSFORM_ATTRIBUTES: { - this->logger->log(this->logger,CONTROL_MORE,"Generate Transform attributes"); + this->logger->log(this->logger,CONTROL|MORE,"Generate Transform attributes"); /* before iterative generate the transform attributes, store the current length position */ u_int32_t transform_length_position_offset = this->last_payload_length_position_offset; @@ -968,7 +968,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) iterator->destroy(iterator); - this->logger->log(this->logger,CONTROL_MORE,"Length of Transform is %d, offset is %d",length_of_transform,transform_length_position_offset); + this->logger->log(this->logger,CONTROL|MORE,"Length of Transform is %d, offset is %d",length_of_transform,transform_length_position_offset); int16_val = htons(length_of_transform); this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),transform_length_position_offset); @@ -985,7 +985,7 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) case ATTRIBUTE_LENGTH_OR_VALUE: { - this->logger->log(this->logger,CONTROL_MORE,"Generate Attribute Length or Value field"); + this->logger->log(this->logger,CONTROL|MORE,"Generate Attribute Length or Value field"); if (this->attribute_format == FALSE) { status = this->generate_u_int_type(this,U_INT_16,rules[i].offset); @@ -1002,14 +1002,14 @@ static status_t generate_payload (private_generator_t *this,payload_t *payload) { if (this->attribute_format == FALSE) { - this->logger->log(this->logger,CONTROL_MORE,"Attribute value has not fixed size"); + this->logger->log(this->logger,CONTROL|MORE,"Attribute value has not fixed size"); /* the attribute value is generated */ status = this->generate_from_chunk(this,rules[i].offset); } break; } default: - this->logger->log(this->logger,CONTROL_MORE,"Field Type %s is not supported",mapping_find(encoding_type_m,rules[i].type)); + this->logger->log(this->logger,CONTROL|MORE,"Field Type %s is not supported",mapping_find(encoding_type_m,rules[i].type)); return NOT_SUPPORTED; } } diff --git a/Source/charon/ike_sa.c b/Source/charon/ike_sa.c index 5f6cd40c1..5e5ca2249 100644 --- a/Source/charon/ike_sa.c +++ b/Source/charon/ike_sa.c @@ -139,7 +139,7 @@ static status_t process_message (private_ike_sa_t *this, message_t *message) status_t status; /* @TODO Add Message Processing here */ - this->logger->log(this->logger, CONTROL_MORE, "Process message of exchange type %s",mapping_find(exchange_type_m,message->get_exchange_type(message))); + this->logger->log(this->logger, CONTROL|MORE, "Process message of exchange type %s",mapping_find(exchange_type_m,message->get_exchange_type(message))); /* parse body */ status = message->parse_body(message); @@ -293,7 +293,7 @@ static status_t build_sa_payload(private_ike_sa_t *this, sa_payload_t **payload) linked_list_iterator_t *iterator; status_t status; - this->logger->log(this->logger, CONTROL_MORE, "building sa payload"); + this->logger->log(this->logger, CONTROL|MORE, "building sa payload"); sa_payload = sa_payload_create(); if (sa_payload == NULL) @@ -327,7 +327,7 @@ static status_t build_ke_payload(private_ike_sa_t *this, ke_payload_t **payload) chunk_t key_data; - this->logger->log(this->logger, CONTROL_MORE, "building ke payload"); + this->logger->log(this->logger, CONTROL|MORE, "building ke payload"); key_data.ptr = "12345"; key_data.len = strlen("12345"); @@ -356,7 +356,7 @@ static status_t build_nonce_payload(private_ike_sa_t *this, nonce_payload_t **pa nonce_payload_t *nonce_payload; chunk_t nonce; - this->logger->log(this->logger, CONTROL_MORE, "building nonce payload"); + this->logger->log(this->logger, CONTROL|MORE, "building nonce payload"); if (this->randomizer->allocate_pseudo_random_bytes(this->randomizer, 16, &nonce) != SUCCESS) { diff --git a/Source/charon/ike_sa_manager.c b/Source/charon/ike_sa_manager.c index aaeb29583..58d4f8709 100644 --- a/Source/charon/ike_sa_manager.c +++ b/Source/charon/ike_sa_manager.c @@ -331,7 +331,7 @@ static status_t checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id, /* can we give this out to new requesters?*/ if (entry->driveout_new_threads) { - this->logger->log(this->logger,CONTROL_MORE,"Drive out new thread for existing IKE_SA"); + this->logger->log(this->logger,CONTROL|MORE,"Drive out new thread for existing IKE_SA"); /* no we can't */ retval = NOT_FOUND; } @@ -354,7 +354,7 @@ static status_t checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id, { /* we must signal here, others are interested that we leave */ pthread_cond_signal(&(entry->condvar)); - this->logger->log(this->logger,CONTROL_MORE,"Drive out waiting thread for existing IKE_SA"); + this->logger->log(this->logger,CONTROL|MORE,"Drive out waiting thread for existing IKE_SA"); retval = NOT_FOUND; } else @@ -477,7 +477,7 @@ static status_t checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id, else { /* responder set, initiator not: here is something seriously wrong! */ - this->logger->log(this->logger,CONTROL_MORE,"Invalid IKE_SA SPI's"); + this->logger->log(this->logger,CONTROL|MORE,"Invalid IKE_SA SPI's"); /* DON'T use return, we must unlock the mutex! */ retval = INVALID_ARG; } diff --git a/Source/charon/message.c b/Source/charon/message.c index b0146eb97..5d7e0eaa9 100644 --- a/Source/charon/message.c +++ b/Source/charon/message.c @@ -677,7 +677,7 @@ static status_t parse_body (private_message_t *this) status = iterator->current(iterator,(void **)¤t_payload); if (status != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "Could not get payload from internal list"); + this->logger->log(this->logger, CONTROL|MORE, "Could not get payload from internal list"); iterator->destroy(iterator); return status; } @@ -686,7 +686,7 @@ static status_t parse_body (private_message_t *this) found_payloads++; if (found_payloads > max_occurence) { - this->logger->log(this->logger, CONTROL_MORE, "Payload of type %s more than %d times (%d) occured in current message", + this->logger->log(this->logger, CONTROL|MORE, "Payload of type %s more than %d times (%d) occured in current message", mapping_find(payload_type_m,current_payload->get_type(current_payload)),max_occurence,found_payloads); iterator->destroy(iterator); return NOT_SUPPORTED; @@ -696,7 +696,7 @@ static status_t parse_body (private_message_t *this) } if (found_payloads < min_occurence) { - this->logger->log(this->logger, CONTROL_MORE, "Payload of type %s not occured %d times", + this->logger->log(this->logger, CONTROL|MORE, "Payload of type %s not occured %d times", mapping_find(payload_type_m,payload_type),min_occurence); iterator->destroy(iterator); return NOT_SUPPORTED; @@ -732,7 +732,7 @@ static status_t destroy (private_message_t *this) { payload_t *payload; iterator->current(iterator, (void**)&payload); - this->logger->log(this->logger, CONTROL_MORE, "Destroying payload of type %s", + this->logger->log(this->logger, CONTROL|MORE, "Destroying payload of type %s", mapping_find(payload_type_m, payload->get_type(payload))); payload->destroy(payload); } diff --git a/Source/charon/parser.c b/Source/charon/parser.c index 316530e33..bb76785be 100644 --- a/Source/charon/parser.c +++ b/Source/charon/parser.c @@ -543,7 +543,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ for (rule_number = 0; rule_number < rule_count; rule_number++) { rule = &(this->rules[rule_number]); - this->logger->log(this->logger, CONTROL_MORE, " parsing rule %d %s", + this->logger->log(this->logger, CONTROL|MORE, " parsing rule %d %s", rule_number, mapping_find(encoding_type_m, rule->type)); switch (rule->type) { @@ -812,7 +812,7 @@ parser_t *parser_create(chunk_t data) } this->logger = global_logger_manager->create_logger(global_logger_manager, PARSER, NULL); - this->logger->enable_level(this->logger, CONTROL|CONTROL_MORE|ERROR|RAW); + this->logger->enable_level(this->logger, CONTROL|MORE|ERROR|RAW); if (this->logger == NULL) diff --git a/Source/charon/thread_pool.c b/Source/charon/thread_pool.c index 9d48ae4ed..9b47b1265 100644 --- a/Source/charon/thread_pool.c +++ b/Source/charon/thread_pool.c @@ -72,7 +72,7 @@ static void job_processing(private_thread_pool_t *this) /* cancellation disabled by default */ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); - this->logger->log(this->logger, CONTROL_MORE, "thread %u started working", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u started working", pthread_self()); for (;;) { job_t *job; @@ -80,7 +80,7 @@ static void job_processing(private_thread_pool_t *this) global_job_queue->get(global_job_queue, &job); job_type = job->get_type(job); - this->logger->log(this->logger, CONTROL_MORE, "thread %u got a job of type %s", pthread_self(),mapping_find(job_type_m,job_type)); + this->logger->log(this->logger, CONTROL|MORE, "thread %u got a job of type %s", pthread_self(),mapping_find(job_type_m,job_type)); /* process them here */ switch (job_type) @@ -96,13 +96,13 @@ static void job_processing(private_thread_pool_t *this) if (incoming_packet_job->get_packet(incoming_packet_job,&packet) != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Packet in job of type %s could not be retrieved!", pthread_self(),mapping_find(job_type_m,job_type)); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Packet in job of type %s could not be retrieved!", pthread_self(),mapping_find(job_type_m,job_type)); break; } message = message_create_from_packet(packet); if (message == NULL) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Message could not be created from packet!", pthread_self(),mapping_find(job_type_m,job_type)); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Message could not be created from packet!", pthread_self(),mapping_find(job_type_m,job_type)); packet->destroy(packet); break; } @@ -110,21 +110,21 @@ static void job_processing(private_thread_pool_t *this) status = message->parse_header(message); if (status != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Message header could not be verified!", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Message header could not be verified!", pthread_self()); message->destroy(message); break; } if ((message->get_major_version(message) != IKE_MAJOR_VERSION) || (message->get_minor_version(message) != IKE_MINOR_VERSION)) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: IKE Version %d.%d not supported", pthread_self(),message->get_major_version(message),message->get_minor_version(message)); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: IKE Version %d.%d not supported", pthread_self(),message->get_major_version(message),message->get_minor_version(message)); /* Todo send notify */ } status = message->get_ike_sa_id(message,&ike_sa_id); if (status != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: IKE SA ID of message could not be created!", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: IKE SA ID of message could not be created!", pthread_self()); message->destroy(message); break; } @@ -132,7 +132,7 @@ static void job_processing(private_thread_pool_t *this) status = global_ike_sa_manager->checkout(global_ike_sa_manager,ike_sa_id, &ike_sa); if (status != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: IKE SA could not be checked out", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: IKE SA could not be checked out", pthread_self()); message->destroy(message); break; } @@ -145,18 +145,18 @@ static void job_processing(private_thread_pool_t *this) u_int64_t responder; bool is_initiator; checked_out_ike_sa_id->get_values(checked_out_ike_sa_id,&initiator,&responder,&is_initiator); - this->logger->log(this->logger, CONTROL_MORE, "IKE SA with SPI's I:%d, R:%d checked out", initiator,responder); + this->logger->log(this->logger, CONTROL|MORE, "IKE SA with SPI's I:%d, R:%d checked out", initiator,responder); } status = ike_sa->process_message (ike_sa,message); if (status != SUCCESS) { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Message could not be processed by IKE SA", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Message could not be processed by IKE SA", pthread_self()); } status = global_ike_sa_manager->checkin(global_ike_sa_manager,ike_sa); if (status != SUCCESS){ - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Checkin of IKE SA return errors", pthread_self()); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Checkin of IKE SA return errors", pthread_self()); } message->destroy(message); ike_sa_id->destroy(ike_sa_id); @@ -216,7 +216,7 @@ static void job_processing(private_thread_pool_t *this) } case RETRANSMIT_REQUEST: { - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Job of type %s not supported!", pthread_self(),mapping_find(job_type_m,job_type)); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Job of type %s not supported!", pthread_self(),mapping_find(job_type_m,job_type)); break; } @@ -232,7 +232,7 @@ static void job_processing(private_thread_pool_t *this) u_int64_t responder; bool is_initiator; ike_sa_id->get_values(ike_sa_id,&initiator,&responder,&is_initiator); - this->logger->log(this->logger, CONTROL_MORE, "thread %u: Going to delete IKE SA with SPI's I:%d, R:%d", pthread_self(),initiator,responder); + this->logger->log(this->logger, CONTROL|MORE, "thread %u: Going to delete IKE SA with SPI's I:%d, R:%d", pthread_self(),initiator,responder); } status = global_ike_sa_manager->delete(global_ike_sa_manager, ike_sa_id); if (status != SUCCESS) diff --git a/Source/charon/utils/logger.h b/Source/charon/utils/logger.h index db6d25d60..04fa8cdd4 100644 --- a/Source/charon/utils/logger.h +++ b/Source/charon/utils/logger.h @@ -27,35 +27,51 @@ #include "../types.h" /** - * Log Levels supported by the logger object + * @brief Log Levels supported by the logger object + * + * Logleves are devided in two types: + * - One to specify the type log + * - One to specify the detail-level of the log + * Use combinations of these to build detailed loglevels, such + * as CONTROL|MORE fore a detailed cotrol level, or + * use RAW| to see all raw data dumps (except private) */ typedef enum logger_level_e logger_level_t; enum logger_level_e { /** - * basic control messages + * control flow */ CONTROL = 1, /** - * detailed control messages + * error reporting */ - CONTROL_MORE = 2, + ERROR = 2, /** - * raw data dumps not containing private data + * raw data dumps */ RAW = 4, /** * private data dumps */ PRIVATE = 8, + + /** + * use more detailed output for those above + */ + MORE = 16, + /** + * use even more detailed output + */ + MOST = MORE + 32, /** - * print errors + * use full detailed output */ - ERROR = 16, + ALL = MOST + 64, /** - * All Lol Levels + * Summary for all types with all detail-levels */ - ALL = 255 + FULL = ALL + CONTROL + ERROR + RAW + PRIVATE }; /** |