- created encoding package
[strongswan.git] / Source / charon / encoding / payloads / transform_attribute.h
1 /**
2 * @file transform_attribute.h
3 *
4 * @brief Declaration of the class transform_attribute_t.
5 *
6 * An object of this type represents an IKEv2 TRANSFORM attribute.
7 *
8 */
9
10 /*
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
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 #ifndef TRANSFORM_ATTRIBUTE_H_
26 #define TRANSFORM_ATTRIBUTE_H_
27
28 #include <types.h>
29 #include <encoding/payloads/payload.h>
30
31
32 /**
33 * Type of the attribute, as in IKEv2 draft 3.3.5
34 */
35 typedef enum transform_attribute_type_e transform_attribute_type_t;
36
37 enum transform_attribute_type_e {
38 ATTRIBUTE_UNDEFINED = 16384,
39 KEY_LENGTH = 14
40 };
41
42 /**
43 * string mappings for transform_attribute_type_t
44 */
45 extern mapping_t transform_attribute_type_m[];
46
47 /**
48 * Object representing an IKEv2- TRANSFORM Attribute
49 *
50 * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
51 *
52 */
53 typedef struct transform_attribute_s transform_attribute_t;
54
55 struct transform_attribute_s {
56 /**
57 * implements payload_t interface
58 */
59 payload_t payload_interface;
60
61 /**
62 * @brief Returns the currently set value of the attribute
63 *
64 * @warning Returned data are not copied
65 *
66 * @param this calling transform_attribute_t object
67 * @return chunk_t pointing to the value
68 */
69 chunk_t (*get_value_chunk) (transform_attribute_t *this);
70
71 /**
72 * @brief Returns the currently set value of the attribute
73 *
74 * @warning Returned data are not copied
75 *
76 * @param this calling transform_attribute_t object
77 * @return value
78 */
79 u_int16_t (*get_value) (transform_attribute_t *this);
80
81 /**
82 * @brief Sets the value of the attribute.
83 *
84 * @warning Value is getting copied
85 *
86 * @param this calling transform_attribute_t object
87 * @param value chunk_t pointing to the value to set
88 * @return
89 * - SUCCESS or
90 * - OUT_OF_RES
91 */
92 status_t (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
93
94 /**
95 * @brief Sets the value of the attribute.
96 *
97 * @param this calling transform_attribute_t object
98 * @param value value to set
99 * @return
100 * - SUCCESS or
101 * - OUT_OF_RES
102 */
103 status_t (*set_value) (transform_attribute_t *this, u_int16_t value);
104
105 /**
106 * @brief Sets the type of the attribute.
107 *
108 * @param this calling transform_attribute_t object
109 * @param type type to set (most significant bit is set to zero)
110 * @return SUCCESS
111 */
112 status_t (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
113
114 /**
115 * @brief get the type of the attribute.
116 *
117 * @param this calling transform_attribute_t object
118 * @return type of the value
119 */
120 u_int16_t (*get_attribute_type) (transform_attribute_t *this);
121
122 /**
123 * @brief Clones an transform_attribute_t object.
124 *
125 * @param this transform_attribute_t object to clone
126 * @param clone the new clone will be written there
127 * @return
128 * - OUT_OF_RES
129 * - SUCCESS
130 */
131 status_t (*clone) (transform_attribute_t *this,transform_attribute_t **clone);
132
133 /**
134 * @brief Destroys an transform_attribute_t object.
135 *
136 * @param this transform_attribute_t object to destroy
137 * @return
138 * SUCCESS in any case
139 */
140 status_t (*destroy) (transform_attribute_t *this);
141 };
142
143 /**
144 * @brief Creates an empty transform_attribute_t object
145 *
146 * @return
147 * - created transform_attribute_t object, or
148 * - NULL if failed
149 */
150
151 transform_attribute_t *transform_attribute_create();
152
153 #endif /*TRANSFORM_ATTRIBUTE_H_*/