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