- refactored ike proposal
[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/linked_list.h>
29 #include <config/proposal.h>
30 #include <transforms/crypters/crypter.h>
31 #include <transforms/prfs/prf.h>
32 #include <transforms/signers/signer.h>
33 #include <transforms/diffie_hellman.h>
34
35
36
37 typedef struct init_config_t init_config_t;
38
39 /**
40 * @brief Represents a configuration class holding all needed informations for IKE_SA_INIT phase.
41 *
42 * @b Constructors:
43 * - init_config_create()
44 *
45 * @ingroup config
46 */
47 struct init_config_t {
48
49 /**
50 * @brief Get my host information as host_t object.
51 *
52 * Object is NOT getting cloned.
53 *
54 * @param this calling object
55 * @return host information as host_t object
56 */
57 host_t *(*get_my_host) (init_config_t *this);
58
59 /**
60 * @brief Get other host information as host_t object.
61 *
62 * Object is NOT getting cloned.
63 *
64 * @param this calling object
65 * @return host information as host_t object
66 */
67 host_t *(*get_other_host) (init_config_t *this);
68
69 /**
70 * @brief Get my host information as host_t object.
71 *
72 * Object is getting cloned and has to get destroyed by caller.
73 *
74 * @param this calling object
75 * @return host information as host_t object
76 */
77 host_t *(*get_my_host_clone) (init_config_t *this);
78
79 /**
80 * @brief Get other host information as host_t object.
81 *
82 * @warning Object is getting cloned and has to get destroyed by caller.
83 *
84 * @param this calling object
85 * @return host information as host_t object
86 */
87 host_t *(*get_other_host_clone) (init_config_t *this);
88
89 /**
90 * @brief Returns a list of all supported proposals.
91 *
92 * Returned list is still owned by init_config and MUST NOT
93 * modified or destroyed.
94 *
95 * @param this calling object
96 * @return list containing all the proposals
97 */
98 linked_list_t *(*get_proposals) (init_config_t *this);
99
100 /**
101 * @brief Adds a proposal to the list..
102 *
103 * The first added proposal has the highest priority, the last
104 * added the lowest.
105 *
106 * @param this calling object
107 * @param priority priority of adding proposal
108 * @param proposal proposal to add
109 */
110 void (*add_proposal) (init_config_t *this, proposal_t *proposal);
111
112 /**
113 * @brief Select a proposed from suggested proposals.
114 *
115 * Returned proposal must be destroyed after usage.
116 *
117 * @param this calling object
118 * @param proposals list of proposals to select from
119 * @return selected proposal, or NULL if none matches.
120 */
121 proposal_t *(*select_proposal) (init_config_t *this, linked_list_t *proposals);
122
123 /**
124 * @brief Get the DH group to use for connection initialization.
125 *
126 * @param this calling object
127 * @return dh group to use for initialization
128 */
129 diffie_hellman_group_t (*get_dh_group) (init_config_t *this);
130
131 /**
132 * @brief Check if a suggested dh group is acceptable.
133 *
134 * If we guess a wrong DH group for IKE_SA_INIT, the other
135 * peer will send us a offer. But is this acceptable for us?
136 *
137 * @param this calling object
138 * @return dh group to use for initialization
139 */
140 bool (*check_dh_group) (init_config_t *this, diffie_hellman_group_t dh_group);
141
142 /**
143 * @brief Destroys a init_config_t object.
144 *
145 * @param this calling object
146 */
147 void (*destroy) (init_config_t *this);
148 };
149
150 /**
151 * @brief Creates a init_config_t object.
152 *
153 * @return init_config_t object.
154 *
155 * @ingroup config
156 */
157 init_config_t * init_config_create(char *my_ip, char *other_ip, u_int16_t my_port, u_int16_t other_port);
158
159 #endif //_INIT_CONFIG_H_