2 * Copyright (C) 2008 Martin Willi
3 * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #include <dispatcher.h>
21 #include <database/database.h>
23 #include "filter/auth_filter.h"
24 #include "controller/user_controller.h"
25 #include "controller/peer_controller.h"
27 int main(int arc
, char *argv
[])
29 dispatcher_t
*dispatcher
;
36 library_init(STRONGSWAN_CONF
);
37 lib
->plugins
->load(lib
->plugins
, IPSEC_PLUGINDIR
,
38 lib
->settings
->get_str(lib
->settings
, "medsrv.load", PLUGINS
));
40 socket
= lib
->settings
->get_str(lib
->settings
, "medsrv.socket", NULL
);
41 debug
= lib
->settings
->get_bool(lib
->settings
, "medsrv.debug", FALSE
);
42 timeout
= lib
->settings
->get_time(lib
->settings
, "medsrv.timeout", 900);
43 threads
= lib
->settings
->get_int(lib
->settings
, "medsrv.threads", 5);
44 uri
= lib
->settings
->get_str(lib
->settings
, "medsrv.database", NULL
);
47 fprintf(stderr
, "database URI medsrv.database not defined.\n");
51 db
= lib
->db
->create(lib
->db
, uri
);
54 fprintf(stderr
, "opening database failed.\n");
58 dispatcher
= dispatcher_create(socket
, debug
, timeout
,
59 (context_constructor_t
)user_create
, db
);
60 dispatcher
->add_filter(dispatcher
,
61 (filter_constructor_t
)auth_filter_create
, db
);
62 dispatcher
->add_controller(dispatcher
,
63 (controller_constructor_t
)user_controller_create
, db
);
64 dispatcher
->add_controller(dispatcher
,
65 (controller_constructor_t
)peer_controller_create
, db
);
67 dispatcher
->run(dispatcher
, threads
);
69 dispatcher
->waitsignal(dispatcher
);
70 dispatcher
->destroy(dispatcher
);