9539231ca536f90f550b5006948a355c652bbd42
[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 message types for IKEv2, and a subset for IKEv1.
37 */
38 enum notify_type_t {
39 /* notify error messages */
40 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
41 /* IKEv1 alias */
42 INVALID_PAYLOAD_TYPE = 1,
43 INVALID_IKE_SPI = 4,
44 INVALID_MAJOR_VERSION = 5,
45 INVALID_SYNTAX = 7,
46 /* IKEv1 alias */
47 INVALID_EXCHANGE_TYPE = 7,
48 INVALID_MESSAGE_ID = 9,
49 INVALID_SPI = 11,
50 NO_PROPOSAL_CHOSEN = 14,
51 /* IKEv1 only */
52 PAYLOAD_MALFORMED = 16,
53 INVALID_KE_PAYLOAD = 17,
54 /* IKEv1 only */
55 INVALID_HASH_INFORMATION = 23,
56 AUTHENTICATION_FAILED = 24,
57 SINGLE_PAIR_REQUIRED = 34,
58 NO_ADDITIONAL_SAS = 35,
59 INTERNAL_ADDRESS_FAILURE = 36,
60 FAILED_CP_REQUIRED = 37,
61 TS_UNACCEPTABLE = 38,
62 INVALID_SELECTORS = 39,
63 /* mobile extension, RFC 4555 */
64 UNACCEPTABLE_ADDRESSES = 40,
65 UNEXPECTED_NAT_DETECTED = 41,
66 /* mobile IPv6 bootstrapping, RFC 5026 */
67 USE_ASSIGNED_HoA = 42,
68 /* IKEv2 RFC 5996 */
69 TEMPORARY_FAILURE = 43,
70 CHILD_SA_NOT_FOUND = 44,
71
72 /* IKE-ME, private use */
73 ME_CONNECT_FAILED = 8192,
74
75 /* Windows error code */
76 MS_NOTIFY_STATUS = 12345,
77
78 /* notify status messages */
79 INITIAL_CONTACT = 16384,
80 SET_WINDOW_SIZE = 16385,
81 ADDITIONAL_TS_POSSIBLE = 16386,
82 IPCOMP_SUPPORTED = 16387,
83 NAT_DETECTION_SOURCE_IP = 16388,
84 NAT_DETECTION_DESTINATION_IP = 16389,
85 COOKIE = 16390,
86 USE_TRANSPORT_MODE = 16391,
87 HTTP_CERT_LOOKUP_SUPPORTED = 16392,
88 REKEY_SA = 16393,
89 ESP_TFC_PADDING_NOT_SUPPORTED = 16394,
90 NON_FIRST_FRAGMENTS_ALSO = 16395,
91 /* mobike extension, RFC4555 */
92 MOBIKE_SUPPORTED = 16396,
93 ADDITIONAL_IP4_ADDRESS = 16397,
94 ADDITIONAL_IP6_ADDRESS = 16398,
95 NO_ADDITIONAL_ADDRESSES = 16399,
96 UPDATE_SA_ADDRESSES = 16400,
97 COOKIE2 = 16401,
98 NO_NATS_ALLOWED = 16402,
99 /* repeated authentication extension, RFC4478 */
100 AUTH_LIFETIME = 16403,
101 /* multiple authentication exchanges, RFC 4739 */
102 MULTIPLE_AUTH_SUPPORTED = 16404,
103 ANOTHER_AUTH_FOLLOWS = 16405,
104 /* redirect mechanism, RFC 5685 */
105 REDIRECT_SUPPORTED = 16406,
106 REDIRECT = 16407,
107 REDIRECTED_FROM = 16408,
108 /* session resumption, RFC 5723 */
109 TICKET_LT_OPAQUE = 16409,
110 TICKET_REQUEST = 16410,
111 TICKET_ACK = 16411,
112 TICKET_NACK = 16412,
113 TICKET_OPAQUE = 16413,
114 /* IPv6 configuration, RFC 5739 */
115 LINK_ID = 16414,
116 /* wrapped esp, RFC 5840 */
117 USE_WESP_MODE = 16415,
118 /* robust header compression, RFC 5857 */
119 ROHC_SUPPORTED = 16416,
120 /* EAP-only authentication, RFC 5998 */
121 EAP_ONLY_AUTHENTICATION = 16417,
122 /* Childless initiation of IKEv2 SA, RFC 6023 */
123 CHILDLESS_IKEV2_SUPPORTED = 16418,
124 /* Quick crash detection for IKE, RFC 6290 */
125 QUICK_CRASH_DETECTION = 16419,
126 /* High availability of IKEv2/IPsec, RFC 6311 */
127 IKEV2_MESSAGE_ID_SYNC_SUPPORTED = 16420,
128 IKEV2_REPLAY_COUNTER_SYNC_SUPPORTED = 16421,
129 IKEV2_MESSAGE_ID_SYNC = 16422,
130 IPSEC_REPLAY_COUNTER_SYNC = 16423,
131 /* IKEv1 initial contact */
132 INITIAL_CONTACT_IKEV1 = 24578,
133 /* BEET mode, not even a draft yet. private use */
134 USE_BEET_MODE = 40961,
135 /* IKE-ME, private use */
136 ME_MEDIATION = 40962,
137 ME_ENDPOINT = 40963,
138 ME_CALLBACK = 40964,
139 ME_CONNECTID = 40965,
140 ME_CONNECTKEY = 40966,
141 ME_CONNECTAUTH = 40967,
142 ME_RESPONSE = 40968
143 };
144
145 /**
146 * enum name for notify_type_t.
147 */
148 extern enum_name_t *notify_type_names;
149
150 /**
151 * enum name for notify_type_t (shorter strings).
152 */
153 extern enum_name_t *notify_type_short_names;
154
155 /**
156 * Class representing an IKEv2-Notify Payload.
157 *
158 * The Notify Payload format is described in Draft section 3.10.
159 */
160 struct notify_payload_t {
161 /**
162 * The payload_t interface.
163 */
164 payload_t payload_interface;
165
166 /**
167 * Gets the protocol id of this payload.
168 *
169 * @return protocol id of this payload
170 */
171 u_int8_t (*get_protocol_id) (notify_payload_t *this);
172
173 /**
174 * Sets the protocol id of this payload.
175 *
176 * @param protocol_id protocol id to set
177 */
178 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
179
180 /**
181 * Gets the notify message type of this payload.
182 *
183 * @return notify message type of this payload
184 */
185 notify_type_t (*get_notify_type) (notify_payload_t *this);
186
187 /**
188 * Sets notify message type of this payload.
189 *
190 * @param type notify message type to set
191 */
192 void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
193
194 /**
195 * Returns the currently set spi of this payload.
196 *
197 * This is only valid for notifys with protocol AH|ESP
198 *
199 * @return SPI value
200 */
201 u_int32_t (*get_spi) (notify_payload_t *this);
202
203 /**
204 * Sets the spi of this payload.
205 *
206 * This is only valid for notifys with protocol AH|ESP
207 *
208 * @param spi SPI value
209 */
210 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
211
212 /**
213 * Returns the currently set notification data of payload.
214 *
215 * Returned data are not copied.
216 *
217 * @return chunk_t pointing to the value
218 */
219 chunk_t (*get_notification_data) (notify_payload_t *this);
220
221 /**
222 * Sets the notification data of this payload.
223 *
224 * @warning Value is getting copied.
225 *
226 * @param notification_data chunk_t pointing to the value to set
227 */
228 void (*set_notification_data) (notify_payload_t *this,
229 chunk_t notification_data);
230
231 /**
232 * Destroys an notify_payload_t object.
233 */
234 void (*destroy) (notify_payload_t *this);
235 };
236
237 /**
238 * Creates an empty notify_payload_t object
239 *
240 * @param type payload type, NOTIFY or NOTIFY_V1
241 * @return created notify_payload_t object
242 */
243 notify_payload_t *notify_payload_create(payload_type_t type);
244
245 /**
246 * Creates an notify_payload_t object of specific type for specific protocol id.
247 *
248 * @param type payload type, NOTIFY or NOTIFY_V1
249 * @param protocol protocol id (IKE, AH or ESP)
250 * @param type notify type (see notify_type_t)
251 * @return notify_payload_t object
252 */
253 notify_payload_t *notify_payload_create_from_protocol_and_type(
254 payload_type_t type, protocol_id_t protocol, notify_type_t notify);
255
256 #endif /** NOTIFY_PAYLOAD_H_ @}*/