Pass full pool list to release_address
[strongswan.git] / src / libhydra / attributes / attribute_manager.h
1 /*
2 * Copyright (C) 2008-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_manager attribute_manager
18 * @{ @ingroup attributes
19 */
20
21 #ifndef ATTRIBUTE_MANAGER_H_
22 #define ATTRIBUTE_MANAGER_H_
23
24 #include "attribute_provider.h"
25 #include "attribute_handler.h"
26
27 typedef struct attribute_manager_t attribute_manager_t;
28
29 /**
30 * The attribute manager hands out attributes or handles them.
31 *
32 * The attribute manager manages both, attribute providers and attribute
33 * handlers. Attribute providers are responsible to hand out attributes if
34 * a connecting peer requests them. Handlers handle such attributes if they
35 * are received on the requesting peer.
36 */
37 struct attribute_manager_t {
38
39 /**
40 * Acquire a virtual IP address to assign to a peer.
41 *
42 * @param pools list of pool names (char*) to acquire from
43 * @param id peer identity to get address forua
44 * @param requested IP in configuration request
45 * @return allocated address, NULL to serve none
46 */
47 host_t* (*acquire_address)(attribute_manager_t *this,
48 linked_list_t *pool, identification_t *id,
49 host_t *requested);
50
51 /**
52 * Release a previously acquired address.
53 *
54 * @param pools list of pool names (char*) to release to
55 * @param address address to release
56 * @param id peer identity to get address for
57 * @return TRUE if address released to pool
58 */
59 bool (*release_address)(attribute_manager_t *this,
60 linked_list_t *pools, host_t *address,
61 identification_t *id);
62
63 /**
64 * Create an enumerator over attributes to hand out to a peer.
65 *
66 * @param pool list of pools names (char*) to query attributes from
67 * @param id peer identity to hand out attributes to
68 * @param vip list of virtual IPs (host_t*) to assign to peer
69 * @return enumerator (configuration_attribute_type_t, chunk_t)
70 */
71 enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
72 linked_list_t *pool, identification_t *id,
73 linked_list_t *vips);
74
75 /**
76 * Register an attribute provider to the manager.
77 *
78 * @param provider attribute provider to register
79 */
80 void (*add_provider)(attribute_manager_t *this,
81 attribute_provider_t *provider);
82 /**
83 * Unregister an attribute provider from the manager.
84 *
85 * @param provider attribute provider to unregister
86 */
87 void (*remove_provider)(attribute_manager_t *this,
88 attribute_provider_t *provider);
89
90 /**
91 * Handle a configuration attribute by passing them to the handlers.
92 *
93 * @param server server from which the attribute was received
94 * @param handler handler we requested the attribute for, if any
95 * @param type type of configuration attribute
96 * @param data associated attribute data
97 * @return handler which handled this attribute, NULL if none
98 */
99 attribute_handler_t* (*handle)(attribute_manager_t *this,
100 identification_t *server, attribute_handler_t *handler,
101 configuration_attribute_type_t type, chunk_t data);
102
103 /**
104 * Release an attribute previously handle()d by a handler.
105 *
106 * @param handler handler returned by handle() for this attribute
107 * @param server server from which the attribute was received
108 * @param type type of attribute to release
109 * @param data associated attribute data
110 */
111 void (*release)(attribute_manager_t *this, attribute_handler_t *handler,
112 identification_t *server,
113 configuration_attribute_type_t type,
114 chunk_t data);
115
116 /**
117 * Create an enumerator over attributes to request from server.
118 *
119 * @param id server identity to hand out attributes to
120 * @param vip list of virtual IPs (host_t*) going to request
121 * @return enumerator (attribute_handler_t, ca_type_t, chunk_t)
122 */
123 enumerator_t* (*create_initiator_enumerator)(attribute_manager_t *this,
124 identification_t *id, linked_list_t *vips);
125
126 /**
127 * Register an attribute handler to the manager.
128 *
129 * @param handler attribute handler to register
130 */
131 void (*add_handler)(attribute_manager_t *this,
132 attribute_handler_t *handler);
133
134 /**
135 * Unregister an attribute handler from the manager.
136 *
137 * @param handler attribute handler to unregister
138 */
139 void (*remove_handler)(attribute_manager_t *this,
140 attribute_handler_t *handler);
141
142 /**
143 * Destroy a attribute_manager instance.
144 */
145 void (*destroy)(attribute_manager_t *this);
146 };
147
148 /**
149 * Create a attribute_manager instance.
150 */
151 attribute_manager_t *attribute_manager_create();
152
153 #endif /** ATTRIBUTE_MANAGER_H_ @}*/