e15f6a538360c0f3c153c75e100d563ca6ad00ec
[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 * - 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 * - NOT_FOUND (not yet implemented)
73 * - SUCCESS
74 */
75 status_t (*get_local_host) (configuration_manager_t *this, char *name, host_t **host);
76
77 /**
78 * Returns the DH group number to use when initiating a connection.
79 *
80 * To make sure that different group numbers are supported in case
81 * a group number is not supported by other peer, a priority has to get defined.
82 *
83 *
84 * @param this calling object
85 * @param name name of the configuration
86 * @param dh_group_number the DH group number gets stored at this location
87 * @param priority priority to use for selection of DH group number.
88 * Highest priority is 1. All higher values have lower
89 * priority.
90 *
91 * @return
92 * - FAILED (not yet implemented)
93 * - NOT_FOUND (not yet implemented)
94 * - SUCCESS
95 */
96 status_t (*get_dh_group_number) (configuration_manager_t *this, char *name, u_int16_t *dh_group_number, u_int16_t priority);
97
98 /**
99 * Returns the proposals which should be used to initiate a connection with a specific
100 * host.
101 *
102 * The proposals of type proposal_substructure_t * are returned over the given iterator
103 * and have to be destroyed by the caller.
104 *
105 *
106 * @param this calling object
107 * @param host host information used to find the correct proposals
108 * @param list iterator where the proposals are written to
109 *
110 * @return
111 * - NOT_FOUND (not yet implemented)
112 * - SUCCESS
113 */
114 status_t (*get_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *list);
115
116 /**
117 * Checks the suggested proposals passed as iterator in and selects one proposal to be sent as selection
118 * of this proposals.
119 *
120 * Currently there is no check implemented. The first suggested proposal is cloned and then as selected returned.
121 *
122 *
123 * @param this calling object
124 * @param host host information used to find the correct proposals
125 * @param in iterator with suggested proposals of type proposal_substructure_t *
126 * @param out The selected proposals of type proposal_substructure_t * are written to this iterator
127 *
128 * @return
129 * - FAILED
130 * - NOT_FOUND (not yet implemented)
131 * - SUCCESS
132 */
133 status_t (*select_proposals_for_host) (configuration_manager_t *this, host_t *host, iterator_t *in, iterator_t *out);
134
135 /**
136 * Checks if the selected proposals of a remote hosts are valid.
137 *
138 *
139 * @param this calling object
140 * @param host host information
141 * @param proposals iterator with selected proposals
142 * @param[out] valid TRUE if selected proposals are accepted
143 *
144 * @return
145 * - FAILED
146 * - NOT_FOUND (not yet implemented)
147 * - SUCCESS
148 */
149 status_t (*check_selected_proposals_for_host) (configuration_manager_t *this,
150 host_t *host,
151 iterator_t *proposals,
152 bool *valid);
153
154 /**
155 * Checks if a given dh_group number is allowed for a specific host
156 *
157 *
158 * @param this calling object
159 * @param host host information
160 * @param group DH group number to check if allowed
161 * @param[out] allowed will be set to TRUE if group number is allowed, FALSE otherwise
162 *
163 * @return
164 * - FAILED
165 * - NOT_FOUND (not yet implemented)
166 * - SUCCESS
167 */
168 status_t (*is_dh_group_allowed_for_host) (configuration_manager_t *this, host_t *host, diffie_hellman_group_t group, bool *allowed);
169
170 /**
171 * Destroys configuration manager
172 *
173 *
174 * @param this calling object
175 * @return
176 * - SUCCESS
177 */
178 status_t (*destroy) (configuration_manager_t *this);
179 };
180
181 /**
182 * Creates the mighty configuration manager
183 *
184 * @return
185 * - pointer to created manager object if succeeded
186 * - NULL if memory allocation failed
187 */
188 configuration_manager_t *configuration_manager_create();
189
190 #endif /*CONFIGURATION_MANAGER_H_*/