changed session timeout to 15 minutes
[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/ikesa_controller.h"
30 #include "controller/gateway_controller.h"
31 #include "controller/control_controller.h"
32 #include "controller/config_controller.h"
33
34 #define DBFILE IPSECDIR "/manager.db"
35 #define SESSION_TIMEOUT 900
36 #define THREADS 10
37
38 int main (int arc, char *argv[])
39 {
40 dispatcher_t *dispatcher;
41 database_t *database;
42 char *socket = NULL;
43
44 #ifdef FCGI_SOCKET
45 socket = FCGI_SOCKET;
46 #endif /* FCGI_SOCKET */
47
48 database = database_create(DBFILE);
49 if (database == NULL)
50 {
51 fprintf(stderr, "opening database '%s' failed.\n", DBFILE);
52 return 1;
53 }
54
55 dispatcher = dispatcher_create(socket, SESSION_TIMEOUT,
56 (context_constructor_t)manager_create, database);
57 dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
58 dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
59 dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
60 dispatcher->add_controller(dispatcher, control_controller_create, NULL);
61 dispatcher->add_controller(dispatcher, config_controller_create, NULL);
62
63 dispatcher->run(dispatcher, THREADS, NULL, NULL, NULL, NULL);
64
65 dispatcher->waitsignal(dispatcher);
66
67 dispatcher->destroy(dispatcher);
68 database->destroy(database);
69
70 return 0;
71 }
72