2 * @file ike_sa_manager.c
4 * @brief Implementation of ike_sa_mananger_t.
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 #include "ike_sa_manager.h"
30 #include <sa/ike_sa_id.h>
32 #include <utils/linked_list.h>
34 typedef struct entry_t entry_t
;
37 * An entry in the linked list, contains IKE_SA, locking and lookup data.
42 * Number of threads waiting for this ike_sa_t object.
47 * Condvar where threads can wait until ike_sa_t object is free for use again.
49 pthread_cond_t condvar
;
52 * Is this ike_sa currently checked out?
57 * Does this SA drives out new threads?
59 bool driveout_new_threads
;
62 * Does this SA drives out waiting threads?
64 bool driveout_waiting_threads
;
67 * Identifiaction of an IKE_SA (SPIs).
69 ike_sa_id_t
*ike_sa_id
;
72 * The contained ike_sa_t object.
78 * Implementation of entry_t.destroy.
80 static status_t
entry_destroy(entry_t
*this)
82 /* also destroy IKE SA */
83 this->ike_sa
->destroy(this->ike_sa
);
84 this->ike_sa_id
->destroy(this->ike_sa_id
);
90 * Creates a new entry for the ike_sa_t list.
92 static entry_t
*entry_create(ike_sa_id_t
*ike_sa_id
)
94 entry_t
*this = malloc_thing(entry_t
);
96 this->waiting_threads
= 0;
97 pthread_cond_init(&(this->condvar
), NULL
);
99 /* we set checkout flag when we really give it out */
100 this->checked_out
= FALSE
;
101 this->driveout_new_threads
= FALSE
;
102 this->driveout_waiting_threads
= FALSE
;
104 /* ike_sa_id is always cloned */
105 this->ike_sa_id
= ike_sa_id
->clone(ike_sa_id
);
107 /* create new ike_sa */
108 this->ike_sa
= ike_sa_create(ike_sa_id
);
114 typedef struct private_ike_sa_manager_t private_ike_sa_manager_t
;
117 * Additional private members of ike_sa_manager_t.
119 struct private_ike_sa_manager_t
{
121 * Public interface of ike_sa_manager_t.
123 ike_sa_manager_t
public;
126 * Lock for exclusivly accessing the manager.
128 pthread_mutex_t mutex
;
131 * Linked list with entries for the ike_sa_t objects.
133 linked_list_t
*ike_sa_list
;
136 * A randomizer, to get random SPIs for our side
138 randomizer_t
*randomizer
;
142 * Implementation of private_ike_sa_manager_t.get_entry_by_id.
144 static status_t
get_entry_by_id(private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
, entry_t
**entry
)
146 linked_list_t
*list
= this->ike_sa_list
;
147 iterator_t
*iterator
;
151 /* create iterator over list of ike_sa's */
152 iterator
= list
->create_iterator(list
, TRUE
);
157 while (iterator
->iterate(iterator
, (void**)¤t
))
159 if (current
->ike_sa_id
->equals(current
->ike_sa_id
, ike_sa_id
))
161 DBG2(DBG_MGR
, "found entry by both SPIs");
166 if (ike_sa_id
->get_responder_spi(ike_sa_id
) == 0 ||
167 current
->ike_sa_id
->get_responder_spi(current
->ike_sa_id
) == 0)
169 /* seems to be a half ready ike_sa */
170 if ((current
->ike_sa_id
->get_initiator_spi(current
->ike_sa_id
) ==
171 ike_sa_id
->get_initiator_spi(ike_sa_id
)) &&
172 (current
->ike_sa_id
->is_initiator(ike_sa_id
) ==
173 ike_sa_id
->is_initiator(current
->ike_sa_id
)))
175 DBG2(DBG_MGR
, "found entry by initiator SPI");
183 iterator
->destroy(iterator
);
188 * Implementation of private_ike_sa_manager_t.get_entry_by_sa.
190 static status_t
get_entry_by_sa(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
, entry_t
**entry
)
192 linked_list_t
*list
= this->ike_sa_list
;
193 iterator_t
*iterator
;
197 iterator
= list
->create_iterator(list
, TRUE
);
202 while (iterator
->iterate(iterator
, (void**)¤t
))
204 /* only pointers are compared */
205 if (current
->ike_sa
== ike_sa
)
207 DBG2(DBG_MGR
, "found entry by pointer");
213 iterator
->destroy(iterator
);
219 * Implementation of private_ike_sa_manager_s.delete_entry.
221 static status_t
delete_entry(private_ike_sa_manager_t
*this, entry_t
*entry
)
223 linked_list_t
*list
= this->ike_sa_list
;
224 iterator_t
*iterator
;
228 iterator
= list
->create_iterator(list
, TRUE
);
232 while (iterator
->iterate(iterator
, (void**)¤t
))
234 if (current
== entry
)
236 /* mark it, so now new threads can get this entry */
237 entry
->driveout_new_threads
= TRUE
;
238 /* wait until all workers have done their work */
239 while (entry
->waiting_threads
)
242 pthread_cond_broadcast(&(entry
->condvar
));
243 /* they will wake us again when their work is done */
244 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
247 DBG2(DBG_MGR
, "found entry by pointer, deleting it");
248 iterator
->remove(iterator
);
249 entry_destroy(entry
);
254 iterator
->destroy(iterator
);
259 * Wait until no other thread is using an IKE_SA, return FALSE if entry not
262 static bool wait_for_entry(private_ike_sa_manager_t
*this, entry_t
*entry
)
264 if (entry
->driveout_new_threads
)
266 /* we are not allowed to get this */
269 while (entry
->checked_out
&& !entry
->driveout_waiting_threads
)
271 /* so wait until we can get it for us.
272 * we register us as waiting. */
273 entry
->waiting_threads
++;
274 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
275 entry
->waiting_threads
--;
277 /* hm, a deletion request forbids us to get this SA, get next one */
278 if (entry
->driveout_waiting_threads
)
280 /* we must signal here, others may be waiting on it, too */
281 pthread_cond_signal(&(entry
->condvar
));
288 * Implementation of private_ike_sa_manager_t.get_next_spi.
290 static u_int64_t
get_next_spi(private_ike_sa_manager_t
*this)
294 this->randomizer
->get_pseudo_random_bytes(this->randomizer
, 8, (u_int8_t
*)&spi
);
300 * Implementation of of ike_sa_manager.checkout.
302 static ike_sa_t
* checkout(private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
)
304 bool responder_spi_set
;
305 bool initiator_spi_set
;
306 bool original_initiator
;
307 ike_sa_t
*ike_sa
= NULL
;
309 DBG2(DBG_MGR
, "checkout IKE_SA: %J", ike_sa_id
);
311 DBG2(DBG_MGR
, "%d IKE_SAs in manager",
312 this->ike_sa_list
->get_count(this->ike_sa_list
));
314 /* each access is locked */
315 pthread_mutex_lock(&(this->mutex
));
317 responder_spi_set
= ike_sa_id
->get_responder_spi(ike_sa_id
);
318 initiator_spi_set
= ike_sa_id
->get_initiator_spi(ike_sa_id
);
319 original_initiator
= ike_sa_id
->is_initiator(ike_sa_id
);
321 if ((initiator_spi_set
&& responder_spi_set
) ||
322 ((initiator_spi_set
&& !responder_spi_set
) && (original_initiator
)))
324 /* we SHOULD have an IKE_SA for these SPIs in the list,
325 * if not, we can't handle the request...
328 /* look for the entry */
329 if (get_entry_by_id(this, ike_sa_id
, &entry
) == SUCCESS
)
331 if (wait_for_entry(this, entry
))
333 DBG2(DBG_MGR
, "IKE_SA successfully checked out");
334 /* ok, this IKE_SA is finally ours */
335 entry
->checked_out
= TRUE
;
336 ike_sa
= entry
->ike_sa
;
337 /* update responder SPI when it's not set */
338 if (entry
->ike_sa_id
->get_responder_spi(entry
->ike_sa_id
) == 0)
340 ike_sa_id_t
*ike_sa_ike_sa_id
= ike_sa
->get_id(ike_sa
);
341 u_int64_t spi
= ike_sa_id
->get_responder_spi(ike_sa_id
);
343 ike_sa_ike_sa_id
->set_responder_spi(ike_sa_ike_sa_id
, spi
);
344 entry
->ike_sa_id
->set_responder_spi(entry
->ike_sa_id
, spi
);
349 DBG2(DBG_MGR
, "IKE_SA found, but not allowed to check it out");
354 DBG2(DBG_MGR
, "IKE_SA not stored in list");
355 /* looks like there is no such IKE_SA, better luck next time... */
358 else if ((initiator_spi_set
&& !responder_spi_set
) && (!original_initiator
))
360 /* an IKE_SA_INIT from an another endpoint,
361 * he is the initiator.
362 * For simplicity, we do NOT check for retransmitted
363 * IKE_SA_INIT-Requests here, so EVERY single IKE_SA_INIT-
364 * Request (even a retransmitted one) will result in a
365 * IKE_SA. This could be improved...
367 u_int64_t responder_spi
;
370 /* set SPIs, we are the responder */
371 responder_spi
= get_next_spi(this);
373 /* we also set arguments spi, so its still valid */
374 ike_sa_id
->set_responder_spi(ike_sa_id
, responder_spi
);
377 new_entry
= entry_create(ike_sa_id
);
379 this->ike_sa_list
->insert_last(this->ike_sa_list
, new_entry
);
381 /* check ike_sa out */
382 DBG2(DBG_MGR
, "IKE_SA added to list of known IKE_SAs");
383 new_entry
->checked_out
= TRUE
;
384 ike_sa
= new_entry
->ike_sa
;
386 else if (!initiator_spi_set
&& !responder_spi_set
)
388 /* checkout of a new and unused IKE_SA, used for rekeying */
391 if (original_initiator
)
393 ike_sa_id
->set_initiator_spi(ike_sa_id
, get_next_spi(this));
397 ike_sa_id
->set_responder_spi(ike_sa_id
, get_next_spi(this));
400 new_entry
= entry_create(ike_sa_id
);
401 DBG2(DBG_MGR
, "created IKE_SA: %J", ike_sa_id
);
403 this->ike_sa_list
->insert_last(this->ike_sa_list
, new_entry
);
405 /* check ike_sa out */
406 new_entry
->checked_out
= TRUE
;
407 ike_sa
= new_entry
->ike_sa
;
411 /* responder set, initiator not: here is something seriously wrong! */
412 DBG2(DBG_MGR
, "invalid IKE_SA SPIs");
415 pthread_mutex_unlock(&(this->mutex
));
417 charon
->bus
->set_sa(charon
->bus
, ike_sa
);
422 * Implementation of of ike_sa_manager.checkout_by_id.
424 static ike_sa_t
* checkout_by_peer(private_ike_sa_manager_t
*this,
425 host_t
*my_host
, host_t
*other_host
,
426 identification_t
*my_id
,
427 identification_t
*other_id
)
429 iterator_t
*iterator
;
431 ike_sa_t
*ike_sa
= NULL
;
433 pthread_mutex_lock(&(this->mutex
));
435 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
436 while (iterator
->iterate(iterator
, (void**)&entry
))
438 identification_t
*found_my_id
, *found_other_id
;
439 host_t
*found_my_host
, *found_other_host
;
442 if (!wait_for_entry(this, entry
))
447 if (entry
->ike_sa
->get_state(entry
->ike_sa
) == IKE_DELETING
)
449 /* skip IKE_SA which are not useable */
453 found_my_id
= entry
->ike_sa
->get_my_id(entry
->ike_sa
);
454 found_other_id
= entry
->ike_sa
->get_other_id(entry
->ike_sa
);
455 found_my_host
= entry
->ike_sa
->get_my_host(entry
->ike_sa
);
456 found_other_host
= entry
->ike_sa
->get_other_host(entry
->ike_sa
);
458 if (found_my_id
->get_type(found_my_id
) == ID_ANY
&&
459 found_other_id
->get_type(found_other_id
) == ID_ANY
)
461 /* IKE_SA has no IDs yet, so we can't use it */
465 /* compare ID and hosts. Supplied ID may contain wildcards, and IP
467 if ((found_my_host
->is_anyaddr(found_my_host
) ||
468 my_host
->ip_equals(my_host
, found_my_host
)) &&
469 (found_other_host
->is_anyaddr(found_other_host
) ||
470 other_host
->ip_equals(other_host
, found_other_host
)) &&
471 found_my_id
->matches(found_my_id
, my_id
, &wc
) &&
472 found_other_id
->matches(found_other_id
, other_id
, &wc
))
474 /* looks good, we take this one */
475 DBG2(DBG_MGR
, "found an existing IKE_SA for %H[%D]...%H[%D]",
476 my_host
, other_host
, my_id
, other_id
);
477 entry
->checked_out
= TRUE
;
478 ike_sa
= entry
->ike_sa
;
481 iterator
->destroy(iterator
);
485 u_int64_t initiator_spi
;
487 ike_sa_id_t
*new_ike_sa_id
;
489 initiator_spi
= get_next_spi(this);
490 new_ike_sa_id
= ike_sa_id_create(0, 0, TRUE
);
491 new_ike_sa_id
->set_initiator_spi(new_ike_sa_id
, initiator_spi
);
494 new_entry
= entry_create(new_ike_sa_id
);
495 DBG2(DBG_MGR
, "created IKE_SA: %J", new_ike_sa_id
);
496 new_ike_sa_id
->destroy(new_ike_sa_id
);
498 this->ike_sa_list
->insert_last(this->ike_sa_list
, new_entry
);
500 /* check ike_sa out */
501 DBG2(DBG_MGR
, "new IKE_SA created for IDs [%D]...[%D]", my_id
, other_id
);
502 new_entry
->checked_out
= TRUE
;
503 ike_sa
= new_entry
->ike_sa
;
505 pthread_mutex_unlock(&(this->mutex
));
506 charon
->bus
->set_sa(charon
->bus
, ike_sa
);
511 * Implementation of of ike_sa_manager.checkout_by_id.
513 static ike_sa_t
* checkout_by_id(private_ike_sa_manager_t
*this, u_int32_t id
,
516 iterator_t
*iterator
, *children
;
518 ike_sa_t
*ike_sa
= NULL
;
519 child_sa_t
*child_sa
;
521 pthread_mutex_lock(&(this->mutex
));
523 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
524 while (iterator
->iterate(iterator
, (void**)&entry
))
526 if (wait_for_entry(this, entry
))
528 /* look for a child with such a reqid ... */
531 children
= entry
->ike_sa
->create_child_sa_iterator(entry
->ike_sa
);
532 while (children
->iterate(children
, (void**)&child_sa
))
534 if (child_sa
->get_reqid(child_sa
) == id
)
536 ike_sa
= entry
->ike_sa
;
540 children
->destroy(children
);
542 else /* ... or for a IKE_SA with such a unique id */
544 if (entry
->ike_sa
->get_unique_id(entry
->ike_sa
) == id
)
546 ike_sa
= entry
->ike_sa
;
549 /* got one, return */
552 entry
->checked_out
= TRUE
;
557 iterator
->destroy(iterator
);
558 pthread_mutex_unlock(&(this->mutex
));
560 charon
->bus
->set_sa(charon
->bus
, ike_sa
);
565 * Implementation of of ike_sa_manager.checkout_by_name.
567 static ike_sa_t
* checkout_by_name(private_ike_sa_manager_t
*this, char *name
,
570 iterator_t
*iterator
, *children
;
572 ike_sa_t
*ike_sa
= NULL
;
573 child_sa_t
*child_sa
;
575 pthread_mutex_lock(&(this->mutex
));
577 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
578 while (iterator
->iterate(iterator
, (void**)&entry
))
580 if (wait_for_entry(this, entry
))
582 /* look for a child with such a policy name ... */
585 children
= entry
->ike_sa
->create_child_sa_iterator(entry
->ike_sa
);
586 while (children
->iterate(children
, (void**)&child_sa
))
588 if (streq(child_sa
->get_name(child_sa
), name
))
590 ike_sa
= entry
->ike_sa
;
594 children
->destroy(children
);
596 else /* ... or for a IKE_SA with such a connection name */
598 if (streq(entry
->ike_sa
->get_name(entry
->ike_sa
), name
))
600 ike_sa
= entry
->ike_sa
;
603 /* got one, return */
606 entry
->checked_out
= TRUE
;
611 iterator
->destroy(iterator
);
612 pthread_mutex_unlock(&(this->mutex
));
614 charon
->bus
->set_sa(charon
->bus
, ike_sa
);
619 * Iterator hook for iterate, gets ike_sas instead of entries
621 static bool iterator_hook(private_ike_sa_manager_t
* this, entry_t
*in
,
624 /* check out entry */
625 if (wait_for_entry(this, in
))
634 * Implementation of ike_sa_manager_t.create_iterator.
636 static iterator_t
*create_iterator(private_ike_sa_manager_t
* this)
638 iterator_t
*iterator
= this->ike_sa_list
->create_iterator_locked(
639 this->ike_sa_list
, &this->mutex
);
640 /* register hook to iterator over ike_sas, not entries */
641 iterator
->set_iterator_hook(iterator
, (iterator_hook_t
*)iterator_hook
, this);
646 * Implementation of ike_sa_manager_t.checkin.
648 static status_t
checkin(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
)
650 /* to check the SA back in, we look for the pointer of the ike_sa
652 * We can't search by SPI's since the MAY have changed (e.g. on reception
653 * of a IKE_SA_INIT response). Updating of the SPI MAY be necessary...
657 ike_sa_id_t
*ike_sa_id
;
659 ike_sa_id
= ike_sa
->get_id(ike_sa
);
661 DBG2(DBG_MGR
, "checkin IKE_SA: %J", ike_sa_id
);
663 pthread_mutex_lock(&(this->mutex
));
665 /* look for the entry */
666 if (get_entry_by_sa(this, ike_sa
, &entry
) == SUCCESS
)
668 /* ike_sa_id must be updated */
669 entry
->ike_sa_id
->replace_values(entry
->ike_sa_id
, ike_sa
->get_id(ike_sa
));
670 /* signal waiting threads */
671 entry
->checked_out
= FALSE
;
672 DBG2(DBG_MGR
, "check-in of IKE_SA successful.");
673 pthread_cond_signal(&(entry
->condvar
));
678 DBG2(DBG_MGR
, "tried to check in nonexisting IKE_SA");
679 /* this SA is no more, this REALLY should not happen */
683 DBG2(DBG_MGR
, "%d IKE_SAs in manager now",
684 this->ike_sa_list
->get_count(this->ike_sa_list
));
685 pthread_mutex_unlock(&(this->mutex
));
687 charon
->bus
->set_sa(charon
->bus
, NULL
);
693 * Implementation of ike_sa_manager_t.checkin_and_destroy.
695 static status_t
checkin_and_destroy(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
)
697 /* deletion is a bit complex, we must garant that no thread is waiting for
699 * We take this SA from the list, and start signaling while threads
700 * are in the condvar.
704 ike_sa_id_t
*ike_sa_id
;
706 ike_sa_id
= ike_sa
->get_id(ike_sa
);
707 DBG2(DBG_MGR
, "checkin and destroy IKE_SA: %J", ike_sa_id
);
709 pthread_mutex_lock(&(this->mutex
));
711 if (get_entry_by_sa(this, ike_sa
, &entry
) == SUCCESS
)
713 /* drive out waiting threads, as we are in hurry */
714 entry
->driveout_waiting_threads
= TRUE
;
716 delete_entry(this, entry
);
718 DBG2(DBG_MGR
, "check-in and destroy of IKE_SA successful");
723 DBG2(DBG_MGR
, "tried to check-in and delete nonexisting IKE_SA");
727 pthread_mutex_unlock(&(this->mutex
));
728 charon
->bus
->set_sa(charon
->bus
, ike_sa
);
733 * Implementation of ike_sa_manager_t.get_half_open_count.
735 static int get_half_open_count(private_ike_sa_manager_t
*this, host_t
*ip
)
737 iterator_t
*iterator
;
741 pthread_mutex_lock(&(this->mutex
));
742 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
743 while (iterator
->iterate(iterator
, (void**)&entry
))
745 /* we check if we have a responder CONNECTING IKE_SA without checkout */
746 if (!entry
->ike_sa_id
->is_initiator(entry
->ike_sa_id
) &&
747 entry
->ike_sa
->get_state(entry
->ike_sa
) == IKE_CONNECTING
)
749 /* if we have a host, we have wait until no other uses the IKE_SA */
752 if (wait_for_entry(this, entry
) && ip
->ip_equals(ip
,
753 entry
->ike_sa
->get_other_host(entry
->ike_sa
)))
764 iterator
->destroy(iterator
);
766 pthread_mutex_unlock(&(this->mutex
));
771 * Implementation of ike_sa_manager_t.destroy.
773 static void destroy(private_ike_sa_manager_t
*this)
775 /* destroy all list entries */
776 linked_list_t
*list
= this->ike_sa_list
;
777 iterator_t
*iterator
;
780 pthread_mutex_lock(&(this->mutex
));
781 DBG2(DBG_MGR
, "going to destroy IKE_SA manager and all managed IKE_SA's");
782 /* Step 1: drive out all waiting threads */
783 DBG2(DBG_MGR
, "set driveout flags for all stored IKE_SA's");
784 iterator
= list
->create_iterator(list
, TRUE
);
785 while (iterator
->iterate(iterator
, (void**)&entry
))
787 /* do not accept new threads, drive out waiting threads */
788 entry
->driveout_new_threads
= TRUE
;
789 entry
->driveout_waiting_threads
= TRUE
;
791 DBG2(DBG_MGR
, "wait for all threads to leave IKE_SA's");
792 /* Step 2: wait until all are gone */
793 iterator
->reset(iterator
);
794 while (iterator
->iterate(iterator
, (void**)&entry
))
796 while (entry
->waiting_threads
)
799 pthread_cond_broadcast(&(entry
->condvar
));
800 /* go sleeping until they are gone */
801 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
804 DBG2(DBG_MGR
, "delete all IKE_SA's");
805 /* Step 3: initiate deletion of all IKE_SAs */
806 iterator
->reset(iterator
);
807 while (iterator
->iterate(iterator
, (void**)&entry
))
809 entry
->ike_sa
->delete(entry
->ike_sa
);
811 iterator
->destroy(iterator
);
813 DBG2(DBG_MGR
, "destroy all entries");
814 /* Step 4: destroy all entries */
815 list
->destroy_function(list
, (void*)entry_destroy
);
816 pthread_mutex_unlock(&(this->mutex
));
818 this->randomizer
->destroy(this->randomizer
);
824 * Described in header.
826 ike_sa_manager_t
*ike_sa_manager_create()
828 private_ike_sa_manager_t
*this = malloc_thing(private_ike_sa_manager_t
);
830 /* assign public functions */
831 this->public.destroy
= (void(*)(ike_sa_manager_t
*))destroy
;
832 this->public.checkout
= (ike_sa_t
*(*)(ike_sa_manager_t
*, ike_sa_id_t
*))checkout
;
833 this->public.checkout_by_peer
= (ike_sa_t
*(*)(ike_sa_manager_t
*,host_t
*,host_t
*,identification_t
*,identification_t
*))checkout_by_peer
;
834 this->public.checkout_by_id
= (ike_sa_t
*(*)(ike_sa_manager_t
*,u_int32_t
,bool))checkout_by_id
;
835 this->public.checkout_by_name
= (ike_sa_t
*(*)(ike_sa_manager_t
*,char*,bool))checkout_by_name
;
836 this->public.create_iterator
= (iterator_t
*(*)(ike_sa_manager_t
*))create_iterator
;
837 this->public.checkin
= (status_t(*)(ike_sa_manager_t
*,ike_sa_t
*))checkin
;
838 this->public.checkin_and_destroy
= (status_t(*)(ike_sa_manager_t
*,ike_sa_t
*))checkin_and_destroy
;
839 this->public.get_half_open_count
= (int(*)(ike_sa_manager_t
*,host_t
*))get_half_open_count
;
841 /* initialize private variables */
842 this->ike_sa_list
= linked_list_create();
843 pthread_mutex_init(&this->mutex
, NULL
);
844 this->randomizer
= randomizer_create();
846 return &this->public;