updated copyright information
[strongswan.git] / src / charon / encoding / payloads / cp_payload.h
1 /**
2 * @file cp_payload.h
3 *
4 * @brief Interface of cp_payload_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef CP_PAYLOAD_H_
25 #define CP_PAYLOAD_H_
26
27 #include <types.h>
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/configuration_attribute.h>
30 #include <utils/linked_list.h>
31
32 /**
33 * CP_PAYLOAD length in bytes without any proposal substructure.
34 *
35 * @ingroup payloads
36 */
37 #define CP_PAYLOAD_HEADER_LENGTH 8
38
39
40 typedef enum config_type_t config_type_t;
41
42 /**
43 * Config Type of an Configuration Payload.
44 *
45 * @ingroup payloads
46 */
47 enum config_type_t {
48 CFG_REQUEST = 1,
49 CFG_REPLY = 2,
50 CFG_SET = 3,
51 CFG_ACK = 4,
52 };
53
54 /**
55 * string mappings for config_type_t.
56 *
57 * @ingroup payloads
58 */
59 extern mapping_t config_type_m[];
60
61
62 typedef struct cp_payload_t cp_payload_t;
63
64 /**
65 * @brief Class representing an IKEv2-CP Payload.
66 *
67 * The CP Payload format is described in RFC section 3.15.
68 *
69 * @b Constructors:
70 * - cp_payload_create()
71 *
72 * @ingroup payloads
73 */
74 struct cp_payload_t {
75 /**
76 * The payload_t interface.
77 */
78 payload_t payload_interface;
79
80 /**
81 * @brief Creates an iterator of stored configuration_attribute_t objects.
82 *
83 * @warning The created iterator has to get destroyed by the caller!
84 *
85 * @warning When deleting an attribute using this iterator,
86 * the length of this configuration_attribute_t has to be refreshed
87 * by calling get_length()!
88 *
89 * @param this calling cp_payload_t object
90 * @param[in] forward iterator direction (TRUE: front to end)
91 * @return created iterator_t object
92 */
93 iterator_t *(*create_configuration_attribute_iterator) (cp_payload_t *this, bool forward);
94
95 /**
96 * @brief Adds a configuration_attribute_t object to this object.
97 *
98 * @warning The added configuration_attribute_t object is
99 * getting destroyed in destroy function of cp_payload_t.
100 *
101 * @param this calling cp_payload_t object
102 * @param attribute configuration_attribute_t object to add
103 */
104 void (*add_configuration_attribute) (cp_payload_t *this, configuration_attribute_t *attribute);
105
106 /**
107 * @brief Set the config type.
108 *
109 * @param this calling cp_payload_t object
110 * @param config_type config_type_t to set
111 */
112 void (*set_config_type) (cp_payload_t *this,config_type_t config_type);
113
114 /**
115 * @brief Get the config type.
116 *
117 * @param this calling cp_payload_t object
118 * @return config_type_t
119 */
120 config_type_t (*get_config_type) (cp_payload_t *this);
121
122 /**
123 * @brief Destroys an cp_payload_t object.
124 *
125 * @param this cp_payload_t object to destroy
126 */
127 void (*destroy) (cp_payload_t *this);
128 };
129
130 /**
131 * @brief Creates an empty cp_payload_t object
132 *
133 * @return cp_payload_t object
134 *
135 * @ingroup payloads
136 */
137 cp_payload_t *cp_payload_create(void);
138
139 #endif /*CP_PAYLOAD_H_*/