- added compution of all needed keys and also creation of needed
[strongswan.git] / Source / charon / encoding / payloads / proposal_substructure.h
1 /**
2 * @file proposal_substructure.h
3 *
4 * @brief Declaration of the class proposal_substructure_t.
5 *
6 * An object of this type represents an IKEv2 PROPOSAL Substructure and contains transforms.
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 PROPOSAL_SUBSTRUCTURE_H_
26 #define PROPOSAL_SUBSTRUCTURE_H_
27
28 #include <types.h>
29 #include <encoding/payloads/payload.h>
30 #include <encoding/payloads/transform_substructure.h>
31 #include <utils/linked_list.h>
32
33 /**
34 * Length of the proposal substructure header
35 * (without spi)
36 */
37 #define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
38
39
40 typedef enum protocol_id_t protocol_id_t;
41
42 /**
43 * Protocol ID of a proposal
44 */
45 enum protocol_id_t {
46 UNDEFINED_PROTOCOL_ID = 201,
47 IKE = 1,
48 AH = 2,
49 ESP = 3,
50 };
51
52 typedef struct proposal_substructure_t proposal_substructure_t;
53
54 /**
55 * Object representing an IKEv2- PROPOSAL SUBSTRUCTURE
56 *
57 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
58 *
59 */
60 struct proposal_substructure_t {
61 /**
62 * implements payload_t interface
63 */
64 payload_t payload_interface;
65
66 /**
67 * @brief Creates an iterator of stored transform_substructure_t objects.
68 *
69 * @warning The created iterator has to get destroyed by the caller!
70 * When deleting any transform over this iterator, call
71 * get_size to make sure the length and number values are ok.
72 *
73 * @param this calling proposal_substructure_t object
74 * @param iterator the created iterator is stored at the pointed pointer
75 * @param[in] forward iterator direction (TRUE: front to end)
76 * @return
77 * - SUCCESS or
78 * - OUT_OF_RES if iterator could not be created
79 */
80 status_t (*create_transform_substructure_iterator) (proposal_substructure_t *this,iterator_t **iterator, bool forward);
81
82 /**
83 * @brief Adds a transform_substructure_t object to this object.
84 *
85 * @warning The added transform_substructure_t object is
86 * getting destroyed in destroy function of proposal_substructure_t.
87 *
88 * @param this calling proposal_substructure_t object
89 * @param transform transform_substructure_t object to add
90 * @return - SUCCESS if succeeded
91 * - FAILED otherwise
92 */
93 status_t (*add_transform_substructure) (proposal_substructure_t *this,transform_substructure_t *transform);
94
95 /**
96 * @brief Sets the proposal number of current proposal.
97 *
98 * @param this calling proposal_substructure_t object
99 * @param id proposal number to set
100 * @return - SUCCESS
101 */
102 status_t (*set_proposal_number) (proposal_substructure_t *this,u_int8_t proposal_number);
103
104 /**
105 * @brief get proposal number of current proposal.
106 *
107 * @param this calling proposal_substructure_t object
108 * @return proposal number of current proposal substructure.
109 */
110 u_int8_t (*get_proposal_number) (proposal_substructure_t *this);
111
112 /**
113 * @brief Sets the protocol id of current proposal.
114 *
115 * @param this calling proposal_substructure_t object
116 * @param id protocol id to set
117 * @return - SUCCESS
118 */
119 status_t (*set_protocol_id) (proposal_substructure_t *this,u_int8_t protocol_id);
120
121 /**
122 * @brief get protocol id of current proposal.
123 *
124 * @param this calling proposal_substructure_t object
125 * @return protocol id of current proposal substructure.
126 */
127 u_int8_t (*get_protocol_id) (proposal_substructure_t *this);
128
129 /**
130 * @brief Get informations for a specific transform type.
131 *
132 * @param this calling proposal_substructure_t object
133 * @param type type to get informations for
134 * @param transform_id transform id of the specific type
135 * @param key_length key length of the specific key length transform attribute
136 * @return
137 * - SUCCESS if transform type is part of this proposal and
138 * all data (incl. key length) could be fetched
139 * - FAILED if transform type is not part of this proposal
140 * - OUT_OF_RES
141 */
142 status_t (*get_info_for_transform_type) (proposal_substructure_t *this,transform_type_t type, u_int16_t *transform_id, u_int16_t *key_length);
143
144
145 /**
146 * @brief Returns the currently set SPI of this proposal.
147 *
148 * @warning Returned data are not copied
149 *
150 * @param this calling proposal_substructure_t object
151 * @return chunk_t pointing to the value
152 */
153 chunk_t (*get_spi) (proposal_substructure_t *this);
154
155 /**
156 * @brief Sets the SPI of the current proposal.
157 *
158 * @warning SPI is getting copied
159 *
160 * @param this calling proposal_substructure_t object
161 * @param spi chunk_t pointing to the value to set
162 * @return
163 * - SUCCESS or
164 * - OUT_OF_RES
165 */
166 status_t (*set_spi) (proposal_substructure_t *this, chunk_t spi);
167
168 /**
169 * @brief Clones an proposal_substructure_t object.
170 *
171 * @param this proposal_substructure_t object to clone
172 * @param clone cloned object will be written there
173 * @return
174 * - SUCCESS
175 * - OUT_OF_RES
176 */
177 status_t (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone);
178
179 /**
180 * @brief Destroys an proposal_substructure_t object.
181 *
182 * @param this proposal_substructure_t object to destroy
183 * @return
184 * SUCCESS in any case
185 */
186 status_t (*destroy) (proposal_substructure_t *this);
187 };
188
189 /**
190 * @brief Creates an empty proposal_substructure_t object
191 *
192 * @return
193 * - created proposal_substructure_t object, or
194 * - NULL if failed
195 */
196
197 proposal_substructure_t *proposal_substructure_create();
198
199
200
201 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/