added connection name to IKE_SA title
[strongswan.git] / src / manager / main.c
1 /**
2 * @file main.c
3 *
4 * @brief Implementation of dispatcher_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include <dispatcher.h>
24 #include <stdio.h>
25
26 #include "manager.h"
27 #include "database.h"
28 #include "controller/auth_controller.h"
29 #include "controller/status_controller.h"
30 #include "controller/gateway_controller.h"
31
32 #define DBFILE IPSECDIR "/sqlite.db"
33 #define SESSION_TIMEOUT 180
34 #define THREADS 10
35
36 int main (int arc, char *argv[])
37 {
38 dispatcher_t *dispatcher;
39 database_t *database;
40
41 database = database_create(DBFILE);
42 if (database == NULL)
43 {
44 fprintf(stderr, "opening database '%s' failed.\n", DBFILE);
45 return 1;
46 }
47
48 dispatcher = dispatcher_create(SESSION_TIMEOUT,
49 (context_constructor_t)manager_create, database);
50 dispatcher->add_controller(dispatcher, status_controller_create, NULL);
51 dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
52 dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
53
54 dispatcher->run(dispatcher, THREADS);
55
56 dispatcher->waitsignal(dispatcher);
57
58 dispatcher->destroy(dispatcher);
59 database->destroy(database);
60
61 return 0;
62 }
63