2 * @file transform_substructure.h
4 * @brief Declaration of the class transform_substructure_t.
6 * An object of this type represents an IKEv2 TRANSFORM Substructure and contains Attributes.
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 #ifndef TRANSFORM_SUBSTRUCTURE_H_
26 #define TRANSFORM_SUBSTRUCTURE_H_
29 #include <definitions.h>
30 #include <encoding/payloads/payload.h>
31 #include <encoding/payloads/transform_attribute.h>
32 #include <utils/linked_list.h>
36 * IKEv1 Value for a transform payload
38 #define TRANSFORM_TYPE_VALUE 3
41 * Length of the transform substructure header in bytes
43 #define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
47 * Type of a transform, as in IKEv2 draft 3.3.2
49 typedef enum transform_type_e transform_type_t
;
51 enum transform_type_e
{
52 UNDEFINED_TRANSFORM_TYPE
= 241,
53 ENCRYPTION_ALGORITHM
= 1,
54 PSEUDO_RANDOM_FUNCTION
= 2,
55 INTEGRITIY_ALGORITHM
= 3,
56 DIFFIE_HELLMAN_GROUP
= 4,
57 EXTENDED_SEQUENCE_NUNBERS
= 5
61 * string mappings for transform_type_t
63 extern mapping_t transform_type_m
[];
66 * Encryption algorithm, as in IKEv2 draft 3.3.2
68 typedef enum encryption_algorithm_e encryption_algorithm_t
;
70 enum encryption_algorithm_e
{
71 ENCR_UNDEFINED
= 1024,
88 * string mappings for encryption_algorithm_t
90 extern mapping_t encryption_algorithm_m
[];
93 * Pseudo random function, as in IKEv2 draft 3.3.2
95 typedef enum pseudo_random_function_e pseudo_random_function_t
;
97 enum pseudo_random_function_e
{
106 * string mappings for encryption_algorithm_t
108 extern mapping_t pseudo_random_function_m
[];
111 * Integrity algorithm, as in IKEv2 draft 3.3.2
113 typedef enum integrity_algorithm_e integrity_algorithm_t
;
115 enum integrity_algorithm_e
{
116 AUTH_UNDEFINED
= 1024,
117 AUTH_HMAC_MD5_96
= 1,
118 AUTH_HMAC_SHA1_96
= 2,
125 * string mappings for integrity_algorithm_t
127 extern mapping_t integrity_algorithm_m
[];
131 * Diffie-Hellman group, as in IKEv2 draft 3.3.2 and RFC 3526
133 typedef enum diffie_hellman_group_e diffie_hellman_group_t
;
135 enum diffie_hellman_group_e
{
136 MODP_UNDEFINED
= 1024,
148 * string mappings for diffie_hellman_group_t
150 extern mapping_t diffie_hellman_group_m
[];
153 * Extended sequence numbers, as in IKEv2 draft 3.3.2
155 typedef enum extended_sequence_numbers_e extended_sequence_numbers_t
;
157 enum extended_sequence_numbers_e
{
158 NO_EXT_SEQ_NUMBERS
= 0,
163 * string mappings for extended_sequence_numbers_t
165 extern mapping_t extended_sequence_numbers_m
[];
168 * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE
170 * The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
173 typedef struct transform_substructure_s transform_substructure_t
;
175 struct transform_substructure_s
{
177 * implements payload_t interface
179 payload_t payload_interface
;
182 * @brief Creates an iterator of stored transform_attribute_t objects.
184 * @warning The created iterator has to get destroyed by the caller!
186 * @warning When deleting an transform attribute using this iterator,
187 * the length of this transform substructure has to be refreshed
188 * by calling get_length()!
190 * @param this calling transform_substructure_t object
191 * @param iterator the created iterator is stored at the pointed pointer
192 * @param[in] forward iterator direction (TRUE: front to end)
195 * - OUT_OF_RES if iterator could not be created
197 status_t (*create_transform_attribute_iterator
) (transform_substructure_t
*this,linked_list_iterator_t
**iterator
, bool forward
);
200 * @brief Adds a transform_attribute_t object to this object.
202 * @warning The added proposal_substructure_t object is
203 * getting destroyed in destroy function of transform_substructure_t.
205 * @param this calling transform_substructure_t object
206 * @param proposal transform_attribute_t object to add
207 * @return - SUCCESS if succeeded
210 status_t (*add_transform_attribute
) (transform_substructure_t
*this,transform_attribute_t
*attribute
);
213 * @brief Sets the next_payload field of this substructure
215 * If this is the last transform, next payload field is set to 0,
216 * otherwise to 3 (payload type of transform in IKEv1)
218 * @param this calling transform_substructure_t object
219 * @param is_last When TRUE, next payload field is set to 0, otherwise to 3
222 status_t (*set_is_last_transform
) (transform_substructure_t
*this, bool is_last
);
225 * @brief Checks if this is the last transform.
227 * @param this calling transform_substructure_t object
228 * @return TRUE if this is the last Transform, FALSE otherwise
230 bool (*get_is_last_transform
) (transform_substructure_t
*this);
233 * @brief Sets transform type of the current transform substructure.
235 * @param this calling transform_substructure_t object
236 * @param type type value to set
239 status_t (*set_transform_type
) (transform_substructure_t
*this,u_int8_t type
);
242 * @brief get transform type of the current transform.
244 * @param this calling transform_substructure_t object
245 * @return Transform type of current transform substructure.
247 u_int8_t (*get_transform_type
) (transform_substructure_t
*this);
250 * @brief Sets transform id of the current transform substructure.
252 * @param this calling transform_substructure_t object
253 * @param id transform id to set
256 status_t (*set_transform_id
) (transform_substructure_t
*this,u_int16_t id
);
259 * @brief get transform id of the current transform.
261 * @param this calling transform_substructure_t object
262 * @return Transform id of current transform substructure.
264 u_int16_t (*get_transform_id
) (transform_substructure_t
*this);
267 * @brief Clones an transform_substructure_t object.
269 * @param this transform_substructure_t object to clone
270 * @param clone pointer to a transform_substructure_t object pointer
271 * where the new object is stored to.
274 * - SUCCESS in any case
276 status_t (*clone
) (transform_substructure_t
*this,transform_substructure_t
**clone
);
279 * @brief Destroys an transform_substructure_t object.
281 * @param this transform_substructure_t object to destroy
283 * SUCCESS in any case
285 status_t (*destroy
) (transform_substructure_t
*this);
289 * @brief Creates an empty transform_substructure_t object
292 * - created transform_substructure_t object, or
296 transform_substructure_t
*transform_substructure_create();
298 #endif /*TRANSFORM_SUBSTRUCTURE_H_*/