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 * 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.
48 UNDEFINED_PROTOCOL_ID
= 201,
54 typedef struct proposal_substructure_t proposal_substructure_t
;
57 * Object representing an IKEv2-PROPOSAL SUBSTRUCTURE.
59 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
63 struct proposal_substructure_t
{
65 * The payload_t interface.
67 payload_t payload_interface
;
70 * @brief Creates an iterator of stored transform_substructure_t objects.
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.
76 * @param this calling proposal_substructure_t object
77 * @param[in] forward iterator direction (TRUE: front to end)
78 * @return created iterator_t object
80 iterator_t
* (*create_transform_substructure_iterator
) (proposal_substructure_t
*this, 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
91 void (*add_transform_substructure
) (proposal_substructure_t
*this,transform_substructure_t
*transform
);
94 * @brief Sets the proposal number of current proposal.
96 * @param this calling proposal_substructure_t object
97 * @param id proposal number to set
99 void (*set_proposal_number
) (proposal_substructure_t
*this,u_int8_t proposal_number
);
102 * @brief get proposal number of current proposal.
104 * @param this calling proposal_substructure_t object
105 * @return proposal number of current proposal substructure.
107 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
110 * @brief Sets the protocol id of current proposal.
112 * @param this calling proposal_substructure_t object
113 * @param id protocol id to set
115 void (*set_protocol_id
) (proposal_substructure_t
*this,u_int8_t protocol_id
);
118 * @brief get protocol id of current proposal.
120 * @param this calling proposal_substructure_t object
121 * @return protocol id of current proposal substructure.
123 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
126 * @brief Get informations for a specific transform type.
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
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
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
);
141 * @brief Returns the currently set SPI of this proposal.
143 * @warning Returned data are not copied
145 * @param this calling proposal_substructure_t object
146 * @return chunk_t pointing to the value
148 chunk_t (*get_spi
) (proposal_substructure_t
*this);
151 * @brief Sets the SPI of the current proposal.
153 * @warning SPI is getting copied
155 * @param this calling proposal_substructure_t object
156 * @param spi chunk_t pointing to the value to set
158 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
161 * @brief Clones an proposal_substructure_t object.
163 * @param this proposal_substructure_t object to clone
164 * @return cloned object
166 proposal_substructure_t
* (*clone
) (proposal_substructure_t
*this);
169 * @brief Destroys an proposal_substructure_t object.
171 * @param this proposal_substructure_t object to destroy
173 void (*destroy
) (proposal_substructure_t
*this);
177 * @brief Creates an empty proposal_substructure_t object
179 * @return created proposal_substructure_t object
183 proposal_substructure_t
*proposal_substructure_create();
187 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/