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