moved attribute_manager to libstrongswan
[strongswan.git] / src / charon / encoding / payloads / configuration_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 configuration_attribute configuration_attribute
19 * @{ @ingroup payloads
20 */
21
22 #ifndef CONFIGURATION_ATTRIBUTE_H_
23 #define CONFIGURATION_ATTRIBUTE_H_
24
25 typedef struct configuration_attribute_t configuration_attribute_t;
26
27 #include <library.h>
28 #include <attributes/attributes.h>
29 #include <encoding/payloads/payload.h>
30
31
32 /**
33 * Configuration attribute header length in bytes.
34 */
35 #define CONFIGURATION_ATTRIBUTE_HEADER_LENGTH 4
36
37 /**
38 * Class representing an IKEv2-CONFIGURATION Attribute.
39 *
40 * The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
41 */
42 struct configuration_attribute_t {
43 /**
44 * The payload_t interface.
45 */
46 payload_t payload_interface;
47
48 /**
49 * Returns the currently set value of the attribute.
50 *
51 * @warning Returned data are not copied.
52 *
53 * @return chunk_t pointing to the value
54 */
55 chunk_t (*get_value) (configuration_attribute_t *this);
56
57 /**
58 * Sets the value of the attribute.
59 *
60 * Value is getting copied.
61 *
62 * @param value chunk_t pointing to the value to set
63 */
64 void (*set_value) (configuration_attribute_t *this, chunk_t value);
65
66 /**
67 * Sets the type of the attribute.
68 *
69 * @param type type to set (most significant bit is set to zero)
70 */
71 void (*set_type) (configuration_attribute_t *this, u_int16_t type);
72
73 /**
74 * get the type of the attribute.
75 *
76 * @return type of the value
77 */
78 u_int16_t (*get_type) (configuration_attribute_t *this);
79
80 /**
81 * get the length of an attribute.
82 *
83 * @return type of the value
84 */
85 u_int16_t (*get_length) (configuration_attribute_t *this);
86
87 /**
88 * Destroys an configuration_attribute_t object.
89 */
90 void (*destroy) (configuration_attribute_t *this);
91 };
92
93 /**
94 * Creates an empty configuration_attribute_t object.
95 *
96 * @return created configuration_attribute_t object
97 */
98 configuration_attribute_t *configuration_attribute_create(void);
99
100 #endif /** CONFIGURATION_ATTRIBUTE_H_ @}*/