- added notify message handling to ike_sa_init_requested_t and
[strongswan.git] / Source / 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 * Critical flag must not be set.
34 *
35 * @ingroup payloads
36 */
37 #define NOTIFY_PAYLOAD_CRITICAL_FLAG FALSE;
38
39 /**
40 * Notify payload length in bytes without any spi and notification data.
41 *
42 * @ingroup payloads
43 */
44 #define NOTIFY_PAYLOAD_HEADER_LENGTH 8
45
46 typedef enum notify_message_type_t notify_message_type_t;
47
48
49 /**
50 * @brief Notify message types.
51 *
52 * Ssee IKEv2 draft 3.10.1.
53 *
54 * @ingroup payloads
55 */
56 enum notify_message_type_t {
57 UNSUPPORTED_CRITICAL_PAYLOAD = 1,
58 INVALID_IKE_SPI = 4,
59 INVALID_MAJOR_VERSION = 5,
60 INVALID_SYNTAX = 7,
61 INVALID_MESSAGE_ID = 9,
62 INVALID_SPI = 11,
63 NO_PROPOSAL_CHOSEN = 14,
64 INVALID_KE_PAYLOAD = 17,
65 AUTHENTICATION_FAILED = 24,
66 SINGLE_PAIR_REQUIRED = 34,
67 NO_ADDITIONAL_SAS = 35,
68 INTERNAL_ADDRESS_FAILURE = 36,
69 FAILED_CP_REQUIRED = 37,
70 TS_UACCEPTABLE = 38,
71 INVALID_SELECTORS = 39
72 };
73
74 /**
75 * String mappings for notify_message_type_t.
76 */
77 extern mapping_t notify_message_type_m[];
78
79
80
81 typedef struct notify_payload_t notify_payload_t;
82
83 /**
84 * Object representing an IKEv2-Notify Payload.
85 *
86 * The Notify Payload format is described in Draft section 3.10.
87 *
88 *
89 * @ingroup payloads
90 */
91 struct notify_payload_t {
92 /**
93 * The payload_t interface.
94 */
95 payload_t payload_interface;
96
97 /**
98 * @brief Gets the protocol id of this payload.
99 *
100 * @param this calling notify_payload_t object
101 * @return protocol id of this payload
102 */
103 u_int8_t (*get_protocol_id) (notify_payload_t *this);
104
105 /**
106 * @brief Sets the protocol id of this payload.
107 *
108 * @param this calling notify_payload_t object
109 * @param protocol_id protocol id to set
110 */
111 void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
112
113 /**
114 * @brief Gets the notify message type of this payload.
115 *
116 * @param this calling notify_payload_t object
117 * @return notify message type of this payload
118 */
119 u_int16_t (*get_notify_message_type) (notify_payload_t *this);
120
121 /**
122 * @brief Sets notify message type of this payload.
123 *
124 * @param this calling notify_payload_t object
125 * @param notify_message_type notify message type to set
126 */
127 void (*set_notify_message_type) (notify_payload_t *this, u_int16_t notify_message_type);
128
129 /**
130 * @brief Returns the currently set spi of this payload.
131 *
132 * @warning Returned data are not copied.
133 *
134 * @param this calling notify_payload_t object
135 * @return chunk_t pointing to the value
136 */
137 chunk_t (*get_spi) (notify_payload_t *this);
138
139 /**
140 * @brief Sets the spi of this payload.
141 *
142 * @warning Value is getting copied.
143 *
144 * @param this calling notify_payload_t object
145 * @param spi chunk_t pointing to the value to set
146 */
147 void (*set_spi) (notify_payload_t *this, chunk_t spi);
148
149 /**
150 * @brief Returns the currently set notification data of payload.
151 *
152 * @warning Returned data are not copied.
153 *
154 * @param this calling notify_payload_t object
155 * @return chunk_t pointing to the value
156 */
157 chunk_t (*get_notification_data) (notify_payload_t *this);
158
159 /**
160 * @brief Sets the notification data of this payload.
161 *
162 * @warning Value is getting copied.
163 *
164 * @param this calling notify_payload_t object
165 * @param notification_data chunk_t pointing to the value to set
166 */
167 void (*set_notification_data) (notify_payload_t *this, chunk_t notification_data);
168
169 /**
170 * @brief Destroys an notify_payload_t object.
171 *
172 * @param this notify_payload_t object to destroy
173 */
174 void (*destroy) (notify_payload_t *this);
175 };
176
177 /**
178 * @brief Creates an empty notify_payload_t object
179 *
180 * @return created notify_payload_t object
181 *
182 * @ingroup payloads
183 */
184 notify_payload_t *notify_payload_create();
185
186 /**
187 * @brief Creates an notify_payload_t object of specific type for specific protocol id.
188 *
189 * @param protocol_id protocol id (IKE, AH or ESP)
190 * @param notify_message_type notify type (see notify_message_type_t)
191 * @return created notify_payload_t object
192 *
193 * @ingroup payloads
194 */
195 notify_payload_t *notify_payload_create_from_protocol_and_type(protocol_id_t protocol_id, notify_message_type_t notify_message_type);
196
197
198 #endif /*NOTIFY_PAYLOAD_H_*/