show validity of OCSP responses
[strongswan.git] / src / libcharon / encoding / payloads / notify_payload.h
1 /*
2 * Copyright (C) 2006-2008 Tobias Brunner
3 * Copyright (C) 2006 Daniel Roethlisberger
4 * Copyright (C) 2005-2006 Martin Willi
5 * Copyright (C) 2005 Jan Hutter
6 * Hochschule fuer Technik Rapperswil
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 */
18
19 /**
20 * @defgroup notify_payload notify_payload
21 * @{ @ingroup payloads
22 */
23
24 #ifndef NOTIFY_PAYLOAD_H_
25 #define NOTIFY_PAYLOAD_H_
26
27 typedef enum notify_type_t notify_type_t;
28 typedef struct notify_payload_t notify_payload_t;
29
30 #include <library.h>
31 #include <encoding/payloads/payload.h>
32 #include <encoding/payloads/proposal_substructure.h>
33 #include <utils/linked_list.h>
34
35 /**
36 * Notify payload length in bytes without any spi and notification data.
37 */
38 #define NOTIFY_PAYLOAD_HEADER_LENGTH 8
39
40 /**
41 * Notify message types.
42 *
43 * See IKEv2 RFC 3.10.1.
44 */
45 enum notify_type_t {
46 /* notify error messages */
47 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
48 INVALID_IKE_SPI = 4,
49 INVALID_MAJOR_VERSION = 5,
50 INVALID_SYNTAX = 7,
51 INVALID_MESSAGE_ID = 9,
52 INVALID_SPI = 11,
53 NO_PROPOSAL_CHOSEN = 14,
54 INVALID_KE_PAYLOAD = 17,
55 AUTHENTICATION_FAILED = 24,
56 SINGLE_PAIR_REQUIRED = 34,
57 NO_ADDITIONAL_SAS = 35,
58 INTERNAL_ADDRESS_FAILURE = 36,
59 FAILED_CP_REQUIRED = 37,
60 TS_UNACCEPTABLE = 38,
61 INVALID_SELECTORS = 39,
62 /* mobile extension, RFC 4555 */
63 UNACCEPTABLE_ADDRESSES = 40,
64 UNEXPECTED_NAT_DETECTED = 41,
65 /* mobile IPv6 bootstrapping, RFC 5026 */
66 USE_ASSIGNED_HoA = 42,
67
68 /* IKE-ME, private use */
69 ME_CONNECT_FAILED = 8192,
70
71 /* notify status messages */
72 INITIAL_CONTACT = 16384,
73 SET_WINDOW_SIZE = 16385,
74 ADDITIONAL_TS_POSSIBLE = 16386,
75 IPCOMP_SUPPORTED = 16387,
76 NAT_DETECTION_SOURCE_IP = 16388,
77 NAT_DETECTION_DESTINATION_IP = 16389,
78 COOKIE = 16390,
79 USE_TRANSPORT_MODE = 16391,
80 HTTP_CERT_LOOKUP_SUPPORTED = 16392,
81 REKEY_SA = 16393,
82 ESP_TFC_PADDING_NOT_SUPPORTED = 16394,
83 NON_FIRST_FRAGMENTS_ALSO = 16395,
84 /* mobike extension, RFC4555 */
85 MOBIKE_SUPPORTED = 16396,
86 ADDITIONAL_IP4_ADDRESS = 16397,
87 ADDITIONAL_IP6_ADDRESS = 16398,
88 NO_ADDITIONAL_ADDRESSES = 16399,
89 UPDATE_SA_ADDRESSES = 16400,
90 COOKIE2 = 16401,
91 NO_NATS_ALLOWED = 16402,
92 /* repeated authentication extension, RFC4478 */
93 AUTH_LIFETIME = 16403,
94 /* multiple authentication exchanges, RFC 4739 */
95 MULTIPLE_AUTH_SUPPORTED = 16404,
96 ANOTHER_AUTH_FOLLOWS = 16405,
97 /* redirect mechanism, RFC 5685 */
98 REDIRECT_SUPPORTED = 16406,
99 REDIRECT = 16407,
100 REDIRECTED_FROM = 16408,
101 /* session resumption, RFC 5723 */
102 TICKET_LT_OPAQUE = 16409,
103 TICKET_REQUEST = 16410,
104 TICKET_ACK = 16411,
105 TICKET_NACK = 16412,
106 TICKET_OPAQUE = 16413,
107 /* IPv6 configuration, RFC 5739 */
108 LINK_ID = 16414,
109 /* wrapped esp, RFC 5840 */
110 USE_WESP_MODE = 16415,
111 /* robust header compression, RFC 5857 */
112 ROHC_SUPPORTED = 16416,
113 /* RFC-ietf-ipsecme-eap-mutual, assigned by IANA */
114 EAP_ONLY_AUTHENTICATION = 16417,
115
116 /* BEET mode, not even a draft yet. private use */
117 USE_BEET_MODE = 40961,
118 /* IKE-ME, private use */
119 ME_MEDIATION = 40962,
120 ME_ENDPOINT = 40963,
121 ME_CALLBACK = 40964,
122 ME_CONNECTID = 40965,
123 ME_CONNECTKEY = 40966,
124 ME_CONNECTAUTH = 40967,
125 ME_RESPONSE = 40968
126 };
127
128 /**
129 * enum name for notify_type_t.
130 */
131 extern enum_name_t *notify_type_names;
132
133 /**
134 * enum name for notify_type_t (shorter strings).
135 */
136 extern enum_name_t *notify_type_short_names;
137
138 /**
139 * Class representing an IKEv2-Notify Payload.
140 *
141 * The Notify Payload format is described in Draft section 3.10.
142 */
143 struct notify_payload_t {
144 /**
145 * The payload_t interface.
146 */
147 payload_t payload_interface;
148
149 /**
150 * Gets the protocol id of this payload.
151 *
152 * @return protocol id of this payload
153 */
154 u_int8_t (*get_protocol_id) (notify_payload_t *this);
155
156 /**
157 * Sets the protocol id of this payload.
158 *
159 * @param protocol_id protocol id to set
160 */
161 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
162
163 /**
164 * Gets the notify message type of this payload.
165 *
166 * @return notify message type of this payload
167 */
168 notify_type_t (*get_notify_type) (notify_payload_t *this);
169
170 /**
171 * Sets notify message type of this payload.
172 *
173 * @param type notify message type to set
174 */
175 void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
176
177 /**
178 * Returns the currently set spi of this payload.
179 *
180 * This is only valid for notifys with protocol AH|ESP
181 *
182 * @return SPI value
183 */
184 u_int32_t (*get_spi) (notify_payload_t *this);
185
186 /**
187 * Sets the spi of this payload.
188 *
189 * This is only valid for notifys with protocol AH|ESP
190 *
191 * @param spi SPI value
192 */
193 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
194
195 /**
196 * Returns the currently set notification data of payload.
197 *
198 * Returned data are not copied.
199 *
200 * @return chunk_t pointing to the value
201 */
202 chunk_t (*get_notification_data) (notify_payload_t *this);
203
204 /**
205 * Sets the notification data of this payload.
206 *
207 * @warning Value is getting copied.
208 *
209 * @param notification_data chunk_t pointing to the value to set
210 */
211 void (*set_notification_data) (notify_payload_t *this,
212 chunk_t notification_data);
213
214 /**
215 * Destroys an notify_payload_t object.
216 */
217 void (*destroy) (notify_payload_t *this);
218 };
219
220 /**
221 * Creates an empty notify_payload_t object
222 *
223 * @return created notify_payload_t object
224 */
225 notify_payload_t *notify_payload_create(void);
226
227 /**
228 * Creates an notify_payload_t object of specific type for specific protocol id.
229 *
230 * @param protocol_id protocol id (IKE, AH or ESP)
231 * @param type notify type (see notify_type_t)
232 * @return notify_payload_t object
233 */
234 notify_payload_t *notify_payload_create_from_protocol_and_type(
235 protocol_id_t protocol_id, notify_type_t type);
236
237 #endif /** NOTIFY_PAYLOAD_H_ @}*/