Annotation of embedaddon/strongswan/src/manager/main.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2007 Martin Willi
                      3:  * HSR Hochschule fuer Technik Rapperswil
                      4:  *
                      5:  * This program is free software; you can redistribute it and/or modify it
                      6:  * under the terms of the GNU General Public License as published by the
                      7:  * Free Software Foundation; either version 2 of the License, or (at your
                      8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
                      9:  *
                     10:  * This program is distributed in the hope that it will be useful, but
                     11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
                     13:  * for more details.
                     14:  */
                     15: 
                     16: #include <fast_dispatcher.h>
                     17: #include <utils/debug.h>
                     18: #include <stdio.h>
                     19: 
                     20: #include "manager.h"
                     21: #include "storage.h"
                     22: #include "controller/auth_controller.h"
                     23: #include "controller/ikesa_controller.h"
                     24: #include "controller/gateway_controller.h"
                     25: #include "controller/control_controller.h"
                     26: #include "controller/config_controller.h"
                     27: 
                     28: int main (int arc, char *argv[])
                     29: {
                     30:        fast_dispatcher_t *dispatcher;
                     31:        storage_t *storage;
                     32:        char *socket;
                     33:        char *database;
                     34:        bool debug;
                     35:        int threads, timeout;
                     36: 
                     37:        library_init(NULL, "manager");
                     38:        if (!lib->plugins->load(lib->plugins,
                     39:                        lib->settings->get_str(lib->settings, "manager.load", PLUGINS)))
                     40:        {
                     41:                return 1;
                     42:        }
                     43: 
                     44:        socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
                     45:        debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
                     46:        timeout = lib->settings->get_time(lib->settings, "manager.timeout", 900);
                     47:        threads = lib->settings->get_int(lib->settings, "manager.threads", 10);
                     48:        database = lib->settings->get_str(lib->settings, "manager.database", NULL);
                     49:        if (!database)
                     50:        {
                     51:                DBG1(DBG_LIB, "database URI undefined, set manager.database "
                     52:                         "in strongswan.conf");
                     53:                return 1;
                     54:        }
                     55: 
                     56:        storage = storage_create(database);
                     57:        if (storage == NULL)
                     58:        {
                     59:                return 1;
                     60:        }
                     61: 
                     62:        dispatcher = fast_dispatcher_create(socket, debug, timeout,
                     63:                                                (fast_context_constructor_t)manager_create, storage);
                     64:        dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
                     65:        dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
                     66:        dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
                     67:        dispatcher->add_controller(dispatcher, control_controller_create, NULL);
                     68:        dispatcher->add_controller(dispatcher, config_controller_create, NULL);
                     69: 
                     70:        dispatcher->run(dispatcher, threads);
                     71: 
                     72:        dispatcher->waitsignal(dispatcher);
                     73: 
                     74:        dispatcher->destroy(dispatcher);
                     75:        storage->destroy(storage);
                     76: 
                     77:        library_deinit();
                     78: 
                     79:        return 0;
                     80: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>