fixing a problem if the mediation server initiates the rekeying
[strongswan.git] / src / charon / sa / ike_sa.h
1 /*
2 * Copyright (C) 2006-2008 Tobias Brunner
3 * Copyright (C) 2006 Daniel Roethlisberger
4 * Copyright (C) 2005-2006 Martin Willi
5 * Copyright (C) 2005 Jan Hutter
6 * Hochschule fuer Technik Rapperswil
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * $Id$
19 */
20
21 /**
22 * @defgroup ike_sa ike_sa
23 * @{ @ingroup sa
24 */
25
26 #ifndef IKE_SA_H_
27 #define IKE_SA_H_
28
29 typedef enum ike_extension_t ike_extension_t;
30 typedef enum ike_condition_t ike_condition_t;
31 typedef enum ike_sa_state_t ike_sa_state_t;
32 typedef enum statistic_t statistic_t;
33 typedef struct ike_sa_t ike_sa_t;
34
35 #include <library.h>
36 #include <encoding/message.h>
37 #include <encoding/payloads/proposal_substructure.h>
38 #include <sa/ike_sa_id.h>
39 #include <sa/child_sa.h>
40 #include <sa/tasks/task.h>
41 #include <utils/randomizer.h>
42 #include <crypto/prfs/prf.h>
43 #include <crypto/crypters/crypter.h>
44 #include <crypto/signers/signer.h>
45 #include <config/peer_cfg.h>
46 #include <config/ike_cfg.h>
47 #include <credentials/auth_info.h>
48
49 /**
50 * Timeout in milliseconds after that a half open IKE_SA gets deleted.
51 */
52 #define HALF_OPEN_IKE_SA_TIMEOUT 30000
53
54 /**
55 * Interval to send keepalives when NATed, in seconds.
56 */
57 #define KEEPALIVE_INTERVAL 20
58
59 /**
60 * After which time rekeying should be retried if it failed, in seconds.
61 */
62 #define RETRY_INTERVAL 30
63
64 /**
65 * Jitter to subtract from RETRY_INTERVAL to randomize rekey retry.
66 */
67 #define RETRY_JITTER 20
68
69 /**
70 * Extensions (or optional features) the peer supports
71 */
72 enum ike_extension_t {
73
74 /**
75 * peer supports NAT traversal as specified in RFC4306
76 */
77 EXT_NATT = (1<<0),
78
79 /**
80 * peer supports MOBIKE (RFC4555)
81 */
82 EXT_MOBIKE = (1<<1),
83 };
84
85 /**
86 * Conditions of an IKE_SA, change during its lifetime
87 */
88 enum ike_condition_t {
89
90 /**
91 * Connection is natted (or faked) somewhere
92 */
93 COND_NAT_ANY = (1<<0),
94
95 /**
96 * we are behind NAT
97 */
98 COND_NAT_HERE = (1<<1),
99
100 /**
101 * other is behind NAT
102 */
103 COND_NAT_THERE = (1<<2),
104
105 /**
106 * Faking NAT to enforce UDP encapsulation
107 */
108 COND_NAT_FAKE = (1<<3),
109
110 /**
111 * peer has ben authenticated using EAP
112 */
113 COND_EAP_AUTHENTICATED = (1<<4),
114
115 /**
116 * received a certificate request from the peer
117 */
118 COND_CERTREQ_SEEN = (1<<4),
119 };
120
121 /**
122 * Information and statistics to query from an SA
123 */
124 enum statistic_t {
125
126 /**
127 * Relative time for scheduled rekeying
128 */
129 STAT_REKEY_TIME,
130
131 /**
132 * Relative time for scheduled reauthentication
133 */
134 STAT_REAUTH_TIME,
135 };
136
137 /**
138 * State of an IKE_SA.
139 *
140 * An IKE_SA passes various states in its lifetime. A newly created
141 * SA is in the state CREATED.
142 * @verbatim
143 +----------------+
144 ¦ SA_CREATED ¦
145 +----------------+
146 ¦
147 on initiate()---> ¦ <----- on IKE_SA_INIT received
148 V
149 +----------------+
150 ¦ SA_CONNECTING ¦
151 +----------------+
152 ¦
153 ¦ <----- on IKE_AUTH successfully completed
154 V
155 +----------------+
156 ¦ SA_ESTABLISHED ¦-------------------------+ <-- on rekeying
157 +----------------+ ¦
158 ¦ V
159 on delete()---> ¦ <----- on IKE_SA +-------------+
160 ¦ delete request ¦ SA_REKEYING ¦
161 ¦ received +-------------+
162 V ¦
163 +----------------+ ¦
164 ¦ SA_DELETING ¦<------------------------+ <-- after rekeying
165 +----------------+
166 ¦
167 ¦ <----- after delete() acknowledged
168 ¦
169 \V/
170 X
171 / \
172 @endverbatim
173 */
174 enum ike_sa_state_t {
175
176 /**
177 * IKE_SA just got created, but is not initiating nor responding yet.
178 */
179 IKE_CREATED,
180
181 /**
182 * IKE_SA gets initiated actively or passively
183 */
184 IKE_CONNECTING,
185
186 /**
187 * IKE_SA is fully established
188 */
189 IKE_ESTABLISHED,
190
191 /**
192 * IKE_SA rekeying in progress
193 */
194 IKE_REKEYING,
195
196 /**
197 * IKE_SA is in progress of deletion
198 */
199 IKE_DELETING,
200 };
201
202 /**
203 * enum names for ike_sa_state_t.
204 */
205 extern enum_name_t *ike_sa_state_names;
206
207 /**
208 * Class ike_sa_t representing an IKE_SA.
209 *
210 * An IKE_SA contains crypto information related to a connection
211 * with a peer. It contains multiple IPsec CHILD_SA, for which
212 * it is responsible. All traffic is handled by an IKE_SA, using
213 * the task manager and its tasks.
214 */
215 struct ike_sa_t {
216
217 /**
218 * Get the id of the SA.
219 *
220 * Returned ike_sa_id_t object is not getting cloned!
221 *
222 * @return ike_sa's ike_sa_id_t
223 */
224 ike_sa_id_t* (*get_id) (ike_sa_t *this);
225
226 /**
227 * Get the numerical ID uniquely defining this IKE_SA.
228 *
229 * @return unique ID
230 */
231 u_int32_t (*get_unique_id) (ike_sa_t *this);
232
233 /**
234 * Get the state of the IKE_SA.
235 *
236 * @return state of the IKE_SA
237 */
238 ike_sa_state_t (*get_state) (ike_sa_t *this);
239
240 /**
241 * Set the state of the IKE_SA.
242 *
243 * @param state state to set for the IKE_SA
244 */
245 void (*set_state) (ike_sa_t *this, ike_sa_state_t ike_sa);
246
247 /**
248 * Get the name of the connection this IKE_SA uses.
249 *
250 * @return name
251 */
252 char* (*get_name) (ike_sa_t *this);
253
254 /**
255 * Get statistic values from the IKE_SA.
256 *
257 * @param kind kind of requested value
258 * @return value as integer
259 */
260 u_int32_t (*get_statistic)(ike_sa_t *this, statistic_t kind);
261
262 /**
263 * Get the own host address.
264 *
265 * @return host address
266 */
267 host_t* (*get_my_host) (ike_sa_t *this);
268
269 /**
270 * Set the own host address.
271 *
272 * @param me host address
273 */
274 void (*set_my_host) (ike_sa_t *this, host_t *me);
275
276 /**
277 * Get the other peers host address.
278 *
279 * @return host address
280 */
281 host_t* (*get_other_host) (ike_sa_t *this);
282
283 /**
284 * Set the others host address.
285 *
286 * @param other host address
287 */
288 void (*set_other_host) (ike_sa_t *this, host_t *other);
289
290 /**
291 * Update the IKE_SAs host.
292 *
293 * Hosts may be NULL to use current host.
294 *
295 * @param me new local host address, or NULL
296 * @param other new remote host address, or NULL
297 */
298 void (*update_hosts)(ike_sa_t *this, host_t *me, host_t *other);
299
300 /**
301 * Get the own identification.
302 *
303 * @return identification
304 */
305 identification_t* (*get_my_id) (ike_sa_t *this);
306
307 /**
308 * Set the own identification.
309 *
310 * @param me identification
311 */
312 void (*set_my_id) (ike_sa_t *this, identification_t *me);
313
314 /**
315 * Get the other peer's identification.
316 *
317 * @return identification
318 */
319 identification_t* (*get_other_id) (ike_sa_t *this);
320
321 /**
322 * Set the other peer's identification.
323 *
324 * @param other identification
325 */
326 void (*set_other_id) (ike_sa_t *this, identification_t *other);
327
328 /**
329 * Get the config used to setup this IKE_SA.
330 *
331 * @return ike_config
332 */
333 ike_cfg_t* (*get_ike_cfg) (ike_sa_t *this);
334
335 /**
336 * Set the config to setup this IKE_SA.
337 *
338 * @param config ike_config to use
339 */
340 void (*set_ike_cfg) (ike_sa_t *this, ike_cfg_t* config);
341
342 /**
343 * Get the peer config used by this IKE_SA.
344 *
345 * @return peer_config
346 */
347 peer_cfg_t* (*get_peer_cfg) (ike_sa_t *this);
348
349 /**
350 * Set the peer config to use with this IKE_SA.
351 *
352 * @param config peer_config to use
353 */
354 void (*set_peer_cfg) (ike_sa_t *this, peer_cfg_t *config);
355
356 /**
357 * Get authentication/authorization info for local peer.
358 *
359 * @return auth_info for me
360 */
361 auth_info_t* (*get_my_auth)(ike_sa_t *this);
362
363 /**
364 * Get authentication/authorization info for remote peer.
365 *
366 * @return auth_info for me
367 */
368 auth_info_t* (*get_other_auth)(ike_sa_t *this);
369
370 /**
371 * Add an additional address for the peer.
372 *
373 * In MOBIKE, a peer may transmit additional addresses where it is
374 * reachable. These are stored in the IKE_SA.
375 * The own list of addresses is not stored, they are queried from
376 * the kernel when required.
377 *
378 * @param host host to add to list
379 */
380 void (*add_additional_address)(ike_sa_t *this, host_t *host);
381
382 /**
383 * Create an iterator over all additional addresses of the peer.
384 *
385 * @return iterator over addresses
386 */
387 iterator_t* (*create_additional_address_iterator)(ike_sa_t *this);
388
389 /**
390 * Enable an extension the peer supports.
391 *
392 * If support for an IKE extension is detected, this method is called
393 * to enable that extension and behave accordingly.
394 *
395 * @param extension extension to enable
396 */
397 void (*enable_extension)(ike_sa_t *this, ike_extension_t extension);
398
399 /**
400 * Check if the peer supports an extension.
401 *
402 * @param extension extension to check for support
403 * @return TRUE if peer supports it, FALSE otherwise
404 */
405 bool (*supports_extension)(ike_sa_t *this, ike_extension_t extension);
406
407 /**
408 * Enable/disable a condition flag for this IKE_SA.
409 *
410 * @param condition condition to enable/disable
411 * @param enable TRUE to enable condition, FALSE to disable
412 */
413 void (*set_condition) (ike_sa_t *this, ike_condition_t condition, bool enable);
414
415 /**
416 * Check if a condition flag is set.
417 *
418 * @param condition condition to check
419 * @return TRUE if condition flag set, FALSE otherwise
420 */
421 bool (*has_condition) (ike_sa_t *this, ike_condition_t condition);
422
423 /**
424 * Get the number of queued MOBIKE address updates.
425 *
426 * @return number of pending updates
427 */
428 u_int32_t (*get_pending_updates)(ike_sa_t *this);
429
430 /**
431 * Set the number of queued MOBIKE address updates.
432 *
433 * @param updates number of pending updates
434 */
435 void (*set_pending_updates)(ike_sa_t *this, u_int32_t updates);
436
437 /**
438 * Check if we are the original initiator of this IKE_SA (rekeying does not
439 * change this flag).
440 */
441 bool (*is_ike_initiator)(ike_sa_t *this);
442
443
444 #ifdef ME
445 /**
446 * Activate mediation server functionality for this IKE_SA.
447 */
448 void (*act_as_mediation_server) (ike_sa_t *this);
449
450 /**
451 * Get the server reflexive host.
452 *
453 * @return server reflexive host
454 */
455 host_t* (*get_server_reflexive_host) (ike_sa_t *this);
456
457 /**
458 * Set the server reflexive host.
459 *
460 * @param host server reflexive host
461 */
462 void (*set_server_reflexive_host) (ike_sa_t *this, host_t *host);
463
464 /**
465 * Get the connect ID.
466 *
467 * @return connect ID
468 */
469 chunk_t (*get_connect_id) (ike_sa_t *this);
470
471 /**
472 * Initiate the mediation of a mediated connection (i.e. initiate a
473 * ME_CONNECT exchange).
474 *
475 * @param mediated_cfg peer_cfg of the mediated connection
476 * @return
477 * - SUCCESS if initialization started
478 * - DESTROY_ME if initialization failed
479 */
480 status_t (*initiate_mediation) (ike_sa_t *this, peer_cfg_t *mediated_cfg);
481
482 /**
483 * Initiate the mediated connection
484 *
485 * @param me local endpoint (gets cloned)
486 * @param other remote endpoint (gets cloned)
487 * @param childs linked list of child_cfg_t of CHILD_SAs (gets cloned)
488 * @param connect_id connect ID (gets cloned)
489 * @return
490 * - SUCCESS if initialization started
491 * - DESTROY_ME if initialization failed
492 */
493 status_t (*initiate_mediated) (ike_sa_t *this, host_t *me, host_t *other,
494 linked_list_t *childs, chunk_t connect_id);
495
496 /**
497 * Relay data from one peer to another (i.e. initiate a
498 * ME_CONNECT exchange).
499 *
500 * Data is cloned.
501 *
502 * @param requester ID of the requesting peer
503 * @param connect_id data of the ME_CONNECTID payload
504 * @param connect_key data of the ME_CONNECTKEY payload
505 * @param endpoints endpoints
506 * @param response TRUE if this is a response
507 * @return
508 * - SUCCESS if relay started
509 * - DESTROY_ME if relay failed
510 */
511 status_t (*relay) (ike_sa_t *this, identification_t *requester, chunk_t connect_id,
512 chunk_t connect_key, linked_list_t *endpoints, bool response);
513
514 /**
515 * Send a callback to a peer.
516 *
517 * Data is cloned.
518 *
519 * @param peer_id ID of the other peer
520 * @return
521 * - SUCCESS if response started
522 * - DESTROY_ME if response failed
523 */
524 status_t (*callback) (ike_sa_t *this, identification_t *peer_id);
525
526 /**
527 * Respond to a ME_CONNECT request.
528 *
529 * Data is cloned.
530 *
531 * @param peer_id ID of the other peer
532 * @param connect_id the connect ID supplied by the initiator
533 * @return
534 * - SUCCESS if response started
535 * - DESTROY_ME if response failed
536 */
537 status_t (*respond) (ike_sa_t *this, identification_t *peer_id, chunk_t connect_id);
538 #endif /* ME */
539
540 /**
541 * Initiate a new connection.
542 *
543 * The configs are owned by the IKE_SA after the call.
544 *
545 * @param child_cfg child config to create CHILD from
546 * @return
547 * - SUCCESS if initialization started
548 * - DESTROY_ME if initialization failed
549 */
550 status_t (*initiate) (ike_sa_t *this, child_cfg_t *child_cfg);
551
552 /**
553 * Route a policy in the kernel.
554 *
555 * Installs the policies in the kernel. If traffic matches,
556 * the kernel requests connection setup from the IKE_SA via acquire().
557 *
558 * @param child_cfg child config to route
559 * @return
560 * - SUCCESS if routed successfully
561 * - FAILED if routing failed
562 */
563 status_t (*route) (ike_sa_t *this, child_cfg_t *child_cfg);
564
565 /**
566 * Unroute a policy in the kernel previously routed.
567 *
568 * @param reqid reqid of CHILD_SA to unroute
569 * @return
570 * - SUCCESS if route removed
571 * - NOT_FOUND if CHILD_SA not found
572 * - DESTROY_ME if last CHILD_SA was unrouted
573 */
574 status_t (*unroute) (ike_sa_t *this, u_int32_t reqid);
575
576 /**
577 * Acquire connection setup for an installed kernel policy.
578 *
579 * If an installed policy raises an acquire, the kernel calls
580 * this function to establish the CHILD_SA (and maybe the IKE_SA).
581 *
582 * @param reqid reqid of the CHILD_SA the policy belongs to.
583 * @return
584 * - SUCCESS if initialization started
585 * - DESTROY_ME if initialization failed
586 */
587 status_t (*acquire) (ike_sa_t *this, u_int32_t reqid);
588
589 /**
590 * Initiates the deletion of an IKE_SA.
591 *
592 * Sends a delete message to the remote peer and waits for
593 * its response. If the response comes in, or a timeout occurs,
594 * the IKE SA gets deleted.
595 *
596 * @return
597 * - SUCCESS if deletion is initialized
598 * - INVALID_STATE, if the IKE_SA is not in
599 * an established state and can not be
600 * delete (but destroyed).
601 */
602 status_t (*delete) (ike_sa_t *this);
603
604 /**
605 * Update IKE_SAs after network interfaces have changed.
606 *
607 * Whenever the network interface configuration changes, the kernel
608 * interface calls roam() on each IKE_SA. The IKE_SA then checks if
609 * the new network config requires changes, and handles appropriate.
610 * If MOBIKE is supported, addresses are updated; If not, the tunnel is
611 * restarted.
612 *
613 * @param address TRUE if address list changed, FALSE otherwise
614 * @return SUCCESS, FAILED, DESTROY_ME
615 */
616 status_t (*roam)(ike_sa_t *this, bool address);
617
618 /**
619 * Processes a incoming IKEv2-Message.
620 *
621 * Message processing may fail. If a critical failure occurs,
622 * process_message() return DESTROY_ME. Then the caller must
623 * destroy the IKE_SA immediatly, as it is unusable.
624 *
625 * @param message message to process
626 * @return
627 * - SUCCESS
628 * - FAILED
629 * - DESTROY_ME if this IKE_SA MUST be deleted
630 */
631 status_t (*process_message) (ike_sa_t *this, message_t *message);
632
633 /**
634 * Generate a IKE message to send it to the peer.
635 *
636 * This method generates all payloads in the message and encrypts/signs
637 * the packet.
638 *
639 * @param message message to generate
640 * @param packet generated output packet
641 * @return
642 * - SUCCESS
643 * - FAILED
644 * - DESTROY_ME if this IKE_SA MUST be deleted
645 */
646 status_t (*generate_message) (ike_sa_t *this, message_t *message,
647 packet_t **packet);
648
649 /**
650 * Retransmits a request.
651 *
652 * @param message_id ID of the request to retransmit
653 * @return
654 * - SUCCESS
655 * - NOT_FOUND if request doesn't have to be retransmited
656 */
657 status_t (*retransmit) (ike_sa_t *this, u_int32_t message_id);
658
659 /**
660 * Sends a DPD request to the peer.
661 *
662 * To check if a peer is still alive, periodic
663 * empty INFORMATIONAL messages are sent if no
664 * other traffic was received.
665 *
666 * @return
667 * - SUCCESS
668 * - DESTROY_ME, if peer did not respond
669 */
670 status_t (*send_dpd) (ike_sa_t *this);
671
672 /**
673 * Sends a keep alive packet.
674 *
675 * To refresh NAT tables in a NAT router
676 * between the peers, periodic empty
677 * UDP packets are sent if no other traffic
678 * was sent.
679 */
680 void (*send_keepalive) (ike_sa_t *this);
681
682 /**
683 * Derive all keys and create the transforms for IKE communication.
684 *
685 * Keys are derived using the diffie hellman secret, nonces and internal
686 * stored SPIs.
687 * Key derivation differs when an IKE_SA is set up to replace an
688 * existing IKE_SA (rekeying). The SK_d key from the old IKE_SA
689 * is included in the derivation process.
690 *
691 * @param proposal proposal which contains algorithms to use
692 * @param secret secret derived from DH exchange, gets freed
693 * @param nonce_i initiators nonce
694 * @param nonce_r responders nonce
695 * @param initiator TRUE if initiator, FALSE otherwise
696 * @param child_prf PRF with SK_d key when rekeying, NULL otherwise
697 * @param old_prf general purpose PRF of old SA when rekeying
698 */
699 status_t (*derive_keys)(ike_sa_t *this, proposal_t* proposal, chunk_t secret,
700 chunk_t nonce_i, chunk_t nonce_r,
701 bool initiator, prf_t *child_prf, prf_t *old_prf);
702
703 /**
704 * Get a multi purpose prf for the negotiated PRF function.
705 *
706 * @return pointer to prf_t object
707 */
708 prf_t *(*get_prf) (ike_sa_t *this);
709
710 /**
711 * Get the prf-object, which is used to derive keys for child SAs.
712 *
713 * @return pointer to prf_t object
714 */
715 prf_t *(*get_child_prf) (ike_sa_t *this);
716
717 /**
718 * Get the key to build outgoing authentication data.
719 *
720 * @return pointer to prf_t object
721 */
722 chunk_t (*get_skp_build) (ike_sa_t *this);
723
724 /**
725 * Get the key to verify incoming authentication data.
726 *
727 * @return pointer to prf_t object
728 */
729 chunk_t (*get_skp_verify) (ike_sa_t *this);
730
731 /**
732 * Associates a child SA to this IKE SA
733 *
734 * @param child_sa child_sa to add
735 */
736 void (*add_child_sa) (ike_sa_t *this, child_sa_t *child_sa);
737
738 /**
739 * Get a CHILD_SA identified by protocol and SPI.
740 *
741 * @param protocol protocol of the SA
742 * @param spi SPI of the CHILD_SA
743 * @param inbound TRUE if SPI is inbound, FALSE if outbound
744 * @return child_sa, or NULL if none found
745 */
746 child_sa_t* (*get_child_sa) (ike_sa_t *this, protocol_id_t protocol,
747 u_int32_t spi, bool inbound);
748
749 /**
750 * Create an iterator over all CHILD_SAs.
751 *
752 * @return iterator
753 */
754 iterator_t* (*create_child_sa_iterator) (ike_sa_t *this);
755
756 /**
757 * Rekey the CHILD SA with the specified reqid.
758 *
759 * Looks for a CHILD SA owned by this IKE_SA, and start the rekeing.
760 *
761 * @param protocol protocol of the SA
762 * @param spi inbound SPI of the CHILD_SA
763 * @return
764 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
765 * - SUCCESS, if rekeying initiated
766 */
767 status_t (*rekey_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
768
769 /**
770 * Close the CHILD SA with the specified protocol/SPI.
771 *
772 * Looks for a CHILD SA owned by this IKE_SA, deletes it and
773 * notify's the remote peer about the delete. The associated
774 * states and policies in the kernel get deleted, if they exist.
775 *
776 * @param protocol protocol of the SA
777 * @param spi inbound SPI of the CHILD_SA
778 * @return
779 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
780 * - SUCCESS, if delete message sent
781 */
782 status_t (*delete_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
783
784 /**
785 * Destroy a CHILD SA with the specified protocol/SPI.
786 *
787 * Looks for a CHILD SA owned by this IKE_SA and destroys it.
788 *
789 * @param protocol protocol of the SA
790 * @param spi inbound SPI of the CHILD_SA
791 * @return
792 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
793 * - SUCCESS
794 */
795 status_t (*destroy_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
796
797 /**
798 * Rekey the IKE_SA.
799 *
800 * Sets up a new IKE_SA, moves all CHILDs to it and deletes this IKE_SA.
801 *
802 * @return - SUCCESS, if IKE_SA rekeying initiated
803 */
804 status_t (*rekey) (ike_sa_t *this);
805
806 /**
807 * Restablish the IKE_SA.
808 *
809 * Create a completely new IKE_SA with authentication, recreates all children
810 * within the IKE_SA, closes this IKE_SA.
811 *
812 * @return DESTROY_ME to destroy the IKE_SA
813 */
814 status_t (*reestablish) (ike_sa_t *this);
815
816 /**
817 * Set the lifetime limit received from a AUTH_LIFETIME notify.
818 *
819 * @param lifetime lifetime in seconds
820 */
821 void (*set_auth_lifetime)(ike_sa_t *this, u_int32_t lifetime);
822
823 /**
824 * Set the virtual IP to use for this IKE_SA and its children.
825 *
826 * The virtual IP is assigned per IKE_SA, not per CHILD_SA. It has the same
827 * lifetime as the IKE_SA.
828 *
829 * @param local TRUE to set local address, FALSE for remote
830 * @param ip IP to set as virtual IP
831 */
832 void (*set_virtual_ip) (ike_sa_t *this, bool local, host_t *ip);
833
834 /**
835 * Get the virtual IP configured.
836 *
837 * @param local TRUE to get local virtual IP, FALSE for remote
838 * @return host_t *virtual IP
839 */
840 host_t* (*get_virtual_ip) (ike_sa_t *this, bool local);
841
842 /**
843 * Add a DNS server to the system.
844 *
845 * An IRAS may send a DNS server. To use it, it is installed on the
846 * system. The DNS entry has a lifetime until the IKE_SA gets closed.
847 *
848 * @param dns DNS server to install on the system
849 */
850 void (*add_dns_server) (ike_sa_t *this, host_t *dns);
851
852 /**
853 * Inherit all attributes of other to this after rekeying.
854 *
855 * When rekeying is completed, all CHILD_SAs, the virtual IP and all
856 * outstanding tasks are moved from other to this.
857 * As this call may initiate inherited tasks, a status is returned.
858 *
859 * @param other other task to inherit from
860 * @return DESTROY_ME if initiation of inherited task failed
861 */
862 status_t (*inherit) (ike_sa_t *this, ike_sa_t *other);
863
864 /**
865 * Reset the IKE_SA, useable when initiating fails
866 */
867 void (*reset) (ike_sa_t *this);
868
869 /**
870 * Destroys a ike_sa_t object.
871 */
872 void (*destroy) (ike_sa_t *this);
873 };
874
875 /**
876 * Creates an ike_sa_t object with a specific ID.
877 *
878 * @param ike_sa_id ike_sa_id_t object to associate with new IKE_SA
879 * @return ike_sa_t object
880 */
881 ike_sa_t *ike_sa_create(ike_sa_id_t *ike_sa_id);
882
883 #endif /* IKE_SA_H_ @} */