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