diff options
Diffstat (limited to 'Source/charon/utils')
-rw-r--r-- | Source/charon/utils/identification.c | 19 | ||||
-rw-r--r-- | Source/charon/utils/identification.h | 24 | ||||
-rw-r--r-- | Source/charon/utils/logger.c | 4 | ||||
-rw-r--r-- | Source/charon/utils/logger.h | 4 | ||||
-rw-r--r-- | Source/charon/utils/logger_manager.c | 7 |
5 files changed, 40 insertions, 18 deletions
diff --git a/Source/charon/utils/identification.c b/Source/charon/utils/identification.c index 844c98b8d..73f218874 100644 --- a/Source/charon/utils/identification.c +++ b/Source/charon/utils/identification.c @@ -70,6 +70,8 @@ struct private_identification_t { id_type_t type; }; +static private_identification_t *identification_create(); + /** * Implementation of identification_t.get_encoding. */ @@ -114,6 +116,21 @@ static bool equals (private_identification_t *this,private_identification_t *oth } /** + * Implementation of identification_t.clone. + */ +static identification_t *clone(private_identification_t *this) +{ + private_identification_t *clone = identification_create(); + + clone->type = this->type; + clone->encoded = allocator_clone_chunk(this->encoded); + clone->string = allocator_alloc(strlen(this->string) + 1); + strcpy(clone->string, this->string); + + return &clone->public; +} + +/** * Implementation of identification_t.destroy. */ static void destroy(private_identification_t *this) @@ -136,6 +153,7 @@ static private_identification_t *identification_create() this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding; this->public.get_type = (id_type_t (*) (identification_t*))get_type; this->public.get_string = (char* (*) (identification_t*))get_string; + this->public.clone = (identification_t* (*) (identification_t*))clone; this->public.destroy = (void (*) (identification_t*))destroy; this->string = NULL; @@ -144,6 +162,7 @@ static private_identification_t *identification_create() return this; } + /* * Described in header. */ diff --git a/Source/charon/utils/identification.h b/Source/charon/utils/identification.h index 057989b24..38bac5ee1 100644 --- a/Source/charon/utils/identification.h +++ b/Source/charon/utils/identification.h @@ -21,8 +21,8 @@ */ -#ifndef _IDENTIFICATION_H_ -#define _IDENTIFICATION_H_ +#ifndef IDENTIFICATION_H_ +#define IDENTIFICATION_H_ #include "types.h" @@ -120,7 +120,7 @@ struct identification_t { * * @warning Result points to internal data, do NOT free! * - * @param this the identification_t_object + * @param this the identification_t object * @return a chunk containing the encoded bytes */ chunk_t (*get_encoding) (identification_t *this); @@ -128,7 +128,7 @@ struct identification_t { /** * @brief Get the type of this identification. * - * @param this the identification_t_object + * @param this the identification_t object * @return id_type_t */ id_type_t (*get_type) (identification_t *this); @@ -138,7 +138,7 @@ struct identification_t { * * @warning Result points to internal data, do NOT free! * - * @param this the identification_t_object + * @param this the identification_t object * @return string */ char *(*get_string) (identification_t *this); @@ -146,11 +146,19 @@ struct identification_t { /** * @brief Check if two identification_t objects are equal. * - * @param this the identification_t_object - * @param other other identification_t_object + * @param this the identification_t object + * @param other other identification_t object * @return TRUE if the IDs are equal */ bool (*equals) (identification_t *this,identification_t *other); + + /** + * @brief Clone a identification_t instance. + * + * @param this the identification_t object to clone + * @return clone of this + */ + identification_t *(*clone) (identification_t *this); /** * @brief Destroys a identification_t object. @@ -186,4 +194,4 @@ identification_t * identification_create_from_string(id_type_t type, char *strin identification_t * identification_create_from_encoding(id_type_t type, chunk_t encoded); -#endif //_IDENTIFICATION_H_ +#endif /* IDENTIFICATION_H_ */ diff --git a/Source/charon/utils/logger.c b/Source/charon/utils/logger.c index 6b1a91d8b..29f485baa 100644 --- a/Source/charon/utils/logger.c +++ b/Source/charon/utils/logger.c @@ -266,9 +266,9 @@ static void log_bytes(private_logger_t *this, logger_level_t loglevel, char *lab /** * Implementation of logger_t.log_chunk. */ -static void log_chunk(logger_t *this, logger_level_t loglevel, char *label, chunk_t *chunk) +static void log_chunk(logger_t *this, logger_level_t loglevel, char *label, chunk_t chunk) { - this->log_bytes(this, loglevel, label, chunk->ptr, chunk->len); + this->log_bytes(this, loglevel, label, chunk.ptr, chunk.len); } /** diff --git a/Source/charon/utils/logger.h b/Source/charon/utils/logger.h index 3841955df..52c21e6ef 100644 --- a/Source/charon/utils/logger.h +++ b/Source/charon/utils/logger.h @@ -136,9 +136,9 @@ struct logger_t { * @param this logger_t object * @param loglevel or'ed set of logger_level_t's * @param label a labeling name, logged with the bytes - * @param chunk pointer to a chunk to log + * @param chunk chunk to log */ - void (*log_chunk) (logger_t *this, logger_level_t loglevel, char *label, chunk_t *chunk); + void (*log_chunk) (logger_t *this, logger_level_t loglevel, char *label, chunk_t chunk); /** * @brief Enables a loglevel for the current logger_t object. diff --git a/Source/charon/utils/logger_manager.c b/Source/charon/utils/logger_manager.c index 1136be157..fe8ae9bc5 100644 --- a/Source/charon/utils/logger_manager.c +++ b/Source/charon/utils/logger_manager.c @@ -165,7 +165,7 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t /* defaults */ log_thread_ids = FALSE; - logger_level = this->public.get_logger_level(&(this->public),context); + logger_level = this->public.get_logger_level(&(this->public), context); switch(context) { @@ -176,15 +176,12 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t log_thread_ids = TRUE; break; case IKE_SA: - logger_level |= LEVEL1; log_thread_ids = TRUE; break; case CHILD_SA: - logger_level |= LEVEL1; log_thread_ids = TRUE; break; case CONFIG: - logger_level |= FULL; log_thread_ids = TRUE; break; case MESSAGE: @@ -205,14 +202,12 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t case THREAD_POOL: break; case SCHEDULER: - logger_level = 0; break; case SENDER: break; case RECEIVER: break; case SOCKET: - logger_level |= FULL; break; case DAEMON: break; |