- fixed doxygen warnings
[strongswan.git] / Source / charon / config / sa_config.h
1 /**
2 * @file sa_config.h
3 *
4 * @brief Interface of sa_config_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 _SA_CONFIG_H_
24 #define _SA_CONFIG_H_
25
26 #include <types.h>
27 #include <utils/identification.h>
28 #include <encoding/payloads/auth_payload.h>
29 #include <encoding/payloads/transform_substructure.h>
30 #include <network/host.h>
31 #include <transforms/crypters/crypter.h>
32 #include <transforms/signers/signer.h>
33 #include <transforms/diffie_hellman.h>
34 #include <config/traffic_selector.h>
35
36
37 typedef struct child_proposal_t child_proposal_t;
38
39 /**
40 * @brief Storage structure for a proposal for a child sa.
41 *
42 * A proposal for a child sa contains data for
43 * AH, ESP, or both.
44 *
45 * @todo Currently the amount of tranforms with same type in a proposal is limited to 1.
46 * Support of more transforms with same type has to be added.
47 *
48 * @ingroup config
49 */
50 struct child_proposal_t {
51
52 /**
53 * Data for AH, if set.
54 */
55 struct {
56 bool is_set;
57 integrity_algorithm_t integrity_algorithm;
58 size_t integrity_algorithm_key_size;
59 diffie_hellman_group_t diffie_hellman_group;
60 extended_sequence_numbers_t extended_sequence_numbers;
61 u_int8_t spi[4];
62 } ah;
63
64 /**
65 * Data for ESP, if set.
66 */
67 struct {
68 bool is_set;
69 encryption_algorithm_t encryption_algorithm;
70 size_t encryption_algorithm_key_size;
71 integrity_algorithm_t integrity_algorithm;
72 size_t integrity_algorithm_key_size;
73 diffie_hellman_group_t diffie_hellman_group;
74 extended_sequence_numbers_t extended_sequence_numbers;
75 u_int8_t spi[4];
76 } esp;
77 };
78
79
80 typedef struct sa_config_t sa_config_t;
81
82 /**
83 * @brief Stores configuration of an initialized connection.
84 *
85 * During the IKE_AUTH phase, we have enough data to specify a
86 * configuration.
87 *
88 * @warning This config is not thread save.
89 *
90 * @b Constructors:
91 * - sa_config_create()
92 *
93 * @ingroup config
94 */
95 struct sa_config_t {
96
97 /**
98 * @brief Get own id to use for identification.
99 *
100 * Returned object is not getting cloned.
101 *
102 * @param this calling object
103 * @return own id
104 */
105 identification_t *(*get_my_id) (sa_config_t *this);
106
107 /**
108 * @brief Get id of communication partner.
109 *
110 * Returned object is not getting cloned.
111 *
112 * @param this calling object
113 * @return other id
114 */
115 identification_t *(*get_other_id) (sa_config_t *this);
116
117 /**
118 * @brief Get authentication method to use for IKE_AUTH.
119 *
120 * @param this calling object
121 * @return authentication methood
122 */
123 auth_method_t (*get_auth_method) (sa_config_t *this);
124
125 /**
126 * @brief Get lifetime of IKE_SA in milliseconds.
127 *
128 * @return IKE_SA lifetime in milliseconds.
129 */
130 u_int32_t (*get_ike_sa_lifetime) (sa_config_t *this);
131
132 /**
133 * @brief Get configured traffic selectors for initiator site.
134 *
135 * Returns a pointer to an allocated array, in which
136 * pointers to traffic selectors are stored.
137 *
138 * @warning Resulting pointer array must be freed!
139 * @warning Traffic selectors in array must be destroyed!
140 *
141 * @param this calling object
142 * @param[out] traffic_selectors pointer where traffic selectors will be allocated
143 * @return number of returned traffic selectors
144 */
145 size_t (*get_traffic_selectors_initiator) (sa_config_t *this, traffic_selector_t **traffic_selectors[]);
146
147
148 /**
149 * @brief Get configured traffic selectors for responder site.
150 *
151 * Returns a pointer to an allocated array, in which
152 * pointers to traffic selectors are stored.
153 *
154 * @warning Resulting pointer array must be freed!
155 * @warning Traffic selectors in array must be destroyed!
156 *
157 * @param this calling object
158 * @param[out] traffic_selectors pointer where traffic selectors will be allocated
159 * @return number of returned traffic selectors
160 */
161 size_t (*get_traffic_selectors_responder) (sa_config_t *this, traffic_selector_t **traffic_selectors[]);
162
163 /**
164 * @brief Select traffic selectors from a supplied list for initiator.
165 *
166 * Returns a pointer to an allocated array, in which
167 * pointers to traffic selectors are stored.
168 *
169 * @warning Resulting pointer array must be freed!
170 * @warning Traffic selectors in array must be destroyed!
171 *
172 * @param this calling object
173 * @param supplied pointer to an array of ts to select from.
174 * @param count number of ts stored at supplied
175 * @param[out] traffic_selectors pointer where selected traffic selectors will be allocated
176 * @return number of selected traffic selectors
177 */
178 size_t (*select_traffic_selectors_initiator) (sa_config_t *this, traffic_selector_t *supplied[], size_t count, traffic_selector_t **selected[]);
179
180 /**
181 * @brief Select traffic selectors from a supplied list for responder.
182 *
183 * Returns a pointer to an allocated array, in which
184 * pointers to traffic selectors are stored.
185 *
186 * @warning Resulting pointer array must be freed!
187 * @warning Traffic selectors in array must be destroyed!
188 *
189 * @param this calling object
190 * @param supplied pointer to an array of ts to select from.
191 * @param count number of ts stored at supplied
192 * @param[out] traffic_selectors pointer where selected traffic selectors will be allocated
193 * @return number of selected traffic selectors
194 */
195 size_t (*select_traffic_selectors_responder) (sa_config_t *this, traffic_selector_t *supplied[], size_t count, traffic_selector_t **selected[]);
196
197 /**
198 * @brief Get the list of proposals for this config.
199 *
200 * @warning Resulting array must be freed!
201 *
202 * @param this calling object
203 * @param[out] traffic_selectors pointer where proposals will be allocated
204 * @return number of allocated proposals
205 */
206 size_t (*get_proposals) (sa_config_t *this, u_int8_t ah_spi[4], u_int8_t esp_spi[4], child_proposal_t *proposals[]);
207
208 /**
209 * @brief Select a proposal from a supplied list
210 *
211 * @warning Resulting array must be freed!
212 *
213 * @param this calling object
214 * @param supplied pointer to an array of proposals to select from.
215 * @param count number of proposals stored at supplied
216 * @return the selected proposal
217 */
218 child_proposal_t* (*select_proposal) (sa_config_t *this, u_int8_t ah_spi[4], u_int8_t esp_spi[4], child_proposal_t *supplied, size_t count);
219
220 /**
221 * @brief Add a traffic selector to the list for initiator.
222 *
223 * Added proposal will be cloned.
224 *
225 * @warning Do not add while other threads are reading.
226 *
227 * @param this calling object
228 * @param traffic_selector traffic_selector to add
229 */
230 void (*add_traffic_selector_initiator) (sa_config_t *this, traffic_selector_t *traffic_selector);
231
232 /**
233 * @brief Add a traffic selector to the list for responder.
234 *
235 * Added proposal will be cloned.
236 *
237 * @warning Do not add while other threads are reading.
238 *
239 * @param this calling object
240 * @param traffic_selector traffic_selector to add
241 */
242 void (*add_traffic_selector_responder) (sa_config_t *this, traffic_selector_t *traffic_selector);
243
244 /**
245 * @brief Add a proposal to the list.
246 *
247 * The proposals are stored by priority, first added
248 * is the most prefered.
249 * Added proposal will be cloned.
250 *
251 * @warning Do not add while other threads are reading.
252 *
253 * @param this calling object
254 * @param proposal proposal to add
255 */
256 void (*add_proposal) (sa_config_t *this, child_proposal_t *proposal);
257
258 /**
259 * @brief Destroys the config object
260 *
261 * @param this calling object
262 */
263 void (*destroy) (sa_config_t *this);
264 };
265
266 /**
267 * @brief Create a configuration object for IKE_AUTH and later.
268 *
269 * @param my_id_type type of my identification
270 * @param my_id my identification as string
271 * @param other_id_type type of other identification
272 * @param other_id other identification as string
273 * @param auth_method Method of authentication
274 * @param ike_sa_lifetime lifetime of this IKE_SA in milliseconds. IKE_SA will be deleted
275 * after this lifetime!
276 * @return sa_config_t object
277 *
278 * @ingroup config
279 */
280 sa_config_t *sa_config_create(id_type_t my_id_type, char *my_id, id_type_t other_id_type, char *other_id, auth_method_t auth_method, u_int32_t ike_sa_lifetime);
281
282 #endif //_SA_CONFIG_H_