2008-06-17 14:17:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Thomas Kallenberg
|
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "uci_plugin.h"
|
|
|
|
#include "uci_config.h"
|
|
|
|
#include "uci_creds.h"
|
2008-07-18 10:34:44 +00:00
|
|
|
#include "uci_control.h"
|
2008-06-17 14:17:51 +00:00
|
|
|
|
|
|
|
#include <daemon.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UCI package name to use for lookups
|
|
|
|
*/
|
|
|
|
#define UCI_PACKAGE "strongswan"
|
|
|
|
|
|
|
|
typedef struct private_uci_plugin_t private_uci_plugin_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* private data of uci plugin
|
|
|
|
*/
|
|
|
|
struct private_uci_plugin_t {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* implements plugin interface
|
|
|
|
*/
|
|
|
|
uci_plugin_t public;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
/**
|
|
|
|
* UCI configuration backend
|
|
|
|
*/
|
|
|
|
uci_config_t *config;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
/**
|
|
|
|
* UCI credential set implementation
|
|
|
|
*/
|
|
|
|
uci_creds_t *creds;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
/**
|
|
|
|
* UCI parser wrapper
|
|
|
|
*/
|
|
|
|
uci_parser_t *parser;
|
2008-07-18 10:34:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UCI control interface
|
|
|
|
*/
|
|
|
|
uci_control_t *control;
|
2008-06-17 14:17:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of plugin_t.destroy
|
|
|
|
*/
|
|
|
|
static void destroy(private_uci_plugin_t *this)
|
|
|
|
{
|
|
|
|
charon->backends->remove_backend(charon->backends, &this->config->backend);
|
|
|
|
charon->credentials->remove_set(charon->credentials, &this->creds->credential_set);
|
|
|
|
this->config->destroy(this->config);
|
|
|
|
this->creds->destroy(this->creds);
|
|
|
|
this->parser->destroy(this->parser);
|
2008-07-18 10:34:44 +00:00
|
|
|
this->control->destroy(this->control);
|
2008-06-17 14:17:51 +00:00
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* see header file
|
|
|
|
*/
|
|
|
|
plugin_t *plugin_create()
|
|
|
|
{
|
|
|
|
private_uci_plugin_t *this = malloc_thing(private_uci_plugin_t);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
this->parser = uci_parser_create(UCI_PACKAGE);
|
|
|
|
this->config = uci_config_create(this->parser);
|
|
|
|
this->creds = uci_creds_create(this->parser);
|
2008-07-18 10:34:44 +00:00
|
|
|
this->control = uci_control_create();
|
2008-06-17 14:17:51 +00:00
|
|
|
charon->backends->add_backend(charon->backends, &this->config->backend);
|
|
|
|
charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-06-17 14:17:51 +00:00
|
|
|
return &this->public.plugin;
|
|
|
|
}
|
|
|
|
|