- code documented
[strongswan.git] / Source / charon / config / configuration_manager.h
1 /**
2 * @file configuration_manager.h
3 *
4 * @brief Interface of configuration_manager_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, 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 CONFIGURATION_MANAGER_H_
24 #define CONFIGURATION_MANAGER_H_
25
26 #include <types.h>
27 #include <config/init_config.h>
28 #include <config/sa_config.h>
29 #include <transforms/rsa/rsa_private_key.h>
30 #include <transforms/rsa/rsa_public_key.h>
31
32
33 typedef struct configuration_manager_t configuration_manager_t;
34
35 /**
36 * @brief Manages all configuration aspects of the daemon.
37 *
38 * @b Constructors:
39 * - configuration_manager_create()
40 *
41 * @ingroup config
42 *
43 */
44 struct configuration_manager_t {
45
46 /**
47 * @brief Returns the configuration information needed for IKE_SA_INIT exchange
48 * for a specific configuration name.
49 *
50 * The returned init_config_t object MUST NOT be destroyed cause it's managed by
51 * this configuration_manager_t object.
52 *
53 * @param this calling object
54 * @param name name of the configuration
55 * @param[out] init_config the init_config_t object is stored at this location
56 *
57 * @return
58 * - NOT_FOUND
59 * - SUCCESS
60 */
61 status_t (*get_init_config_for_name) (configuration_manager_t *this, char *name, init_config_t **init_config);
62
63 /**
64 * @brief Returns the configuration information needed for IKE_SA_INIT exchange
65 * for specific host informations.
66 *
67 * The returned init_config_t object MUST NOT be destroyed cause it's managed by
68 * this configuration_manager_t object.
69 *
70 * @param this calling object
71 * @param my_host my host informations
72 * @param other_host other host informations
73 * @param[out] init_config the init_config_t object is stored at this location
74 *
75 * @return
76 * - NOT_FOUND
77 * - SUCCESS
78 */
79 status_t (*get_init_config_for_host) (configuration_manager_t *this, host_t *my_host, host_t *other_host,init_config_t **init_config);
80
81 /**
82 * @brief Returns the configuration information needed after IKE_SA_INIT exchange
83 * for a specific configuration name.
84 *
85 * The returned sa_config_t object MUST NOT be destroyed cause it's managed by
86 * this configuration_manager_t object.
87 *
88 * @param this calling object
89 * @param name name of the configuration
90 * @param[out] sa_config the sa_config_t object is stored at this location
91 *
92 * @return
93 * - NOT_FOUND
94 * - SUCCESS
95 */
96 status_t (*get_sa_config_for_name) (configuration_manager_t *this, char *name, sa_config_t **sa_config);
97
98 /**
99 * @brief Returns the configuration information needed after IKE_SA_INIT exchange
100 * for specific init_config_t and ID data.
101 *
102 * The returned sa_config_t object MUST NOT be destroyed cause it's managed by
103 * this configuration_manager_t object.
104 *
105 * @param this calling object
106 * @param init_config init_config_t object
107 * @param other_id identification of other one
108 * @param my_id my identification (can be NULL)
109 * @param[out] sa_config the sa_config_t object is stored at this location
110 *
111 * @return
112 * - NOT_FOUND
113 * - SUCCESS
114 */
115 status_t (*get_sa_config_for_init_config_and_id) (configuration_manager_t *this, init_config_t *init_config, identification_t *other_id, identification_t *my_id,sa_config_t **sa_config);
116
117 /**
118 * @brief Returns the retransmit timeout.
119 *
120 * The timeout values are managed by the configuration manager.
121 *
122 * @param this calling object
123 * @param retransmit_count number of times a message was retransmitted so far
124 * @param[out] timeout the new retransmit timeout in milliseconds
125 *
126 * @return
127 * - FAILED, if the message should not be retransmitted
128 * - SUCCESS
129 */
130 status_t (*get_retransmit_timeout) (configuration_manager_t *this, u_int32_t retransmit_count, u_int32_t *timeout);
131
132 /**
133 * @brief Returns the preshared secret of a specific ID.
134 *
135 * The returned preshared secret MUST NOT be destroyed cause it's managed by
136 * this configuration_manager_t object.
137 *
138 * @param this calling object
139 * @param identification identification_t object identifiying the ID.
140 * @param[out] preshared_secret the preshared secret will be written there.
141 *
142 * @return
143 * - NOT_FOUND if no preshared secrets for specific ID could be found
144 * - SUCCESS
145 */
146 status_t (*get_shared_secret) (configuration_manager_t *this, identification_t *identification, chunk_t *preshared_secret);
147
148 /**
149 * @brief Returns the RSA public key of a specific ID.
150 *
151 * The returned rsa_public_key_t object MUST NOT be destroyed cause it's managed by
152 * this configuration_manager_t object.
153 *
154 * @param this calling object
155 * @param identification identification_t object identifiying the ID.
156 * @param[out] public_key the public key will be written there
157 *
158 * @return
159 * - NOT_FOUND if no key is configured for specific id
160 * - SUCCESS
161 */
162 status_t (*get_rsa_public_key) (configuration_manager_t *this, identification_t *identification, rsa_public_key_t **public_key);
163
164 /**
165 * @brief Returns the RSA private key of a specific ID.
166 *
167 * The returned rsa_private_key_t object MUST NOT be destroyed cause it's managed by
168 * this configuration_manager_t object.
169 *
170 * @param this calling object
171 * @param identification identification_t object identifiying the ID.
172 * @param[out] private_key the private key will be written there
173 *
174 * @return
175 * - NOT_FOUND if no key is configured for specific id
176 * - SUCCESS
177 */
178 status_t (*get_rsa_private_key) (configuration_manager_t *this, identification_t *identification, rsa_private_key_t **private_key);
179
180 /**
181 * Destroys a configuration_manager_t object.
182 *
183 * @param this calling object
184 * @return
185 * - SUCCESS
186 */
187 void (*destroy) (configuration_manager_t *this);
188 };
189
190 /**
191 * @brief Creates the mighty configuration manager.
192 *
193 * @param first_retransmit_timeout first retransmit timeout in milliseconds
194 * @param max_retransmit_count max number of tries to retransmitted a requests (0 for infinite)
195 * @return
196 * - pointer to created configuration_manager_t object
197 * @ingroup config
198 */
199 configuration_manager_t *configuration_manager_create(u_int32_t first_retransmit_timeout,u_int32_t max_retransmit_count);
200
201 #endif /*CONFIGURATION_MANAGER_H_*/