2 * Copyright (C) 2007-2011 Tobias Brunner
3 * Copyright (C) 2007-2011 Martin Willi
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 #include "task_manager_v1.h"
22 #include <sa/ikev1/tasks/main_mode.h>
23 #include <sa/ikev1/tasks/aggressive_mode.h>
24 #include <sa/ikev1/tasks/quick_mode.h>
25 #include <sa/ikev1/tasks/quick_delete.h>
26 #include <sa/ikev1/tasks/xauth.h>
27 #include <sa/ikev1/tasks/mode_config.h>
28 #include <sa/ikev1/tasks/informational.h>
29 #include <sa/ikev1/tasks/isakmp_natd.h>
30 #include <sa/ikev1/tasks/isakmp_vendor.h>
31 #include <sa/ikev1/tasks/isakmp_cert_pre.h>
32 #include <sa/ikev1/tasks/isakmp_cert_post.h>
33 #include <sa/ikev1/tasks/isakmp_delete.h>
34 #include <sa/ikev1/tasks/isakmp_dpd.h>
36 #include <processing/jobs/retransmit_job.h>
37 #include <processing/jobs/delete_ike_sa_job.h>
38 #include <processing/jobs/dpd_timeout_job.h>
41 * Number of old messages hashes we keep for retransmission.
43 * In Main Mode, we must ignore messages from a previous message pair if
44 * we already continued to the next. Otherwise a late retransmission
45 * could be considered as a reply to the newer request.
47 #define MAX_OLD_HASHES 2
50 * First sequence number of responding packets.
52 * To distinguish retransmission jobs for initiating and responding packets,
53 * we split up the sequence counter and use the upper half for responding.
55 #define RESPONDING_SEQ INT_MAX
57 typedef struct exchange_t exchange_t
;
60 * An exchange in the air, used do detect and handle retransmission
65 * Message ID used for this transaction
70 * generated packet for retransmission
75 typedef struct private_task_manager_t private_task_manager_t
;
78 * private data of the task manager
80 struct private_task_manager_t
{
85 task_manager_v1_t
public;
88 * associated IKE_SA we are serving
93 * RNG to create message IDs
98 * Exchange we are currently handling as responder
102 * Message ID of the last response
107 * Hash of a previously received message
112 * packet for retransmission
117 * Sequence number of the last sent message
122 * how many times we have retransmitted so far
129 * Exchange we are currently handling as initiator
133 * Message ID of the exchange
138 * Hashes of old responses we can ignore
140 u_int32_t old_hashes
[MAX_OLD_HASHES
];
143 * Position in old hash array
148 * Sequence number of the last sent message
153 * how many times we have retransmitted so far
158 * packet for retransmission
163 * type of the initated exchange
165 exchange_type_t type
;
170 * List of queued tasks not yet in action
172 linked_list_t
*queued_tasks
;
175 * List of active tasks, initiated by ourselve
177 linked_list_t
*active_tasks
;
180 * List of tasks initiated by peer
182 linked_list_t
*passive_tasks
;
185 * Queued messages not yet ready to process
190 * Number of times we retransmit messages before giving up
192 u_int retransmit_tries
;
195 * Retransmission timeout
197 double retransmit_timeout
;
200 * Base to calculate retransmission timeout
202 double retransmit_base
;
205 * Sequence number for sending DPD requests
210 * Sequence number for received DPD requests
215 METHOD(task_manager_t
, flush_queue
, void,
216 private_task_manager_t
*this, task_queue_t queue
)
223 this->queued
->destroy(this->queued
);
228 case TASK_QUEUE_ACTIVE
:
229 list
= this->active_tasks
;
230 /* cancel pending retransmits */
231 this->initiating
.type
= EXCHANGE_TYPE_UNDEFINED
;
232 DESTROY_IF(this->initiating
.packet
);
233 this->initiating
.packet
= NULL
;
235 case TASK_QUEUE_PASSIVE
:
236 list
= this->passive_tasks
;
238 case TASK_QUEUE_QUEUED
:
239 list
= this->queued_tasks
;
244 while (list
->remove_last(list
, (void**)&task
) == SUCCESS
)
251 * flush all tasks in the task manager
253 static void flush(private_task_manager_t
*this)
255 flush_queue(this, TASK_QUEUE_QUEUED
);
256 flush_queue(this, TASK_QUEUE_PASSIVE
);
257 flush_queue(this, TASK_QUEUE_ACTIVE
);
261 * move a task of a specific type from the queue to the active list
263 static bool activate_task(private_task_manager_t
*this, task_type_t type
)
265 enumerator_t
*enumerator
;
269 enumerator
= this->queued_tasks
->create_enumerator(this->queued_tasks
);
270 while (enumerator
->enumerate(enumerator
, (void**)&task
))
272 if (task
->get_type(task
) == type
)
274 DBG2(DBG_IKE
, " activating %N task", task_type_names
, type
);
275 this->queued_tasks
->remove_at(this->queued_tasks
, enumerator
);
276 this->active_tasks
->insert_last(this->active_tasks
, task
);
281 enumerator
->destroy(enumerator
);
286 * Retransmit a packet, either as initiator or as responder
288 static status_t
retransmit_packet(private_task_manager_t
*this, u_int32_t seqnr
,
289 u_int mid
, u_int retransmitted
, packet_t
*packet
)
293 if (retransmitted
> this->retransmit_tries
)
295 DBG1(DBG_IKE
, "giving up after %u retransmits", retransmitted
- 1);
298 t
= (u_int32_t
)(this->retransmit_timeout
* 1000.0 *
299 pow(this->retransmit_base
, retransmitted
));
302 DBG1(DBG_IKE
, "sending retransmit %u of %s message ID %u, seq %u",
303 retransmitted
, seqnr
< RESPONDING_SEQ ?
"request" : "response",
304 mid
, seqnr
< RESPONDING_SEQ ? seqnr
: seqnr
- RESPONDING_SEQ
);
306 charon
->sender
->send(charon
->sender
, packet
->clone(packet
));
307 lib
->scheduler
->schedule_job_ms(lib
->scheduler
, (job_t
*)
308 retransmit_job_create(seqnr
, this->ike_sa
->get_id(this->ike_sa
)), t
);
312 METHOD(task_manager_t
, retransmit
, status_t
,
313 private_task_manager_t
*this, u_int32_t seqnr
)
315 status_t status
= SUCCESS
;
317 if (seqnr
== this->initiating
.seqnr
&& this->initiating
.packet
)
319 status
= retransmit_packet(this, seqnr
, this->initiating
.mid
,
320 this->initiating
.retransmitted
, this->initiating
.packet
);
321 if (status
== NEED_MORE
)
323 this->initiating
.retransmitted
++;
327 if (seqnr
== this->responding
.seqnr
&& this->responding
.packet
)
329 status
= retransmit_packet(this, seqnr
, this->responding
.mid
,
330 this->responding
.retransmitted
, this->responding
.packet
);
331 if (status
== NEED_MORE
)
333 this->responding
.retransmitted
++;
341 * Check if we have to wait for a mode config before starting a quick mode
343 static bool mode_config_expected(private_task_manager_t
*this)
345 enumerator_t
*enumerator
;
346 peer_cfg_t
*peer_cfg
;
350 peer_cfg
= this->ike_sa
->get_peer_cfg(this->ike_sa
);
353 enumerator
= peer_cfg
->create_pool_enumerator(peer_cfg
);
354 if (!enumerator
->enumerate(enumerator
, &pool
))
355 { /* no pool configured */
356 enumerator
->destroy(enumerator
);
359 enumerator
->destroy(enumerator
);
361 enumerator
= this->ike_sa
->create_virtual_ip_enumerator(this->ike_sa
,
363 if (!enumerator
->enumerate(enumerator
, &host
))
364 { /* have a pool, but no VIP assigned yet */
365 enumerator
->destroy(enumerator
);
368 enumerator
->destroy(enumerator
);
373 METHOD(task_manager_t
, initiate
, status_t
,
374 private_task_manager_t
*this)
376 enumerator_t
*enumerator
;
381 exchange_type_t exchange
= EXCHANGE_TYPE_UNDEFINED
;
382 bool new_mid
= FALSE
, expect_response
= FALSE
, cancelled
= FALSE
, keep
= FALSE
;
384 if (this->initiating
.type
!= EXCHANGE_TYPE_UNDEFINED
&&
385 this->initiating
.type
!= INFORMATIONAL_V1
)
387 DBG2(DBG_IKE
, "delaying task initiation, %N exchange in progress",
388 exchange_type_names
, this->initiating
.type
);
389 /* do not initiate if we already have a message in the air */
393 if (this->active_tasks
->get_count(this->active_tasks
) == 0)
395 DBG2(DBG_IKE
, "activating new tasks");
396 switch (this->ike_sa
->get_state(this->ike_sa
))
399 activate_task(this, TASK_ISAKMP_VENDOR
);
400 activate_task(this, TASK_ISAKMP_CERT_PRE
);
401 if (activate_task(this, TASK_MAIN_MODE
))
405 else if (activate_task(this, TASK_AGGRESSIVE_MODE
))
407 exchange
= AGGRESSIVE
;
409 activate_task(this, TASK_ISAKMP_CERT_POST
);
410 activate_task(this, TASK_ISAKMP_NATD
);
413 if (activate_task(this, TASK_ISAKMP_DELETE
))
415 exchange
= INFORMATIONAL_V1
;
419 if (activate_task(this, TASK_XAUTH
))
421 exchange
= TRANSACTION
;
425 if (activate_task(this, TASK_INFORMATIONAL
))
427 exchange
= INFORMATIONAL_V1
;
432 case IKE_ESTABLISHED
:
433 if (activate_task(this, TASK_MODE_CONFIG
))
435 exchange
= TRANSACTION
;
439 if (!mode_config_expected(this) &&
440 activate_task(this, TASK_QUICK_MODE
))
442 exchange
= QUICK_MODE
;
446 if (activate_task(this, TASK_INFORMATIONAL
))
448 exchange
= INFORMATIONAL_V1
;
452 if (activate_task(this, TASK_QUICK_DELETE
))
454 exchange
= INFORMATIONAL_V1
;
458 if (activate_task(this, TASK_ISAKMP_DELETE
))
460 exchange
= INFORMATIONAL_V1
;
464 if (activate_task(this, TASK_ISAKMP_DPD
))
466 exchange
= INFORMATIONAL_V1
;
477 DBG2(DBG_IKE
, "reinitiating already active tasks");
478 enumerator
= this->active_tasks
->create_enumerator(this->active_tasks
);
479 while (enumerator
->enumerate(enumerator
, (void**)&task
))
481 DBG2(DBG_IKE
, " %N task", task_type_names
, task
->get_type(task
));
482 switch (task
->get_type(task
))
487 case TASK_AGGRESSIVE_MODE
:
488 exchange
= AGGRESSIVE
;
490 case TASK_QUICK_MODE
:
491 exchange
= QUICK_MODE
;
494 exchange
= TRANSACTION
;
502 enumerator
->destroy(enumerator
);
505 if (exchange
== EXCHANGE_TYPE_UNDEFINED
)
507 DBG2(DBG_IKE
, "nothing to initiate");
508 /* nothing to do yet... */
512 me
= this->ike_sa
->get_my_host(this->ike_sa
);
513 other
= this->ike_sa
->get_other_host(this->ike_sa
);
517 if (!this->rng
->get_bytes(this->rng
, sizeof(this->initiating
.mid
),
518 (void*)&this->initiating
.mid
))
520 DBG1(DBG_IKE
, "failed to allocate message ID, destroying IKE_SA");
525 message
= message_create(IKEV1_MAJOR_VERSION
, IKEV1_MINOR_VERSION
);
526 message
->set_message_id(message
, this->initiating
.mid
);
527 message
->set_source(message
, me
->clone(me
));
528 message
->set_destination(message
, other
->clone(other
));
529 message
->set_exchange_type(message
, exchange
);
530 this->initiating
.type
= exchange
;
531 this->initiating
.retransmitted
= 0;
533 enumerator
= this->active_tasks
->create_enumerator(this->active_tasks
);
534 while (enumerator
->enumerate(enumerator
, (void*)&task
))
536 switch (task
->build(task
, message
))
539 /* task completed, remove it */
540 this->active_tasks
->remove_at(this->active_tasks
, enumerator
);
541 if (task
->get_type(task
) == TASK_AGGRESSIVE_MODE
||
542 task
->get_type(task
) == TASK_QUICK_MODE
)
543 { /* last message of three message exchange */
549 expect_response
= TRUE
;
550 /* processed, but task needs another exchange */
557 if (this->ike_sa
->get_state(this->ike_sa
) != IKE_CONNECTING
)
559 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
563 /* critical failure, destroy IKE_SA */
564 enumerator
->destroy(enumerator
);
565 message
->destroy(message
);
571 enumerator
->destroy(enumerator
);
573 if (this->active_tasks
->get_count(this->active_tasks
) == 0 &&
574 (exchange
== QUICK_MODE
|| exchange
== AGGRESSIVE
))
575 { /* tasks completed, no exchange active anymore */
576 this->initiating
.type
= EXCHANGE_TYPE_UNDEFINED
;
580 message
->destroy(message
);
581 return initiate(this);
584 DESTROY_IF(this->initiating
.packet
);
585 status
= this->ike_sa
->generate_message(this->ike_sa
, message
,
586 &this->initiating
.packet
);
587 if (status
!= SUCCESS
)
589 /* message generation failed. There is nothing more to do than to
591 message
->destroy(message
);
593 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
597 this->initiating
.seqnr
++;
600 message
->destroy(message
);
601 return retransmit(this, this->initiating
.seqnr
);
604 { /* keep the packet for retransmission, the responder might request it */
605 charon
->sender
->send(charon
->sender
,
606 this->initiating
.packet
->clone(this->initiating
.packet
));
610 charon
->sender
->send(charon
->sender
, this->initiating
.packet
);
611 this->initiating
.packet
= NULL
;
613 message
->destroy(message
);
615 if (exchange
== INFORMATIONAL_V1
)
617 switch (this->ike_sa
->get_state(this->ike_sa
))
620 /* close after sending an INFORMATIONAL when unestablished */
623 /* close after sending a DELETE */
629 return initiate(this);
633 * build a response depending on the "passive" task list
635 static status_t
build_response(private_task_manager_t
*this, message_t
*request
)
637 enumerator_t
*enumerator
;
641 bool delete = FALSE
, cancelled
= FALSE
, expect_request
= FALSE
;
644 me
= request
->get_destination(request
);
645 other
= request
->get_source(request
);
647 message
= message_create(IKEV1_MAJOR_VERSION
, IKEV1_MINOR_VERSION
);
648 message
->set_exchange_type(message
, request
->get_exchange_type(request
));
649 /* send response along the path the request came in */
650 message
->set_source(message
, me
->clone(me
));
651 message
->set_destination(message
, other
->clone(other
));
652 message
->set_message_id(message
, request
->get_message_id(request
));
653 message
->set_request(message
, FALSE
);
655 this->responding
.mid
= request
->get_message_id(request
);
656 this->responding
.retransmitted
= 0;
657 this->responding
.seqnr
++;
659 enumerator
= this->passive_tasks
->create_enumerator(this->passive_tasks
);
660 while (enumerator
->enumerate(enumerator
, (void*)&task
))
662 switch (task
->build(task
, message
))
665 /* task completed, remove it */
666 this->passive_tasks
->remove_at(this->passive_tasks
, enumerator
);
670 /* processed, but task needs another exchange */
671 if (task
->get_type(task
) == TASK_QUICK_MODE
||
672 task
->get_type(task
) == TASK_AGGRESSIVE_MODE
)
673 { /* we rely on initiator retransmission, except for
674 * three-message exchanges */
675 expect_request
= TRUE
;
683 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
686 /* destroy IKE_SA, but SEND response first */
692 enumerator
->destroy(enumerator
);
694 DESTROY_IF(this->responding
.packet
);
695 this->responding
.packet
= NULL
;
698 message
->destroy(message
);
699 return initiate(this);
701 status
= this->ike_sa
->generate_message(this->ike_sa
, message
,
702 &this->responding
.packet
);
703 message
->destroy(message
);
704 if (status
!= SUCCESS
)
706 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
710 if (expect_request
&& !delete)
712 return retransmit(this, this->responding
.seqnr
);
714 charon
->sender
->send(charon
->sender
,
715 this->responding
.packet
->clone(this->responding
.packet
));
724 * Send a notify in a separate INFORMATIONAL exchange back to the sender.
725 * The notify protocol_id is set to ISAKMP
727 static void send_notify(private_task_manager_t
*this, message_t
*request
,
735 if (request
->get_exchange_type(request
) == INFORMATIONAL_V1
)
736 { /* don't respond to INFORMATIONAL requests to avoid a notify war */
737 DBG1(DBG_IKE
, "ignore malformed INFORMATIONAL request");
740 if (!this->rng
->get_bytes(this->rng
, sizeof(mid
), (void*)&mid
))
742 DBG1(DBG_IKE
, "failed to allocate message ID");
745 response
= message_create(IKEV1_MAJOR_VERSION
, IKEV1_MINOR_VERSION
);
746 response
->set_exchange_type(response
, INFORMATIONAL_V1
);
747 response
->set_request(response
, TRUE
);
748 response
->set_message_id(response
, mid
);
749 response
->add_payload(response
, (payload_t
*)
750 notify_payload_create_from_protocol_and_type(NOTIFY_V1
,
753 me
= this->ike_sa
->get_my_host(this->ike_sa
);
754 if (me
->is_anyaddr(me
))
756 me
= request
->get_destination(request
);
757 this->ike_sa
->set_my_host(this->ike_sa
, me
->clone(me
));
759 other
= this->ike_sa
->get_other_host(this->ike_sa
);
760 if (other
->is_anyaddr(other
))
762 other
= request
->get_source(request
);
763 this->ike_sa
->set_other_host(this->ike_sa
, other
->clone(other
));
765 response
->set_source(response
, me
->clone(me
));
766 response
->set_destination(response
, other
->clone(other
));
767 if (this->ike_sa
->generate_message(this->ike_sa
, response
,
770 charon
->sender
->send(charon
->sender
, packet
);
772 response
->destroy(response
);
776 * Process a DPD request/response
778 static bool process_dpd(private_task_manager_t
*this, message_t
*message
)
780 notify_payload_t
*notify
;
785 type
= DPD_R_U_THERE
;
786 notify
= message
->get_notify(message
, type
);
789 type
= DPD_R_U_THERE_ACK
;
790 notify
= message
->get_notify(message
, type
);
796 data
= notify
->get_notification_data(notify
);
801 seq
= untoh32(data
.ptr
);
803 if (type
== DPD_R_U_THERE
)
805 if (this->dpd_recv
== 0 || seq
== this->dpd_recv
)
806 { /* check sequence validity */
807 this->dpd_recv
= seq
+ 1;
808 this->ike_sa
->set_statistic(this->ike_sa
, STAT_INBOUND
,
809 time_monotonic(NULL
));
811 /* but respond anyway */
812 this->ike_sa
->queue_task(this->ike_sa
,
813 &isakmp_dpd_create(this->ike_sa
, DPD_R_U_THERE_ACK
, seq
)->task
);
815 else /* DPD_R_U_THERE_ACK */
817 if (seq
== this->dpd_send
- 1)
819 this->ike_sa
->set_statistic(this->ike_sa
, STAT_INBOUND
,
820 time_monotonic(NULL
));
824 DBG1(DBG_IKE
, "received invalid DPD sequence number %u "
825 "(expected %u), ignored", seq
, this->dpd_send
- 1);
832 * handle an incoming request message
834 static status_t
process_request(private_task_manager_t
*this,
837 enumerator_t
*enumerator
;
839 bool send_response
= FALSE
, dpd
= FALSE
;
841 if (message
->get_exchange_type(message
) == INFORMATIONAL_V1
||
842 this->passive_tasks
->get_count(this->passive_tasks
) == 0)
843 { /* create tasks depending on request type, if not already some queued */
844 switch (message
->get_exchange_type(message
))
847 task
= (task_t
*)isakmp_vendor_create(this->ike_sa
, FALSE
);
848 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
849 task
= (task_t
*)isakmp_cert_pre_create(this->ike_sa
, FALSE
);
850 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
851 task
= (task_t
*)main_mode_create(this->ike_sa
, FALSE
);
852 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
853 task
= (task_t
*)isakmp_cert_post_create(this->ike_sa
, FALSE
);
854 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
855 task
= (task_t
*)isakmp_natd_create(this->ike_sa
, FALSE
);
856 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
859 task
= (task_t
*)isakmp_vendor_create(this->ike_sa
, FALSE
);
860 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
861 task
= (task_t
*)isakmp_cert_pre_create(this->ike_sa
, FALSE
);
862 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
863 task
= (task_t
*)aggressive_mode_create(this->ike_sa
, FALSE
);
864 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
865 task
= (task_t
*)isakmp_cert_post_create(this->ike_sa
, FALSE
);
866 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
867 task
= (task_t
*)isakmp_natd_create(this->ike_sa
, FALSE
);
868 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
871 if (this->ike_sa
->get_state(this->ike_sa
) != IKE_ESTABLISHED
)
873 DBG1(DBG_IKE
, "received quick mode request for "
874 "unestablished IKE_SA, ignored");
877 task
= (task_t
*)quick_mode_create(this->ike_sa
, NULL
,
879 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
881 case INFORMATIONAL_V1
:
882 if (process_dpd(this, message
))
888 task
= (task_t
*)informational_create(this->ike_sa
, NULL
);
889 this->passive_tasks
->insert_first(this->passive_tasks
, task
);
893 if (this->ike_sa
->get_state(this->ike_sa
) != IKE_CONNECTING
)
895 task
= (task_t
*)mode_config_create(this->ike_sa
, FALSE
);
899 task
= (task_t
*)xauth_create(this->ike_sa
, FALSE
);
901 this->passive_tasks
->insert_last(this->passive_tasks
, task
);
909 return initiate(this);
911 this->ike_sa
->set_statistic(this->ike_sa
, STAT_INBOUND
, time_monotonic(NULL
));
913 /* let the tasks process the message */
914 enumerator
= this->passive_tasks
->create_enumerator(this->passive_tasks
);
915 while (enumerator
->enumerate(enumerator
, (void*)&task
))
917 switch (task
->process(task
, message
))
920 /* task completed, remove it */
921 this->passive_tasks
->remove_at(this->passive_tasks
, enumerator
);
925 /* processed, but task needs at least another call to build() */
926 send_response
= TRUE
;
929 send_response
= FALSE
;
933 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
936 /* critical failure, destroy IKE_SA */
937 this->passive_tasks
->remove_at(this->passive_tasks
, enumerator
);
938 enumerator
->destroy(enumerator
);
944 enumerator
->destroy(enumerator
);
948 if (build_response(this, message
) != SUCCESS
)
954 { /* We don't send a response, so don't retransmit one if we get
955 * the same message again. */
956 DESTROY_IF(this->responding
.packet
);
957 this->responding
.packet
= NULL
;
959 if (this->passive_tasks
->get_count(this->passive_tasks
) == 0 &&
960 this->queued_tasks
->get_count(this->queued_tasks
) > 0)
962 /* passive tasks completed, check if an active task has been queued,
963 * such as XAUTH or modeconfig push */
964 return initiate(this);
970 * handle an incoming response message
972 static status_t
process_response(private_task_manager_t
*this,
975 enumerator_t
*enumerator
;
980 if (message
->get_exchange_type(message
) != this->initiating
.type
)
982 DBG1(DBG_IKE
, "received %N response, but expected %N",
983 exchange_type_names
, message
->get_exchange_type(message
),
984 exchange_type_names
, this->initiating
.type
);
985 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
989 enumerator
= this->active_tasks
->create_enumerator(this->active_tasks
);
990 while (enumerator
->enumerate(enumerator
, (void*)&task
))
992 switch (task
->process(task
, message
))
995 /* task completed, remove it */
996 this->active_tasks
->remove_at(this->active_tasks
, enumerator
);
1000 /* processed, but task needs another exchange */
1006 charon
->bus
->ike_updown(charon
->bus
, this->ike_sa
, FALSE
);
1009 /* critical failure, destroy IKE_SA */
1010 this->active_tasks
->remove_at(this->active_tasks
, enumerator
);
1011 enumerator
->destroy(enumerator
);
1012 task
->destroy(task
);
1017 enumerator
->destroy(enumerator
);
1019 this->initiating
.type
= EXCHANGE_TYPE_UNDEFINED
;
1020 DESTROY_IF(this->initiating
.packet
);
1021 this->initiating
.packet
= NULL
;
1023 if (this->queued
&& this->active_tasks
->get_count(this->active_tasks
) == 0)
1025 queued
= this->queued
;
1026 this->queued
= NULL
;
1027 status
= this->public.task_manager
.process_message(
1028 &this->public.task_manager
, queued
);
1029 queued
->destroy(queued
);
1030 if (status
== DESTROY_ME
)
1036 return initiate(this);
1040 * Parse the given message and verify that it is valid.
1042 static status_t
parse_message(private_task_manager_t
*this, message_t
*msg
)
1046 status
= msg
->parse_body(msg
, this->ike_sa
->get_keymat(this->ike_sa
));
1048 if (status
!= SUCCESS
)
1053 DBG1(DBG_IKE
, "unsupported exchange type");
1054 send_notify(this, msg
, INVALID_EXCHANGE_TYPE
);
1057 DBG1(DBG_IKE
, "message parsing failed");
1058 send_notify(this, msg
, PAYLOAD_MALFORMED
);
1061 DBG1(DBG_IKE
, "message verification failed");
1062 send_notify(this, msg
, PAYLOAD_MALFORMED
);
1065 DBG1(DBG_IKE
, "integrity check failed");
1066 send_notify(this, msg
, INVALID_HASH_INFORMATION
);
1069 DBG1(DBG_IKE
, "found encrypted message, but no keys available");
1070 send_notify(this, msg
, PAYLOAD_MALFORMED
);
1074 DBG1(DBG_IKE
, "%N %s with message ID %u processing failed",
1075 exchange_type_names
, msg
->get_exchange_type(msg
),
1076 msg
->get_request(msg
) ?
"request" : "response",
1077 msg
->get_message_id(msg
));
1079 if (this->ike_sa
->get_state(this->ike_sa
) == IKE_CREATED
)
1080 { /* invalid initiation attempt, close SA */
1087 METHOD(task_manager_t
, process_message
, status_t
,
1088 private_task_manager_t
*this, message_t
*msg
)
1090 u_int32_t hash
, mid
, i
;
1094 /* TODO-IKEv1: update hosts more selectively */
1095 me
= msg
->get_destination(msg
);
1096 other
= msg
->get_source(msg
);
1097 mid
= msg
->get_message_id(msg
);
1098 hash
= chunk_hash(msg
->get_packet_data(msg
));
1099 for (i
= 0; i
< MAX_OLD_HASHES
; i
++)
1101 if (this->initiating
.old_hashes
[i
] == hash
)
1103 if (this->initiating
.packet
&&
1104 i
== (this->initiating
.old_hash_pos
% MAX_OLD_HASHES
) &&
1105 (msg
->get_exchange_type(msg
) == QUICK_MODE
||
1106 msg
->get_exchange_type(msg
) == AGGRESSIVE
))
1108 DBG1(DBG_IKE
, "received retransmit of response with ID %u, "
1109 "resending last request", mid
);
1110 charon
->sender
->send(charon
->sender
,
1111 this->initiating
.packet
->clone(this->initiating
.packet
));
1114 DBG1(DBG_IKE
, "received retransmit of response with ID %u, "
1115 "but next request already sent", mid
);
1120 if ((mid
&& mid
== this->initiating
.mid
) ||
1121 (this->initiating
.mid
== 0 &&
1122 msg
->get_exchange_type(msg
) == this->initiating
.type
&&
1123 this->active_tasks
->get_count(this->active_tasks
)))
1125 msg
->set_request(msg
, FALSE
);
1126 charon
->bus
->message(charon
->bus
, msg
, TRUE
, FALSE
);
1127 status
= parse_message(this, msg
);
1128 if (status
!= SUCCESS
)
1132 this->ike_sa
->set_statistic(this->ike_sa
, STAT_INBOUND
,
1133 time_monotonic(NULL
));
1134 this->ike_sa
->update_hosts(this->ike_sa
, me
, other
, TRUE
);
1135 charon
->bus
->message(charon
->bus
, msg
, TRUE
, TRUE
);
1136 if (process_response(this, msg
) != SUCCESS
)
1141 this->initiating
.old_hashes
[(++this->initiating
.old_hash_pos
) %
1142 MAX_OLD_HASHES
] = hash
;
1146 if (hash
== this->responding
.hash
)
1148 if (this->responding
.packet
)
1150 DBG1(DBG_IKE
, "received retransmit of request with ID %u, "
1151 "retransmitting response", mid
);
1152 charon
->sender
->send(charon
->sender
,
1153 this->responding
.packet
->clone(this->responding
.packet
));
1155 else if (this->initiating
.packet
&&
1156 this->initiating
.type
== INFORMATIONAL_V1
)
1158 DBG1(DBG_IKE
, "received retransmit of DPD request, "
1159 "retransmitting response");
1160 charon
->sender
->send(charon
->sender
,
1161 this->initiating
.packet
->clone(this->initiating
.packet
));
1165 DBG1(DBG_IKE
, "received retransmit of request with ID %u, "
1166 "but no response to retransmit", mid
);
1170 if (msg
->get_exchange_type(msg
) == TRANSACTION
&&
1171 this->active_tasks
->get_count(this->active_tasks
))
1172 { /* main mode not yet complete, queue XAuth/Mode config tasks */
1175 DBG1(DBG_IKE
, "ignoring additional %N request, queue full",
1176 exchange_type_names
, TRANSACTION
);
1179 this->queued
= message_create_from_packet(msg
->get_packet(msg
));
1180 if (this->queued
->parse_header(this->queued
) != SUCCESS
)
1182 this->queued
->destroy(this->queued
);
1183 this->queued
= NULL
;
1186 DBG1(DBG_IKE
, "queueing %N request as tasks still active",
1187 exchange_type_names
, TRANSACTION
);
1191 msg
->set_request(msg
, TRUE
);
1192 charon
->bus
->message(charon
->bus
, msg
, TRUE
, FALSE
);
1193 status
= parse_message(this, msg
);
1194 if (status
!= SUCCESS
)
1198 /* if this IKE_SA is virgin, we check for a config */
1199 if (this->ike_sa
->get_ike_cfg(this->ike_sa
) == NULL
)
1201 ike_sa_id_t
*ike_sa_id
;
1205 ike_cfg
= charon
->backends
->get_ike_cfg(charon
->backends
,
1207 if (ike_cfg
== NULL
)
1209 /* no config found for these hosts, destroy */
1210 DBG1(DBG_IKE
, "no IKE config found for %H...%H, sending %N",
1211 me
, other
, notify_type_names
, NO_PROPOSAL_CHOSEN
);
1212 send_notify(this, msg
, NO_PROPOSAL_CHOSEN
);
1215 this->ike_sa
->set_ike_cfg(this->ike_sa
, ike_cfg
);
1216 ike_cfg
->destroy(ike_cfg
);
1217 /* add a timeout if peer does not establish it completely */
1218 ike_sa_id
= this->ike_sa
->get_id(this->ike_sa
);
1219 job
= (job_t
*)delete_ike_sa_job_create(ike_sa_id
, FALSE
);
1220 lib
->scheduler
->schedule_job(lib
->scheduler
, job
,
1221 lib
->settings
->get_int(lib
->settings
,
1222 "%s.half_open_timeout", HALF_OPEN_IKE_SA_TIMEOUT
,
1225 this->ike_sa
->update_hosts(this->ike_sa
, me
, other
, TRUE
);
1226 charon
->bus
->message(charon
->bus
, msg
, TRUE
, TRUE
);
1227 if (process_request(this, msg
) != SUCCESS
)
1232 this->responding
.hash
= hash
;
1237 METHOD(task_manager_t
, queue_task
, void,
1238 private_task_manager_t
*this, task_t
*task
)
1240 DBG2(DBG_IKE
, "queueing %N task", task_type_names
, task
->get_type(task
));
1241 this->queued_tasks
->insert_last(this->queued_tasks
, task
);
1245 * Check if a given task has been queued already
1247 static bool has_queued(private_task_manager_t
*this, task_type_t type
)
1249 enumerator_t
*enumerator
;
1253 enumerator
= this->queued_tasks
->create_enumerator(this->queued_tasks
);
1254 while (enumerator
->enumerate(enumerator
, &task
))
1256 if (task
->get_type(task
) == type
)
1262 enumerator
->destroy(enumerator
);
1266 METHOD(task_manager_t
, queue_ike
, void,
1267 private_task_manager_t
*this)
1269 peer_cfg_t
*peer_cfg
;
1271 if (!has_queued(this, TASK_ISAKMP_VENDOR
))
1273 queue_task(this, (task_t
*)isakmp_vendor_create(this->ike_sa
, TRUE
));
1275 if (!has_queued(this, TASK_ISAKMP_CERT_PRE
))
1277 queue_task(this, (task_t
*)isakmp_cert_pre_create(this->ike_sa
, TRUE
));
1279 peer_cfg
= this->ike_sa
->get_peer_cfg(this->ike_sa
);
1280 if (peer_cfg
->use_aggressive(peer_cfg
))
1282 if (!has_queued(this, TASK_AGGRESSIVE_MODE
))
1284 queue_task(this, (task_t
*)aggressive_mode_create(this->ike_sa
, TRUE
));
1289 if (!has_queued(this, TASK_MAIN_MODE
))
1291 queue_task(this, (task_t
*)main_mode_create(this->ike_sa
, TRUE
));
1294 if (!has_queued(this, TASK_ISAKMP_CERT_POST
))
1296 queue_task(this, (task_t
*)isakmp_cert_post_create(this->ike_sa
, TRUE
));
1298 if (!has_queued(this, TASK_ISAKMP_NATD
))
1300 queue_task(this, (task_t
*)isakmp_natd_create(this->ike_sa
, TRUE
));
1304 METHOD(task_manager_t
, queue_ike_reauth
, void,
1305 private_task_manager_t
*this)
1307 enumerator_t
*enumerator
;
1308 child_sa_t
*child_sa
;
1312 new = charon
->ike_sa_manager
->checkout_new(charon
->ike_sa_manager
,
1313 this->ike_sa
->get_version(this->ike_sa
), TRUE
);
1315 { /* shouldn't happen */
1319 new->set_peer_cfg(new, this->ike_sa
->get_peer_cfg(this->ike_sa
));
1320 host
= this->ike_sa
->get_other_host(this->ike_sa
);
1321 new->set_other_host(new, host
->clone(host
));
1322 host
= this->ike_sa
->get_my_host(this->ike_sa
);
1323 new->set_my_host(new, host
->clone(host
));
1324 enumerator
= this->ike_sa
->create_virtual_ip_enumerator(this->ike_sa
, TRUE
);
1325 while (enumerator
->enumerate(enumerator
, &host
))
1327 new->add_virtual_ip(new, TRUE
, host
);
1329 enumerator
->destroy(enumerator
);
1331 enumerator
= this->ike_sa
->create_child_sa_enumerator(this->ike_sa
);
1332 while (enumerator
->enumerate(enumerator
, &child_sa
))
1334 this->ike_sa
->remove_child_sa(this->ike_sa
, enumerator
);
1335 new->add_child_sa(new, child_sa
);
1337 enumerator
->destroy(enumerator
);
1339 if (!new->get_child_count(new))
1340 { /* check if a Quick Mode task is queued (UNITY_LOAD_BALANCE case) */
1343 enumerator
= this->queued_tasks
->create_enumerator(this->queued_tasks
);
1344 while (enumerator
->enumerate(enumerator
, &task
))
1346 if (task
->get_type(task
) == TASK_QUICK_MODE
)
1348 this->queued_tasks
->remove_at(this->queued_tasks
, enumerator
);
1349 task
->migrate(task
, new);
1350 new->queue_task(new, task
);
1353 enumerator
->destroy(enumerator
);
1356 if (new->initiate(new, NULL
, 0, NULL
, NULL
) != DESTROY_ME
)
1358 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, new);
1359 this->ike_sa
->set_state(this->ike_sa
, IKE_REKEYING
);
1363 charon
->ike_sa_manager
->checkin_and_destroy(charon
->ike_sa_manager
, new);
1364 DBG1(DBG_IKE
, "reauthenticating IKE_SA failed");
1366 charon
->bus
->set_sa(charon
->bus
, this->ike_sa
);
1369 METHOD(task_manager_t
, queue_ike_rekey
, void,
1370 private_task_manager_t
*this)
1372 queue_ike_reauth(this);
1375 METHOD(task_manager_t
, queue_ike_delete
, void,
1376 private_task_manager_t
*this)
1378 enumerator_t
*enumerator
;
1379 child_sa_t
*child_sa
;
1381 enumerator
= this->ike_sa
->create_child_sa_enumerator(this->ike_sa
);
1382 while (enumerator
->enumerate(enumerator
, &child_sa
))
1384 queue_task(this, (task_t
*)
1385 quick_delete_create(this->ike_sa
, child_sa
->get_protocol(child_sa
),
1386 child_sa
->get_spi(child_sa
, TRUE
), FALSE
, FALSE
));
1388 enumerator
->destroy(enumerator
);
1390 queue_task(this, (task_t
*)isakmp_delete_create(this->ike_sa
, TRUE
));
1393 METHOD(task_manager_t
, queue_mobike
, void,
1394 private_task_manager_t
*this, bool roam
, bool address
)
1396 /* Not supported in IKEv1 */
1399 METHOD(task_manager_t
, queue_child
, void,
1400 private_task_manager_t
*this, child_cfg_t
*cfg
, u_int32_t reqid
,
1401 traffic_selector_t
*tsi
, traffic_selector_t
*tsr
)
1405 task
= quick_mode_create(this->ike_sa
, cfg
, tsi
, tsr
);
1406 task
->use_reqid(task
, reqid
);
1408 queue_task(this, &task
->task
);
1412 * Check if two CHILD_SAs have the same traffic selector
1414 static bool have_equal_ts(child_sa_t
*a
, child_sa_t
*b
, bool local
)
1416 linked_list_t
*list
;
1417 traffic_selector_t
*ts_a
, *ts_b
;
1419 list
= a
->get_traffic_selectors(a
, local
);
1420 if (list
->get_first(list
, (void**)&ts_a
) == SUCCESS
)
1422 list
= b
->get_traffic_selectors(b
, local
);
1423 if (list
->get_first(list
, (void**)&ts_b
) == SUCCESS
)
1425 return ts_a
->equals(ts_a
, ts_b
);
1432 * Check if a CHILD_SA is redundant and we should delete instead of rekey
1434 static bool is_redundant(private_task_manager_t
*this, child_sa_t
*child_sa
)
1436 enumerator_t
*enumerator
;
1437 child_sa_t
*current
;
1438 bool redundant
= FALSE
;
1440 enumerator
= this->ike_sa
->create_child_sa_enumerator(this->ike_sa
);
1441 while (enumerator
->enumerate(enumerator
, ¤t
))
1443 if (current
->get_state(current
) == CHILD_INSTALLED
&&
1444 streq(current
->get_name(current
), child_sa
->get_name(child_sa
)) &&
1445 have_equal_ts(current
, child_sa
, TRUE
) &&
1446 have_equal_ts(current
, child_sa
, FALSE
) &&
1447 current
->get_lifetime(current
, FALSE
) >
1448 child_sa
->get_lifetime(child_sa
, FALSE
))
1450 DBG1(DBG_IKE
, "deleting redundant CHILD_SA %s{%d}",
1451 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
));
1456 enumerator
->destroy(enumerator
);
1462 * Get the first traffic selector of a CHILD_SA, local or remote
1464 static traffic_selector_t
* get_first_ts(child_sa_t
*child_sa
, bool local
)
1466 traffic_selector_t
*ts
= NULL
;
1467 linked_list_t
*list
;
1469 list
= child_sa
->get_traffic_selectors(child_sa
, local
);
1470 if (list
->get_first(list
, (void**)&ts
) == SUCCESS
)
1477 METHOD(task_manager_t
, queue_child_rekey
, void,
1478 private_task_manager_t
*this, protocol_id_t protocol
, u_int32_t spi
)
1480 child_sa_t
*child_sa
;
1484 child_sa
= this->ike_sa
->get_child_sa(this->ike_sa
, protocol
, spi
, TRUE
);
1487 child_sa
= this->ike_sa
->get_child_sa(this->ike_sa
, protocol
, spi
, FALSE
);
1489 if (child_sa
&& child_sa
->get_state(child_sa
) == CHILD_INSTALLED
)
1491 if (is_redundant(this, child_sa
))
1493 queue_task(this, (task_t
*)quick_delete_create(this->ike_sa
,
1494 protocol
, spi
, FALSE
, FALSE
));
1498 child_sa
->set_state(child_sa
, CHILD_REKEYING
);
1499 cfg
= child_sa
->get_config(child_sa
);
1500 task
= quick_mode_create(this->ike_sa
, cfg
->get_ref(cfg
),
1501 get_first_ts(child_sa
, TRUE
), get_first_ts(child_sa
, FALSE
));
1502 task
->use_reqid(task
, child_sa
->get_reqid(child_sa
));
1503 task
->rekey(task
, child_sa
->get_spi(child_sa
, TRUE
));
1505 queue_task(this, &task
->task
);
1510 METHOD(task_manager_t
, queue_child_delete
, void,
1511 private_task_manager_t
*this, protocol_id_t protocol
, u_int32_t spi
,
1514 queue_task(this, (task_t
*)quick_delete_create(this->ike_sa
, protocol
,
1515 spi
, FALSE
, expired
));
1518 METHOD(task_manager_t
, queue_dpd
, void,
1519 private_task_manager_t
*this)
1521 peer_cfg_t
*peer_cfg
;
1522 u_int32_t t
, retransmit
;
1524 queue_task(this, (task_t
*)isakmp_dpd_create(this->ike_sa
, DPD_R_U_THERE
,
1526 peer_cfg
= this->ike_sa
->get_peer_cfg(this->ike_sa
);
1528 /* compute timeout in milliseconds */
1529 t
= 1000 * peer_cfg
->get_dpd_timeout(peer_cfg
);
1532 /* use the same timeout as a retransmitting IKE message would have */
1533 for (retransmit
= 0; retransmit
<= this->retransmit_tries
; retransmit
++)
1535 t
+= (u_int32_t
)(this->retransmit_timeout
* 1000.0 *
1536 pow(this->retransmit_base
, retransmit
));
1540 /* schedule DPD timeout job */
1541 lib
->scheduler
->schedule_job_ms(lib
->scheduler
,
1542 (job_t
*)dpd_timeout_job_create(this->ike_sa
->get_id(this->ike_sa
)), t
);
1545 METHOD(task_manager_t
, adopt_tasks
, void,
1546 private_task_manager_t
*this, task_manager_t
*other_public
)
1548 private_task_manager_t
*other
= (private_task_manager_t
*)other_public
;
1551 /* move queued tasks from other to this */
1552 while (other
->queued_tasks
->remove_last(other
->queued_tasks
,
1553 (void**)&task
) == SUCCESS
)
1555 DBG2(DBG_IKE
, "migrating %N task", task_type_names
, task
->get_type(task
));
1556 task
->migrate(task
, this->ike_sa
);
1557 this->queued_tasks
->insert_first(this->queued_tasks
, task
);
1561 METHOD(task_manager_t
, busy
, bool,
1562 private_task_manager_t
*this)
1564 return (this->active_tasks
->get_count(this->active_tasks
) > 0);
1567 METHOD(task_manager_t
, incr_mid
, void,
1568 private_task_manager_t
*this, bool initiate
)
1572 METHOD(task_manager_t
, reset
, void,
1573 private_task_manager_t
*this, u_int32_t initiate
, u_int32_t respond
)
1575 enumerator_t
*enumerator
;
1578 /* reset message counters and retransmit packets */
1579 DESTROY_IF(this->responding
.packet
);
1580 DESTROY_IF(this->initiating
.packet
);
1581 this->responding
.packet
= NULL
;
1582 this->responding
.seqnr
= RESPONDING_SEQ
;
1583 this->responding
.retransmitted
= 0;
1584 this->initiating
.packet
= NULL
;
1585 this->initiating
.mid
= 0;
1586 this->initiating
.seqnr
= 0;
1587 this->initiating
.retransmitted
= 0;
1588 this->initiating
.type
= EXCHANGE_TYPE_UNDEFINED
;
1589 if (initiate
!= UINT_MAX
)
1591 this->dpd_send
= initiate
;
1593 if (respond
!= UINT_MAX
)
1595 this->dpd_recv
= respond
;
1598 /* reset queued tasks */
1599 enumerator
= this->queued_tasks
->create_enumerator(this->queued_tasks
);
1600 while (enumerator
->enumerate(enumerator
, &task
))
1602 task
->migrate(task
, this->ike_sa
);
1604 enumerator
->destroy(enumerator
);
1606 /* reset active tasks */
1607 while (this->active_tasks
->remove_last(this->active_tasks
,
1608 (void**)&task
) == SUCCESS
)
1610 task
->migrate(task
, this->ike_sa
);
1611 this->queued_tasks
->insert_first(this->queued_tasks
, task
);
1615 METHOD(task_manager_t
, create_task_enumerator
, enumerator_t
*,
1616 private_task_manager_t
*this, task_queue_t queue
)
1620 case TASK_QUEUE_ACTIVE
:
1621 return this->active_tasks
->create_enumerator(this->active_tasks
);
1622 case TASK_QUEUE_PASSIVE
:
1623 return this->passive_tasks
->create_enumerator(this->passive_tasks
);
1624 case TASK_QUEUE_QUEUED
:
1625 return this->queued_tasks
->create_enumerator(this->queued_tasks
);
1627 return enumerator_create_empty();
1631 METHOD(task_manager_t
, destroy
, void,
1632 private_task_manager_t
*this)
1636 this->active_tasks
->destroy(this->active_tasks
);
1637 this->queued_tasks
->destroy(this->queued_tasks
);
1638 this->passive_tasks
->destroy(this->passive_tasks
);
1640 DESTROY_IF(this->queued
);
1641 DESTROY_IF(this->responding
.packet
);
1642 DESTROY_IF(this->initiating
.packet
);
1643 DESTROY_IF(this->rng
);
1650 task_manager_v1_t
*task_manager_v1_create(ike_sa_t
*ike_sa
)
1652 private_task_manager_t
*this;
1657 .process_message
= _process_message
,
1658 .queue_task
= _queue_task
,
1659 .queue_ike
= _queue_ike
,
1660 .queue_ike_rekey
= _queue_ike_rekey
,
1661 .queue_ike_reauth
= _queue_ike_reauth
,
1662 .queue_ike_delete
= _queue_ike_delete
,
1663 .queue_mobike
= _queue_mobike
,
1664 .queue_child
= _queue_child
,
1665 .queue_child_rekey
= _queue_child_rekey
,
1666 .queue_child_delete
= _queue_child_delete
,
1667 .queue_dpd
= _queue_dpd
,
1668 .initiate
= _initiate
,
1669 .retransmit
= _retransmit
,
1670 .incr_mid
= _incr_mid
,
1672 .adopt_tasks
= _adopt_tasks
,
1674 .create_task_enumerator
= _create_task_enumerator
,
1675 .flush_queue
= _flush_queue
,
1676 .destroy
= _destroy
,
1680 .type
= EXCHANGE_TYPE_UNDEFINED
,
1683 .seqnr
= RESPONDING_SEQ
,
1686 .rng
= lib
->crypto
->create_rng(lib
->crypto
, RNG_WEAK
),
1687 .queued_tasks
= linked_list_create(),
1688 .active_tasks
= linked_list_create(),
1689 .passive_tasks
= linked_list_create(),
1690 .retransmit_tries
= lib
->settings
->get_int(lib
->settings
,
1691 "%s.retransmit_tries", RETRANSMIT_TRIES
, charon
->name
),
1692 .retransmit_timeout
= lib
->settings
->get_double(lib
->settings
,
1693 "%s.retransmit_timeout", RETRANSMIT_TIMEOUT
, charon
->name
),
1694 .retransmit_base
= lib
->settings
->get_double(lib
->settings
,
1695 "%s.retransmit_base", RETRANSMIT_BASE
, charon
->name
),
1700 DBG1(DBG_IKE
, "no RNG found, unable to create IKE_SA");
1704 if (!this->rng
->get_bytes(this->rng
, sizeof(this->dpd_send
),
1705 (void*)&this->dpd_send
))
1707 DBG1(DBG_IKE
, "failed to allocate message ID, unable to create IKE_SA");
1711 this->dpd_send
&= 0x7FFFFFFF;
1713 return &this->public;