first revision of new manager webapp
[strongswan.git] / src / manager / lib / dispatcher.h
1 /**
2 * @file dispatcher.h
3 *
4 * @brief Interface 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 #ifndef DISPATCHER_H_
24 #define DISPATCHER_H_
25
26 #include "controller.h"
27
28 typedef struct dispatcher_t dispatcher_t;
29
30 /**
31 * @brief Dispatcher, accepts connections using multiple threads.
32 *
33 * The dispatcher creates a session for each client (using SID cookies). In
34 * each session, a session context is created using the context constructor.
35 * Each controller is instanciated in the session using the controller
36 * constructor added with add_controller.
37 */
38 struct dispatcher_t {
39
40 /**
41 * @brief Register a controller to the dispatcher.
42 *
43 * @param constructor constructor function to the conntroller
44 * @param param param to pass to constructor
45 */
46 void (*add_controller)(dispatcher_t *this,
47 controller_constructor_t constructor, void *param);
48
49 /**
50 * @brief Start with dispatching.
51 *
52 * @param thread number of dispatching threads
53 */
54 void (*run)(dispatcher_t *this, int threads);
55
56 /**
57 * @brief Wait for a relevant signal action.
58 */
59 void (*waitsignal)(dispatcher_t *this);
60
61 /**
62 * @brief Destroy the dispatcher_t.
63 */
64 void (*destroy) (dispatcher_t *this);
65 };
66
67 /**
68 * @brief Create a dispatcher.
69 *
70 * The context constructor is invoked to create a session context for
71 * each session.
72 *
73 * @param constructor construction function for session context
74 * @param param parameter to supply to context constructor
75 */
76 dispatcher_t *dispatcher_create(context_constructor_t constructor, void *param);
77
78 #endif /* DISPATCHER_H_ */