- parser succesfully parses sa payload
[strongswan.git] / Source / charon / 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 "payload.h"
30 #include "../utils/linked_list.h"
31 #include "transform_substructure.h"
32
33 /**
34 * Length of the proposal substructure header
35 * (without spi)
36 */
37 #define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
38
39 /**
40 * Object representing an IKEv2- PROPOSAL SUBSTRUCTURE
41 *
42 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
43 *
44 */
45 typedef struct proposal_substructure_s proposal_substructure_t;
46
47 struct proposal_substructure_s {
48 /**
49 * implements payload_t interface
50 */
51 payload_t payload_interface;
52
53 /**
54 * @brief Creates an iterator of stored transform_substructure_t objects.
55 *
56 * @warning The created iterator has to get destroyed by the caller!
57 * When deleting any transform over this iterator, call
58 * get_size to make sure the length and number values are ok.
59 *
60 * @param this calling proposal_substructure_t object
61 * @param iterator the created iterator is stored at the pointed pointer
62 * @param[in] forward iterator direction (TRUE: front to end)
63 * @return
64 * - SUCCESS or
65 * - OUT_OF_RES if iterator could not be created
66 */
67 status_t (*create_transform_substructure_iterator) (proposal_substructure_t *this,linked_list_iterator_t **iterator, bool forward);
68
69 /**
70 * @brief Adds a transform_substructure_t object to this object.
71 *
72 * @warning The added transform_substructure_t object is
73 * getting destroyed in destroy function of proposal_substructure_t.
74 *
75 * @param this calling proposal_substructure_t object
76 * @param transform transform_substructure_t object to add
77 * @return - SUCCESS if succeeded
78 * - FAILED otherwise
79 */
80 status_t (*add_transform_substructure) (proposal_substructure_t *this,transform_substructure_t *transform);
81
82 /**
83 * @brief Sets the proposal number of current proposal.
84 *
85 * @param this calling proposal_substructure_t object
86 * @param id proposal number to set
87 * @return - SUCCESS
88 */
89 status_t (*set_proposal_number) (proposal_substructure_t *this,u_int8_t proposal_number);
90
91 /**
92 * @brief get proposal number of current proposal.
93 *
94 * @param this calling proposal_substructure_t object
95 * @return proposal number of current proposal substructure.
96 */
97 u_int8_t (*get_proposal_number) (proposal_substructure_t *this);
98
99 /**
100 * @brief Sets the protocol id of current proposal.
101 *
102 * @param this calling proposal_substructure_t object
103 * @param id protocol id to set
104 * @return - SUCCESS
105 */
106 status_t (*set_protocol_id) (proposal_substructure_t *this,u_int8_t protocol_id);
107
108 /**
109 * @brief get protocol id of current proposal.
110 *
111 * @param this calling proposal_substructure_t object
112 * @return protocol id of current proposal substructure.
113 */
114 u_int8_t (*get_protocol_id) (proposal_substructure_t *this);
115
116
117 /**
118 * @brief Returns the currently set SPI of this proposal.
119 *
120 * @warning Returned data are not copied
121 *
122 * @param this calling proposal_substructure_t object
123 * @return chunk_t pointing to the value
124 */
125 chunk_t (*get_spi) (proposal_substructure_t *this);
126
127 /**
128 * @brief Sets the SPI of the current proposal.
129 *
130 * @warning SPI is getting copied
131 *
132 * @param this calling proposal_substructure_t object
133 * @param spi chunk_t pointing to the value to set
134 * @return
135 * - SUCCESS or
136 * - OUT_OF_RES
137 */
138 status_t (*set_spi) (proposal_substructure_t *this, chunk_t spi);
139
140 /**
141 * @brief Destroys an proposal_substructure_t object.
142 *
143 * @param this proposal_substructure_t object to destroy
144 * @return
145 * SUCCESS in any case
146 */
147 status_t (*destroy) (proposal_substructure_t *this);
148 };
149
150 /**
151 * @brief Creates an empty proposal_substructure_t object
152 *
153 * @return
154 * - created proposal_substructure_t object, or
155 * - NULL if failed
156 */
157
158 proposal_substructure_t *proposal_substructure_create();
159
160
161
162 #endif /*PROPOSAL_SUBSTRUCTURE_H_*/