aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/plugins/sql')
-rw-r--r--src/charon/plugins/sql/pool.c52
-rw-r--r--src/charon/plugins/sql/sql_attribute.c24
-rw-r--r--src/charon/plugins/sql/sql_attribute.h2
-rw-r--r--src/charon/plugins/sql/sql_config.c42
-rw-r--r--src/charon/plugins/sql/sql_config.h4
-rw-r--r--src/charon/plugins/sql/sql_cred.c20
-rw-r--r--src/charon/plugins/sql/sql_cred.h4
-rw-r--r--src/charon/plugins/sql/sql_logger.c20
-rw-r--r--src/charon/plugins/sql/sql_logger.h4
-rw-r--r--src/charon/plugins/sql/sql_plugin.c22
10 files changed, 97 insertions, 97 deletions
diff --git a/src/charon/plugins/sql/pool.c b/src/charon/plugins/sql/pool.c
index ef119c966..c029dea24 100644
--- a/src/charon/plugins/sql/pool.c
+++ b/src/charon/plugins/sql/pool.c
@@ -43,7 +43,7 @@ static u_int get_pool_size(chunk_t start, chunk_t end)
if (start.len < sizeof(u_int) || end.len < sizeof(u_int))
{
- return 0;
+ return 0;
}
start_ptr = (u_int*)(start.ptr + start.len - sizeof(u_int));
end_ptr = (u_int*)(end.ptr + end.len - sizeof(u_int));
@@ -103,7 +103,7 @@ static void status(void)
{
enumerator_t *pool, *lease;
bool found = FALSE;
-
+
pool = db->query(db, "SELECT id, name, start, end, timeout FROM pools",
DB_INT, DB_TEXT, DB_BLOB, DB_BLOB, DB_UINT);
if (pool)
@@ -112,7 +112,7 @@ static void status(void)
chunk_t start_chunk, end_chunk;
host_t *start, *end;
u_int id, timeout, online = 0, used = 0, size = 0;
-
+
while (pool->enumerate(pool, &id, &name,
&start_chunk, &end_chunk, &timeout))
{
@@ -122,7 +122,7 @@ static void status(void)
"end", "timeout", "size", "online", "usage");
found = TRUE;
}
-
+
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);
@@ -159,7 +159,7 @@ static void status(void)
lease->destroy(lease);
}
printf("%5d (%2d%%) ", used, used*100/size);
-
+
printf("\n");
DESTROY_IF(start);
DESTROY_IF(end);
@@ -180,7 +180,7 @@ static void add(char *name, host_t *start, host_t *end, int timeout)
{
chunk_t start_addr, end_addr, cur_addr;
u_int id, count;
-
+
start_addr = start->get_address(start);
end_addr = end->get_address(end);
cur_addr = chunk_clonea(start_addr);
@@ -224,7 +224,7 @@ static void add(char *name, host_t *start, host_t *end, int timeout)
db->execute(db, NULL, "END TRANSACTION");
}
printf("done.\n", count);
-
+
exit(0);
}
@@ -236,7 +236,7 @@ static void del(char *name)
enumerator_t *query;
u_int id;
bool found = FALSE;
-
+
query = db->query(db, "SELECT id FROM pools WHERE name = ?",
DB_TEXT, name, DB_UINT);
if (!query)
@@ -277,9 +277,9 @@ static void resize(char *name, host_t *end)
enumerator_t *query;
chunk_t old_addr, new_addr, cur_addr;
u_int id, count;
-
+
new_addr = end->get_address(end);
-
+
query = db->query(db, "SELECT id, end FROM pools WHERE name = ?",
DB_TEXT, name, DB_UINT, DB_BLOB);
if (!query || !query->enumerate(query, &id, &old_addr))
@@ -306,7 +306,7 @@ static void resize(char *name, host_t *end)
fprintf(stderr, "pool '%s' not found.\n", name);
exit(-1);
}
-
+
printf("allocating %d new addresses... ", count);
fflush(stdout);
if (db->get_driver(db) == DB_SQLITE)
@@ -326,7 +326,7 @@ static void resize(char *name, host_t *end)
db->execute(db, NULL, "END TRANSACTION");
}
printf("done.\n", count);
-
+
exit(0);
}
@@ -356,7 +356,7 @@ static enumerator_t *create_lease_query(char *filter)
[FIL_STATE] = "status",
NULL
};
-
+
/* if the filter string contains a distinguished name as a ID, we replace
* ", " by "/ " in order to not confuse the getsubopt parser */
pos = filter;
@@ -368,7 +368,7 @@ static enumerator_t *create_lease_query(char *filter)
}
pos++;
}
-
+
while (filter && *filter != '\0')
{
switch (getsubopt(&filter, token, &value))
@@ -493,7 +493,7 @@ static void leases(char *filter, bool utc)
host_t *address;
identification_t *identity;
bool found = FALSE;
-
+
query = create_lease_query(filter);
if (!query)
{
@@ -513,7 +513,7 @@ static void leases(char *filter, bool utc)
}
address = host_create_from_chunk(AF_UNSPEC, address_chunk, 0);
identity = identification_create_from_encoding(identity_type, identity_chunk);
-
+
printf("%-8s %-15H ", name, address);
if (released == 0)
{
@@ -531,7 +531,7 @@ static void leases(char *filter, bool utc)
{
printf("%-7s ", "expired");
}
-
+
printf(" %T ", &acquired, utc);
if (released)
{
@@ -564,7 +564,7 @@ static void leases(char *filter, bool utc)
static void purge(char *name)
{
int purged = 0;
-
+
purged = db->execute(db, NULL,
"DELETE FROM leases WHERE address IN ("
" SELECT id FROM addresses WHERE pool IN ("
@@ -595,7 +595,7 @@ static void cleanup(void)
static void dbg_stderr(int level, char *fmt, ...)
{
va_list args;
-
+
if (level <= 1)
{
va_start(args, fmt);
@@ -639,7 +639,7 @@ int main(int argc, char *argv[])
{
exit(SS_RC_INITIALIZATION_FAILED);
}
-
+
uri = lib->settings->get_str(lib->settings, "charon.plugins.sql.database", NULL);
if (!uri)
{
@@ -653,14 +653,14 @@ int main(int argc, char *argv[])
exit(SS_RC_INITIALIZATION_FAILED);
}
atexit(cleanup);
-
+
while (TRUE)
{
int c;
-
+
struct option long_opts[] = {
{ "help", no_argument, NULL, 'h' },
-
+
{ "utc", no_argument, NULL, 'u' },
{ "status", no_argument, NULL, 'w' },
{ "add", required_argument, NULL, 'a' },
@@ -668,14 +668,14 @@ int main(int argc, char *argv[])
{ "resize", required_argument, NULL, 'r' },
{ "leases", no_argument, NULL, 'l' },
{ "purge", required_argument, NULL, 'p' },
-
+
{ "start", required_argument, NULL, 's' },
{ "end", required_argument, NULL, 'e' },
{ "timeout", required_argument, NULL, 't' },
{ "filter", required_argument, NULL, 'f' },
{ 0,0,0,0 }
};
-
+
c = getopt_long(argc, argv, "", long_opts, NULL);
switch (c)
{
@@ -744,7 +744,7 @@ int main(int argc, char *argv[])
}
break;
}
-
+
switch (operation)
{
case OP_USAGE:
diff --git a/src/charon/plugins/sql/sql_attribute.c b/src/charon/plugins/sql/sql_attribute.c
index 77601e612..9045f7739 100644
--- a/src/charon/plugins/sql/sql_attribute.c
+++ b/src/charon/plugins/sql/sql_attribute.c
@@ -30,12 +30,12 @@ struct private_sql_attribute_t {
* public functions
*/
sql_attribute_t public;
-
+
/**
* database connection
*/
database_t *db;
-
+
/**
* wheter to record lease history in lease table
*/
@@ -49,13 +49,13 @@ static u_int get_identity(private_sql_attribute_t *this, identification_t *id)
{
enumerator_t *e;
u_int row;
-
+
/* look for peer identity in the identities table */
e = this->db->query(this->db,
"SELECT id FROM identities WHERE type = ? AND data = ?",
DB_INT, id->get_type(id), DB_BLOB, id->get_encoding(id),
DB_UINT);
-
+
if (e && e->enumerate(e, &row))
{
e->destroy(e);
@@ -111,7 +111,7 @@ static host_t* check_lease(private_sql_attribute_t *this, char *name,
if (!e || !e->enumerate(e, &id, &address))
{
DESTROY_IF(e);
- break;
+ break;
}
address = chunk_clonea(address);
e->destroy(e);
@@ -172,11 +172,11 @@ static host_t* get_lease(private_sql_attribute_t *this, char *name,
if (!e || !e->enumerate(e, &id, &address))
{
DESTROY_IF(e);
- break;
+ break;
}
address = chunk_clonea(address);
e->destroy(e);
-
+
if (timeout)
{
hits = this->db->execute(this->db, NULL,
@@ -290,12 +290,12 @@ static bool release_address(private_sql_attribute_t *this,
enumerator_t *enumerator;
bool found = FALSE;
time_t now = time(NULL);
-
+
enumerator = enumerator_create_token(name, ",", " ");
while (enumerator->enumerate(enumerator, &name))
{
u_int pool, timeout;
-
+
pool = get_pool(this, name, &timeout);
if (pool)
{
@@ -337,16 +337,16 @@ sql_attribute_t *sql_attribute_create(database_t *db)
{
private_sql_attribute_t *this = malloc_thing(private_sql_attribute_t);
time_t now = time(NULL);
-
+
this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *, host_t *))acquire_address;
this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))release_address;
this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, identification_t *id))enumerator_create_empty;
this->public.destroy = (void(*)(sql_attribute_t*))destroy;
-
+
this->db = db;
this->history = lib->settings->get_bool(lib->settings,
"charon.plugins.sql.lease_history", TRUE);
-
+
/* close any "online" leases in the case we crashed */
if (this->history)
{
diff --git a/src/charon/plugins/sql/sql_attribute.h b/src/charon/plugins/sql/sql_attribute.h
index 23700dea9..6d4958d32 100644
--- a/src/charon/plugins/sql/sql_attribute.h
+++ b/src/charon/plugins/sql/sql_attribute.h
@@ -34,7 +34,7 @@ struct sql_attribute_t {
* Implements attribute provider interface
*/
attribute_provider_t provider;
-
+
/**
* Destroy a sql_attribute instance.
*/
diff --git a/src/charon/plugins/sql/sql_config.c b/src/charon/plugins/sql/sql_config.c
index 67b5c3b64..7c76c572d 100644
--- a/src/charon/plugins/sql/sql_config.c
+++ b/src/charon/plugins/sql/sql_config.c
@@ -30,7 +30,7 @@ struct private_sql_config_t {
* Public part
*/
sql_config_t public;
-
+
/**
* database connection
*/
@@ -58,7 +58,7 @@ static traffic_selector_t *build_traffic_selector(private_sql_config_t *this,
TS_LOCAL_DYNAMIC = 2,
TS_REMOTE_DYNAMIC = 3,
} kind;
-
+
while (e->enumerate(e, &kind, &type, &protocol,
&start_addr, &end_addr, &start_port, &end_port))
{
@@ -99,7 +99,7 @@ static void add_traffic_selectors(private_sql_config_t *this,
enumerator_t *e;
traffic_selector_t *ts;
bool local;
-
+
e = this->db->query(this->db,
"SELECT kind, type, protocol, "
"start_addr, end_addr, start_port, end_port "
@@ -126,8 +126,8 @@ static child_cfg_t *build_child_cfg(private_sql_config_t *this, enumerator_t *e)
int id, lifetime, rekeytime, jitter, hostaccess, mode, dpd, close, ipcomp;
char *name, *updown;
child_cfg_t *child_cfg;
-
- if (e->enumerate(e, &id, &name, &lifetime, &rekeytime, &jitter,
+
+ if (e->enumerate(e, &id, &name, &lifetime, &rekeytime, &jitter,
&updown, &hostaccess, &mode, &dpd, &close, &ipcomp))
{
lifetime_cfg_t lft = {
@@ -150,7 +150,7 @@ static void add_child_cfgs(private_sql_config_t *this, peer_cfg_t *peer, int id)
{
enumerator_t *e;
child_cfg_t *child_cfg;
-
+
e = this->db->query(this->db,
"SELECT id, name, lifetime, rekeytime, jitter, "
"updown, hostaccess, mode, dpd_action, close_action, ipcomp "
@@ -177,11 +177,11 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
{
int certreq, force_encap;
char *local, *remote;
-
+
while (e->enumerate(e, &certreq, &force_encap, &local, &remote))
{
ike_cfg_t *ike_cfg;
-
+
ike_cfg = ike_cfg_create(certreq, force_encap, local, remote);
/* TODO: read proposal from db */
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
@@ -197,7 +197,7 @@ static ike_cfg_t* get_ike_cfg_by_id(private_sql_config_t *this, int id)
{
enumerator_t *e;
ike_cfg_t *ike_cfg = NULL;
-
+
e = this->db->query(this->db,
"SELECT certreq, force_encap, local, remote "
"FROM ike_configs WHERE id = ?",
@@ -218,7 +218,7 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id)
{
enumerator_t *e;
peer_cfg_t *peer_cfg = NULL;
-
+
e = this->db->query(this->db,
"SELECT c.id, name, ike_cfg, l.type, l.data, r.type, r.data, "
"cert_policy, uniqueid, auth_method, eap_type, eap_vendor, "
@@ -232,8 +232,8 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id)
"WHERE id = ?",
DB_INT, id,
DB_INT, DB_TEXT, DB_INT, DB_INT, DB_BLOB, DB_INT, DB_BLOB,
- DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
- DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
+ DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
+ DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, DB_INT,
DB_INT, DB_TEXT, DB_TEXT,
DB_INT, DB_INT, DB_INT, DB_BLOB);
if (e)
@@ -256,11 +256,11 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
mediation, mediated_by, p_type;
chunk_t l_data, r_data, p_data;
char *name, *virtual, *pool;
-
+
while (e->enumerate(e,
&id, &name, &ike_cfg, &l_type, &l_data, &r_type, &r_data,
&cert_policy, &uniqueid, &auth_method, &eap_type, &eap_vendor,
- &keyingtries, &rekeytime, &reauthtime, &jitter, &overtime, &mobike,
+ &keyingtries, &rekeytime, &reauthtime, &jitter, &overtime, &mobike,
&dpd_delay, &virtual, &pool,
&mediation, &mediated_by, &p_type, &p_data))
{
@@ -269,7 +269,7 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e,
ike_cfg_t *ike;
host_t *vip = NULL;
auth_cfg_t *auth;
-
+
local_id = identification_create_from_encoding(l_type, l_data);
remote_id = identification_create_from_encoding(r_type, r_data);
if ((me && !me->matches(me, local_id)) ||
@@ -331,7 +331,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_sql_config_t *this, char *name)
{
enumerator_t *e;
peer_cfg_t *peer_cfg = NULL;
-
+
e = this->db->query(this->db,
"SELECT c.id, name, ike_cfg, l.type, l.data, r.type, r.data, "
"cert_policy, uniqueid, auth_method, eap_type, eap_vendor, "
@@ -404,14 +404,14 @@ static enumerator_t* create_ike_cfg_enumerator(private_sql_config_t *this,
host_t *me, host_t *other)
{
ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
-
+
e->this = this;
e->me = me;
e->other = other;
e->current = NULL;
e->public.enumerate = (void*)ike_enumerator_enumerate;
e->public.destroy = (void*)ike_enumerator_destroy;
-
+
e->inner = this->db->query(this->db,
"SELECT certreq, force_encap, local, remote "
"FROM ike_configs",
@@ -473,7 +473,7 @@ static enumerator_t* create_peer_cfg_enumerator(private_sql_config_t *this,
identification_t *other)
{
peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
-
+
e->this = this;
e->me = me;
e->other = other;
@@ -526,9 +526,9 @@ sql_config_t *sql_config_create(database_t *db)
this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
this->public.destroy = (void(*)(sql_config_t*))destroy;
-
+
this->db = db;
-
+
return &this->public;
}
diff --git a/src/charon/plugins/sql/sql_config.h b/src/charon/plugins/sql/sql_config.h
index abc6ef382..700d00a97 100644
--- a/src/charon/plugins/sql/sql_config.h
+++ b/src/charon/plugins/sql/sql_config.h
@@ -35,11 +35,11 @@ struct sql_config_t {
* Implements backend_t interface
*/
backend_t backend;
-
+
/**
* Destry the backend.
*/
- void (*destroy)(sql_config_t *this);
+ void (*destroy)(sql_config_t *this);
};
/**
diff --git a/src/charon/plugins/sql/sql_cred.c b/src/charon/plugins/sql/sql_cred.c
index f8b7a35c1..12f4ab045 100644
--- a/src/charon/plugins/sql/sql_cred.c
+++ b/src/charon/plugins/sql/sql_cred.c
@@ -30,7 +30,7 @@ struct private_sql_cred_t {
* Public part
*/
sql_cred_t public;
-
+
/**
* database connection
*/
@@ -92,7 +92,7 @@ static enumerator_t* create_private_enumerator(private_sql_cred_t *this,
identification_t *id)
{
private_enumerator_t *e;
-
+
e = malloc_thing(private_enumerator_t);
e->current = NULL;
e->public.enumerate = (void*)private_enumerator_enumerate;
@@ -178,7 +178,7 @@ static enumerator_t* create_cert_enumerator(private_sql_cred_t *this,
identification_t *id, bool trusted)
{
cert_enumerator_t *e;
-
+
e = malloc_thing(cert_enumerator_t);
e->current = NULL;
e->public.enumerate = (void*)cert_enumerator_enumerate;
@@ -275,11 +275,11 @@ static void shared_enumerator_destroy(shared_enumerator_t *this)
* Implementation of credential_set_t.create_shared_enumerator.
*/
static enumerator_t* create_shared_enumerator(private_sql_cred_t *this,
- shared_key_type_t type,
+ shared_key_type_t type,
identification_t *me, identification_t *other)
{
shared_enumerator_t *e;
-
+
e = malloc_thing(shared_enumerator_t);
e->me = me;
e->other = other;
@@ -306,12 +306,12 @@ static enumerator_t* create_shared_enumerator(private_sql_cred_t *this,
DB_INT, me->get_type(me), DB_BLOB, me->get_encoding(me),
DB_INT, other->get_type(other), DB_BLOB, other->get_encoding(other),
DB_INT, type == SHARED_ANY, DB_INT, type,
- DB_INT, DB_BLOB);
+ DB_INT, DB_BLOB);
}
else
{
identification_t *id = me ? me : other;
-
+
e->inner = this->db->query(this->db,
"SELECT s.type, s.data FROM shared_secrets AS s "
"JOIN shared_secret_identity AS si ON s.id = si.shared_secret "
@@ -350,16 +350,16 @@ static void destroy(private_sql_cred_t *this)
sql_cred_t *sql_cred_create(database_t *db)
{
private_sql_cred_t *this = malloc_thing(private_sql_cred_t);
-
+
this->public.set.create_private_enumerator = (void*)create_private_enumerator;
this->public.set.create_cert_enumerator = (void*)create_cert_enumerator;
this->public.set.create_shared_enumerator = (void*)create_shared_enumerator;
this->public.set.create_cdp_enumerator = (void*)return_null;
this->public.set.cache_cert = (void*)cache_cert;
this->public.destroy = (void(*)(sql_cred_t*))destroy;
-
+
this->db = db;
-
+
return &this->public;
}
diff --git a/src/charon/plugins/sql/sql_cred.h b/src/charon/plugins/sql/sql_cred.h
index 2a9a96df1..7f387398e 100644
--- a/src/charon/plugins/sql/sql_cred.h
+++ b/src/charon/plugins/sql/sql_cred.h
@@ -35,11 +35,11 @@ struct sql_cred_t {
* Implements credential_set_t interface
*/
credential_set_t set;
-
+
/**
* Destry the backend.
*/
- void (*destroy)(sql_cred_t *this);
+ void (*destroy)(sql_cred_t *this);
};
/**
diff --git a/src/charon/plugins/sql/sql_logger.c b/src/charon/plugins/sql/sql_logger.c
index 20d42662b..d350c4c3d 100644
--- a/src/charon/plugins/sql/sql_logger.c
+++ b/src/charon/plugins/sql/sql_logger.c
@@ -30,17 +30,17 @@ struct private_sql_logger_t {
* Public part
*/
sql_logger_t public;
-
+
/**
* database connection
*/
database_t *db;
-
+
/**
* logging level
*/
int level;
-
+
/**
* avoid recursive logging
*/
@@ -67,7 +67,7 @@ static bool log_(private_sql_logger_t *this, debug_t group, level_t level,
identification_t *local_id, *remote_id;
u_int64_t ispi, rspi;
ike_sa_id_t *id;
-
+
id = ike_sa->get_id(ike_sa);
ispi = id->get_initiator_spi(id);
rspi = id->get_responder_spi(id);
@@ -86,9 +86,9 @@ static bool log_(private_sql_logger_t *this, debug_t group, level_t level,
remote_id = ike_sa->get_other_id(ike_sa);
local_host = ike_sa->get_my_host(ike_sa);
remote_host = ike_sa->get_other_host(ike_sa);
-
+
vsnprintf(buffer, sizeof(buffer), format, args);
-
+
this->db->execute(this->db, NULL, "REPLACE INTO ike_sas ("
"local_spi, remote_spi, id, initiator, "
"local_id_type, local_id_data, "
@@ -129,17 +129,17 @@ static void destroy(private_sql_logger_t *this)
sql_logger_t *sql_logger_create(database_t *db)
{
private_sql_logger_t *this = malloc_thing(private_sql_logger_t);
-
+
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;
this->recursive = FALSE;
-
+
this->level = lib->settings->get_int(lib->settings,
"charon.plugins.sql.loglevel", -1);
-
+
return &this->public;
}
diff --git a/src/charon/plugins/sql/sql_logger.h b/src/charon/plugins/sql/sql_logger.h
index 3636c2293..a933705da 100644
--- a/src/charon/plugins/sql/sql_logger.h
+++ b/src/charon/plugins/sql/sql_logger.h
@@ -35,11 +35,11 @@ struct sql_logger_t {
* Implements bus_listener_t interface
*/
listener_t listener;
-
+
/**
* Destry the backend.
*/
- void (*destroy)(sql_logger_t *this);
+ void (*destroy)(sql_logger_t *this);
};
/**
diff --git a/src/charon/plugins/sql/sql_plugin.c b/src/charon/plugins/sql/sql_plugin.c
index e5a4afd1d..65691cc00 100644
--- a/src/charon/plugins/sql/sql_plugin.c
+++ b/src/charon/plugins/sql/sql_plugin.c
@@ -32,27 +32,27 @@ struct private_sql_plugin_t {
* implements plugin interface
*/
sql_plugin_t public;
-
+
/**
* database connection instance
*/
database_t *db;
-
+
/**
* configuration backend
*/
sql_config_t *config;
-
+
/**
* credential set
*/
sql_cred_t *cred;
-
+
/**
* CFG attributes
*/
sql_attribute_t *attribute;
-
+
/**
* bus listener/logger
*/
@@ -83,18 +83,18 @@ plugin_t *plugin_create()
{
char *uri;
private_sql_plugin_t *this;
-
+
uri = lib->settings->get_str(lib->settings, "charon.plugins.sql.database", NULL);
if (!uri)
{
DBG1(DBG_CFG, "sql plugin: database URI not set");
return NULL;
}
-
+
this = malloc_thing(private_sql_plugin_t);
-
+
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
+
this->db = lib->db->create(lib->db, uri);
if (!this->db)
{
@@ -106,12 +106,12 @@ plugin_t *plugin_create()
this->cred = sql_cred_create(this->db);
this->attribute = sql_attribute_create(this->db);
this->logger = sql_logger_create(this->db);
-
+
charon->backends->add_backend(charon->backends, &this->config->backend);
charon->credentials->add_set(charon->credentials, &this->cred->set);
charon->attributes->add_provider(charon->attributes, &this->attribute->provider);
charon->bus->add_listener(charon->bus, &this->logger->listener);
-
+
return &this->public.plugin;
}