- moved linked_list_iterator_t to iterator_t, located in iterator.h
[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 */
45 struct configuration_manager_t {
46
47 /**
48 * Gets the remote host information for a specific configuration name.
49 *
50 * A host information consist of IP address and UDP port.
51 *
52 * @param this calling object
53 * @param name name of the configuration
54 * @param host remote host information gets stored at this location
55 *
56 * @return
57 * - OUT_OF_RES
58 * - NOT_FOUND
59 * - SUCCESS
60 */
61 status_t (*get_remote_host) (configuration_manager_t *this, char *name, host_t **host);
62
63 /**
64 * Gets the local host information for a specific configuration name
65 *
66 * A host information consist of IP address and UDP port.
67 *
68 * @param this calling object
69 * @param name name of the configuration
70 * @param host local host information gets stored at this location
71 *
72 * @return
73 * - OUT_OF_RES
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 * - OUT_OF_RES
114 * - NOT_FOUND (not yet implemented)
115 * - SUCCESS
116 */
117 status_t (*get_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *list);
118
119 /**
120 * Checks the suggested proposals passed as iterator in and selects one proposal to be sent as selection
121 * of this proposals.
122 *
123 * Currently there is no check implemented. The first suggested proposal is cloned and then as selected returned.
124 *
125 *
126 * @param this calling object
127 * @param host host information used to find the correct proposals
128 * @param in iterator with suggested proposals of type proposal_substructure_t *
129 * @param out The selected proposals of type proposal_substructure_t * are written to this iterator
130 *
131 * @return
132 * - OUT_OF_RES
133 * - FAILED
134 * - NOT_FOUND (not yet implemented)
135 * - SUCCESS
136 */
137 status_t (*select_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *in, iterator_t *out);
138
139 /**
140 * Returns the transforms of type crypter_t, signer_t and prf_t as specified in given proposal.
141 *
142 *
143 * @param this calling object
144 * @param host host information
145 * @param proposals iterator with selected proposals
146 * @param[out] encryption_algorithm
147 * @param[out] pseudo_random_function
148 * @param[out] integrity_algorithm
149 *
150 * @return
151 * - OUT_OF_RES
152 * - FAILED
153 * - NOT_FOUND (not yet implemented)
154 * - SUCCESS
155 */
156 status_t (*get_transforms_for_host_and_proposals) (configuration_manager_t *this, host_t *host, iterator_t *proposals,encryption_algorithm_t *encryption_algorithm,pseudo_random_function_t *pseudo_random_function, integrity_algorithm_t *integrity_algorithm);
157
158 /**
159 * Checks if a given dh_group number is allowed for a specific host
160 *
161 *
162 * @param this calling object
163 * @param host host information
164 * @param group DH group number to check if allowed
165 * @param[out] allowed will be set to TRUE if group number is allowed, FALSE otherwise
166 *
167 * @return
168 * - FAILED
169 * - NOT_FOUND (not yet implemented)
170 * - SUCCESS
171 */
172 status_t (*is_dh_group_allowed_for_host) (configuration_manager_t *this, host_t *host, diffie_hellman_group_t group, bool *allowed);
173
174 /**
175 * Destroys configuration manager
176 *
177 *
178 * @param this calling object
179 * @return
180 * - SUCCESS
181 */
182 status_t (*destroy) (configuration_manager_t *this);
183 };
184
185 /**
186 * Creates the mighty configuration manager
187 *
188 * @return
189 * - pointer to created manager object if succeeded
190 * - NULL if memory allocation failed
191 */
192 configuration_manager_t *configuration_manager_create();
193
194 #endif /*CONFIGURATION_MANAGER_H_*/