updated copyright information
[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 #include <types.h>
30 #include <encoding/payloads/payload.h>
31 #include <encoding/payloads/proposal_substructure.h>
32 #include <utils/linked_list.h>
33
34 /**
35 * Notify payload length in bytes without any spi and notification data.
36 *
37 * @ingroup payloads
38 */
39 #define NOTIFY_PAYLOAD_HEADER_LENGTH 8
40
41 typedef enum notify_type_t notify_type_t;
42
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 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
53 INVALID_IKE_SPI = 4,
54 INVALID_MAJOR_VERSION = 5,
55 INVALID_SYNTAX = 7,
56 INVALID_MESSAGE_ID = 9,
57 INVALID_SPI = 11,
58 NO_PROPOSAL_CHOSEN = 14,
59 INVALID_KE_PAYLOAD = 17,
60 AUTHENTICATION_FAILED = 24,
61 SINGLE_PAIR_REQUIRED = 34,
62 NO_ADDITIONAL_SAS = 35,
63 INTERNAL_ADDRESS_FAILURE = 36,
64 FAILED_CP_REQUIRED = 37,
65 TS_UNACCEPTABLE = 38,
66 INVALID_SELECTORS = 39,
67
68 INITIAL_CONTACT = 16384,
69 SET_WINDOW_SIZE = 16385,
70 NAT_DETECTION_SOURCE_IP = 16388,
71 NAT_DETECTION_DESTINATION_IP = 16389,
72 REKEY_SA = 16393,
73 };
74
75 /**
76 * String mappings for notify_type_t.
77 *
78 * @ingroup payloads
79 */
80 extern mapping_t notify_type_m[];
81
82
83 typedef struct notify_payload_t notify_payload_t;
84
85 /**
86 * @brief Class representing an IKEv2-Notify Payload.
87 *
88 * The Notify Payload format is described in Draft section 3.10.
89 *
90 * @b Constructors:
91 * - notify_payload_create()
92 * - notify_payload_create_from_protocol_and_type()
93 *
94 * @todo Build specified constructor/getter for notify's
95 *
96 * @ingroup payloads
97 */
98 struct notify_payload_t {
99 /**
100 * The payload_t interface.
101 */
102 payload_t payload_interface;
103
104 /**
105 * @brief Gets the protocol id of this payload.
106 *
107 * @param this calling notify_payload_t object
108 * @return protocol id of this payload
109 */
110 u_int8_t (*get_protocol_id) (notify_payload_t *this);
111
112 /**
113 * @brief Sets the protocol id of this payload.
114 *
115 * @param this calling notify_payload_t object
116 * @param protocol_id protocol id to set
117 */
118 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
119
120 /**
121 * @brief Gets the notify message type of this payload.
122 *
123 * @param this calling notify_payload_t object
124 * @return notify message type of this payload
125 */
126 notify_type_t (*get_notify_type) (notify_payload_t *this);
127
128 /**
129 * @brief Sets notify message type of this payload.
130 *
131 * @param this calling notify_payload_t object
132 * @param type notify message type to set
133 */
134 void (*set_notify_type) (notify_payload_t *this, notify_type_t type);
135
136 /**
137 * @brief Returns the currently set spi of this payload.
138 *
139 * This is only valid for notifys with protocol AH|ESP
140 *
141 * @param this calling notify_payload_t object
142 * @return SPI value
143 */
144 u_int32_t (*get_spi) (notify_payload_t *this);
145
146 /**
147 * @brief Sets the spi of this payload.
148 *
149 * This is only valid for notifys with protocol AH|ESP
150 *
151 * @param this calling notify_payload_t object
152 * @param spi SPI value
153 */
154 void (*set_spi) (notify_payload_t *this, u_int32_t spi);
155
156 /**
157 * @brief Returns the currently set notification data of payload.
158 *
159 * @warning Returned data are not copied.
160 *
161 * @param this calling notify_payload_t object
162 * @return chunk_t pointing to the value
163 */
164 chunk_t (*get_notification_data) (notify_payload_t *this);
165
166 /**
167 * @brief Sets the notification data of this payload.
168 *
169 * @warning Value is getting copied.
170 *
171 * @param this calling notify_payload_t object
172 * @param notification_data chunk_t pointing to the value to set
173 */
174 void (*set_notification_data) (notify_payload_t *this, chunk_t notification_data);
175
176 /**
177 * @brief Destroys an notify_payload_t object.
178 *
179 * @param this notify_payload_t object to destroy
180 */
181 void (*destroy) (notify_payload_t *this);
182 };
183
184 /**
185 * @brief Creates an empty notify_payload_t object
186 *
187 * @return created notify_payload_t object
188 *
189 * @ingroup payloads
190 */
191 notify_payload_t *notify_payload_create(void);
192
193 /**
194 * @brief Creates an notify_payload_t object of specific type for specific protocol id.
195 *
196 * @param protocol_id protocol id (IKE, AH or ESP)
197 * @param type notify type (see notify_type_t)
198 * @return notify_payload_t object
199 *
200 * @ingroup payloads
201 */
202 notify_payload_t *notify_payload_create_from_protocol_and_type(protocol_id_t protocol_id, notify_type_t type);
203
204
205 #endif /*NOTIFY_PAYLOAD_H_*/