2007-09-11 15:22:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Martin Willi
|
2018-05-23 14:04:50 +00:00
|
|
|
* HSR Hochschule fuer Technik Rapperswil
|
2007-09-11 15:22:02 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-07-17 09:50:45 +00:00
|
|
|
#include <fast_dispatcher.h>
|
2012-10-16 14:03:21 +00:00
|
|
|
#include <utils/debug.h>
|
2007-09-11 15:22:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "manager.h"
|
2008-03-13 14:14:44 +00:00
|
|
|
#include "storage.h"
|
2007-09-11 15:22:02 +00:00
|
|
|
#include "controller/auth_controller.h"
|
2007-11-13 11:58:28 +00:00
|
|
|
#include "controller/ikesa_controller.h"
|
2007-09-11 15:22:02 +00:00
|
|
|
#include "controller/gateway_controller.h"
|
2007-11-12 15:09:11 +00:00
|
|
|
#include "controller/control_controller.h"
|
2007-11-12 18:34:50 +00:00
|
|
|
#include "controller/config_controller.h"
|
2007-09-11 15:22:02 +00:00
|
|
|
|
|
|
|
int main (int arc, char *argv[])
|
|
|
|
{
|
2013-07-17 09:50:45 +00:00
|
|
|
fast_dispatcher_t *dispatcher;
|
2008-03-13 14:14:44 +00:00
|
|
|
storage_t *storage;
|
2008-03-28 12:41:05 +00:00
|
|
|
char *socket;
|
|
|
|
char *database;
|
|
|
|
bool debug;
|
|
|
|
int threads, timeout;
|
2008-03-13 14:14:44 +00:00
|
|
|
|
2014-01-22 10:50:39 +00:00
|
|
|
library_init(NULL, "manager");
|
2013-06-28 08:44:15 +00:00
|
|
|
if (!lib->plugins->load(lib->plugins,
|
2009-09-01 14:20:45 +00:00
|
|
|
lib->settings->get_str(lib->settings, "manager.load", PLUGINS)))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-03-28 12:41:05 +00:00
|
|
|
socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
|
|
|
|
debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
|
2008-09-04 16:19:46 +00:00
|
|
|
timeout = lib->settings->get_time(lib->settings, "manager.timeout", 900);
|
2008-03-28 12:41:05 +00:00
|
|
|
threads = lib->settings->get_int(lib->settings, "manager.threads", 10);
|
|
|
|
database = lib->settings->get_str(lib->settings, "manager.database", NULL);
|
|
|
|
if (!database)
|
|
|
|
{
|
2010-03-31 15:28:46 +00:00
|
|
|
DBG1(DBG_LIB, "database URI undefined, set manager.database "
|
|
|
|
"in strongswan.conf");
|
2018-09-17 14:30:51 +00:00
|
|
|
return 1;
|
2008-03-28 12:41:05 +00:00
|
|
|
}
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-03-28 12:41:05 +00:00
|
|
|
storage = storage_create(database);
|
2008-03-13 14:14:44 +00:00
|
|
|
if (storage == NULL)
|
2007-09-11 15:22:02 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2013-07-17 09:50:45 +00:00
|
|
|
dispatcher = fast_dispatcher_create(socket, debug, timeout,
|
|
|
|
(fast_context_constructor_t)manager_create, storage);
|
2007-11-13 11:58:28 +00:00
|
|
|
dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
|
2007-09-11 15:22:02 +00:00
|
|
|
dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
|
2007-09-14 14:07:30 +00:00
|
|
|
dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
|
2007-11-12 15:09:11 +00:00
|
|
|
dispatcher->add_controller(dispatcher, control_controller_create, NULL);
|
2007-11-12 18:34:50 +00:00
|
|
|
dispatcher->add_controller(dispatcher, config_controller_create, NULL);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-03-28 12:41:05 +00:00
|
|
|
dispatcher->run(dispatcher, threads);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2007-09-11 15:22:02 +00:00
|
|
|
dispatcher->waitsignal(dispatcher);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2007-09-11 15:22:02 +00:00
|
|
|
dispatcher->destroy(dispatcher);
|
2008-03-13 14:14:44 +00:00
|
|
|
storage->destroy(storage);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-03-13 14:14:44 +00:00
|
|
|
library_deinit();
|
2007-09-11 15:22:02 +00:00
|
|
|
|
2009-09-04 12:50:23 +00:00
|
|
|
return 0;
|
2007-09-11 15:22:02 +00:00
|
|
|
}
|