- added compution of all needed keys and also creation of needed
[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 * Checks if the selected proposals of a remote hosts are valid.
141 *
142 *
143 * @param this calling object
144 * @param host host information
145 * @param proposals iterator with selected proposals
146 * @param[out] valid TRUE if selected proposals are accepted
147 *
148 * @return
149 * - OUT_OF_RES
150 * - FAILED
151 * - NOT_FOUND (not yet implemented)
152 * - SUCCESS
153 */
154 status_t (*check_selected_proposals_for_host) (configuration_manager_t *this,
155 host_t *host,
156 iterator_t *proposals,
157 bool *valid);
158
159 /**
160 * Checks if a given dh_group number is allowed for a specific host
161 *
162 *
163 * @param this calling object
164 * @param host host information
165 * @param group DH group number to check if allowed
166 * @param[out] allowed will be set to TRUE if group number is allowed, FALSE otherwise
167 *
168 * @return
169 * - FAILED
170 * - NOT_FOUND (not yet implemented)
171 * - SUCCESS
172 */
173 status_t (*is_dh_group_allowed_for_host) (configuration_manager_t *this, host_t *host, diffie_hellman_group_t group, bool *allowed);
174
175 /**
176 * Destroys configuration manager
177 *
178 *
179 * @param this calling object
180 * @return
181 * - SUCCESS
182 */
183 status_t (*destroy) (configuration_manager_t *this);
184 };
185
186 /**
187 * Creates the mighty configuration manager
188 *
189 * @return
190 * - pointer to created manager object if succeeded
191 * - NULL if memory allocation failed
192 */
193 configuration_manager_t *configuration_manager_create();
194
195 #endif /*CONFIGURATION_MANAGER_H_*/