]> git.ipfire.org Git - people/ms/strongswan.git/blob - programs/charon/charon/encoding/payloads/configuration_attribute.h
- import of strongswan-2.7.0
[people/ms/strongswan.git] / programs / charon / 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 RFC 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 * @brief Class representing an IKEv2-CONFIGURATION Attribute.
74 *
75 * The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
76 *
77 * @b Constructors:
78 * - configuration_attribute_create()
79 *
80 * @ingroup payloads
81 */
82 struct configuration_attribute_t {
83 /**
84 * The payload_t interface.
85 */
86 payload_t payload_interface;
87
88 /**
89 * @brief Returns the currently set value of the attribute.
90 *
91 * @warning Returned data are not copied.
92 *
93 * @param this calling configuration_attribute_t object
94 * @return chunk_t pointing to the value
95 */
96 chunk_t (*get_value) (configuration_attribute_t *this);
97
98 /**
99 * @brief Sets the value of the attribute.
100 *
101 * @warning Value is getting copied.
102 *
103 * @param this calling configuration_attribute_t object
104 * @param value chunk_t pointing to the value to set
105 */
106 void (*set_value) (configuration_attribute_t *this, chunk_t value);
107
108 /**
109 * @brief Sets the type of the attribute.
110 *
111 * @param this calling configuration_attribute_t object
112 * @param type type to set (most significant bit is set to zero)
113 */
114 void (*set_attribute_type) (configuration_attribute_t *this, u_int16_t type);
115
116 /**
117 * @brief get the type of the attribute.
118 *
119 * @param this calling configuration_attribute_t object
120 * @return type of the value
121 */
122 u_int16_t (*get_attribute_type) (configuration_attribute_t *this);
123
124 /**
125 * @brief get the length of an attribute.
126 *
127 * @param this calling configuration_attribute_t object
128 * @return type of the value
129 */
130 u_int16_t (*get_attribute_length) (configuration_attribute_t *this);
131
132 /**
133 * @brief Destroys an configuration_attribute_t object.
134 *
135 * @param this configuration_attribute_t object to destroy
136 */
137 void (*destroy) (configuration_attribute_t *this);
138 };
139
140 /**
141 * @brief Creates an empty configuration_attribute_t object.
142 *
143 * @return created configuration_attribute_t object
144 *
145 * @ingroup payloads
146 */
147 configuration_attribute_t *configuration_attribute_create();
148
149 #endif /* CONFIGURATION_ATTRIBUTE_H_*/