- dead end implementation
[strongswan.git] / Source / charon / config / init_config.h
1 /**
2 * @file init_config.h
3 *
4 * @brief Interface of init_config_t.
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 _INIT_CONFIG_H_
24 #define _INIT_CONFIG_H_
25
26 #include <types.h>
27 #include <network/host.h>
28 #include <utils/iterator.h>
29 #include <transforms/crypters/crypter.h>
30 #include <transforms/prfs/prf.h>
31 #include <transforms/signers/signer.h>
32 #include <transforms/diffie_hellman.h>
33
34
35 typedef struct ike_proposal_t ike_proposal_t;
36
37 /**
38 * @brief Represents a Proposal used in IKE_SA_INIT phase.
39 *
40 * @todo Currently the amount of tranforms with same type in a IKE proposal is limited to 1.
41 * Support of more transforms with same type has to be added.
42 *
43 * @ingroup config
44 */
45 struct ike_proposal_t {
46 /**
47 * Encryption algorithm.
48 */
49 encryption_algorithm_t encryption_algorithm;
50
51 /**
52 * Key length of encryption algorithm in bytes.
53 */
54 u_int16_t encryption_algorithm_key_length;
55
56 /**
57 * Integrity algorithm.
58 */
59 integrity_algorithm_t integrity_algorithm;
60
61 /**
62 * Key length of integrity algorithm.
63 */
64 u_int16_t integrity_algorithm_key_length;
65
66 /**
67 * Pseudo random function (prf).
68 */
69 pseudo_random_function_t pseudo_random_function;
70
71 /**
72 * Key length of prf.
73 */
74 u_int16_t pseudo_random_function_key_length;
75
76 /**
77 * Diffie hellman group.
78 */
79 diffie_hellman_group_t diffie_hellman_group;
80 };
81
82
83 typedef struct init_config_t init_config_t;
84
85 /**
86 * @brief Represents a configuration class holding all needed informations for IKE_SA_INIT phase.
87 *
88 * @b Constructors:
89 * - init_config_create()
90 *
91 * @ingroup config
92 */
93 struct init_config_t {
94
95 /**
96 * @brief Get my host information as host_t object.
97 *
98 * Object is NOT getting cloned.
99 *
100 * @param this calling object
101 * @return host information as host_t object
102 */
103 host_t * (*get_my_host) (init_config_t *this);
104
105 /**
106 * @brief Get other host information as host_t object.
107 *
108 * Object is NOT getting cloned.
109 *
110 * @param this calling object
111 * @return host information as host_t object
112 */
113 host_t * (*get_other_host) (init_config_t *this);
114
115 /**
116 * @brief Get my host information as host_t object.
117 *
118 * Object is getting cloned and has to get destroyed by caller.
119 *
120 * @param this calling object
121 * @return host information as host_t object
122 */
123 host_t * (*get_my_host_clone) (init_config_t *this);
124
125 /**
126 * @brief Get other host information as host_t object.
127 *
128 * @warning Object is getting cloned and has to get destroyed by caller.
129 *
130 * @param this calling object
131 * @return host information as host_t object
132 */
133 host_t * (*get_other_host_clone) (init_config_t *this);
134
135 /**
136 * @brief Get the diffie hellman group to use as initiator with given priority.
137 *
138 * @param this calling object
139 * @param priority priority of dh group number (starting at 1)
140 * @return diffie hellman group number for given priority or
141 * MODP_UNDEFINED for not supported priorities
142 */
143 diffie_hellman_group_t (*get_dh_group_number) (init_config_t *this,size_t priority);
144
145 /**
146 * @brief Returns a list of all supported ike_proposals of type ike_proposal_t *.
147 *
148 * Returned array of ike_proposal_t has to get destroyed by the caller.
149 *
150 * @param this calling object
151 * @param proposals first proposal in a array
152 * @return number of proposals in array
153 */
154 size_t (*get_proposals) (init_config_t *this,ike_proposal_t **proposals);
155
156 /**
157 * @brief Adds a proposal with given priority to the current stored proposals.
158 *
159 * If allready a proposal with given priority is stored the other one is
160 * moved one priority back. If priority is higher then all other stored
161 * proposals, it is inserted as last one.
162 *
163 * @param this calling object
164 * @param priority priority of adding proposal
165 * @param proposal proposal to add
166 */
167 void (*add_proposal) (init_config_t *this,size_t priority, ike_proposal_t proposal);
168
169 /**
170 * @brief Select a proposed from suggested proposals.
171 *
172 * @param this calling object
173 * @param suggested_proposals first proposal in a array
174 * @param proposal_count number of suggested proposals in array
175 * @param selected_proposal the ike_proposal_t pointing to is set
176 * @return
177 * - SUCCESS if a proposal was selected
178 * - NOT_FOUND if none of suggested proposals is supported
179 */
180 status_t (*select_proposal) (init_config_t *this, ike_proposal_t *proposals, size_t proposal_count, ike_proposal_t *selected_proposal);
181
182 /**
183 * @brief Destroys a init_config_t object.
184 *
185 * @param this calling object
186 */
187 void (*destroy) (init_config_t *this);
188 };
189
190 /**
191 * @brief Creates a init_config_t object.
192 *
193 * @return init_config_t object.
194 *
195 * @ingroup config
196 */
197 init_config_t * init_config_create(char * my_ip, char *other_ip, u_int16_t my_port, u_int16_t other_port);
198
199 #endif //_INIT_CONFIG_H_