2 * Copyright (C) 2007-2008 Tobias Brunner
3 * Copyright (C) 2005-2009 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * @defgroup peer_cfg peer_cfg
26 typedef enum cert_policy_t cert_policy_t
;
27 typedef enum unique_policy_t unique_policy_t
;
28 typedef struct peer_cfg_t peer_cfg_t
;
31 #include <utils/identification.h>
32 #include <utils/enumerator.h>
33 #include <selectors/traffic_selector.h>
34 #include <config/proposal.h>
35 #include <config/ike_cfg.h>
36 #include <config/child_cfg.h>
37 #include <sa/authenticators/authenticator.h>
38 #include <sa/authenticators/eap/eap_method.h>
39 #include <credentials/auth_cfg.h>
42 * Certificate sending policy. This is also used for certificate
43 * requests when using this definition for the other peer. If
44 * it is CERT_NEVER_SEND, a certreq is omitted, otherwise its
47 * @warning These definitions must be the same as in pluto/starter,
48 * as they are sent over the stroke socket.
51 /** always send certificates, even when not requested */
53 /** send certificate upon cert request */
54 CERT_SEND_IF_ASKED
= 1,
55 /** never send a certificate, even when requested */
60 * enum strings for cert_policy_t
62 extern enum_name_t
*cert_policy_names
;
65 * Uniqueness of an IKE_SA, used to drop multiple connections with one peer.
67 enum unique_policy_t
{
68 /** do not check for client uniqueness */
70 /** replace unique IKE_SAs if new ones get established */
72 /** keep existing IKE_SAs, close the new ones on connection attept */
77 * enum strings for unique_policy_t
79 extern enum_name_t
*unique_policy_names
;
82 * Configuration of a peer, specified by IDs.
84 * The peer config defines a connection between two given IDs. It contains
85 * exactly one ike_cfg_t, which is used for initiation. Additionally, it
86 * contains multiple child_cfg_t defining which CHILD_SAs are allowed for this
89 +-------------------+ +---------------+
90 +---------------+ | peer_cfg | +---------------+ |
91 | ike_cfg | +-------------------+ | child_cfg | |
92 +---------------+ | - ids | +---------------+ |
93 | - hosts | 1 1 | - cas | 1 n | - proposals | |
94 | - proposals |<-----| - auth info |----->| - traffic sel | |
95 | - ... | | - dpd config | | - ... |-+
96 +---------------+ | - ... | +---------------+
101 +-------------------+ +-------------------+
102 +-------------------+ | +-------------------+ |
103 | auth_cfg | | | auth_cfg | |
104 +-------------------+ | +-------------------+ |
105 | - local rules |-+ | - remote constr. |-+
106 +-------------------+ +-------------------+
109 * Each peer_cfg has two lists of authentication config attached. Local
110 * authentication configs define how to authenticate ourself against the remote
111 * peer. Each config is enforced using the multiple authentication extension
113 * The remote authentication configs are handled as constraints. The peer has
114 * to fulfill each of these rules (using multiple authentication, in any order)
115 * to gain access to the configuration.
120 * Get the name of the peer_cfg.
122 * Returned object is not getting cloned.
124 * @return peer_cfg's name
126 char* (*get_name
) (peer_cfg_t
*this);
129 * Get the IKE version to use for initiating.
131 * @return IKE major version
133 u_int (*get_ike_version
)(peer_cfg_t
*this);
136 * Get the IKE config to use for initiaton.
138 * @return the IKE config to use
140 ike_cfg_t
* (*get_ike_cfg
) (peer_cfg_t
*this);
143 * Attach a CHILD config.
145 * @param child_cfg CHILD config to add
147 void (*add_child_cfg
) (peer_cfg_t
*this, child_cfg_t
*child_cfg
);
150 * Detach a CHILD config, pointed to by an enumerator.
152 * @param enumerator enumerator indicating element position
154 void (*remove_child_cfg
)(peer_cfg_t
*this, enumerator_t
*enumerator
);
157 * Create an enumerator for all attached CHILD configs.
159 * @return an enumerator over all CHILD configs.
161 enumerator_t
* (*create_child_cfg_enumerator
) (peer_cfg_t
*this);
164 * Select a CHILD config from traffic selectors.
166 * @param my_ts TS for local side
167 * @param other_ts TS for remote side
168 * @param my_host host to narrow down dynamic TS for local side
169 * @param other_host host to narrow down dynamic TS for remote side
170 * @return selected CHILD config, or NULL if no match found
172 child_cfg_t
* (*select_child_cfg
) (peer_cfg_t
*this, linked_list_t
*my_ts
,
173 linked_list_t
*other_ts
, host_t
*my_host
,
177 * Add an authentication config to the peer configuration.
179 * @param config config to add
180 * @param local TRUE for local rules, FALSE for remote constraints
182 void (*add_auth_cfg
)(peer_cfg_t
*this, auth_cfg_t
*cfg
, bool local
);
185 * Create an enumerator over registered authentication configs.
187 * @param local TRUE for local rules, FALSE for remote constraints
188 * @return enumerator over auth_cfg_t*
190 enumerator_t
* (*create_auth_cfg_enumerator
)(peer_cfg_t
*this, bool local
);
193 * Should be sent a certificate for this connection?
195 * @return certificate sending policy
197 cert_policy_t (*get_cert_policy
) (peer_cfg_t
*this);
200 * How to handle uniqueness of IKE_SAs?
202 * @return unique policy
204 unique_policy_t (*get_unique_policy
) (peer_cfg_t
*this);
207 * Get the max number of retries after timeout.
209 * @return max number retries
211 u_int32_t (*get_keyingtries
) (peer_cfg_t
*this);
214 * Get a time to start rekeying (is randomized with jitter).
216 * @return time in s when to start rekeying, 0 disables rekeying
218 u_int32_t (*get_rekey_time
)(peer_cfg_t
*this);
221 * Get a time to start reauthentication (is randomized with jitter).
223 * @return time in s when to start reauthentication, 0 disables it
225 u_int32_t (*get_reauth_time
)(peer_cfg_t
*this);
228 * Get the timeout of a rekeying/reauthenticating SA.
230 * @return timeout in s
232 u_int32_t (*get_over_time
)(peer_cfg_t
*this);
235 * Use MOBIKE (RFC4555) if peer supports it?
237 * @return TRUE to enable MOBIKE support
239 bool (*use_mobike
) (peer_cfg_t
*this);
242 * Get the DPD check interval.
244 * @return dpd_delay in seconds
246 u_int32_t (*get_dpd
) (peer_cfg_t
*this);
249 * Get a virtual IP for the local peer.
251 * If no virtual IP should be used, NULL is returned. %any means to request
252 * a virtual IP using configuration payloads. A specific address is also
253 * used for a request and may be changed by the server.
255 * @param suggestion NULL, %any or specific
256 * @return virtual IP, %any or NULL
258 host_t
* (*get_virtual_ip
) (peer_cfg_t
*this);
261 * Get the name of the pool to acquire configuration attributes from.
263 * @return pool name, NULL if none defined
265 char* (*get_pool
)(peer_cfg_t
*this);
269 * Is this a mediation connection?
271 * @return TRUE, if this is a mediation connection
273 bool (*is_mediation
) (peer_cfg_t
*this);
276 * Get peer_cfg of the connection this one is mediated through.
278 * @return the peer_cfg of the mediation connection
280 peer_cfg_t
* (*get_mediated_by
) (peer_cfg_t
*this);
283 * Get the id of the other peer at the mediation server.
285 * This is the leftid of the peer's connection with the mediation server.
287 * If it is not configured, it is assumed to be the same as the right id
288 * of this connection.
290 * @return the id of the other peer
292 identification_t
* (*get_peer_id
) (peer_cfg_t
*this);
296 * Check if two peer configurations are equal.
298 * This method does not compare associated ike/child_cfg.
300 * @param other candidate to check for equality against this
301 * @return TRUE if peer_cfg and ike_cfg are equal
303 bool (*equals
)(peer_cfg_t
*this, peer_cfg_t
*other
);
306 * Increase reference count.
308 * @return reference to this
310 peer_cfg_t
* (*get_ref
) (peer_cfg_t
*this);
313 * Destroys the peer_cfg object.
315 * Decrements the internal reference counter and
316 * destroys the peer_cfg when it reaches zero.
318 void (*destroy
) (peer_cfg_t
*this);
322 * Create a configuration object for IKE_AUTH and later.
324 * name-string gets cloned, ID's not.
325 * Virtual IPs are used if they are != NULL. A %any host means the virtual
326 * IP should be obtained from the other peer.
327 * Lifetimes are in seconds. To prevent to peers to start rekeying at the
328 * same time, a jitter may be specified. Rekeying of an SA starts at
329 * (rekeylifetime - random(0, jitter)).
331 * @param name name of the peer_cfg
332 * @param ike_version which IKE version we should use for this peer
333 * @param ike_cfg IKE config to use when acting as initiator
334 * @param cert_policy should we send a certificate payload?
335 * @param unique uniqueness of an IKE_SA
336 * @param keyingtries how many keying tries should be done before giving up
337 * @param rekey_time timeout before starting rekeying
338 * @param reauth_time timeout before starting reauthentication
339 * @param jitter_time timerange to randomly subtract from rekey/reauth time
340 * @param over_time maximum overtime before closing a rekeying/reauth SA
341 * @param mobike use MOBIKE (RFC4555) if peer supports it
342 * @param dpd DPD check interval, 0 to disable
343 * @param virtual_ip virtual IP for local host, or NULL
344 * @param pool pool name to get configuration attributes from, or NULL
345 * @param mediation TRUE if this is a mediation connection
346 * @param mediated_by peer_cfg_t of the mediation connection to mediate through
347 * @param peer_id ID that identifies our peer at the mediation server
348 * @return peer_cfg_t object
350 peer_cfg_t
*peer_cfg_create(char *name
, u_int ike_version
, ike_cfg_t
*ike_cfg
,
351 cert_policy_t cert_policy
, unique_policy_t unique
,
352 u_int32_t keyingtries
, u_int32_t rekey_time
,
353 u_int32_t reauth_time
, u_int32_t jitter_time
,
354 u_int32_t over_time
, bool mobike
, u_int32_t dpd
,
355 host_t
*virtual_ip
, char *pool
,
356 bool mediation
, peer_cfg_t
*mediated_by
,
357 identification_t
*peer_id
);
359 #endif /** PEER_CFG_H_ @}*/