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