2 * @file proposal_substructure.h
4 * @brief Interface of proposal_substructure_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
23 #ifndef PROPOSAL_SUBSTRUCTURE_H_
24 #define PROPOSAL_SUBSTRUCTURE_H_
27 #include <encoding/payloads/payload.h>
28 #include <encoding/payloads/transform_substructure.h>
29 #include <utils/linked_list.h>
32 * IKEv1 Value for a proposal payload.
36 #define PROPOSAL_TYPE_VALUE 2
39 * Length of the proposal substructure header
44 #define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
47 typedef enum protocol_id_t protocol_id_t
;
50 * Protocol ID of a proposal.
55 UNDEFINED_PROTOCOL_ID
= 201,
62 * String mappings for protocol_id_t.
64 extern mapping_t protocol_id_m
[];
66 typedef struct proposal_substructure_t proposal_substructure_t
;
69 * Object representing an IKEv2-PROPOSAL SUBSTRUCTURE.
71 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
75 struct proposal_substructure_t
{
77 * The payload_t interface.
79 payload_t payload_interface
;
82 * @brief Creates an iterator of stored transform_substructure_t objects.
84 * @warning The created iterator has to get destroyed by the caller!
85 * When deleting any transform over this iterator, call
86 * get_size to make sure the length and number values are ok.
88 * @param this calling proposal_substructure_t object
89 * @param[in] forward iterator direction (TRUE: front to end)
90 * @return created iterator_t object
92 iterator_t
* (*create_transform_substructure_iterator
) (proposal_substructure_t
*this, bool forward
);
95 * @brief Adds a transform_substructure_t object to this object.
97 * @warning The added transform_substructure_t object is
98 * getting destroyed in destroy function of proposal_substructure_t.
100 * @param this calling proposal_substructure_t object
101 * @param transform transform_substructure_t object to add
103 void (*add_transform_substructure
) (proposal_substructure_t
*this,transform_substructure_t
*transform
);
106 * @brief Sets the proposal number of current proposal.
108 * @param this calling proposal_substructure_t object
109 * @param id proposal number to set
111 void (*set_proposal_number
) (proposal_substructure_t
*this,u_int8_t proposal_number
);
114 * @brief get proposal number of current proposal.
116 * @param this calling proposal_substructure_t object
117 * @return proposal number of current proposal substructure.
119 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
122 * @brief get the number of transforms in current proposal.
124 * @param this calling proposal_substructure_t object
125 * @return transform count in current proposal
127 size_t (*get_transform_count
) (proposal_substructure_t
*this);
130 * @brief get size of the set spi in bytes.
132 * @param this calling proposal_substructure_t object
133 * @return size of the spi in bytes
135 size_t (*get_spi_size
) (proposal_substructure_t
*this);
138 * @brief Sets the protocol id of current proposal.
140 * @param this calling proposal_substructure_t object
141 * @param id protocol id to set
143 void (*set_protocol_id
) (proposal_substructure_t
*this,u_int8_t protocol_id
);
146 * @brief get protocol id of current proposal.
148 * @param this calling proposal_substructure_t object
149 * @return protocol id of current proposal substructure.
151 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
154 * @brief Get informations for a specific transform type.
156 * @param this calling proposal_substructure_t object
157 * @param type type to get informations for
158 * @param transform_id transform id of the specific type
159 * @param key_length key length of the specific key length transform attribute
161 * - SUCCESS if transform type is part of this proposal and
162 * all data (incl. key length) could be fetched
163 * - NOT_FOUND if transform type is not part of this proposal
165 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
);
168 * @brief Sets the next_payload field of this substructure
170 * If this is the last proposal, next payload field is set to 0,
173 * @param this calling proposal_substructure_t object
174 * @param is_last When TRUE, next payload field is set to 0, otherwise to 2
176 void (*set_is_last_proposal
) (proposal_substructure_t
*this, bool is_last
);
179 * @brief Returns the currently set SPI of this proposal.
181 * @warning Returned data are not copied
183 * @param this calling proposal_substructure_t object
184 * @return chunk_t pointing to the value
186 chunk_t (*get_spi
) (proposal_substructure_t
*this);
189 * @brief Sets the SPI of the current proposal.
191 * @warning SPI is getting copied
193 * @param this calling proposal_substructure_t object
194 * @param spi chunk_t pointing to the value to set
196 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
199 * @brief Clones an proposal_substructure_t object.
201 * @param this proposal_substructure_t object to clone
202 * @return cloned object
204 proposal_substructure_t
* (*clone
) (proposal_substructure_t
*this);
207 * @brief Destroys an proposal_substructure_t object.
209 * @param this proposal_substructure_t object to destroy
211 void (*destroy
) (proposal_substructure_t
*this);
215 * @brief Creates an empty proposal_substructure_t object
217 * @return created proposal_substructure_t object
221 proposal_substructure_t
*proposal_substructure_create();
225 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/