2 * @file proposal_substructure.h
4 * @brief Declaration of the class proposal_substructure_t.
6 * An object of this type represents an IKEv2 PROPOSAL Substructure and contains transforms.
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
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>.
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
25 #ifndef PROPOSAL_SUBSTRUCTURE_H_
26 #define PROPOSAL_SUBSTRUCTURE_H_
29 #include <encoding/payloads/payload.h>
30 #include <encoding/payloads/transform_substructure.h>
31 #include <utils/linked_list.h>
34 * Length of the proposal substructure header
37 #define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
40 typedef enum protocol_id_t protocol_id_t
;
43 * Protocol ID of a proposal
46 UNDEFINED_PROTOCOL_ID
= 201,
52 typedef struct proposal_substructure_t proposal_substructure_t
;
55 * Object representing an IKEv2- PROPOSAL SUBSTRUCTURE
57 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
60 struct proposal_substructure_t
{
62 * implements payload_t interface
64 payload_t payload_interface
;
67 * @brief Creates an iterator of stored transform_substructure_t objects.
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.
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)
78 * - OUT_OF_RES if iterator could not be created
80 status_t (*create_transform_substructure_iterator
) (proposal_substructure_t
*this,iterator_t
**iterator
, bool forward
);
83 * @brief Adds a transform_substructure_t object to this object.
85 * @warning The added transform_substructure_t object is
86 * getting destroyed in destroy function of proposal_substructure_t.
88 * @param this calling proposal_substructure_t object
89 * @param transform transform_substructure_t object to add
90 * @return - SUCCESS if succeeded
93 status_t (*add_transform_substructure
) (proposal_substructure_t
*this,transform_substructure_t
*transform
);
96 * @brief Sets the proposal number of current proposal.
98 * @param this calling proposal_substructure_t object
99 * @param id proposal number to set
102 status_t (*set_proposal_number
) (proposal_substructure_t
*this,u_int8_t proposal_number
);
105 * @brief get proposal number of current proposal.
107 * @param this calling proposal_substructure_t object
108 * @return proposal number of current proposal substructure.
110 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
113 * @brief Sets the protocol id of current proposal.
115 * @param this calling proposal_substructure_t object
116 * @param id protocol id to set
119 status_t (*set_protocol_id
) (proposal_substructure_t
*this,u_int8_t protocol_id
);
122 * @brief get protocol id of current proposal.
124 * @param this calling proposal_substructure_t object
125 * @return protocol id of current proposal substructure.
127 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
131 * @brief Returns the currently set SPI of this proposal.
133 * @warning Returned data are not copied
135 * @param this calling proposal_substructure_t object
136 * @return chunk_t pointing to the value
138 chunk_t (*get_spi
) (proposal_substructure_t
*this);
141 * @brief Sets the SPI of the current proposal.
143 * @warning SPI is getting copied
145 * @param this calling proposal_substructure_t object
146 * @param spi chunk_t pointing to the value to set
151 status_t (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
154 * @brief Clones an proposal_substructure_t object.
156 * @param this proposal_substructure_t object to clone
157 * @param clone cloned object will be written there
162 status_t (*clone
) (proposal_substructure_t
*this,proposal_substructure_t
**clone
);
165 * @brief Destroys an proposal_substructure_t object.
167 * @param this proposal_substructure_t object to destroy
169 * SUCCESS in any case
171 status_t (*destroy
) (proposal_substructure_t
*this);
175 * @brief Creates an empty proposal_substructure_t object
178 * - created proposal_substructure_t object, or
182 proposal_substructure_t
*proposal_substructure_create();
186 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/