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