d2e94197c32792da81961b301e6d6fff0212f470
[strongswan.git] / src / charon / encoding / payloads / cp_payload.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 cp_payload cp_payload
21 * @{ @ingroup payloads
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 <library.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 #define CP_PAYLOAD_HEADER_LENGTH 8
39
40 /**
41 * Config Type of an Configuration Payload.
42 */
43 enum config_type_t {
44 CFG_REQUEST = 1,
45 CFG_REPLY = 2,
46 CFG_SET = 3,
47 CFG_ACK = 4,
48 };
49
50 /**
51 * enum name for config_type_t.
52 */
53 extern enum_name_t *config_type_names;
54
55 /**
56 * Class representing an IKEv2-CP Payload.
57 *
58 * The CP Payload format is described in RFC section 3.15.
59 */
60 struct cp_payload_t {
61 /**
62 * The payload_t interface.
63 */
64 payload_t payload_interface;
65
66 /**
67 * Creates an iterator of stored configuration_attribute_t objects.
68 *
69 * When deleting an attribute using this iterator, the length of this
70 * configuration_attribute_t has to be refreshed by calling get_length()!
71 *
72 * @return created iterator_t object
73 */
74 iterator_t *(*create_attribute_iterator) (cp_payload_t *this);
75
76 /**
77 * Adds a configuration_attribute_t object to this object.
78 *
79 * The added configuration_attribute_t object is getting destroyed in
80 * destroy function of cp_payload_t.
81 *
82 * @param attribute configuration_attribute_t object to add
83 */
84 void (*add_configuration_attribute) (cp_payload_t *this, configuration_attribute_t *attribute);
85
86 /**
87 * Set the config type.
88 *
89 * @param config_type config_type_t to set
90 */
91 void (*set_config_type) (cp_payload_t *this,config_type_t config_type);
92
93 /**
94 * Get the config type.
95 *
96 * @return config_type_t
97 */
98 config_type_t (*get_config_type) (cp_payload_t *this);
99
100 /**
101 * Destroys an cp_payload_t object.
102 */
103 void (*destroy) (cp_payload_t *this);
104 };
105
106 /**
107 * Creates an empty cp_payload_t object
108 *
109 * @return cp_payload_t object
110 */
111 cp_payload_t *cp_payload_create(void);
112
113 #endif /*CP_PAYLOAD_H_ @} */