summaryrefslogtreecommitdiff
path: root/src/charon/plugins/sql
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2008-12-05 16:44:41 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2008-12-05 16:44:41 +0000
commit2db1ef4ac8928944958712923b9c89c263a337d2 (patch)
tree700043d9d97b7e7ba344b448918728af0a8be8d1 /src/charon/plugins/sql
parent5dc75410286b0e3a16845b44dd696ba0f40df573 (diff)
downloadvyos-strongswan-2db1ef4ac8928944958712923b9c89c263a337d2.tar.gz
vyos-strongswan-2db1ef4ac8928944958712923b9c89c263a337d2.zip
- Updated to new upstream.
Diffstat (limited to 'src/charon/plugins/sql')
-rw-r--r--src/charon/plugins/sql/pool.c14
-rw-r--r--src/charon/plugins/sql/sql_attribute.c22
-rw-r--r--src/charon/plugins/sql/sql_logger.c13
-rw-r--r--src/charon/plugins/sql/sql_logger.h2
4 files changed, 14 insertions, 37 deletions
diff --git a/src/charon/plugins/sql/pool.c b/src/charon/plugins/sql/pool.c
index b3ad72ab2..8f5dc54dd 100644
--- a/src/charon/plugins/sql/pool.c
+++ b/src/charon/plugins/sql/pool.c
@@ -36,14 +36,6 @@ database_t *db;
host_t *start = NULL, *end = NULL;
/**
- * create a host from a blob
- */
-static host_t *host_create_from_blob(chunk_t blob)
-{
- return host_create_from_chunk(blob.len == 4 ? AF_INET : AF_INET6, blob, 0);
-}
-
-/**
* calculate the size of a pool using start and end address chunk
*/
static u_int get_pool_size(chunk_t start, chunk_t end)
@@ -132,8 +124,8 @@ static void status(void)
found = TRUE;
}
- start = host_create_from_blob(start_chunk);
- end = host_create_from_blob(end_chunk);
+ start = host_create_from_chunk(AF_UNSPEC, start_chunk, 0);
+ end = host_create_from_chunk(AF_UNSPEC, end_chunk, 0);
size = get_pool_size(start_chunk, end_chunk);
printf("%8s %15H %15H ", name, start, end);
if (timeout)
@@ -541,7 +533,7 @@ static void leases(char *filter, bool utc)
printf("%-8s %-15s %-7s %-*s %-*s %s\n",
"name", "address", "status", len, "start", len, "end", "identity");
}
- address = host_create_from_blob(address_chunk);
+ address = host_create_from_chunk(AF_UNSPEC, address_chunk, 0);
identity = identification_create_from_encoding(identity_type, identity_chunk);
printf("%-8s %-15H ", name, address);
diff --git a/src/charon/plugins/sql/sql_attribute.c b/src/charon/plugins/sql/sql_attribute.c
index 1e5c28966..486a432ca 100644
--- a/src/charon/plugins/sql/sql_attribute.c
+++ b/src/charon/plugins/sql/sql_attribute.c
@@ -17,6 +17,8 @@
#include "sql_attribute.h"
+#include <time.h>
+
#include <daemon.h>
typedef struct private_sql_attribute_t private_sql_attribute_t;
@@ -43,22 +45,6 @@ struct private_sql_attribute_t {
};
/**
- * read a host_t address from the addresses table
- */
-static host_t *host_from_chunk(chunk_t chunk)
-{
- switch (chunk.len)
- {
- case 4:
- return host_create_from_chunk(AF_INET, chunk, 0);
- case 16:
- return host_create_from_chunk(AF_INET6, chunk, 0);
- default:
- return NULL;
- }
-}
-
-/**
* lookup/insert an identity
*/
static u_int get_identity(private_sql_attribute_t *this, identification_t *id)
@@ -143,7 +129,7 @@ static host_t *get_address(private_sql_attribute_t *this, char *name,
"WHERE id = ? AND identity = ? AND released != 0",
DB_UINT, now, DB_UINT, id, DB_UINT, identity) > 0)
{
- host = host_from_chunk(address);
+ host = host_create_from_chunk(AF_UNSPEC, address, 0);
if (host)
{
DBG1(DBG_CFG, "acquired existing lease "
@@ -175,7 +161,7 @@ static host_t *get_address(private_sql_attribute_t *this, char *name,
DB_UINT, now, DB_UINT, identity,
DB_UINT, id, DB_UINT, now - timeout) > 0)
{
- host = host_from_chunk(address);
+ host = host_create_from_chunk(AF_UNSPEC, address, 0);
if (host)
{
DBG1(DBG_CFG, "acquired new lease "
diff --git a/src/charon/plugins/sql/sql_logger.c b/src/charon/plugins/sql/sql_logger.c
index 6a87f9f1d..4cbaaa3e6 100644
--- a/src/charon/plugins/sql/sql_logger.c
+++ b/src/charon/plugins/sql/sql_logger.c
@@ -49,13 +49,11 @@ struct private_sql_logger_t {
bool recursive;
};
-
/**
- * Implementation of bus_listener_t.signal.
+ * Implementation of bus_listener_t.log.
*/
-static bool signal_(private_sql_logger_t *this, signal_t signal, level_t level,
- int thread, ike_sa_t* ike_sa, void *data,
- char *format, va_list args)
+static bool log_(private_sql_logger_t *this, debug_t group, level_t level,
+ int thread, ike_sa_t* ike_sa, char *format, va_list args)
{
if (this->recursive)
{
@@ -111,7 +109,7 @@ static bool signal_(private_sql_logger_t *this, signal_t signal, level_t level,
DB_BLOB, remote_host->get_address(remote_host));
this->db->execute(this->db, NULL, "INSERT INTO logs ("
"local_spi, signal, level, msg) VALUES (?, ?, ?, ?)",
- DB_BLOB, local_spi, DB_INT, signal, DB_INT, level,
+ DB_BLOB, local_spi, DB_INT, group, DB_INT, level,
DB_TEXT, buffer);
}
this->recursive = FALSE;
@@ -134,7 +132,8 @@ sql_logger_t *sql_logger_create(database_t *db)
{
private_sql_logger_t *this = malloc_thing(private_sql_logger_t);
- this->public.listener.signal = (bool(*)(bus_listener_t*,signal_t,level_t,int,ike_sa_t*,void*,char*,va_list))signal_;
+ memset(&this->public.listener, 0, sizeof(listener_t));
+ this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
this->public.destroy = (void(*)(sql_logger_t*))destroy;
this->db = db;
diff --git a/src/charon/plugins/sql/sql_logger.h b/src/charon/plugins/sql/sql_logger.h
index 30507bcaf..a2c6fb5e9 100644
--- a/src/charon/plugins/sql/sql_logger.h
+++ b/src/charon/plugins/sql/sql_logger.h
@@ -36,7 +36,7 @@ struct sql_logger_t {
/**
* Implements bus_listener_t interface
*/
- bus_listener_t listener;
+ listener_t listener;
/**
* Destry the backend.