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