2 * Copyright (C) 2006-2018 Tobias Brunner
3 * Copyright (C) 2006 Daniel Roethlisberger
4 * Copyright (C) 2005-2009 Martin Willi
5 * Copyright (C) 2005 Jan Hutter
6 * HSR Hochschule fuer Technik Rapperswil
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>.
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
20 * @defgroup ike_sa ike_sa
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
;
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>
41 #include <sa/task_manager.h>
42 #include <sa/keymat.h>
43 #include <config/peer_cfg.h>
44 #include <config/ike_cfg.h>
45 #include <credentials/auth_cfg.h>
46 #include <networking/packet.h>
49 * Timeout in seconds after that a half open IKE_SA gets deleted.
51 #define HALF_OPEN_IKE_SA_TIMEOUT 30
54 * Interval to send keepalives when NATed, in seconds.
56 #define KEEPALIVE_INTERVAL 20
59 * After which time rekeying should be retried if it failed, in seconds.
61 #define RETRY_INTERVAL 15
64 * Jitter to subtract from RETRY_INTERVAL to randomize rekey retry.
66 #define RETRY_JITTER 10
69 * Number of redirects allowed within REDIRECT_LOOP_DETECT_PERIOD.
71 #define MAX_REDIRECTS 5
74 * Time period in seconds in which at most MAX_REDIRECTS are allowed.
76 #define REDIRECT_LOOP_DETECT_PERIOD 300
79 * Extensions (or optional features) the peer supports
81 enum ike_extension_t
{
84 * peer supports NAT traversal as specified in RFC4306 or RFC3947
85 * including some RFC3947 drafts
90 * peer supports MOBIKE (RFC4555)
95 * peer supports HTTP cert lookups as specified in RFC4306
97 EXT_HASH_AND_URL
= (1<<2),
100 * peer supports multiple authentication exchanges, RFC4739
102 EXT_MULTIPLE_AUTH
= (1<<3),
105 * peer uses strongSwan, accept private use extensions
107 EXT_STRONGSWAN
= (1<<4),
110 * peer supports EAP-only authentication, draft-eronen-ipsec-ikev2-eap-auth
112 EXT_EAP_ONLY_AUTHENTICATION
= (1<<5),
115 * peer is probably a Windows RAS client
117 EXT_MS_WINDOWS
= (1<<6),
120 * peer supports XAuth authentication, draft-ietf-ipsec-isakmp-xauth-06
125 * peer supports DPD detection, RFC 3706 (or IKEv2)
130 * peer supports Cisco Unity configuration attributes
132 EXT_CISCO_UNITY
= (1<<9),
135 * peer supports NAT traversal as specified in
136 * draft-ietf-ipsec-nat-t-ike-02 .. -03
138 EXT_NATT_DRAFT_02_03
= (1<<10),
141 * peer supports proprietary IKEv1 or standardized IKEv2 fragmentation
143 EXT_IKE_FRAGMENTATION
= (1<<11),
146 * Signature Authentication, RFC 7427
148 EXT_SIGNATURE_AUTH
= (1<<12),
151 * IKEv2 Redirect Mechanism, RFC 5685
153 EXT_IKE_REDIRECTION
= (1<<13),
156 * IKEv2 Message ID sync, RFC 6311
158 EXT_IKE_MESSAGE_ID_SYNC
= (1<<14),
161 * Postquantum Preshared Keys, draft-ietf-ipsecme-qr-ikev2
167 * Conditions of an IKE_SA, change during its lifetime
169 enum ike_condition_t
{
172 * Connection is natted (or faked) somewhere
174 COND_NAT_ANY
= (1<<0),
179 COND_NAT_HERE
= (1<<1),
182 * other is behind NAT
184 COND_NAT_THERE
= (1<<2),
187 * Faking NAT to enforce UDP encapsulation
189 COND_NAT_FAKE
= (1<<3),
192 * peer has been authenticated using EAP at least once
194 COND_EAP_AUTHENTICATED
= (1<<4),
197 * received a certificate request from the peer
199 COND_CERTREQ_SEEN
= (1<<5),
202 * Local peer is the "original" IKE initiator. Unaffected from rekeying.
204 COND_ORIGINAL_INITIATOR
= (1<<6),
207 * IKE_SA is stale, the peer is currently unreachable (MOBIKE)
212 * Initial contact received
214 COND_INIT_CONTACT_SEEN
= (1<<8),
217 * Peer has been authenticated using XAuth
219 COND_XAUTH_AUTHENTICATED
= (1<<9),
222 * This IKE_SA is currently being reauthenticated
224 COND_REAUTHENTICATING
= (1<<10),
227 * This IKE_SA has been redirected
229 COND_REDIRECTED
= (1<<11),
232 * Online certificate revocation checking is suspended for this IKE_SA
234 COND_ONLINE_VALIDATION_SUSPENDED
= (1<<12),
237 * A Postquantum Preshared Key was used when this IKE_SA was created
243 * Timing information and statistics to query from an SA
246 /** Timestamp of SA establishement */
247 STAT_ESTABLISHED
= 0,
248 /** Timestamp of scheduled rekeying */
250 /** Timestamp of scheduled reauthentication */
252 /** Timestamp of scheduled delete */
254 /** Timestamp of last inbound IKE packet */
256 /** Timestamp of last outbound IKE packet */
263 * State of an IKE_SA.
265 * An IKE_SA passes various states in its lifetime. A newly created
266 * SA is in the state CREATED.
272 on initiate()---> ¦ <----- on IKE_SA_INIT received
278 ¦ <----- on IKE_AUTH successfully completed
281 ¦ SA_ESTABLISHED ¦-------------------------+ <-- on rekeying
282 +----------------+ ¦
284 on delete()---> ¦ <----- on IKE_SA +-------------+
285 ¦ delete request ¦ SA_REKEYING ¦
286 ¦ received +-------------+
288 +----------------+ ¦
289 ¦ SA_DELETING ¦<------------------------+ <-- after rekeying
292 ¦ <----- after delete() acknowledged
299 enum ike_sa_state_t
{
302 * IKE_SA just got created, but is not initiating nor responding yet.
307 * IKE_SA gets initiated actively or passively
312 * IKE_SA is fully established
317 * IKE_SA is managed externally and does not process messages
322 * IKE_SA rekeying in progress
327 * IKE_SA has been rekeyed (or is redundant)
332 * IKE_SA is in progress of deletion
337 * IKE_SA object gets destroyed
343 * enum names for ike_sa_state_t.
345 extern enum_name_t
*ike_sa_state_names
;
348 * Class ike_sa_t representing an IKE_SA.
350 * An IKE_SA contains crypto information related to a connection
351 * with a peer. It contains multiple IPsec CHILD_SA, for which
352 * it is responsible. All traffic is handled by an IKE_SA, using
353 * the task manager and its tasks.
358 * Get the id of the SA.
360 * Returned ike_sa_id_t object is not getting cloned!
362 * @return ike_sa's ike_sa_id_t
364 ike_sa_id_t
* (*get_id
) (ike_sa_t
*this);
367 * Gets the IKE version of the SA
369 ike_version_t (*get_version
)(ike_sa_t
*this);
372 * Get the numerical ID uniquely defining this IKE_SA.
376 uint32_t (*get_unique_id
) (ike_sa_t
*this);
379 * Get the state of the IKE_SA.
381 * @return state of the IKE_SA
383 ike_sa_state_t (*get_state
) (ike_sa_t
*this);
386 * Set the state of the IKE_SA.
388 * @param state state to set for the IKE_SA
390 void (*set_state
) (ike_sa_t
*this, ike_sa_state_t state
);
393 * Get the name of the connection this IKE_SA uses.
397 char* (*get_name
) (ike_sa_t
*this);
400 * Get statistic values from the IKE_SA.
402 * @param kind kind of requested value
403 * @return value as integer
405 uint32_t (*get_statistic
)(ike_sa_t
*this, statistic_t kind
);
408 * Set statistic value of the IKE_SA.
410 * @param kind kind of value to update
411 * @param value value as integer
413 void (*set_statistic
)(ike_sa_t
*this, statistic_t kind
, uint32_t value
);
416 * Get the own host address.
418 * @return host address
420 host_t
* (*get_my_host
) (ike_sa_t
*this);
423 * Set the own host address.
425 * @param me host address
427 void (*set_my_host
) (ike_sa_t
*this, host_t
*me
);
430 * Get the other peers host address.
432 * @return host address
434 host_t
* (*get_other_host
) (ike_sa_t
*this);
437 * Set the others host address.
439 * @param other host address
441 void (*set_other_host
) (ike_sa_t
*this, host_t
*other
);
444 * Float to port 4500 (e.g. if a NAT is detected).
446 * The port of either endpoint is changed only if it is currently
447 * set to the default value of 500.
449 void (*float_ports
)(ike_sa_t
*this);
452 * Update the IKE_SAs host.
454 * Hosts may be NULL to use current host.
456 * @param me new local host address, or NULL
457 * @param other new remote host address, or NULL
458 * @param force force update
460 void (*update_hosts
)(ike_sa_t
*this, host_t
*me
, host_t
*other
, bool force
);
463 * Get the own identification.
465 * @return identification
467 identification_t
* (*get_my_id
) (ike_sa_t
*this);
470 * Set the own identification.
472 * @param me identification
474 void (*set_my_id
) (ike_sa_t
*this, identification_t
*me
);
477 * Get the other peer's identification.
479 * @return identification
481 identification_t
* (*get_other_id
) (ike_sa_t
*this);
484 * Get the others peer identity, but prefer an EAP-Identity.
486 * @return EAP or IKEv2 identity
488 identification_t
* (*get_other_eap_id
)(ike_sa_t
*this);
491 * Set the other peer's identification.
493 * @param other identification
495 void (*set_other_id
) (ike_sa_t
*this, identification_t
*other
);
498 * Get the config used to setup this IKE_SA.
502 ike_cfg_t
* (*get_ike_cfg
) (ike_sa_t
*this);
505 * Set the config to setup this IKE_SA.
507 * @param config ike_config to use
509 void (*set_ike_cfg
) (ike_sa_t
*this, ike_cfg_t
* config
);
512 * Get the peer config used by this IKE_SA.
514 * @return peer_config
516 peer_cfg_t
* (*get_peer_cfg
) (ike_sa_t
*this);
519 * Set the peer config to use with this IKE_SA.
521 * @param config peer_config to use
523 void (*set_peer_cfg
) (ike_sa_t
*this, peer_cfg_t
*config
);
526 * Get the authentication config with rules of the current auth round.
528 * @param local TRUE for local rules, FALSE for remote constraints
529 * @return current cfg
531 auth_cfg_t
* (*get_auth_cfg
)(ike_sa_t
*this, bool local
);
534 * Insert a completed authentication round.
536 * @param local TRUE for own rules, FALSE for others constraints
537 * @param cfg auth config to append
539 void (*add_auth_cfg
)(ike_sa_t
*this, bool local
, auth_cfg_t
*cfg
);
542 * Create an enumerator over added authentication rounds.
544 * @param local TRUE for own rules, FALSE for others constraints
545 * @return enumerator over auth_cfg_t
547 enumerator_t
* (*create_auth_cfg_enumerator
)(ike_sa_t
*this, bool local
);
550 * Verify the trustchains (validity, revocation) in completed public key
553 * @return TRUE if certificates were valid, FALSE otherwise
555 bool (*verify_peer_certificate
)(ike_sa_t
*this);
558 * Get the selected proposal of this IKE_SA.
560 * @return selected proposal
562 proposal_t
* (*get_proposal
)(ike_sa_t
*this);
565 * Set the proposal selected for this IKE_SA.
567 * @param selected proposal
569 void (*set_proposal
)(ike_sa_t
*this, proposal_t
*proposal
);
572 * Set the message ID of the IKE_SA.
574 * The IKE_SA stores two message IDs, one for initiating exchanges (send)
575 * and one to respond to exchanges (expect).
577 * @param initiate TRUE to set message ID for initiating
578 * @param mid message id to set
580 void (*set_message_id
)(ike_sa_t
*this, bool initiate
, uint32_t mid
);
583 * Get the message ID of the IKE_SA.
585 * The IKE_SA stores two message IDs, one for initiating exchanges (send)
586 * and one to respond to exchanges (expect).
588 * @param initiate TRUE to get message ID for initiating
589 * @return current message
591 uint32_t (*get_message_id
)(ike_sa_t
*this, bool initiate
);
594 * Add an additional address for the peer.
596 * In MOBIKE, a peer may transmit additional addresses where it is
597 * reachable. These are stored in the IKE_SA.
598 * The own list of addresses is not stored, they are queried from
599 * the kernel when required.
601 * @param host host to add to list
603 void (*add_peer_address
)(ike_sa_t
*this, host_t
*host
);
606 * Create an enumerator over all known addresses of the peer.
608 * @return enumerator over addresses
610 enumerator_t
* (*create_peer_address_enumerator
)(ike_sa_t
*this);
613 * Remove all known addresses of the peer.
615 void (*clear_peer_addresses
)(ike_sa_t
*this);
618 * Check if mappings have changed on a NAT for our source address.
620 * @param hash received DESTINATION_IP hash
621 * @return TRUE if mappings have changed
623 bool (*has_mapping_changed
)(ike_sa_t
*this, chunk_t hash
);
626 * Enable an extension the peer supports.
628 * If support for an IKE extension is detected, this method is called
629 * to enable that extension and behave accordingly.
631 * @param extension extension to enable
633 void (*enable_extension
)(ike_sa_t
*this, ike_extension_t extension
);
636 * Check if the peer supports an extension.
638 * @param extension extension to check for support
639 * @return TRUE if peer supports it, FALSE otherwise
641 bool (*supports_extension
)(ike_sa_t
*this, ike_extension_t extension
);
644 * Enable/disable a condition flag for this IKE_SA.
646 * @param condition condition to enable/disable
647 * @param enable TRUE to enable condition, FALSE to disable
649 void (*set_condition
) (ike_sa_t
*this, ike_condition_t condition
, bool enable
);
652 * Check if a condition flag is set.
654 * @param condition condition to check
655 * @return TRUE if condition flag set, FALSE otherwise
657 bool (*has_condition
) (ike_sa_t
*this, ike_condition_t condition
);
661 * Activate mediation server functionality for this IKE_SA.
663 void (*act_as_mediation_server
) (ike_sa_t
*this);
666 * Get the server reflexive host.
668 * @return server reflexive host
670 host_t
* (*get_server_reflexive_host
) (ike_sa_t
*this);
673 * Set the server reflexive host.
675 * @param host server reflexive host
677 void (*set_server_reflexive_host
) (ike_sa_t
*this, host_t
*host
);
680 * Get the connect ID.
684 chunk_t (*get_connect_id
) (ike_sa_t
*this);
687 * Initiate the mediation of a mediated connection (i.e. initiate a
688 * ME_CONNECT exchange to a mediation server).
690 * @param mediated_cfg peer_cfg of the mediated connection
692 * - SUCCESS if initialization started
693 * - DESTROY_ME if initialization failed
695 status_t (*initiate_mediation
) (ike_sa_t
*this, peer_cfg_t
*mediated_cfg
);
698 * Initiate the mediated connection
700 * @param me local endpoint (gets cloned)
701 * @param other remote endpoint (gets cloned)
702 * @param connect_id connect ID (gets cloned)
704 * - SUCCESS if initialization started
705 * - DESTROY_ME if initialization failed
707 status_t (*initiate_mediated
) (ike_sa_t
*this, host_t
*me
, host_t
*other
,
711 * Relay data from one peer to another (i.e. initiate a ME_CONNECT exchange
716 * @param requester ID of the requesting peer
717 * @param connect_id data of the ME_CONNECTID payload
718 * @param connect_key data of the ME_CONNECTKEY payload
719 * @param endpoints endpoints
720 * @param response TRUE if this is a response
722 * - SUCCESS if relay started
723 * - DESTROY_ME if relay failed
725 status_t (*relay
) (ike_sa_t
*this, identification_t
*requester
,
726 chunk_t connect_id
, chunk_t connect_key
,
727 linked_list_t
*endpoints
, bool response
);
730 * Send a callback to a peer.
734 * @param peer_id ID of the other peer
736 * - SUCCESS if response started
737 * - DESTROY_ME if response failed
739 status_t (*callback
) (ike_sa_t
*this, identification_t
*peer_id
);
742 * Respond to a ME_CONNECT request.
746 * @param peer_id ID of the other peer
747 * @param connect_id the connect ID supplied by the initiator
749 * - SUCCESS if response started
750 * - DESTROY_ME if response failed
752 status_t (*respond
) (ike_sa_t
*this, identification_t
*peer_id
,
757 * Initiate a new connection.
759 * The configs are owned by the IKE_SA after the call. If the initiate
760 * is triggered by a packet, traffic selectors of the packet can be added
763 * @param child_cfg child config to create CHILD from
764 * @param reqid reqid to use for CHILD_SA, 0 assigne uniquely
765 * @param tsi source of triggering packet
766 * @param tsr destination of triggering packet.
768 * - SUCCESS if initialization started
769 * - DESTROY_ME if initialization failed
771 status_t (*initiate
) (ike_sa_t
*this, child_cfg_t
*child_cfg
,
772 uint32_t reqid
, traffic_selector_t
*tsi
,
773 traffic_selector_t
*tsr
);
776 * Retry initiation of this IKE_SA after it got deferred previously.
779 * - SUCCESS if initiation deferred or started
780 * - DESTROY_ME if initiation failed
782 status_t (*retry_initiate
) (ike_sa_t
*this);
785 * Initiates the deletion of an IKE_SA.
787 * Sends a delete message to the remote peer and waits for
788 * its response. If the response comes in, or a timeout occurs,
789 * the IKE SA gets destroyed, unless force is TRUE then the IKE_SA is
790 * destroyed immediately without waiting for a response.
792 * @param force whether to immediately destroy the IKE_SA afterwards
793 * without waiting for a response
795 * - SUCCESS if deletion is initialized
796 * - DESTROY_ME, if destroying is forced, or the IKE_SA
797 * is not in an established state and can not be
798 * deleted (but destroyed)
800 status_t (*delete) (ike_sa_t
*this, bool force
);
803 * Update IKE_SAs after network interfaces have changed.
805 * Whenever the network interface configuration changes, the kernel
806 * interface calls roam() on each IKE_SA. The IKE_SA then checks if
807 * the new network config requires changes, and handles appropriate.
808 * If MOBIKE is supported, addresses are updated; If not, the tunnel is
811 * @param address TRUE if address list changed, FALSE otherwise
812 * @return SUCCESS, FAILED, DESTROY_ME
814 status_t (*roam
)(ike_sa_t
*this, bool address
);
817 * Processes an incoming IKE message.
819 * Message processing may fail. If a critical failure occurs,
820 * process_message() return DESTROY_ME. Then the caller must
821 * destroy the IKE_SA immediately, as it is unusable.
823 * @param message message to process
827 * - DESTROY_ME if this IKE_SA MUST be deleted
829 status_t (*process_message
)(ike_sa_t
*this, message_t
*message
);
832 * Generate an IKE message to send it to the peer.
834 * This method generates all payloads in the message and encrypts/signs
837 * @param message message to generate
838 * @param packet generated output packet
842 * - DESTROY_ME if this IKE_SA MUST be deleted
844 status_t (*generate_message
)(ike_sa_t
*this, message_t
*message
,
848 * Generate an IKE message to send it to the peer. If enabled and supported
849 * it will be fragmented.
851 * This method generates all payloads in the message and encrypts/signs
852 * the packet/fragments.
854 * @param message message to generate
855 * @param packets enumerator of generated packet_t* (are not destroyed
856 * with the enumerator)
860 * - DESTROY_ME if this IKE_SA MUST be deleted
862 status_t (*generate_message_fragmented
)(ike_sa_t
*this, message_t
*message
,
863 enumerator_t
**packets
);
866 * Retransmits a request.
868 * @param message_id ID of the request to retransmit
871 * - NOT_FOUND if request doesn't have to be retransmitted
873 status_t (*retransmit
) (ike_sa_t
*this, uint32_t message_id
);
876 * Sends a DPD request to the peer.
878 * To check if a peer is still alive, periodic
879 * empty INFORMATIONAL messages are sent if no
880 * other traffic was received.
884 * - DESTROY_ME, if peer did not respond
886 status_t (*send_dpd
) (ike_sa_t
*this);
889 * Sends a keep alive packet.
891 * To refresh NAT tables in a NAT router between the peers, periodic empty
892 * UDP packets are sent if no other traffic was sent.
894 * @param scheduled if this is a scheduled keepalive
896 void (*send_keepalive
) (ike_sa_t
*this, bool scheduled
);
899 * Redirect an active IKE_SA.
901 * @param gateway gateway ID (IP or FQDN) of the target
902 * @return state, including DESTROY_ME, if this IKE_SA MUST be
905 status_t (*redirect
)(ike_sa_t
*this, identification_t
*gateway
);
908 * Handle a redirect request.
910 * The behavior is different depending on the state of the IKE_SA.
912 * @param gateway gateway ID (IP or FQDN) of the target
913 * @return FALSE if redirect not possible, TRUE otherwise
915 bool (*handle_redirect
)(ike_sa_t
*this, identification_t
*gateway
);
918 * Get the address of the gateway that redirected us.
920 * @return original gateway address
922 host_t
*(*get_redirected_from
)(ike_sa_t
*this);
925 * Get the keying material of this IKE_SA.
927 * @return per IKE_SA keymat instance
929 keymat_t
* (*get_keymat
)(ike_sa_t
*this);
932 * Associates a child SA to this IKE SA
934 * @param child_sa child_sa to add
936 void (*add_child_sa
) (ike_sa_t
*this, child_sa_t
*child_sa
);
939 * Get a CHILD_SA identified by protocol and SPI.
941 * @param protocol protocol of the SA
942 * @param spi SPI of the CHILD_SA
943 * @param inbound TRUE if SPI is inbound, FALSE if outbound
944 * @return child_sa, or NULL if none found
946 child_sa_t
* (*get_child_sa
) (ike_sa_t
*this, protocol_id_t protocol
,
947 uint32_t spi
, bool inbound
);
950 * Get the number of CHILD_SAs.
952 * @return number of CHILD_SAs
954 int (*get_child_count
) (ike_sa_t
*this);
957 * Create an enumerator over all CHILD_SAs.
961 enumerator_t
* (*create_child_sa_enumerator
) (ike_sa_t
*this);
964 * Remove the CHILD_SA the given enumerator points to from this IKE_SA.
966 * @param enumerator enumerator pointing to CHILD_SA
968 void (*remove_child_sa
) (ike_sa_t
*this, enumerator_t
*enumerator
);
971 * Rekey the CHILD SA with the specified reqid.
973 * Looks for a CHILD SA owned by this IKE_SA, and start the rekeing.
975 * @param protocol protocol of the SA
976 * @param spi inbound SPI of the CHILD_SA
978 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
979 * - SUCCESS, if rekeying initiated
981 status_t (*rekey_child_sa
) (ike_sa_t
*this, protocol_id_t protocol
, uint32_t spi
);
984 * Close the CHILD SA with the specified protocol/SPI.
986 * Looks for a CHILD SA owned by this IKE_SA, deletes it and
987 * notify's the remote peer about the delete. The associated
988 * states and policies in the kernel get deleted, if they exist.
990 * @param protocol protocol of the SA
991 * @param spi inbound SPI of the CHILD_SA
992 * @param expired TRUE if CHILD_SA is expired
994 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
995 * - SUCCESS, if delete message sent
997 status_t (*delete_child_sa
)(ike_sa_t
*this, protocol_id_t protocol
,
998 uint32_t spi
, bool expired
);
1001 * Destroy a CHILD SA with the specified protocol/SPI.
1003 * Looks for a CHILD SA owned by this IKE_SA and destroys it.
1005 * @param protocol protocol of the SA
1006 * @param spi inbound SPI of the CHILD_SA
1008 * - NOT_FOUND, if IKE_SA has no such CHILD_SA
1011 status_t (*destroy_child_sa
) (ike_sa_t
*this, protocol_id_t protocol
, uint32_t spi
);
1016 * Sets up a new IKE_SA, moves all CHILD_SAs to it and deletes this IKE_SA.
1018 * @return - SUCCESS, if IKE_SA rekeying initiated
1020 status_t (*rekey
) (ike_sa_t
*this);
1023 * Reauthenticate the IKE_SA.
1025 * Triggers a new IKE_SA that replaces this one. IKEv1 implicitly inherits
1026 * all Quick Modes, while IKEv2 recreates all active and queued CHILD_SAs
1027 * in the new IKE_SA.
1029 * @return DESTROY_ME to destroy the IKE_SA
1031 status_t (*reauth
) (ike_sa_t
*this);
1034 * Restablish the IKE_SA.
1036 * Reestablish an IKE_SA after it has been closed.
1038 * @return DESTROY_ME to destroy the IKE_SA
1040 status_t (*reestablish
) (ike_sa_t
*this);
1043 * Set the lifetime limit received/to send in a AUTH_LIFETIME notify.
1045 * If the IKE_SA is already ESTABLISHED, an INFORMATIONAL is sent with
1046 * an AUTH_LIFETIME notify. The call never fails on unestablished SAs.
1048 * @param lifetime lifetime in seconds
1049 * @return DESTROY_ME to destroy the IKE_SA
1051 status_t (*set_auth_lifetime
)(ike_sa_t
*this, uint32_t lifetime
);
1054 * Add a virtual IP to use for this IKE_SA and its children.
1056 * The virtual IP is assigned per IKE_SA, not per CHILD_SA. It has the same
1057 * lifetime as the IKE_SA.
1059 * @param local TRUE to set local address, FALSE for remote
1060 * @param ip IP to set as virtual IP
1062 void (*add_virtual_ip
) (ike_sa_t
*this, bool local
, host_t
*ip
);
1065 * Clear all virtual IPs stored on this IKE_SA.
1067 * @param local TRUE to clear local addresses, FALSE for remote
1069 void (*clear_virtual_ips
) (ike_sa_t
*this, bool local
);
1072 * Create an enumerator over virtual IPs.
1074 * @param local TRUE to get local virtual IP, FALSE for remote
1075 * @return enumerator over host_t*
1077 enumerator_t
* (*create_virtual_ip_enumerator
) (ike_sa_t
*this, bool local
);
1080 * Register a configuration attribute to the IKE_SA.
1082 * If an IRAS sends a configuration attribute it is installed and
1083 * registered at the IKE_SA. Attributes are inherit()ed and get released
1084 * when the IKE_SA is closed.
1086 * Unhandled attributes are passed as well, but with a NULL handler. They
1087 * do not get released.
1089 * @param handler handler installed the attribute, use for release()
1090 * @param type configuration attribute type
1091 * @param data associated attribute data
1093 void (*add_configuration_attribute
)(ike_sa_t
*this,
1094 attribute_handler_t
*handler
,
1095 configuration_attribute_type_t type
, chunk_t data
);
1098 * Create an enumerator over received configuration attributes.
1100 * The resulting enumerator is over the configuration_attribute_type_t type,
1101 * a value chunk_t followed by a bool flag. The boolean flag indicates if
1102 * the attribute has been handled by an attribute handler.
1104 * @return enumerator over type, value and the "handled" flag.
1106 enumerator_t
* (*create_attribute_enumerator
)(ike_sa_t
*this);
1109 * Set local and remote host addresses to be used for IKE.
1111 * These addresses are communicated via the KMADDRESS field of a MIGRATE
1112 * message sent via the NETLINK or PF _KEY kernel socket interface.
1114 * @param local local kmaddress
1115 * @param remote remote kmaddress
1117 void (*set_kmaddress
) (ike_sa_t
*this, host_t
*local
, host_t
*remote
);
1120 * Create enumerator over a task queue of this IKE_SA.
1122 * @param queue type to enumerate
1123 * @return enumerator over task_t
1125 enumerator_t
* (*create_task_enumerator
)(ike_sa_t
*this, task_queue_t queue
);
1128 * Remove the task the given enumerator points to.
1130 * @note This should be used with caution, in partciular, for tasks in the
1131 * active and passive queues.
1133 * @param enumerator enumerator created with the method above
1135 void (*remove_task
)(ike_sa_t
*this, enumerator_t
*enumerator
);
1138 * Flush a task queue, cancelling all tasks in it.
1140 * @param queue queue type to flush
1142 void (*flush_queue
)(ike_sa_t
*this, task_queue_t queue
);
1145 * Queue a task for initiaton to the task manager.
1147 * @param task task to queue
1149 void (*queue_task
)(ike_sa_t
*this, task_t
*task
);
1152 * Queue a task in the manager, but delay its initiation for at least the
1153 * given number of seconds.
1155 * @param task task to queue
1156 * @param delay minimum delay in s before initiating the task
1158 void (*queue_task_delayed
)(ike_sa_t
*this, task_t
*task
, uint32_t delay
);
1161 * Adopt child creating tasks from the given IKE_SA.
1163 * @param other other IKE_SA to adopt tasks from
1165 void (*adopt_child_tasks
)(ike_sa_t
*this, ike_sa_t
*other
);
1168 * Inherit required attributes to new SA before rekeying.
1170 * Some properties of the SA must be applied before starting IKE_SA
1171 * rekeying, such as the configuration or support extensions.
1173 * @param other other IKE_SA to inherit from
1175 void (*inherit_pre
)(ike_sa_t
*this, ike_sa_t
*other
);
1178 * Inherit all attributes of other to this after rekeying.
1180 * When rekeying is completed, all CHILD_SAs, the virtual IP and all
1181 * outstanding tasks are moved from other to this.
1183 * @param other other IKE SA to inherit from
1185 void (*inherit_post
) (ike_sa_t
*this, ike_sa_t
*other
);
1188 * Reset the IKE_SA, usable when initiating fails.
1190 * @param new_spi TRUE to allocate a new initiator SPI
1192 void (*reset
) (ike_sa_t
*this, bool new_spi
);
1195 * Destroys a ike_sa_t object.
1197 void (*destroy
) (ike_sa_t
*this);
1201 * Creates an ike_sa_t object with a specific ID and IKE version.
1203 * @param ike_sa_id ike_sa_id_t to associate with new IKE_SA/ISAKMP_SA
1204 * @param initiator TRUE to create this IKE_SA as initiator
1205 * @param version IKE version of this SA
1206 * @return ike_sa_t object
1208 ike_sa_t
*ike_sa_create(ike_sa_id_t
*ike_sa_id
, bool initiator
,
1209 ike_version_t version
);
1211 #endif /** IKE_SA_H_ @}*/