refactored strongswan manager
[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 * The first controller added serves as default controller. Client's
44 * get redirected to it if no other controller matches.
45 *
46 * @param constructor constructor function to the conntroller
47 * @param param param to pass to constructor
48 */
49 void (*add_controller)(dispatcher_t *this,
50 controller_constructor_t constructor, void *param);
51
52 /**
53 * @brief Start with dispatching.
54 *
55 * @param thread number of dispatching threads
56 */
57 void (*run)(dispatcher_t *this, int threads);
58
59 /**
60 * @brief Wait for a relevant signal action.
61 */
62 void (*waitsignal)(dispatcher_t *this);
63
64 /**
65 * @brief Destroy the dispatcher_t.
66 */
67 void (*destroy) (dispatcher_t *this);
68 };
69
70 /**
71 * @brief Create a dispatcher.
72 *
73 * The context constructor is invoked to create a session context for
74 * each session.
75 *
76 * @param socket FastCGI socket path, NULL for dynamic
77 * @param timeout session timeout
78 * @param constructor construction function for session context
79 * @param param parameter to supply to context constructor
80 */
81 dispatcher_t *dispatcher_create(char *socket, int timeout,
82 context_constructor_t constructor, void *param);
83
84 #endif /* DISPATCHER_H_ */