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