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