- memory allocation checks removed
[strongswan.git] / Source / charon / config / configuration_manager.h
1 /**
2 * @file configuration_manager.h
3 *
4 * @brief Manages all configuration aspects of the daemon.
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_MANAGER_H_
24 #define CONFIGURATION_MANAGER_H_
25
26 #include <types.h>
27 #include <utils/linked_list.h>
28 #include <network/host.h>
29 #include <encoding/payloads/transform_substructure.h>
30 #include <transforms/prfs/prf.h>
31 #include <transforms/signers/signer.h>
32 #include <transforms/crypters/crypter.h>
33
34
35 typedef struct configuration_manager_t configuration_manager_t;
36
37 /**
38 * @brief Manages all configuration aspects of the daemon.
39 *
40 * Currently the configuration manager class does not store specific configurations.
41 * It is expected, that in future different configurations are stored in a linked list
42 * or a hash map and are managed by this class.
43 *
44 * @ingroup config
45 *
46 */
47 struct configuration_manager_t {
48
49 /**
50 * Gets the remote host information for a specific configuration name.
51 *
52 * A host information consist of IP address and UDP port.
53 *
54 * @param this calling object
55 * @param name name of the configuration
56 * @param host remote host information gets stored at this location
57 *
58 * @return
59 * - NOT_FOUND
60 * - SUCCESS
61 */
62 status_t (*get_remote_host) (configuration_manager_t *this, char *name, host_t **host);
63
64 /**
65 * Gets the local host information for a specific configuration name
66 *
67 * A host information consist of IP address and UDP port.
68 *
69 * @param this calling object
70 * @param name name of the configuration
71 * @param host local host information gets stored at this location
72 *
73 * @return
74 * - NOT_FOUND (not yet implemented)
75 * - SUCCESS
76 */
77 status_t (*get_local_host) (configuration_manager_t *this, char *name, host_t **host);
78
79 /**
80 * Returns the DH group number to use when initiating a connection.
81 *
82 * To make sure that different group numbers are supported in case
83 * a group number is not supported by other peer, a priority has to get defined.
84 *
85 *
86 * @param this calling object
87 * @param name name of the configuration
88 * @param dh_group_number the DH group number gets stored at this location
89 * @param priority priority to use for selection of DH group number.
90 * Highest priority is 1. All higher values have lower
91 * priority.
92 *
93 * @return
94 * - FAILED (not yet implemented)
95 * - NOT_FOUND (not yet implemented)
96 * - SUCCESS
97 */
98 status_t (*get_dh_group_number) (configuration_manager_t *this, char *name, u_int16_t *dh_group_number, u_int16_t priority);
99
100 /**
101 * Returns the proposals which should be used to initiate a connection with a specific
102 * host.
103 *
104 * The proposals of type proposal_substructure_t * are returned over the given iterator
105 * and have to be destroyed by the caller.
106 *
107 *
108 * @param this calling object
109 * @param host host information used to find the correct proposals
110 * @param list iterator where the proposals are written to
111 *
112 * @return
113 * - NOT_FOUND (not yet implemented)
114 * - SUCCESS
115 */
116 status_t (*get_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *list);
117
118 /**
119 * Checks the suggested proposals passed as iterator in and selects one proposal to be sent as selection
120 * of this proposals.
121 *
122 * Currently there is no check implemented. The first suggested proposal is cloned and then as selected returned.
123 *
124 *
125 * @param this calling object
126 * @param host host information used to find the correct proposals
127 * @param in iterator with suggested proposals of type proposal_substructure_t *
128 * @param out The selected proposals of type proposal_substructure_t * are written to this iterator
129 *
130 * @return
131 * - FAILED
132 * - NOT_FOUND (not yet implemented)
133 * - SUCCESS
134 */
135 status_t (*select_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *in, iterator_t *out);
136
137 /**
138 * Checks if the selected proposals of a remote hosts are valid.
139 *
140 *
141 * @param this calling object
142 * @param host host information
143 * @param proposals iterator with selected proposals
144 * @param[out] valid TRUE if selected proposals are accepted
145 *
146 * @return
147 * - FAILED
148 * - NOT_FOUND (not yet implemented)
149 * - SUCCESS
150 */
151 status_t (*check_selected_proposals_for_host) (configuration_manager_t *this,
152 host_t *host,
153 iterator_t *proposals,
154 bool *valid);
155
156 /**
157 * Checks if a given dh_group number is allowed for a specific host
158 *
159 *
160 * @param this calling object
161 * @param host host information
162 * @param group DH group number to check if allowed
163 * @param[out] allowed will be set to TRUE if group number is allowed, FALSE otherwise
164 *
165 * @return
166 * - FAILED
167 * - NOT_FOUND (not yet implemented)
168 * - SUCCESS
169 */
170 status_t (*is_dh_group_allowed_for_host) (configuration_manager_t *this, host_t *host, diffie_hellman_group_t group, bool *allowed);
171
172 /**
173 * Destroys configuration manager
174 *
175 *
176 * @param this calling object
177 * @return
178 * - SUCCESS
179 */
180 status_t (*destroy) (configuration_manager_t *this);
181 };
182
183 /**
184 * Creates the mighty configuration manager
185 *
186 * @return
187 * - pointer to created manager object if succeeded
188 * - NULL if memory allocation failed
189 *
190 * @ingroup config
191 */
192 configuration_manager_t *configuration_manager_create();
193
194 #endif /*CONFIGURATION_MANAGER_H_*/