4 * @brief Interface of connection_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include <utils/host.h>
28 #include <utils/linked_list.h>
29 #include <utils/identification.h>
30 #include <config/proposal.h>
31 #include <crypto/diffie_hellman.h>
34 typedef enum auth_method_t auth_method_t
;
43 * Computed as specified in section 2.15 of RFC using
44 * an RSA private key over a PKCS#1 padded hash.
46 RSA_DIGITAL_SIGNATURE
= 1,
49 * Computed as specified in section 2.15 of RFC using the
50 * shared key associated with the identity in the ID payload
51 * and the negotiated prf function
53 SHARED_KEY_MESSAGE_INTEGRITY_CODE
= 2,
56 * Computed as specified in section 2.15 of RFC using a
57 * DSS private key over a SHA-1 hash.
59 DSS_DIGITAL_SIGNATURE
= 3,
63 * string mappings for auth method.
67 extern mapping_t auth_method_m
[];
70 typedef enum cert_policy_t cert_policy_t
;
73 * Certificate sending policy. This is also used for certificate
74 * requests when using this definition for the other peer. If
75 * it is CERT_NEVER_SEND, a certreq is ommited, otherwise its
80 * @warning These definitions must be the same as in pluto/starter,
81 * as they are sent over the stroke socket.
84 /** always send certificates, even when not requested */
86 /** send certificate upon cert request */
87 CERT_SEND_IF_ASKED
= 1,
88 /** never send a certificate, even when requested */
93 * string mappings for certpolicy_t.
97 extern mapping_t cert_policy_m
[];
100 typedef struct connection_t connection_t
;
103 * @brief A connection_t defines the rules to set up an IKE_SA.
107 * - connection_create()
111 struct connection_t
{
114 * @brief Get my address as host_t object.
116 * Object is NOT getting cloned.
118 * @param this calling object
119 * @return host information as host_t object
121 host_t
*(*get_my_host
) (connection_t
*this);
124 * @brief Get others address as host_t object.
126 * Object is NOT getting cloned.
128 * @param this calling object
129 * @return host information as host_t object
131 host_t
*(*get_other_host
) (connection_t
*this);
134 * @brief Update address of my host.
136 * It may be necessary to uptdate own address, as it
137 * is set to the default route (0.0.0.0) in some cases.
138 * Old host is destroyed, new one NOT cloned.
140 * @param this calling object
141 * @param my_host new host to set as my_host
143 void (*update_my_host
) (connection_t
*this, host_t
*my_host
);
146 * @brief Update address of remote host.
148 * It may be necessary to uptdate remote address, as a
149 * connection may define %any (0.0.0.0) or a subnet.
150 * Old host is destroyed, new one NOT cloned.
152 * @param this calling object
153 * @param my_host new host to set as other_host
155 void (*update_other_host
) (connection_t
*this, host_t
*other_host
);
158 * @brief Returns a list of all supported proposals.
160 * Returned list is still owned by connection and MUST NOT
161 * modified or destroyed.
163 * @param this calling object
164 * @return list containing all the proposals
166 linked_list_t
*(*get_proposals
) (connection_t
*this);
169 * @brief Adds a proposal to the list.
171 * The first added proposal has the highest priority, the last
174 * @param this calling object
175 * @param proposal proposal to add
177 void (*add_proposal
) (connection_t
*this, proposal_t
*proposal
);
180 * @brief Select a proposed from suggested proposals.
182 * Returned proposal must be destroyed after usage.
184 * @param this calling object
185 * @param proposals list of proposals to select from
186 * @return selected proposal, or NULL if none matches.
188 proposal_t
*(*select_proposal
) (connection_t
*this, linked_list_t
*proposals
);
191 * @brief Get the authentication method to use
193 * @param this calling object
194 * @return authentication method
196 auth_method_t (*get_auth_method
) (connection_t
*this);
199 * @brief Get the connection name.
201 * Name must not be freed, since it points to
204 * @param this calling object
205 * @return name of the connection
207 char* (*get_name
) (connection_t
*this);
210 * @brief Check if the connection is marked as an IKEv2 connection.
212 * Since all connections (IKEv1+2) are loaded, but charon handles
213 * only those marked with IKEv2, this flag can tell us if we must
214 * ignore a connection on initiaton. Then pluto will do it for us.
216 * @param this calling object
217 * @return - TRUE, if this is an IKEv2 connection
219 bool (*is_ikev2
) (connection_t
*this);
222 * @brief Should be sent a certificate request for this connection?
224 * A certificate request contains serials of our trusted CA certificates.
225 * This flag says if such a request is sent on connection setup to
226 * the peer. It should be ommited when CERT_SEND_NEVER, sended otherwise.
228 * @param this calling object
229 * @return - TRUE, if certificate request should be sent
231 cert_policy_t (*get_cert_req_policy
) (connection_t
*this);
234 * @brief Should be sent a certificate for this connection?
236 * Return the policy used to send the certificate.
238 * @param this calling object
239 * @return certificate sending policy
241 cert_policy_t (*get_cert_policy
) (connection_t
*this);
244 * @brief Get the DH group to use for connection initialization.
246 * @param this calling object
247 * @return dh group to use for initialization
249 diffie_hellman_group_t (*get_dh_group
) (connection_t
*this);
252 * @brief Check if a suggested dh group is acceptable.
254 * If we guess a wrong DH group for IKE_SA_INIT, the other
255 * peer will send us a offer. But is this acceptable for us?
257 * @param this calling object
258 * @return TRUE if group acceptable
260 bool (*check_dh_group
) (connection_t
*this, diffie_hellman_group_t dh_group
);
263 * @brief Clone a connection_t object.
265 * @param this connection to clone
266 * @return clone of it
268 connection_t
*(*clone
) (connection_t
*this);
271 * @brief Destroys a connection_t object.
273 * @param this calling object
275 void (*destroy
) (connection_t
*this);
279 * @brief Creates a connection_t object.
281 * Supplied hosts become owned by connection, so
282 * do not modify or destroy them after a call to
283 * connection_create(). Name gets cloned internally.
285 * @param name connection identifier
286 * @param ikev2 TRUE if this is an IKEv2 connection
287 * @param cert_policy certificate send policy
288 * @param cert_req_policy certificate request send policy
289 * @param my_host host_t representing local address
290 * @param other_host host_t representing remote address
291 * @param auth_method Authentication method to use for our(!) auth data
292 * @return connection_t object.
296 connection_t
* connection_create(char *name
, bool ikev2
,
297 cert_policy_t cert_pol
, cert_policy_t req_pol
,
298 host_t
*my_host
, host_t
*other_host
,
299 auth_method_t auth_method
);
301 #endif /* CONNECTION_H_ */