70ad47b4bbf2905f86e9ec9a395205e30364e31c
[strongswan.git] / src / charon / 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 * $Id$
19 */
20
21 /**
22 * @defgroup notify_payload notify_payload
23 * @{ @ingroup payloads
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 #define NOTIFY_PAYLOAD_HEADER_LENGTH 8
41
42 /**
43 * Notify message types.
44 *
45 * See IKEv2 RFC 3.10.1.
46 */
47 enum notify_type_t {
48 /* notify error messages */
49 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
50 INVALID_IKE_SPI = 4,
51 INVALID_MAJOR_VERSION = 5,
52 INVALID_SYNTAX = 7,
53 INVALID_MESSAGE_ID = 9,
54 INVALID_SPI = 11,
55 NO_PROPOSAL_CHOSEN = 14,
56 INVALID_KE_PAYLOAD = 17,
57 AUTHENTICATION_FAILED = 24,
58 SINGLE_PAIR_REQUIRED = 34,
59 NO_ADDITIONAL_SAS = 35,
60 INTERNAL_ADDRESS_FAILURE = 36,
61 FAILED_CP_REQUIRED = 37,
62 TS_UNACCEPTABLE = 38,
63 INVALID_SELECTORS = 39,
64 UNACCEPTABLE_ADDRESSES = 40,
65 UNEXPECTED_NAT_DETECTED = 41,
66 /* IKE-ME, private use */
67 ME_CONNECT_FAILED = 8192,
68
69 /* notify status messages */
70 INITIAL_CONTACT = 16384,
71 SET_WINDOW_SIZE = 16385,
72 ADDITIONAL_TS_POSSIBLE = 16386,
73 IPCOMP_SUPPORTED = 16387,
74 NAT_DETECTION_SOURCE_IP = 16388,
75 NAT_DETECTION_DESTINATION_IP = 16389,
76 COOKIE = 16390,
77 USE_TRANSPORT_MODE = 16391,
78 HTTP_CERT_LOOKUP_SUPPORTED = 16392,
79 REKEY_SA = 16393,
80 ESP_TFC_PADDING_NOT_SUPPORTED = 16394,
81 NON_FIRST_FRAGMENTS_ALSO = 16395,
82 /* mobike extension, RFC4555 */
83 MOBIKE_SUPPORTED = 16396,
84 ADDITIONAL_IP4_ADDRESS = 16397,
85 ADDITIONAL_IP6_ADDRESS = 16398,
86 NO_ADDITIONAL_ADDRESSES = 16399,
87 UPDATE_SA_ADDRESSES = 16400,
88 COOKIE2 = 16401,
89 NO_NATS_ALLOWED = 16402,
90 /* repeated authentication extension, RFC4478 */
91 AUTH_LIFETIME = 16403,
92 /* multiple authentication exchanges, RFC 4739 */
93 MULTIPLE_AUTH_SUPPORTED = 16404,
94 ANOTHER_AUTH_FOLLOWS = 16405,
95 /* draft-eronen-ipsec-ikev2-eap-auth, not assigned by IANA yet */
96 EAP_ONLY_AUTHENTICATION = 40960,
97 /* BEET mode, not even a draft yet. private use */
98 USE_BEET_MODE = 40961,
99 /* IKE-ME, private use */
100 ME_MEDIATION = 40962,
101 ME_ENDPOINT = 40963,
102 ME_CALLBACK = 40964,
103 ME_CONNECTID = 40965,
104 ME_CONNECTKEY = 40966,
105 ME_CONNECTAUTH = 40967,
106 ME_RESPONSE = 40968
107 };
108
109 /**
110 * enum name for notify_type_t.
111 */
112 extern enum_name_t *notify_type_names;
113
114 /**
115 * enum name for notify_type_t (shorter strings).
116 */
117 extern enum_name_t *notify_type_short_names;
118
119 /**
120 * Class representing an IKEv2-Notify Payload.
121 *
122 * The Notify Payload format is described in Draft section 3.10.
123 */
124 struct notify_payload_t {
125 /**
126 * The payload_t interface.
127 */
128 payload_t payload_interface;
129
130 /**
131 * Gets the protocol id of this payload.
132 *
133 * @return protocol id of this payload
134 */
135 u_int8_t (*get_protocol_id) (notify_payload_t *this);
136
137 /**
138 * Sets the protocol id of this payload.
139 *
140 * @param protocol_id protocol id to set
141 */
142 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
143
144 /**
145 * Gets the notify message type of this payload.
146 *
147 * @return notify message type of this payload
148 */
149 notify_type_t (*get_notify_type) (notify_payload_t *this);
150
151 /**
152 * Sets notify message type of this payload.
153 *
154 * @param type notify message type to set
155 */
156 void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
157
158 /**
159 * Returns the currently set spi of this payload.
160 *
161 * This is only valid for notifys with protocol AH|ESP
162 *
163 * @return SPI value
164 */
165 u_int32_t (*get_spi) (notify_payload_t *this);
166
167 /**
168 * Sets the spi of this payload.
169 *
170 * This is only valid for notifys with protocol AH|ESP
171 *
172 * @param spi SPI value
173 */
174 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
175
176 /**
177 * Returns the currently set notification data of payload.
178 *
179 * Returned data are not copied.
180 *
181 * @return chunk_t pointing to the value
182 */
183 chunk_t (*get_notification_data) (notify_payload_t *this);
184
185 /**
186 * Sets the notification data of this payload.
187 *
188 * @warning Value is getting copied.
189 *
190 * @param notification_data chunk_t pointing to the value to set
191 */
192 void (*set_notification_data) (notify_payload_t *this,
193 chunk_t notification_data);
194
195 /**
196 * Destroys an notify_payload_t object.
197 */
198 void (*destroy) (notify_payload_t *this);
199 };
200
201 /**
202 * Creates an empty notify_payload_t object
203 *
204 * @return created notify_payload_t object
205 */
206 notify_payload_t *notify_payload_create(void);
207
208 /**
209 * Creates an notify_payload_t object of specific type for specific protocol id.
210 *
211 * @param protocol_id protocol id (IKE, AH or ESP)
212 * @param type notify type (see notify_type_t)
213 * @return notify_payload_t object
214 */
215 notify_payload_t *notify_payload_create_from_protocol_and_type(
216 protocol_id_t protocol_id, notify_type_t type);
217
218 #endif /*NOTIFY_PAYLOAD_H_ @} */