Moving charon to libcharon.
[strongswan.git] / src / libcharon / 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
17 /**
18 * @defgroup transform_attribute transform_attribute
19 * @{ @ingroup payloads
20 */
21
22 #ifndef TRANSFORM_ATTRIBUTE_H_
23 #define TRANSFORM_ATTRIBUTE_H_
24
25 typedef enum transform_attribute_type_t transform_attribute_type_t;
26 typedef struct transform_attribute_t transform_attribute_t;
27
28 #include <library.h>
29 #include <encoding/payloads/payload.h>
30
31
32 /**
33 * Type of the attribute, as in IKEv2 RFC 3.3.5.
34 */
35 enum transform_attribute_type_t {
36 ATTRIBUTE_UNDEFINED = 16384,
37 KEY_LENGTH = 14
38 };
39
40 /**
41 * enum name for transform_attribute_type_t.
42 */
43 extern enum_name_t *transform_attribute_type_names;
44
45 /**
46 * Class representing an IKEv2- TRANSFORM Attribute.
47 *
48 * The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
49 */
50 struct transform_attribute_t {
51 /**
52 * The payload_t interface.
53 */
54 payload_t payload_interface;
55
56 /**
57 * Returns the currently set value of the attribute.
58 *
59 * Returned data are not copied.
60 *
61 * @return chunk_t pointing to the value
62 */
63 chunk_t (*get_value_chunk) (transform_attribute_t *this);
64
65 /**
66 * Returns the currently set value of the attribute.
67 *
68 * Returned data are not copied.
69 *
70 * @return value
71 */
72 u_int16_t (*get_value) (transform_attribute_t *this);
73
74 /**
75 * Sets the value of the attribute.
76 *
77 * Value is getting copied.
78 *
79 * @param value chunk_t pointing to the value to set
80 */
81 void (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
82
83 /**
84 * Sets the value of the attribute.
85 *
86 * @param value value to set
87 */
88 void (*set_value) (transform_attribute_t *this, u_int16_t value);
89
90 /**
91 * Sets the type of the attribute.
92 *
93 * @param type type to set (most significant bit is set to zero)
94 */
95 void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
96
97 /**
98 * get the type of the attribute.
99 *
100 * @return type of the value
101 */
102 u_int16_t (*get_attribute_type) (transform_attribute_t *this);
103
104 /**
105 * Clones an transform_attribute_t object.
106 *
107 * @return cloned transform_attribute_t object
108 */
109 transform_attribute_t * (*clone) (transform_attribute_t *this);
110
111 /**
112 * Destroys an transform_attribute_t object.
113 */
114 void (*destroy) (transform_attribute_t *this);
115 };
116
117 /**
118 * Creates an empty transform_attribute_t object.
119 *
120 * @return transform_attribute_t object
121 */
122 transform_attribute_t *transform_attribute_create(void);
123
124 /**
125 * Creates an transform_attribute_t of type KEY_LENGTH.
126 *
127 * @param key_length key length in bytes
128 * @return transform_attribute_t object
129 */
130 transform_attribute_t *transform_attribute_create_key_length(u_int16_t key_length);
131
132 #endif /** TRANSFORM_ATTRIBUTE_H_ @}*/