vici: Add backend providing in-memory connections

This commit is contained in:
Martin Willi
2014-05-07 14:13:36 +02:00
parent dd5ce0a97a
commit b3d8bd8d26
4 changed files with 1607 additions and 0 deletions
+1
View File
@@ -20,6 +20,7 @@ libstrongswan_vici_la_SOURCES = \
vici_dispatcher.h vici_dispatcher.c \
vici_query.h vici_query.c \
vici_control.h vici_control.c \
vici_config.h vici_config.c \
vici_plugin.h vici_plugin.c
libstrongswan_vici_la_LDFLAGS = -module -avoid-version
File diff suppressed because it is too large Load Diff
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 Martin Willi
* Copyright (C) 2014 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup vici_config vici_config
* @{ @ingroup vici
*/
#ifndef VICI_CONFIG_H_
#define VICI_CONFIG_H_
#include "vici_dispatcher.h"
#include <config/backend.h>
typedef struct vici_config_t vici_config_t;
/**
* In-memory configuration backend, managed by VICI.
*/
struct vici_config_t {
/**
* Implements a configuraiton backend.
*/
backend_t backend;
/**
* Destroy a vici_config_t.
*/
void (*destroy)(vici_config_t *this);
};
/**
* Create a vici_config instance.
*
* @param dispatcher dispatcher to receive requests from
* @return config backend
*/
vici_config_t *vici_config_create(vici_dispatcher_t *dispatcher);
#endif /** VICI_CONFIG_H_ @}*/
+14
View File
@@ -17,6 +17,7 @@
#include "vici_dispatcher.h"
#include "vici_query.h"
#include "vici_control.h"
#include "vici_config.h"
#include <library.h>
#include <daemon.h>
@@ -47,6 +48,11 @@ struct private_vici_plugin_t {
* Control commands
*/
vici_control_t *control;
/**
* Configuration backend
*/
vici_config_t *config;
};
METHOD(plugin_t, get_name, char*,
@@ -72,12 +78,20 @@ static bool register_vici(private_vici_plugin_t *this,
{
this->query = vici_query_create(this->dispatcher);
this->control = vici_control_create(this->dispatcher);
this->config = vici_config_create(this->dispatcher);
charon->backends->add_backend(charon->backends,
&this->config->backend);
return TRUE;
}
return FALSE;
}
else
{
charon->backends->remove_backend(charon->backends,
&this->config->backend);
this->config->destroy(this->config);
this->control->destroy(this->control);
this->query->destroy(this->query);
this->dispatcher->destroy(this->dispatcher);