Introduced payload types sa_payload and proposal_substructure
[strongswan.git] / Source / charon / payloads / payload.h
1 /**
2 * @file payload.h
3 *
4 * @brief Generic payload interface
5 *
6 *
7 */
8
9 /*
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef PAYLOAD_H_
25 #define PAYLOAD_H_
26
27 #include "encodings.h"
28 #include "../types.h"
29 #include "../definitions.h"
30
31
32 /**
33 * Payload-Types of a IKEv2-Message
34 *
35 *
36 * Header and substructures are also defined as
37 * payload types with values from PRIVATE USE space.
38 */
39 typedef enum payload_type_e payload_type_t;
40
41 enum payload_type_e{
42
43 /**
44 * NO_PAYLOAD
45 */
46 NO_PAYLOAD = 0,
47
48 /**
49 * SA
50 */
51 SECURITY_ASSOCIATION = 33,
52 /**
53 * KE
54 */
55 KEY_EXCHANGE = 34,
56 /**
57 * IDi
58 */
59 ID_INITIATOR = 35,
60 /**
61 * IDr
62 */
63 ID_RESPONDER = 36,
64 /**
65 * CERT
66 */
67 CERTIFICATE = 37,
68 /**
69 * CERTREQ
70 */
71 CERTIFICATE_REQUEST = 38,
72 /**
73 * AUTH
74 */
75 AUTHENTICATION = 39,
76 /**
77 * Ni, Nr
78 */
79 NONCE = 40,
80 /**
81 * N
82 */
83 NOTIFY = 41,
84 /**
85 * D
86 */
87 DELETE = 42,
88 /**
89 * V
90 */
91 VENDOR_ID = 43,
92 /**
93 * TSi
94 */
95 TRAFFIC_SELECTOR_INITIATOR = 44,
96 /**
97 * TSr
98 */
99 TRAFFIC_SELECTOR_RESPONDER = 45,
100 /**
101 * E
102 */
103 ENCRYPTED = 46,
104 /**
105 * CP
106 */
107 CONFIGURATION = 47,
108 /**
109 * EAP
110 */
111 EXTENSIBLE_AUTHENTICATION = 48,
112
113 /**
114 * Header has a value of PRIVATE USE space
115 *
116 * This payload type is not send over wire and just
117 * used internally to handle IKEv2-Header like a payload.
118 */
119 HEADER = 140,
120
121 /**
122 * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space
123 *
124 * This payload type is not send over wire and just
125 * used internally to handle a proposal substructure like a payload.
126 */
127 PROPOSAL_SUBSTRUCTURE = 141,
128
129 /**
130 * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space
131 *
132 * This payload type is not send over wire and just
133 * used internally to handle a transform substructure like a payload.
134 */
135 TRANSFORM_SUBSTRUCTURE = 142,
136 };
137
138
139 /*
140 * build string mapping array for payload_type_t
141 */
142 extern mapping_t payload_type_t_mappings[];
143
144
145 /**
146 * @brief Generic interface for all payload types (inclusive
147 * header and substructures)
148 *
149 *
150 */
151 typedef struct payload_s payload_t;
152
153 struct payload_s {
154 /**
155 * @brief Destroys a payload and all included substructures.
156 *
157 * @param this payload to destroy
158 * @return
159 * SUCCESS in any case
160 */
161 status_t (*destroy) (payload_t *this);
162
163 /**
164 * @brief Get encoding rules for this payload
165 *
166 * @param this calling object
167 * @param[out] rules location to store pointer of first rule
168 * @param[out] rule_count location to store number of rules
169 * @return
170 * SUCCESS in any case
171 */
172 status_t (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
173
174 /**
175 * @brief get type of payload
176 *
177 * @param this calling object
178 * @return type of this payload
179 */
180 payload_type_t (*get_type) (payload_t *this);
181
182 /**
183 * @brief get type of next payload or zero if this is the last one
184 *
185 * @param this calling object
186 * @return type of next payload
187 */
188 payload_type_t (*get_next_type) (payload_t *this);
189
190 /**
191 * @brief get length of payload
192 *
193 * @param this calling object
194 * @return length of this payload
195 */
196 size_t (*get_length) (payload_t *this);
197 };
198
199 /**
200 * @brief Create an empty payload.
201 *
202 * Useful for the parser, who wants a generic constructor for all payloads.
203 * It supports all payload_t methods.
204 *
205 * @param type type of the payload to create
206 * @return
207 * - created payload, or
208 * - NULL if failed
209 */
210
211 payload_t *payload_create(payload_type_t type);
212
213 #endif /*PAYLOAD_H_*/