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