- parser succesfully parses sa payload
[strongswan.git] / Source / charon / payloads / transform_substructure.h
1 /**
2 * @file transform_substructure.h
3 *
4 * @brief Declaration of the class transform_substructure_t.
5 *
6 * An object of this type represents an IKEv2 TRANSFORM Substructure and contains Attributes.
7 *
8 */
9
10 /*
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
13 *
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>.
18 *
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
22 * for more details.
23 */
24
25 #ifndef TRANSFORM_SUBSTRUCTURE_H_
26 #define TRANSFORM_SUBSTRUCTURE_H_
27
28 #include "../types.h"
29 #include "payload.h"
30 #include "../utils/linked_list.h"
31 #include "transform_attribute.h"
32
33 /**
34 * IKEv1 Value for a transform payload
35 */
36 #define TRANSFORM_TYPE_VALUE 3
37
38 /**
39 * Length of the transform substructure header in bytes
40 */
41 #define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
42
43 /**
44 * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE
45 *
46 * The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
47 *
48 */
49 typedef struct transform_substructure_s transform_substructure_t;
50
51 struct transform_substructure_s {
52 /**
53 * implements payload_t interface
54 */
55 payload_t payload_interface;
56
57 /**
58 * @brief Creates an iterator of stored transform_attribute_t objects.
59 *
60 * @warning The created iterator has to get destroyed by the caller!
61 *
62 * @warning When deleting an transform attribute, the length of this transform substructure
63 * has to be refreshed with get_length!
64 *
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)
68 * @return
69 * - SUCCESS or
70 * - OUT_OF_RES if iterator could not be created
71 */
72 status_t (*create_transform_attribute_iterator) (transform_substructure_t *this,linked_list_iterator_t **iterator, bool forward);
73
74 /**
75 * @brief Adds a transform_attribute_t object to this object.
76 *
77 * @warning The added proposal_substructure_t object is
78 * getting destroyed in destroy function of transform_substructure_t.
79 *
80 * @param this calling transform_substructure_t object
81 * @param proposal transform_attribute_t object to add
82 * @return - SUCCESS if succeeded
83 * - FAILED otherwise
84 */
85 status_t (*add_transform_attribute) (transform_substructure_t *this,transform_attribute_t *attribute);
86
87 /**
88 * @brief Sets the next_payload field of this substructure
89 *
90 * If this is the last transform, next payload field is set to 0,
91 * otherwise to 3 (payload type of transform in IKEv1)
92 *
93 * @param this calling transform_substructure_t object
94 * @param is_last When TRUE, next payload field is set to 0, otherwise to 3
95 * @return - SUCCESS
96 */
97 status_t (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
98
99 /**
100 * @brief Checks if this is the last transform.
101 *
102 * @param this calling transform_substructure_t object
103 * @return TRUE if this is the last Transform, FALSE otherwise
104 */
105 bool (*get_is_last_transform) (transform_substructure_t *this);
106
107 /**
108 * @brief Sets transform type of the current transform substructure.
109 *
110 * @param this calling transform_substructure_t object
111 * @param type type value to set
112 * @return - SUCCESS
113 */
114 status_t (*set_transform_type) (transform_substructure_t *this,u_int8_t type);
115
116 /**
117 * @brief get transform type of the current transform.
118 *
119 * @param this calling transform_substructure_t object
120 * @return Transform type of current transform substructure.
121 */
122 u_int8_t (*get_transform_type) (transform_substructure_t *this);
123
124 /**
125 * @brief Sets transform id of the current transform substructure.
126 *
127 * @param this calling transform_substructure_t object
128 * @param id transform id to set
129 * @return - SUCCESS
130 */
131 status_t (*set_transform_id) (transform_substructure_t *this,u_int16_t id);
132
133 /**
134 * @brief get transform id of the current transform.
135 *
136 * @param this calling transform_substructure_t object
137 * @return Transform id of current transform substructure.
138 */
139 u_int16_t (*get_transform_id) (transform_substructure_t *this);
140
141 /**
142 * @brief Destroys an transform_substructure_t object.
143 *
144 * @param this transform_substructure_t object to destroy
145 * @return
146 * SUCCESS in any case
147 */
148 status_t (*destroy) (transform_substructure_t *this);
149 };
150
151 /**
152 * @brief Creates an empty transform_substructure_t object
153 *
154 * @return
155 * - created transform_substructure_t object, or
156 * - NULL if failed
157 */
158
159 transform_substructure_t *transform_substructure_create();
160
161 #endif /*TRANSFORM_SUBSTRUCTURE_H_*/