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