changed enum and structs names to _t
[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,linked_list_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 /**
131 * @brief Returns the currently set SPI of this proposal.
132 *
133 * @warning Returned data are not copied
134 *
135 * @param this calling proposal_substructure_t object
136 * @return chunk_t pointing to the value
137 */
138 chunk_t (*get_spi) (proposal_substructure_t *this);
139
140 /**
141 * @brief Sets the SPI of the current proposal.
142 *
143 * @warning SPI is getting copied
144 *
145 * @param this calling proposal_substructure_t object
146 * @param spi chunk_t pointing to the value to set
147 * @return
148 * - SUCCESS or
149 * - OUT_OF_RES
150 */
151 status_t (*set_spi) (proposal_substructure_t *this, chunk_t spi);
152
153 /**
154 * @brief Clones an proposal_substructure_t object.
155 *
156 * @param this proposal_substructure_t object to clone
157 * @param clone cloned object will be written there
158 * @return
159 * - SUCCESS
160 * - OUT_OF_RES
161 */
162 status_t (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone);
163
164 /**
165 * @brief Destroys an proposal_substructure_t object.
166 *
167 * @param this proposal_substructure_t object to destroy
168 * @return
169 * SUCCESS in any case
170 */
171 status_t (*destroy) (proposal_substructure_t *this);
172 };
173
174 /**
175 * @brief Creates an empty proposal_substructure_t object
176 *
177 * @return
178 * - created proposal_substructure_t object, or
179 * - NULL if failed
180 */
181
182 proposal_substructure_t *proposal_substructure_create();
183
184
185
186 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/