Removed strayed code fragment
[strongswan.git] / src / charon / encoding / payloads / payload.h
1 /*
2 * Copyright (C) 2007 Tobias Brunner
3 * Copyright (C) 2005-2006 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 /**
19 * @defgroup payload payload
20 * @{ @ingroup payloads
21 */
22
23 #ifndef PAYLOAD_H_
24 #define PAYLOAD_H_
25
26 typedef enum payload_type_t payload_type_t;
27 typedef struct payload_t payload_t;
28
29 #include <library.h>
30 #include <encoding/payloads/encodings.h>
31
32
33 /**
34 * Payload-Types of a IKEv2-Message.
35 *
36 * Header and substructures are also defined as
37 * payload types with values from PRIVATE USE space.
38 */
39 enum payload_type_t{
40
41 /**
42 * End of payload list in next_payload
43 */
44 NO_PAYLOAD = 0,
45
46 /**
47 * The security association (SA) payload containing proposals.
48 */
49 SECURITY_ASSOCIATION = 33,
50
51 /**
52 * The key exchange (KE) payload containing diffie-hellman values.
53 */
54 KEY_EXCHANGE = 34,
55
56 /**
57 * Identification for the original initiator (IDi).
58 */
59 ID_INITIATOR = 35,
60
61 /**
62 * Identification for the original responder (IDr).
63 */
64 ID_RESPONDER = 36,
65
66 /**
67 * Certificate payload with certificates (CERT).
68 */
69 CERTIFICATE = 37,
70
71 /**
72 * Certificate request payload (CERTREQ).
73 */
74 CERTIFICATE_REQUEST = 38,
75
76 /**
77 * Authentication payload contains auth data (AUTH).
78 */
79 AUTHENTICATION = 39,
80
81 /**
82 * Nonces, for initator and responder (Ni, Nr, N)
83 */
84 NONCE = 40,
85
86 /**
87 * Notify paylaod (N).
88 */
89 NOTIFY = 41,
90
91 /**
92 * Delete payload (D)
93 */
94 DELETE = 42,
95
96 /**
97 * Vendor id paylpoad (V).
98 */
99 VENDOR_ID = 43,
100
101 /**
102 * Traffic selector for the original initiator (TSi).
103 */
104 TRAFFIC_SELECTOR_INITIATOR = 44,
105
106 /**
107 * Traffic selector for the original responser (TSr).
108 */
109 TRAFFIC_SELECTOR_RESPONDER = 45,
110
111 /**
112 * Encryption payload, contains other payloads (E).
113 */
114 ENCRYPTED = 46,
115
116 /**
117 * Configuration payload (CP).
118 */
119 CONFIGURATION = 47,
120
121 /**
122 * Extensible authentication payload (EAP).
123 */
124 EXTENSIBLE_AUTHENTICATION = 48,
125
126 #ifdef ME
127 /**
128 * Identification payload for peers has a value from
129 * the PRIVATE USE space.
130 */
131 ID_PEER = 128,
132 #endif /* ME */
133
134 /**
135 * Header has a value of PRIVATE USE space.
136 *
137 * This payload type is not sent over wire and just
138 * used internally to handle IKEv2-Header like a payload.
139 */
140 HEADER = 140,
141
142 /**
143 * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
144 *
145 * This payload type is not sent over wire and just
146 * used internally to handle a proposal substructure like a payload.
147 */
148 PROPOSAL_SUBSTRUCTURE = 141,
149
150 /**
151 * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
152 *
153 * This payload type is not sent over wire and just
154 * used internally to handle a transform substructure like a payload.
155 */
156 TRANSFORM_SUBSTRUCTURE = 142,
157
158 /**
159 * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
160 *
161 * This payload type is not sent over wire and just
162 * used internally to handle a transform attribute like a payload.
163 */
164 TRANSFORM_ATTRIBUTE = 143,
165
166 /**
167 * TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
168 *
169 * This payload type is not sent over wire and just
170 * used internally to handle a transform selector like a payload.
171 */
172 TRAFFIC_SELECTOR_SUBSTRUCTURE = 144,
173
174 /**
175 * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
176 *
177 * This payload type is not sent over wire and just
178 * used internally to handle a transform attribute like a payload.
179 */
180 CONFIGURATION_ATTRIBUTE = 145,
181
182 /**
183 * A unknown payload has a value of PRIVATE USE space.
184 *
185 * This payload type is not sent over wire and just
186 * used internally to handle a unknown payload.
187 */
188 UNKNOWN_PAYLOAD = 146,
189 };
190
191
192 /**
193 * enum names for payload_type_t.
194 */
195 extern enum_name_t *payload_type_names;
196
197 /**
198 * enum names for payload_type_t in a short form.
199 */
200 extern enum_name_t *payload_type_short_names;
201
202 /**
203 * Generic interface for all payload types (incl.header and substructures).
204 *
205 * To handle all kinds of payloads on a generic way, this interface must
206 * be implemented by every payload. This allows parser_t/generator_t a simple
207 * handling of all payloads.
208 */
209 struct payload_t {
210
211 /**
212 * Get encoding rules for this payload.
213 *
214 * @param rules location to store pointer of first rule
215 * @param rule_count location to store number of rules
216 */
217 void (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
218
219 /**
220 * Get type of payload.
221 *
222 * @return type of this payload
223 */
224 payload_type_t (*get_type) (payload_t *this);
225
226 /**
227 * Get type of next payload or NO_PAYLOAD (0) if this is the last one.
228 *
229 * @return type of next payload
230 */
231 payload_type_t (*get_next_type) (payload_t *this);
232
233 /**
234 * Set type of next payload.
235 *
236 * @param type type of next payload
237 */
238 void (*set_next_type) (payload_t *this,payload_type_t type);
239
240 /**
241 * Get length of payload.
242 *
243 * @return length of this payload
244 */
245 size_t (*get_length) (payload_t *this);
246
247 /**
248 * Verifies payload structure and makes consistence check.
249 *
250 * @return SUCCESS, FAILED if consistence not given
251 */
252 status_t (*verify) (payload_t *this);
253
254 /**
255 * Destroys a payload and all included substructures.
256 */
257 void (*destroy) (payload_t *this);
258 };
259
260 /**
261 * Create an empty payload.
262 *
263 * Useful for the parser, who wants a generic constructor for all payloads.
264 * It supports all payload_t methods. If a payload type is not known,
265 * an unknwon_paylod is created with the chunk of data in it.
266 *
267 * @param type type of the payload to create
268 * @return payload_t object
269 */
270 payload_t *payload_create(payload_type_t type);
271
272 #endif /** PAYLOAD_H_ @}*/