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_
30 #include "../utils/linked_list.h"
31 #include "transform_attribute.h"
34 * IKEv1 Value for a transform payload
36 #define TRANSFORM_TYPE_VALUE 3
39 * Length of the transform substructure header in bytes
41 #define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
44 * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE
46 * The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
49 typedef struct transform_substructure_s transform_substructure_t
;
51 struct transform_substructure_s
{
53 * implements payload_t interface
55 payload_t payload_interface
;
58 * @brief Creates an iterator of stored transform_attribute_t objects.
60 * @warning The created iterator has to get destroyed by the caller!
62 * @warning When deleting an transform attribute, the length of this transform substructure
63 * has to be refreshed with get_length!
65 * @param this calling transform_substructure_t object
66 * @param iterator the created iterator is stored at the pointed pointer
67 * @param[in] forward iterator direction (TRUE: front to end)
70 * - OUT_OF_RES if iterator could not be created
72 status_t (*create_transform_attribute_iterator
) (transform_substructure_t
*this,linked_list_iterator_t
**iterator
, bool forward
);
75 * @brief Adds a transform_attribute_t object to this object.
77 * @warning The added proposal_substructure_t object is
78 * getting destroyed in destroy function of transform_substructure_t.
80 * @param this calling transform_substructure_t object
81 * @param proposal transform_attribute_t object to add
82 * @return - SUCCESS if succeeded
85 status_t (*add_transform_attribute
) (transform_substructure_t
*this,transform_attribute_t
*attribute
);
88 * @brief Sets the next_payload field of this substructure
90 * If this is the last transform, next payload field is set to 0,
91 * otherwise to 3 (payload type of transform in IKEv1)
93 * @param this calling transform_substructure_t object
94 * @param is_last When TRUE, next payload field is set to 0, otherwise to 3
97 status_t (*set_is_last_transform
) (transform_substructure_t
*this, bool is_last
);
100 * @brief Checks if this is the last transform.
102 * @param this calling transform_substructure_t object
103 * @return TRUE if this is the last Transform, FALSE otherwise
105 bool (*get_is_last_transform
) (transform_substructure_t
*this);
108 * @brief Sets transform type of the current transform substructure.
110 * @param this calling transform_substructure_t object
111 * @param type type value to set
114 status_t (*set_transform_type
) (transform_substructure_t
*this,u_int8_t type
);
117 * @brief get transform type of the current transform.
119 * @param this calling transform_substructure_t object
120 * @return Transform type of current transform substructure.
122 u_int8_t (*get_transform_type
) (transform_substructure_t
*this);
125 * @brief Sets transform id of the current transform substructure.
127 * @param this calling transform_substructure_t object
128 * @param id transform id to set
131 status_t (*set_transform_id
) (transform_substructure_t
*this,u_int16_t id
);
134 * @brief get transform id of the current transform.
136 * @param this calling transform_substructure_t object
137 * @return Transform id of current transform substructure.
139 u_int16_t (*get_transform_id
) (transform_substructure_t
*this);
142 * @brief Destroys an transform_substructure_t object.
144 * @param this transform_substructure_t object to destroy
146 * SUCCESS in any case
148 status_t (*destroy
) (transform_substructure_t
*this);
152 * @brief Creates an empty transform_substructure_t object
155 * - created transform_substructure_t object, or
159 transform_substructure_t
*transform_substructure_create();
161 #endif /*TRANSFORM_SUBSTRUCTURE_H_*/