implemented and tested functionality to create sa_payload from
[strongswan.git] / Source / charon / encoding / payloads / transform_attribute.h
1 /**
2 * @file transform_attribute.h
3 *
4 * @brief Interface of transform_attribute_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 #ifndef TRANSFORM_ATTRIBUTE_H_
24 #define TRANSFORM_ATTRIBUTE_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28
29
30 typedef enum transform_attribute_type_t transform_attribute_type_t;
31
32 /**
33 * Type of the attribute, as in IKEv2 draft 3.3.5.
34 *
35 * @ingroup payloads
36 */
37 enum transform_attribute_type_t {
38 ATTRIBUTE_UNDEFINED = 16384,
39 KEY_LENGTH = 14
40 };
41
42 /**
43 * String mappings for transform_attribute_type_t.
44 *
45 * @ingroup payloads
46 */
47 extern mapping_t transform_attribute_type_m[];
48
49 typedef struct transform_attribute_t transform_attribute_t;
50
51 /**
52 * Object representing an IKEv2- TRANSFORM Attribute.
53 *
54 * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
55 *
56 * @ingroup payloads
57 */
58 struct transform_attribute_t {
59 /**
60 * The payload_t interface.
61 */
62 payload_t payload_interface;
63
64 /**
65 * @brief Returns the currently set value of the attribute.
66 *
67 * @warning Returned data are not copied.
68 *
69 * @param this calling transform_attribute_t object
70 * @return chunk_t pointing to the value
71 */
72 chunk_t (*get_value_chunk) (transform_attribute_t *this);
73
74 /**
75 * @brief Returns the currently set value of the attribute.
76 *
77 * @warning Returned data are not copied.
78 *
79 * @param this calling transform_attribute_t object
80 * @return value
81 */
82 u_int16_t (*get_value) (transform_attribute_t *this);
83
84 /**
85 * @brief Sets the value of the attribute.
86 *
87 * @warning Value is getting copied.
88 *
89 * @param this calling transform_attribute_t object
90 * @param value chunk_t pointing to the value to set
91 */
92 void (*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 */
100 void (*set_value) (transform_attribute_t *this, u_int16_t value);
101
102 /**
103 * @brief Sets the type of the attribute.
104 *
105 * @param this calling transform_attribute_t object
106 * @param type type to set (most significant bit is set to zero)
107 */
108 void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
109
110 /**
111 * @brief get the type of the attribute.
112 *
113 * @param this calling transform_attribute_t object
114 * @return type of the value
115 */
116 u_int16_t (*get_attribute_type) (transform_attribute_t *this);
117
118 /**
119 * @brief Clones an transform_attribute_t object.
120 *
121 * @param this transform_attribute_t object to clone
122 * @return cloned transform_attribute_t object
123 */
124 transform_attribute_t * (*clone) (transform_attribute_t *this);
125
126 /**
127 * @brief Destroys an transform_attribute_t object.
128 *
129 * @param this transform_attribute_t object to destroy
130 */
131 void (*destroy) (transform_attribute_t *this);
132 };
133
134 /**
135 * @brief Creates an empty transform_attribute_t object.
136 *
137 * @return created transform_attribute_t object
138 *
139 * @ingroup payloads
140 */
141 transform_attribute_t *transform_attribute_create();
142
143 /**
144 * @brief Creates an transform_attribute_t of type KEY_LENGTH.
145 *
146 * @param key_length key length in bytes
147 * @return created transform_attribute_t object
148 *
149 * @ingroup payloads
150 */
151 transform_attribute_t *transform_attribute_create_key_length(u_int16_t key_length);
152
153
154 #endif /*TRANSFORM_ATTRIBUTE_H_*/