]> git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/charon/encoding/payloads/configuration_attribute.h
- code cleaned up
[thirdparty/strongswan.git] / Source / charon / encoding / payloads / configuration_attribute.h
1 /**
2 * @file configuration_attribute.h
3 *
4 * @brief Interface of configuration_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 _CONFIGURATION_ATTRIBUTE_H_
24 #define _CONFIGURATION_ATTRIBUTE_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28
29
30
31 /**
32 * Configuration attribute header length in bytes.
33 *
34 * @ingroup payloads
35 */
36 #define CONFIGURATION_ATTRIBUTE_HEADER_LENGTH 4
37
38
39 typedef enum configuration_attribute_type_t configuration_attribute_type_t;
40
41 /**
42 * Type of the attribute, as in IKEv2 draft 3.15.1.
43 *
44 * @ingroup payloads
45 */
46 enum configuration_attribute_type_t {
47 INTERNAL_IP4_ADDRESS = 1,
48 INTERNAL_IP4_NETMASK = 2,
49 INTERNAL_IP4_DNS = 3,
50 INTERNAL_IP4_NBNS = 4,
51 INTERNAL_ADDRESS_EXPIRY = 5,
52 INTERNAL_IP4_DHCP = 6,
53 APPLICATION_VERSION = 7,
54 INTERNAL_IP6_ADDRESS = 8,
55 INTERNAL_IP6_DNS = 10,
56 INTERNAL_IP6_NBNS = 11,
57 INTERNAL_IP6_DHCP = 12,
58 INTERNAL_IP4_SUBNET = 13,
59 SUPPORTED_ATTRIBUTES = 14,
60 INTERNAL_IP6_SUBNET = 15
61 };
62
63 /**
64 * String mappings for configuration_attribute_type_t.
65 *
66 * @ingroup payloads
67 */
68 extern mapping_t configuration_attribute_type_m[];
69
70 typedef struct configuration_attribute_t configuration_attribute_t;
71
72 /**
73 * Object representing an IKEv2- CONFIGURATION Attribute.
74 *
75 * The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
76 *
77 * @ingroup payloads
78 */
79 struct configuration_attribute_t {
80 /**
81 * The payload_t interface.
82 */
83 payload_t payload_interface;
84
85 /**
86 * @brief Returns the currently set value of the attribute.
87 *
88 * @warning Returned data are not copied.
89 *
90 * @param this calling configuration_attribute_t object
91 * @return chunk_t pointing to the value
92 */
93 chunk_t (*get_value) (configuration_attribute_t *this);
94
95 /**
96 * @brief Sets the value of the attribute.
97 *
98 * @warning Value is getting copied.
99 *
100 * @param this calling configuration_attribute_t object
101 * @param value chunk_t pointing to the value to set
102 */
103 void (*set_value) (configuration_attribute_t *this, chunk_t value);
104
105 /**
106 * @brief Sets the type of the attribute.
107 *
108 * @param this calling configuration_attribute_t object
109 * @param type type to set (most significant bit is set to zero)
110 */
111 void (*set_attribute_type) (configuration_attribute_t *this, u_int16_t type);
112
113 /**
114 * @brief get the type of the attribute.
115 *
116 * @param this calling configuration_attribute_t object
117 * @return type of the value
118 */
119 u_int16_t (*get_attribute_type) (configuration_attribute_t *this);
120
121 /**
122 * @brief get the length of an attribute.
123 *
124 * @param this calling configuration_attribute_t object
125 * @return type of the value
126 */
127 u_int16_t (*get_attribute_length) (configuration_attribute_t *this);
128
129 /**
130 * @brief Destroys an configuration_attribute_t object.
131 *
132 * @param this configuration_attribute_t object to destroy
133 */
134 void (*destroy) (configuration_attribute_t *this);
135 };
136
137 /**
138 * @brief Creates an empty configuration_attribute_t object.
139 *
140 * @return created configuration_attribute_t object
141 *
142 * @ingroup payloads
143 */
144 configuration_attribute_t *configuration_attribute_create();
145
146 #endif /*_CONFIGURATION_ATTRIBUTE_H_*/