32039cbafcf6736b0354638761ff634235b6916e
[strongswan.git] / src / charon / encoding / payloads / transform_attribute.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup transform_attribute transform_attribute
21 * @{ @ingroup payloads
22 */
23
24 #ifndef TRANSFORM_ATTRIBUTE_H_
25 #define TRANSFORM_ATTRIBUTE_H_
26
27 typedef enum transform_attribute_type_t transform_attribute_type_t;
28 typedef struct transform_attribute_t transform_attribute_t;
29
30 #include <library.h>
31 #include <encoding/payloads/payload.h>
32
33
34 /**
35 * Type of the attribute, as in IKEv2 RFC 3.3.5.
36 */
37 enum transform_attribute_type_t {
38 ATTRIBUTE_UNDEFINED = 16384,
39 KEY_LENGTH = 14
40 };
41
42 /**
43 * enum name for transform_attribute_type_t.
44 */
45 extern enum_name_t *transform_attribute_type_names;
46
47 /**
48 * Class representing an IKEv2- TRANSFORM Attribute.
49 *
50 * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
51 */
52 struct transform_attribute_t {
53 /**
54 * The payload_t interface.
55 */
56 payload_t payload_interface;
57
58 /**
59 * Returns the currently set value of the attribute.
60 *
61 * Returned data are not copied.
62 *
63 * @return chunk_t pointing to the value
64 */
65 chunk_t (*get_value_chunk) (transform_attribute_t *this);
66
67 /**
68 * Returns the currently set value of the attribute.
69 *
70 * Returned data are not copied.
71 *
72 * @return value
73 */
74 u_int16_t (*get_value) (transform_attribute_t *this);
75
76 /**
77 * Sets the value of the attribute.
78 *
79 * Value is getting copied.
80 *
81 * @param value chunk_t pointing to the value to set
82 */
83 void (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
84
85 /**
86 * Sets the value of the attribute.
87 *
88 * @param value value to set
89 */
90 void (*set_value) (transform_attribute_t *this, u_int16_t value);
91
92 /**
93 * Sets the type of the attribute.
94 *
95 * @param type type to set (most significant bit is set to zero)
96 */
97 void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
98
99 /**
100 * get the type of the attribute.
101 *
102 * @return type of the value
103 */
104 u_int16_t (*get_attribute_type) (transform_attribute_t *this);
105
106 /**
107 * Clones an transform_attribute_t object.
108 *
109 * @return cloned transform_attribute_t object
110 */
111 transform_attribute_t * (*clone) (transform_attribute_t *this);
112
113 /**
114 * Destroys an transform_attribute_t object.
115 */
116 void (*destroy) (transform_attribute_t *this);
117 };
118
119 /**
120 * Creates an empty transform_attribute_t object.
121 *
122 * @return transform_attribute_t object
123 */
124 transform_attribute_t *transform_attribute_create(void);
125
126 /**
127 * Creates an transform_attribute_t of type KEY_LENGTH.
128 *
129 * @param key_length key length in bytes
130 * @return transform_attribute_t object
131 */
132 transform_attribute_t *transform_attribute_create_key_length(u_int16_t key_length);
133
134 #endif /*TRANSFORM_ATTRIBUTE_H_ @} */