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