refactored PA-TNC message handling by IMVs
[strongswan.git] / src / libfast / controller.h
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup controller_i controller
18 * @{ @ingroup libfast
19 */
20
21 #ifndef CONTROLLER_H_
22 #define CONTROLLER_H_
23
24 #include "request.h"
25 #include "context.h"
26
27 typedef struct controller_t controller_t;
28
29 /**
30 * Constructor function for a controller.
31 *
32 * @param context session specific context, implements context_t
33 * @param param user supplied param, as registered to the dispatcher
34 */
35 typedef controller_t *(*controller_constructor_t)(context_t* context, void *param);
36
37 /**
38 * Controller interface, to be implemented by users controllers.
39 *
40 * Controller instances get created per session, so each session has an
41 * associated set of private controller instances.
42 * The controller handle function is called for each incoming request.
43 */
44 struct controller_t {
45
46 /**
47 * Get the name of the controller.
48 *
49 * @return name of the controller
50 */
51 char* (*get_name)(controller_t *this);
52
53 /**
54 * Handle a HTTP request for that controller.
55 *
56 * Request URLs are parsed in the form
57 * controller_name/p1/p2/p3/p4/p5 with a maximum of 5 parameters. Each
58 * parameter not found in the request URL is set to NULL.
59 *
60 * @param request HTTP request
61 * @param p1 first parameter
62 * @param p2 second parameter
63 * @param p3 third parameter
64 * @param p4 forth parameter
65 * @param p5 fifth parameter
66 * @return
67 */
68 void (*handle)(controller_t *this, request_t *request,
69 char *p1, char *p2, char *p3, char *p4, char *p5);
70
71 /**
72 * Destroy the controller instance.
73 */
74 void (*destroy) (controller_t *this);
75 };
76
77 #endif /** CONTROLLER_H_ @}*/