moved typedefs to beginning of files to solve some include problems
[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 typedef enum config_type_t config_type_t;
28 typedef struct cp_payload_t cp_payload_t;
29
30 #include <types.h>
31 #include <encoding/payloads/payload.h>
32 #include <encoding/payloads/configuration_attribute.h>
33 #include <utils/linked_list.h>
34
35 /**
36 * CP_PAYLOAD length in bytes without any proposal substructure.
37 *
38 * @ingroup payloads
39 */
40 #define CP_PAYLOAD_HEADER_LENGTH 8
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 * enum name for config_type_t.
56 *
57 * @ingroup payloads
58 */
59 extern enum_name_t *config_type_names;
60
61 /**
62 * @brief Class representing an IKEv2-CP Payload.
63 *
64 * The CP Payload format is described in RFC section 3.15.
65 *
66 * @b Constructors:
67 * - cp_payload_create()
68 *
69 * @ingroup payloads
70 */
71 struct cp_payload_t {
72 /**
73 * The payload_t interface.
74 */
75 payload_t payload_interface;
76
77 /**
78 * @brief Creates an iterator of stored configuration_attribute_t objects.
79 *
80 * @warning The created iterator has to get destroyed by the caller!
81 *
82 * @warning When deleting an attribute using this iterator,
83 * the length of this configuration_attribute_t has to be refreshed
84 * by calling get_length()!
85 *
86 * @param this calling cp_payload_t object
87 * @param[in] forward iterator direction (TRUE: front to end)
88 * @return created iterator_t object
89 */
90 iterator_t *(*create_configuration_attribute_iterator) (cp_payload_t *this, bool forward);
91
92 /**
93 * @brief Adds a configuration_attribute_t object to this object.
94 *
95 * @warning The added configuration_attribute_t object is
96 * getting destroyed in destroy function of cp_payload_t.
97 *
98 * @param this calling cp_payload_t object
99 * @param attribute configuration_attribute_t object to add
100 */
101 void (*add_configuration_attribute) (cp_payload_t *this, configuration_attribute_t *attribute);
102
103 /**
104 * @brief Set the config type.
105 *
106 * @param this calling cp_payload_t object
107 * @param config_type config_type_t to set
108 */
109 void (*set_config_type) (cp_payload_t *this,config_type_t config_type);
110
111 /**
112 * @brief Get the config type.
113 *
114 * @param this calling cp_payload_t object
115 * @return config_type_t
116 */
117 config_type_t (*get_config_type) (cp_payload_t *this);
118
119 /**
120 * @brief Destroys an cp_payload_t object.
121 *
122 * @param this cp_payload_t object to destroy
123 */
124 void (*destroy) (cp_payload_t *this);
125 };
126
127 /**
128 * @brief Creates an empty cp_payload_t object
129 *
130 * @return cp_payload_t object
131 *
132 * @ingroup payloads
133 */
134 cp_payload_t *cp_payload_create(void);
135
136 #endif /*CP_PAYLOAD_H_*/