aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/config/connections
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/config/connections')
-rw-r--r--src/charon/config/connections/connection.c16
-rw-r--r--src/charon/config/connections/connection.h4
-rwxr-xr-xsrc/charon/config/connections/connection_store.h44
-rw-r--r--src/charon/config/connections/local_connection_store.c66
4 files changed, 38 insertions, 92 deletions
diff --git a/src/charon/config/connections/connection.c b/src/charon/config/connections/connection.c
index 3d001194b..5dfc00eb2 100644
--- a/src/charon/config/connections/connection.c
+++ b/src/charon/config/connections/connection.c
@@ -24,19 +24,13 @@
#include <string.h>
#include <config/connections/connection.h>
-
#include <utils/linked_list.h>
-#include <utils/logger.h>
-/**
- * String mappings for cert_policy_t.
- */
-mapping_t cert_policy_m[] = {
- {CERT_ALWAYS_SEND, "CERT_ALWAYS_SEND"},
- {CERT_SEND_IF_ASKED, "CERT_SEND_IF_ASKED"},
- {CERT_NEVER_SEND, "CERT_NEVER_SEND"},
- {MAPPING_END, NULL}
-};
+ENUM(cert_policy_names, CERT_ALWAYS_SEND, CERT_NEVER_SEND,
+ "CERT_ALWAYS_SEND",
+ "CERT_SEND_IF_ASKED",
+ "CERT_NEVER_SEND"
+);
typedef struct private_connection_t private_connection_t;
diff --git a/src/charon/config/connections/connection.h b/src/charon/config/connections/connection.h
index ffe22ad13..b3c1207cc 100644
--- a/src/charon/config/connections/connection.h
+++ b/src/charon/config/connections/connection.h
@@ -54,11 +54,11 @@ enum cert_policy_t {
};
/**
- * string mappings for certpolic_t.
+ * enum strings for cert_policy_t
*
* @ingroup config
*/
-extern mapping_t cert_policy_m[];
+extern enum_name_t *cert_policy_names;
typedef struct connection_t connection_t;
diff --git a/src/charon/config/connections/connection_store.h b/src/charon/config/connections/connection_store.h
index 7d42dd26f..9e6c0efe2 100755
--- a/src/charon/config/connections/connection_store.h
+++ b/src/charon/config/connections/connection_store.h
@@ -25,17 +25,17 @@
#include <types.h>
#include <config/connections/connection.h>
-#include <utils/logger.h>
+#include <utils/iterator.h>
typedef struct connection_store_t connection_store_t;
/**
* @brief The interface for a store of connection_t's.
- *
+ *
* @b Constructors:
* - stroke_create()
- *
+ *
* @ingroup config
*/
struct connection_store_t {
@@ -47,7 +47,7 @@ struct connection_store_t {
* It may be used after kernel request for traffic protection.
* The returned connection gets created/cloned and therefore must
* be destroyed after usage.
- *
+ *
* @param this calling object
* @param my_id own address of connection
* @param other_id others address of connection
@@ -55,14 +55,15 @@ struct connection_store_t {
* - connection_t, if found
* - NULL otherwise
*/
- connection_t *(*get_connection_by_hosts) (connection_store_t *this, host_t *my_host, host_t *other_host);
+ connection_t *(*get_connection_by_hosts)(connection_store_t *this,
+ host_t *my_host, host_t *other_host);
/**
* @brief Returns a connection identified by its name.
- *
+ *
* This call is usefull to get a connection identified its
* name, as on an connection setup.
- *
+ *
* @param this calling object
* @param name name of the connection to get
* @return
@@ -73,10 +74,10 @@ struct connection_store_t {
/**
* @brief Add a connection to the store.
- *
- * After a successful call, the connection is owned by the store and may
+ *
+ * After a successful call, the connection is owned by the store and may
* not be manipulated nor destroyed.
- *
+ *
* @param this calling object
* @param connection connection to add
* @return
@@ -87,10 +88,10 @@ struct connection_store_t {
/**
* @brief Delete a connection from the store.
- *
+ *
* Remove a connection from the connection store, identified
* by the connections name.
- *
+ *
* @param this calling object
* @param name name of the connection to delete
* @return
@@ -100,25 +101,16 @@ struct connection_store_t {
status_t (*delete_connection) (connection_store_t *this, char *name);
/**
- * @brief Log the connections stored in the store.
- *
- * Depending on the implementation of the store, the store
- * logs various information to the specified logger.
- * If logger is NULL, the internal logger is used, if name is
- * NULL, all connections are logged
- *
+ * @brief Get an iterator for the stored connections.
+ *
* @param this calling object
- * @param logger logger to use for the log, or NULL
- * @param name name of the connection, or NULL
- * @return
- * - SUCCESS, or
- * - FAILED
+ * @return iterator over all stored connections
*/
- void (*log_connections) (connection_store_t *this, logger_t *logger, char *name);
+ iterator_t* (*create_iterator) (connection_store_t *this);
/**
* @brief Destroys a connection_store_t object.
- *
+ *
* @param this calling object
*/
void (*destroy) (connection_store_t *this);
diff --git a/src/charon/config/connections/local_connection_store.c b/src/charon/config/connections/local_connection_store.c
index af107b83b..8748fb730 100644
--- a/src/charon/config/connections/local_connection_store.c
+++ b/src/charon/config/connections/local_connection_store.c
@@ -24,8 +24,8 @@
#include "local_connection_store.h"
+#include <daemon.h>
#include <utils/linked_list.h>
-#include <utils/logger_manager.h>
typedef struct private_local_connection_store_t private_local_connection_store_t;
@@ -49,11 +49,6 @@ struct private_local_connection_store_t {
* Mutex to exclusivly access connection list
*/
pthread_mutex_t mutex;
-
- /**
- * Assigned logger
- */
- logger_t *logger;
};
@@ -74,9 +69,8 @@ static connection_t *get_connection_by_hosts(private_local_connection_store_t *t
connection_t *candidate;
connection_t *found = NULL;
- this->logger->log(this->logger, CONTROL|LEVEL1,
- "looking for connection for host pair %H...%H",
- my_host, other_host);
+ DBG2(SIG_DBG_CFG, "looking for connection for host pair %H...%H",
+ my_host, other_host);
pthread_mutex_lock(&(this->mutex));
iterator = this->connections->create_iterator(this->connections, TRUE);
@@ -106,11 +100,9 @@ static connection_t *get_connection_by_hosts(private_local_connection_store_t *t
prio |= PRIO_ADDR_ANY;
}
- this->logger->log(this->logger, CONTROL|LEVEL2,
- "candidate connection \"%s\": %H...%H (prio=%d)",
- candidate->get_name(candidate),
- candidate_my_host, candidate_other_host,
- prio);
+ DBG2(SIG_DBG_CFG, "candidate connection \"%s\": %H...%H (prio=%d)",
+ candidate->get_name(candidate),
+ candidate_my_host, candidate_other_host, prio);
if (prio > best_prio)
{
@@ -126,11 +118,8 @@ static connection_t *get_connection_by_hosts(private_local_connection_store_t *t
host_t *found_my_host = found->get_my_host(found);
host_t *found_other_host = found->get_other_host(found);
- this->logger->log(this->logger, CONTROL|LEVEL1,
- "found matching connection \"%s\": %H...%H (prio=%d)",
- found->get_name(found),
- found_my_host, found_other_host,
- best_prio);
+ DBG2(SIG_DBG_CFG, "found matching connection \"%s\": %H...%H (prio=%d)",
+ found->get_name(found), found_my_host, found_other_host, best_prio);
/* give out a new reference to it */
found->get_ref(found);
@@ -213,40 +202,12 @@ static status_t add_connection(private_local_connection_store_t *this, connectio
}
/**
- * Implementation of connection_store_t.log_connections.
+ * Implementation of connection_store_t.create_iterator.
*/
-void log_connections(private_local_connection_store_t *this, logger_t *logger, char *name)
+static iterator_t* create_iterator(private_local_connection_store_t *this)
{
- iterator_t *iterator;
- connection_t *current;
-
- if (logger == NULL)
- {
- logger = this->logger;
- }
-
- pthread_mutex_lock(&(this->mutex));
-
- iterator = this->connections->create_iterator(this->connections, TRUE);
-
- if (iterator->get_count(iterator))
- {
- logger->log(logger, CONTROL, "Templates:");
- }
- while (iterator->has_next(iterator))
- {
- iterator->current(iterator, (void**)&current);
- if (current->is_ikev2(current) && ( name == NULL || streq(name, current->get_name(current))))
- {
- host_t *my_host = current->get_my_host(current);
- host_t *other_host = current->get_other_host(current);
-
- logger->log(logger, CONTROL, " \"%s\": %H...%H",
- current->get_name(current), my_host, other_host);
- }
- }
- iterator->destroy(iterator);
- pthread_mutex_unlock(&(this->mutex));
+ return this->connections->create_iterator_locked(this->connections,
+ &this->mutex);
}
/**
@@ -277,12 +238,11 @@ local_connection_store_t * local_connection_store_create(void)
this->public.connection_store.get_connection_by_name = (connection_t*(*)(connection_store_t*,char*))get_connection_by_name;
this->public.connection_store.delete_connection = (status_t(*)(connection_store_t*,char*))delete_connection;
this->public.connection_store.add_connection = (status_t(*)(connection_store_t*,connection_t*))add_connection;
- this->public.connection_store.log_connections = (void(*)(connection_store_t*,logger_t*,char*))log_connections;
+ this->public.connection_store.create_iterator = (iterator_t*(*)(connection_store_t*))create_iterator;
this->public.connection_store.destroy = (void(*)(connection_store_t*))destroy;
/* private variables */
this->connections = linked_list_create();
- this->logger = logger_manager->get_logger(logger_manager, CONFIG);
pthread_mutex_init(&(this->mutex), NULL);
return (&this->public);