9d364e7b6202d1e47929e3d0c6e3ce2d8adf9897
[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 * $Id$
17 */
18
19 /**
20 * @defgroup configuration_attribute configuration_attribute
21 * @{ @ingroup payloads
22 */
23
24 #ifndef CONFIGURATION_ATTRIBUTE_H_
25 #define CONFIGURATION_ATTRIBUTE_H_
26
27 typedef enum configuration_attribute_type_t configuration_attribute_type_t;
28 typedef struct configuration_attribute_t configuration_attribute_t;
29
30 #include <library.h>
31 #include <encoding/payloads/payload.h>
32
33
34 /**
35 * Configuration attribute header length in bytes.
36 */
37 #define CONFIGURATION_ATTRIBUTE_HEADER_LENGTH 4
38
39 /**
40 * Type of the attribute, as in IKEv2 RFC 3.15.1.
41 */
42 enum configuration_attribute_type_t {
43 INTERNAL_IP4_ADDRESS = 1,
44 INTERNAL_IP4_NETMASK = 2,
45 INTERNAL_IP4_DNS = 3,
46 INTERNAL_IP4_NBNS = 4,
47 INTERNAL_ADDRESS_EXPIRY = 5,
48 INTERNAL_IP4_DHCP = 6,
49 APPLICATION_VERSION = 7,
50 INTERNAL_IP6_ADDRESS = 8,
51 INTERNAL_IP6_DNS = 10,
52 INTERNAL_IP6_NBNS = 11,
53 INTERNAL_IP6_DHCP = 12,
54 INTERNAL_IP4_SUBNET = 13,
55 SUPPORTED_ATTRIBUTES = 14,
56 INTERNAL_IP6_SUBNET = 15,
57 /* proprietary Microsoft attributes */
58 INTERNAL_IP4_SERVER = 23456,
59 INTERNAL_IP6_SERVER = 23457
60 };
61
62 /**
63 * enum names for configuration_attribute_type_t.
64 */
65 extern enum_name_t *configuration_attribute_type_names;
66
67 /**
68 * Class representing an IKEv2-CONFIGURATION Attribute.
69 *
70 * The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
71 */
72 struct configuration_attribute_t {
73 /**
74 * The payload_t interface.
75 */
76 payload_t payload_interface;
77
78 /**
79 * Returns the currently set value of the attribute.
80 *
81 * @warning Returned data are not copied.
82 *
83 * @return chunk_t pointing to the value
84 */
85 chunk_t (*get_value) (configuration_attribute_t *this);
86
87 /**
88 * Sets the value of the attribute.
89 *
90 * Value is getting copied.
91 *
92 * @param value chunk_t pointing to the value to set
93 */
94 void (*set_value) (configuration_attribute_t *this, chunk_t value);
95
96 /**
97 * Sets the type of the attribute.
98 *
99 * @param type type to set (most significant bit is set to zero)
100 */
101 void (*set_type) (configuration_attribute_t *this, u_int16_t type);
102
103 /**
104 * get the type of the attribute.
105 *
106 * @return type of the value
107 */
108 u_int16_t (*get_type) (configuration_attribute_t *this);
109
110 /**
111 * get the length of an attribute.
112 *
113 * @return type of the value
114 */
115 u_int16_t (*get_length) (configuration_attribute_t *this);
116
117 /**
118 * Destroys an configuration_attribute_t object.
119 */
120 void (*destroy) (configuration_attribute_t *this);
121 };
122
123 /**
124 * Creates an empty configuration_attribute_t object.
125 *
126 * @return created configuration_attribute_t object
127 */
128 configuration_attribute_t *configuration_attribute_create(void);
129
130 #endif /* CONFIGURATION_ATTRIBUTE_H_ @} */