c85ef20914b26e4d820b8011f96df00a7a6f8c71
[strongswan.git] / Source / charon / payloads / ke_payload.h
1 /**
2 * @file ke_payload.h
3 *
4 * @brief Declaration of the class ke_payload_t.
5 *
6 * An object of this type represents an IKEv2 KE-Payload.
7 *
8 * See section 3.4 of RFC for details of this payload type.
9 *
10 */
11
12 /*
13 * Copyright (C) 2005 Jan Hutter, Martin Willi
14 * Hochschule fuer Technik Rapperswil
15 *
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the
18 * Free Software Foundation; either version 2 of the License, or (at your
19 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
25 */
26
27 #ifndef KE_PAYLOAD_H_
28 #define KE_PAYLOAD_H_
29
30 #include "../types.h"
31 #include "payload.h"
32 #include "../utils/linked_list.h"
33
34 /**
35 * Critical flag must not be set
36 */
37 #define KE_PAYLOAD_CRITICAL_FLAG FALSE;
38
39 /**
40 * KE payload length in bytes without any key exchange data
41 */
42 #define KE_PAYLOAD_HEADER_LENGTH 8
43
44 /**
45 * Object representing an IKEv2-KE Payload
46 *
47 * The KE Payload format is described in RFC section 3.4.
48 *
49 */
50 typedef struct ke_payload_s ke_payload_t;
51
52 struct ke_payload_s {
53 /**
54 * implements payload_t interface
55 */
56 payload_t payload_interface;
57
58 /**
59 * @brief Returns the currently set key exchange data of this KE payload.
60 *
61 * @warning Returned data are not copied.
62 *
63 * @param this calling ke_payload_t object
64 * @return chunk_t pointing to the value
65 */
66 chunk_t (*get_key_exchange_data) (ke_payload_t *this);
67
68 /**
69 * @brief Sets the key exchange data of this KE payload.
70 *
71 * @warning Value is getting copied.
72 *
73 * @param this calling ke_payload_t object
74 * @param key_exchange_data chunk_t pointing to the value to set
75 * @return
76 * - SUCCESS or
77 * - OUT_OF_RES
78 */
79 status_t (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
80
81 /**
82 * @brief Gets the Diffie-Hellman Group Number of this KE payload.
83 *
84 * @param this calling ke_payload_t object
85 * @return DH Group Number of this payload
86 */
87 u_int16_t (*get_dh_group_number) (ke_payload_t *this);
88
89 /**
90 * @brief Sets the Diffie-Hellman Group Number of this KE payload.
91 *
92 * @param this calling ke_payload_t object
93 * @param dh_group_number DH Group to set
94 * @return SUCCESS
95 */
96 status_t (*set_dh_group_number) (ke_payload_t *this, u_int16_t dh_group_number);
97
98 /**
99 * @brief Destroys an ke_payload_t object.
100 *
101 * @param this ke_payload_t object to destroy
102 * @return
103 * SUCCESS in any case
104 */
105 status_t (*destroy) (ke_payload_t *this);
106 };
107
108 /**
109 * @brief Creates an empty ke_payload_t object
110 *
111 * @return
112 * - created ke_payload_t object, or
113 * - NULL if failed
114 */
115
116 ke_payload_t *ke_payload_create();
117
118
119 #endif /*KE_PAYLOAD_H_*/