Moved data structures to new collections subfolder
[strongswan.git] / src / libhydra / attributes / attribute_handler.h
1 /*
2 * Copyright (C) 2009 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 attribute_handler attribute_handler
18 * @{ @ingroup attributes
19 */
20
21 #ifndef ATTRIBUTE_HANDLER_H_
22 #define ATTRIBUTE_HANDLER_H_
23
24 #include <chunk.h>
25 #include <utils/identification.h>
26 #include <collections/linked_list.h>
27
28 #include "attributes.h"
29
30 typedef struct attribute_handler_t attribute_handler_t;
31
32 /**
33 * Interface to handle configuration payload attributes.
34 */
35 struct attribute_handler_t {
36
37 /**
38 * Handle a configuration attribute.
39 *
40 * After receiving a configuration attriubte, it is passed to each
41 * attribute handler until it is handled.
42 *
43 * @param server server from which the attribute was received
44 * @param type type of configuration attribute to handle
45 * @param data associated attribute data
46 * @return TRUE if attribute handled
47 */
48 bool (*handle)(attribute_handler_t *this, identification_t *server,
49 configuration_attribute_type_t type, chunk_t data);
50
51 /**
52 * Release an attribute handled during handle().
53 *
54 * A handler that handle()d an attribute gets a call to release() when the
55 * connection gets closed. Depending on the implementation, this is required
56 * to remove the attribute.
57 */
58 void (*release)(attribute_handler_t *this, identification_t *server,
59 configuration_attribute_type_t type, chunk_t data);
60
61 /**
62 * Enumerate attributes to request from a server.
63 *
64 * @param server server identity to request attributes from
65 * @param vips list of virtual IPs (host_t*) we are requesting
66 * @return enumerator (configuration_attribute_type_t, chunk_t)
67 */
68 enumerator_t* (*create_attribute_enumerator)(attribute_handler_t *this,
69 identification_t *server, linked_list_t *vips);
70 };
71
72 #endif /** ATTRIBUTE_HANDLER_H_ @}*/