2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
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>.
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
18 * @defgroup transform_attribute transform_attribute
19 * @{ @ingroup payloads
22 #ifndef TRANSFORM_ATTRIBUTE_H_
23 #define TRANSFORM_ATTRIBUTE_H_
25 typedef enum transform_attribute_type_t transform_attribute_type_t
;
26 typedef struct transform_attribute_t transform_attribute_t
;
29 #include <encoding/payloads/payload.h>
32 * Type of the attribute.
34 enum transform_attribute_type_t
{
35 /** IKEv1 Phase 1 attributes */
36 TATTR_PH1_ENCRYPTION_ALGORITHM
= 1,
37 TATTR_PH1_HASH_ALGORITHM
= 2,
38 TATTR_PH1_AUTH_METHOD
= 3,
40 TATTR_PH1_GROUP_TYPE
= 5,
41 TATTR_PH1_GROUP_PRIME
= 6,
42 TATTR_PH1_GROUP_GENONE
= 7,
43 TATTR_PH1_GROUP_GENTWO
= 8,
44 TATTR_PH1_GROUP_CURVE_A
= 9,
45 TATTR_PH1_GROUP_CURVE_B
= 10,
46 TATTR_PH1_LIFE_TYPE
= 11,
47 TATTR_PH1_LIFE_DURATION
= 12,
49 TATTR_PH1_KEY_LENGTH
= 14,
50 TATTR_PH1_FIELD_SIZE
= 15,
51 TATTR_PH1_GROUP_ORDER
= 16,
52 /** IKEv1 Phase 2 attributes */
53 TATTR_PH2_SA_LIFE_TYPE
= 1,
54 TATTR_PH2_SA_LIFE_DURATION
= 2,
56 TATTR_PH2_ENCAP_MODE
= 4,
57 TATTR_PH2_AUTH_ALGORITHM
= 5,
58 TATTR_PH2_KEY_LENGTH
= 6,
59 TATTR_PH2_KEY_ROUNDS
= 7,
60 TATTR_PH2_COMP_DICT_SIZE
= 8,
61 TATTR_PH2_COMP_PRIV_ALGORITHM
= 9,
62 TATTR_PH2_ECN_TUNNEL
= 10,
63 TATTR_PH2_EXT_SEQ_NUMBER
= 11,
64 /* IKEv2 key length attribute */
65 TATTR_IKEV2_KEY_LENGTH
= 14,
66 /* undefined, private use attribute */
67 TATTR_UNDEFINED
= 16384,
71 * Enum names for IKEv1 Phase 1 transform_attribute_type_t.
73 extern enum_name_t
*tattr_ph1_names
;
76 * Enum names for IKEv1 Phase 2 transform_attribute_type_t.
78 extern enum_name_t
*tattr_ph2_names
;
81 * Enum names for IKEv2 transform_attribute_type_t.
83 extern enum_name_t
*tattr_ikev2_names
;
87 * Class representing an IKEv1/IKEv2 TRANSFORM Attribute.
89 struct transform_attribute_t
{
92 * The payload_t interface.
94 payload_t payload_interface
;
97 * Returns the currently set value of the attribute.
99 * Returned data are not copied.
101 * @return chunk_t pointing to the value
103 chunk_t (*get_value_chunk
) (transform_attribute_t
*this);
106 * Returns the currently set value of the attribute.
108 * Returned data are not copied.
112 u_int16_t (*get_value
) (transform_attribute_t
*this);
115 * Sets the value of the attribute.
117 * Value is getting copied.
119 * @param value chunk_t pointing to the value to set
121 void (*set_value_chunk
) (transform_attribute_t
*this, chunk_t value
);
124 * Sets the value of the attribute.
126 * @param value value to set
128 void (*set_value
) (transform_attribute_t
*this, u_int16_t value
);
131 * Sets the type of the attribute.
133 * @param type type to set (most significant bit is set to zero)
135 void (*set_attribute_type
) (transform_attribute_t
*this, u_int16_t type
);
138 * get the type of the attribute.
140 * @return type of the value
142 u_int16_t (*get_attribute_type
) (transform_attribute_t
*this);
145 * Clones an transform_attribute_t object.
147 * @return cloned transform_attribute_t object
149 transform_attribute_t
* (*clone
) (transform_attribute_t
*this);
152 * Destroys an transform_attribute_t object.
154 void (*destroy
) (transform_attribute_t
*this);
158 * Creates an empty transform_attribute_t object.
160 * @param type TRANSFORM_ATTRIBUTE or TRANSFORM_ATTRIBUTE_V1
161 * @return transform_attribute_t object
163 transform_attribute_t
*transform_attribute_create(payload_type_t type
);
166 * Creates an transform_attribute_t of type KEY_LENGTH.
168 * @param key_length key length in bytes
169 * @return transform_attribute_t object
171 transform_attribute_t
*transform_attribute_create_key_length(u_int16_t key_length
);
173 #endif /** TRANSFORM_ATTRIBUTE_H_ @}*/