- removed memory allocation checks!!!
[strongswan.git] / Source / charon / encoding / payloads / proposal_substructure.h
1 /**
2 * @file proposal_substructure.h
3 *
4 * @brief Interface of proposal_substructure_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 PROPOSAL_SUBSTRUCTURE_H_
24 #define PROPOSAL_SUBSTRUCTURE_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28 #include <encoding/payloads/transform_substructure.h>
29 #include <utils/linked_list.h>
30
31 /**
32 * Length of the proposal substructure header
33 * (without spi).
34 *
35 * @ingroup payloads
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 * @ingroup payloads
46 */
47 enum protocol_id_t {
48 UNDEFINED_PROTOCOL_ID = 201,
49 IKE = 1,
50 AH = 2,
51 ESP = 3,
52 };
53
54 typedef struct proposal_substructure_t proposal_substructure_t;
55
56 /**
57 * Object representing an IKEv2-PROPOSAL SUBSTRUCTURE.
58 *
59 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
60 *
61 * @ingroup payloads
62 */
63 struct proposal_substructure_t {
64 /**
65 * The payload_t interface.
66 */
67 payload_t payload_interface;
68
69 /**
70 * @brief Creates an iterator of stored transform_substructure_t objects.
71 *
72 * @warning The created iterator has to get destroyed by the caller!
73 * When deleting any transform over this iterator, call
74 * get_size to make sure the length and number values are ok.
75 *
76 * @param this calling proposal_substructure_t object
77 * @param iterator the created iterator is stored at the pointed pointer
78 * @param[in] forward iterator direction (TRUE: front to end)
79 */
80 void (*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 */
91 void (*add_transform_substructure) (proposal_substructure_t *this,transform_substructure_t *transform);
92
93 /**
94 * @brief Sets the proposal number of current proposal.
95 *
96 * @param this calling proposal_substructure_t object
97 * @param id proposal number to set
98 */
99 void (*set_proposal_number) (proposal_substructure_t *this,u_int8_t proposal_number);
100
101 /**
102 * @brief get proposal number of current proposal.
103 *
104 * @param this calling proposal_substructure_t object
105 * @return proposal number of current proposal substructure.
106 */
107 u_int8_t (*get_proposal_number) (proposal_substructure_t *this);
108
109 /**
110 * @brief Sets the protocol id of current proposal.
111 *
112 * @param this calling proposal_substructure_t object
113 * @param id protocol id to set
114 */
115 void (*set_protocol_id) (proposal_substructure_t *this,u_int8_t protocol_id);
116
117 /**
118 * @brief get protocol id of current proposal.
119 *
120 * @param this calling proposal_substructure_t object
121 * @return protocol id of current proposal substructure.
122 */
123 u_int8_t (*get_protocol_id) (proposal_substructure_t *this);
124
125 /**
126 * @brief Get informations for a specific transform type.
127 *
128 * @param this calling proposal_substructure_t object
129 * @param type type to get informations for
130 * @param transform_id transform id of the specific type
131 * @param key_length key length of the specific key length transform attribute
132 * @return
133 * - SUCCESS if transform type is part of this proposal and
134 * all data (incl. key length) could be fetched
135 * - NOT_FOUND if transform type is not part of this proposal
136 */
137 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);
138
139
140 /**
141 * @brief Returns the currently set SPI of this proposal.
142 *
143 * @warning Returned data are not copied
144 *
145 * @param this calling proposal_substructure_t object
146 * @return chunk_t pointing to the value
147 */
148 chunk_t (*get_spi) (proposal_substructure_t *this);
149
150 /**
151 * @brief Sets the SPI of the current proposal.
152 *
153 * @warning SPI is getting copied
154 *
155 * @param this calling proposal_substructure_t object
156 * @param spi chunk_t pointing to the value to set
157 */
158 void (*set_spi) (proposal_substructure_t *this, chunk_t spi);
159
160 /**
161 * @brief Clones an proposal_substructure_t object.
162 *
163 * @param this proposal_substructure_t object to clone
164 * @param clone cloned object will be written there
165 */
166 void (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone);
167
168 /**
169 * @brief Destroys an proposal_substructure_t object.
170 *
171 * @param this proposal_substructure_t object to destroy
172 */
173 void (*destroy) (proposal_substructure_t *this);
174 };
175
176 /**
177 * @brief Creates an empty proposal_substructure_t object
178 *
179 * @return created proposal_substructure_t object
180 *
181 * @ingroup payloads
182 */
183 proposal_substructure_t *proposal_substructure_create();
184
185
186
187 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/