- show connection templates in status & statusall

- don't complain on termination of IKEv1 connections
This commit is contained in:
Martin Willi
2006-05-23 13:25:57 +00:00
parent 3572b3b689
commit 8b5be79d83
6 changed files with 106 additions and 17 deletions
@@ -25,6 +25,7 @@
#include <types.h>
#include <config/connections/connection.h>
#include <utils/logger.h>
typedef struct connection_store_t connection_store_t;
@@ -101,6 +102,23 @@ struct connection_store_t {
*/
status_t (*add_connection) (connection_store_t *this, connection_t *connection);
/**
* @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
*
* @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
*/
void (*log_connections) (connection_store_t *this, logger_t *logger, char *name);
/**
* @brief Destroys a connection_store_t object.
*
@@ -207,6 +207,42 @@ static status_t add_connection(private_local_connection_store_t *this, connectio
return SUCCESS;
}
/**
* Implementation of connection_store_t.log_connections.
*/
void log_connections(private_local_connection_store_t *this, logger_t *logger, char *name)
{
iterator_t *iterator;
connection_t *current, *found = NULL;
if (logger == NULL)
{
logger = this->logger;
}
logger->log(logger, CONTROL, "templates:");
iterator = this->connections->create_iterator(this->connections, TRUE);
while (iterator->has_next(iterator))
{
iterator->current(iterator, (void**)&current);
if (!name || strcmp(name, current->get_name(current)) == 0)
{
identification_t *my_id, *other_id;
host_t *my_host, *other_host;
my_id = current->get_my_id(current);
other_id = current->get_other_id(current);
my_host = current->get_my_host(current);
other_host = current->get_other_host(current);
logger->log(logger, CONTROL, " \"%s\": %s[%s]...%s[%s]",
current->get_name(current),
my_host->get_address(my_host), my_id->get_string(my_id),
other_host->get_address(other_host), other_id->get_string(other_id));
}
}
iterator->destroy(iterator);
}
/**
* Implementation of connection_store_t.destroy.
*/
@@ -233,6 +269,7 @@ local_connection_store_t * local_connection_store_create(void)
this->public.connection_store.get_connection_by_ids = (connection_t*(*)(connection_store_t*,identification_t*,identification_t*))get_connection_by_ids;
this->public.connection_store.get_connection_by_name = (connection_t*(*)(connection_store_t*,char*))get_connection_by_name;
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.destroy = (void(*)(connection_store_t*))destroy;
/* private variables */