attribute_manager supports attribute_handler's to handle configuration attributes...
[strongswan.git] / src / charon / config / 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 * $Id$
16 */
17
18 /**
19 * @defgroup attribute_handler attribute_handler
20 * @{ @ingroup attributes
21 */
22
23 #ifndef ATTRIBUTE_HANDLER_H_
24 #define ATTRIBUTE_HANDLER_H_
25
26 #include <sa/ike_sa.h>
27 #include <encoding/payloads/configuration_attribute.h>
28
29 typedef struct attribute_handler_t attribute_handler_t;
30
31 /**
32 * Interface to handle configuration payload attributes.
33 */
34 struct attribute_handler_t {
35
36 /**
37 * Handle a configuration attribute.
38 *
39 * After receiving a configuration attriubte, it is passed to each
40 * attribute handler until it is handled.
41 *
42 * @param type type of configuration attribute to handle
43 * @param data associated attribute data
44 * @return TRUE if attribute handled
45 */
46 bool (*handle)(attribute_handler_t *this, ike_sa_t *ike_sa,
47 configuration_attribute_type_t type, chunk_t data);
48
49 /**
50 * Release an attribute handled during handle().
51 *
52 * A handler that handle()d an attribute gets a call to release() when the
53 * IKE_SA gets closed. Depending on the implementation, this is required
54 * to remove the attribute.
55 */
56 void (*release)(attribute_handler_t *this, ike_sa_t *ike_sa,
57 configuration_attribute_type_t type, chunk_t data);
58 };
59
60 #endif /* ATTRIBUTE_HANDLER_ @}*/