replaced the COOKIE notify payload in connectivity checks with a ME_CONNECTAUTH notif...
[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 /* draft-eronen-ipsec-ikev2-eap-auth, not assigned by IANA yet */
93 EAP_ONLY_AUTHENTICATION = 40960,
94 /* BEET mode, not even a draft yet. private use */
95 USE_BEET_MODE = 40961,
96 /* IKE-ME, private use */
97 ME_MEDIATION = 40962,
98 ME_ENDPOINT = 40963,
99 ME_CALLBACK = 40964,
100 ME_CONNECTID = 40965,
101 ME_CONNECTKEY = 40966,
102 ME_CONNECTAUTH = 40967,
103 ME_RESPONSE = 40968
104 };
105
106 /**
107 * enum name for notify_type_t.
108 */
109 extern enum_name_t *notify_type_names;
110
111 /**
112 * enum name for notify_type_t (shorter strings).
113 */
114 extern enum_name_t *notify_type_short_names;
115
116 /**
117 * Class representing an IKEv2-Notify Payload.
118 *
119 * The Notify Payload format is described in Draft section 3.10.
120 */
121 struct notify_payload_t {
122 /**
123 * The payload_t interface.
124 */
125 payload_t payload_interface;
126
127 /**
128 * Gets the protocol id of this payload.
129 *
130 * @return protocol id of this payload
131 */
132 u_int8_t (*get_protocol_id) (notify_payload_t *this);
133
134 /**
135 * Sets the protocol id of this payload.
136 *
137 * @param protocol_id protocol id to set
138 */
139 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
140
141 /**
142 * Gets the notify message type of this payload.
143 *
144 * @return notify message type of this payload
145 */
146 notify_type_t (*get_notify_type) (notify_payload_t *this);
147
148 /**
149 * Sets notify message type of this payload.
150 *
151 * @param type notify message type to set
152 */
153 void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
154
155 /**
156 * Returns the currently set spi of this payload.
157 *
158 * This is only valid for notifys with protocol AH|ESP
159 *
160 * @return SPI value
161 */
162 u_int32_t (*get_spi) (notify_payload_t *this);
163
164 /**
165 * Sets the spi of this payload.
166 *
167 * This is only valid for notifys with protocol AH|ESP
168 *
169 * @param spi SPI value
170 */
171 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
172
173 /**
174 * Returns the currently set notification data of payload.
175 *
176 * Returned data are not copied.
177 *
178 * @return chunk_t pointing to the value
179 */
180 chunk_t (*get_notification_data) (notify_payload_t *this);
181
182 /**
183 * Sets the notification data of this payload.
184 *
185 * @warning Value is getting copied.
186 *
187 * @param notification_data chunk_t pointing to the value to set
188 */
189 void (*set_notification_data) (notify_payload_t *this,
190 chunk_t notification_data);
191
192 /**
193 * Destroys an notify_payload_t object.
194 */
195 void (*destroy) (notify_payload_t *this);
196 };
197
198 /**
199 * Creates an empty notify_payload_t object
200 *
201 * @return created notify_payload_t object
202 */
203 notify_payload_t *notify_payload_create(void);
204
205 /**
206 * Creates an notify_payload_t object of specific type for specific protocol id.
207 *
208 * @param protocol_id protocol id (IKE, AH or ESP)
209 * @param type notify type (see notify_type_t)
210 * @return notify_payload_t object
211 */
212 notify_payload_t *notify_payload_create_from_protocol_and_type(
213 protocol_id_t protocol_id, notify_type_t type);
214
215 #endif /*NOTIFY_PAYLOAD_H_ @} */