first merge of NATT code
[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 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24
25 #ifndef NOTIFY_PAYLOAD_H_
26 #define NOTIFY_PAYLOAD_H_
27
28 #include <types.h>
29 #include <encoding/payloads/payload.h>
30 #include <encoding/payloads/proposal_substructure.h>
31 #include <utils/linked_list.h>
32
33 /**
34 * Notify payload length in bytes without any spi and notification data.
35 *
36 * @ingroup payloads
37 */
38 #define NOTIFY_PAYLOAD_HEADER_LENGTH 8
39
40 typedef enum notify_message_type_t notify_message_type_t;
41
42
43 /**
44 * @brief Notify message types.
45 *
46 * See IKEv2 RFC 3.10.1.
47 *
48 * @ingroup payloads
49 */
50 enum notify_message_type_t {
51 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
52 INVALID_IKE_SPI = 4,
53 INVALID_MAJOR_VERSION = 5,
54 INVALID_SYNTAX = 7,
55 INVALID_MESSAGE_ID = 9,
56 INVALID_SPI = 11,
57 NO_PROPOSAL_CHOSEN = 14,
58 INVALID_KE_PAYLOAD = 17,
59 AUTHENTICATION_FAILED = 24,
60 SINGLE_PAIR_REQUIRED = 34,
61 NO_ADDITIONAL_SAS = 35,
62 INTERNAL_ADDRESS_FAILURE = 36,
63 FAILED_CP_REQUIRED = 37,
64 TS_UNACCEPTABLE = 38,
65 INVALID_SELECTORS = 39,
66
67 INITIAL_CONTACT = 16384,
68 SET_WINDOW_SIZE = 16385,
69 NAT_DETECTION_SOURCE_IP = 16388,
70 NAT_DETECTION_DESTINATION_IP = 16389,
71 REKEY_SA = 16393,
72 };
73
74 /**
75 * String mappings for notify_message_type_t.
76 *
77 * @ingroup payloads
78 */
79 extern mapping_t notify_message_type_m[];
80
81
82 typedef struct notify_payload_t notify_payload_t;
83
84 /**
85 * @brief Class representing an IKEv2-Notify Payload.
86 *
87 * The Notify Payload format is described in Draft section 3.10.
88 *
89 * @b Constructors:
90 * - notify_payload_create()
91 * - notify_payload_create_from_protocol_and_type()
92 *
93 * @todo Build specified constructor/getter for notify's
94 *
95 * @ingroup payloads
96 */
97 struct notify_payload_t {
98 /**
99 * The payload_t interface.
100 */
101 payload_t payload_interface;
102
103 /**
104 * @brief Gets the protocol id of this payload.
105 *
106 * @param this calling notify_payload_t object
107 * @return protocol id of this payload
108 */
109 u_int8_t (*get_protocol_id) (notify_payload_t *this);
110
111 /**
112 * @brief Sets the protocol id of this payload.
113 *
114 * @param this calling notify_payload_t object
115 * @param protocol_id protocol id to set
116 */
117 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
118
119 /**
120 * @brief Gets the notify message type of this payload.
121 *
122 * @param this calling notify_payload_t object
123 * @return notify message type of this payload
124 */
125 notify_message_type_t (*get_notify_message_type) (notify_payload_t *this);
126
127 /**
128 * @brief Sets notify message type of this payload.
129 *
130 * @param this calling notify_payload_t object
131 * @param type notify message type to set
132 */
133 void (*set_notify_message_type) (notify_payload_t *this, notify_message_type_t type);
134
135 /**
136 * @brief Returns the currently set spi of this payload.
137 *
138 * This is only valid for notifys with protocol AH|ESP
139 *
140 * @param this calling notify_payload_t object
141 * @return SPI value
142 */
143 u_int32_t (*get_spi) (notify_payload_t *this);
144
145 /**
146 * @brief Sets the spi of this payload.
147 *
148 * This is only valid for notifys with protocol AH|ESP
149 *
150 * @param this calling notify_payload_t object
151 * @param spi SPI value
152 */
153 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
154
155 /**
156 * @brief Returns the currently set notification data of payload.
157 *
158 * @warning Returned data are not copied.
159 *
160 * @param this calling notify_payload_t object
161 * @return chunk_t pointing to the value
162 */
163 chunk_t (*get_notification_data) (notify_payload_t *this);
164
165 /**
166 * @brief Sets the notification data of this payload.
167 *
168 * @warning Value is getting copied.
169 *
170 * @param this calling notify_payload_t object
171 * @param notification_data chunk_t pointing to the value to set
172 */
173 void (*set_notification_data) (notify_payload_t *this, chunk_t notification_data);
174
175 /**
176 * @brief Destroys an notify_payload_t object.
177 *
178 * @param this notify_payload_t object to destroy
179 */
180 void (*destroy) (notify_payload_t *this);
181 };
182
183 /**
184 * @brief Creates an empty notify_payload_t object
185 *
186 * @return created notify_payload_t object
187 *
188 * @ingroup payloads
189 */
190 notify_payload_t *notify_payload_create(void);
191
192 /**
193 * @brief Creates an notify_payload_t object of specific type for specific protocol id.
194 *
195 * @param protocol_id protocol id (IKE, AH or ESP)
196 * @param notify_message_type notify type (see notify_message_type_t)
197 * @return notify_payload_t object
198 *
199 * @ingroup payloads
200 */
201 notify_payload_t *notify_payload_create_from_protocol_and_type(protocol_id_t protocol_id, notify_message_type_t notify_message_type);
202
203
204 #endif /*NOTIFY_PAYLOAD_H_*/