2 * @file ike_sa_manager.c
4 * @brief Implementation of ike_sa_mananger_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 #include "ike_sa_manager.h"
29 #include <sa/ike_sa_id.h>
30 #include <utils/logger.h>
31 #include <utils/logger_manager.h>
32 #include <utils/linked_list.h>
34 typedef struct ike_sa_entry_t ike_sa_entry_t
;
37 * An entry in the linked list, contains IKE_SA, locking and lookup data.
39 struct ike_sa_entry_t
{
41 * Destructor, also destroys associated ike_sa_t object.
43 status_t (*destroy
) (ike_sa_entry_t
*this);
46 * Number of threads waiting for this ike_sa_t object.
51 * Condvar where threads can wait until ike_sa_t object is free for use again.
53 pthread_cond_t condvar
;
56 * Is this ike_sa currently checked out?
61 * Does this SA drives out new threads?
63 bool driveout_new_threads
;
66 * Does this SA drives out waiting threads?
68 bool driveout_waiting_threads
;
71 * Identifiaction of an IKE_SA (SPIs).
73 ike_sa_id_t
*ike_sa_id
;
76 * The contained ike_sa_t object.
82 * Implementation of ike_sa_entry_t.destroy.
84 static status_t
ike_sa_entry_destroy(ike_sa_entry_t
*this)
86 /* also destroy IKE SA */
87 this->ike_sa
->destroy(this->ike_sa
);
88 this->ike_sa_id
->destroy(this->ike_sa_id
);
94 * @brief Creates a new entry for the ike_sa_t list.
96 * This constructor additionaly creates a new and empty SA.
98 * @param ike_sa_id The associated ike_sa_id_t, will be cloned
99 * @return ike_sa_entry_t object
101 static ike_sa_entry_t
*ike_sa_entry_create(ike_sa_id_t
*ike_sa_id
)
103 ike_sa_entry_t
*this = malloc_thing(ike_sa_entry_t
);
105 /* destroy function */
106 this->destroy
= ike_sa_entry_destroy
;
108 this->waiting_threads
= 0;
109 pthread_cond_init(&(this->condvar
), NULL
);
111 /* we set checkout flag when we really give it out */
112 this->checked_out
= FALSE
;
113 this->driveout_new_threads
= FALSE
;
114 this->driveout_waiting_threads
= FALSE
;
116 /* ike_sa_id is always cloned */
117 this->ike_sa_id
= ike_sa_id
->clone(ike_sa_id
);
119 /* create new ike_sa */
120 this->ike_sa
= ike_sa_create(ike_sa_id
);
126 typedef struct private_ike_sa_manager_t private_ike_sa_manager_t
;
129 * Additional private members of ike_sa_manager_t.
131 struct private_ike_sa_manager_t
{
133 * Public interface of ike_sa_manager_t.
135 ike_sa_manager_t
public;
138 * @brief Get next spi.
140 * We give out SPIs incremental starting at 1.
142 * @param this the ike_sa_manager
143 * @return the next spi
145 u_int64_t (*get_next_spi
) (private_ike_sa_manager_t
*this);
148 * @brief Find the ike_sa_entry_t object in the list by SPIs.
150 * This function simply iterates over the linked list. A hash-table
151 * would be more efficient when storing a lot of IKE_SAs...
153 * @param this calling object
154 * @param ike_sa_id id of the ike_sa, containing SPIs
155 * @param[out] entry pointer to set to the found entry
157 * - SUCCESS when found,
158 * - NOT_FOUND when no such ike_sa_id in list
160 status_t (*get_entry_by_id
) (private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
, ike_sa_entry_t
**entry
);
163 * @brief Find the ike_sa_entry_t in the list by pointer to SA.
165 * This function simply iterates over the linked list. A hash-table
166 * would be more efficient when storing a lot of IKE_SAs...
168 * @param this calling object
169 * @param ike_sa pointer to the ike_sa
170 * @param[out] entry pointer to set to the found entry
172 * - SUCCESS when found,
173 * - NOT_FOUND when no such ike_sa_id in list
175 status_t (*get_entry_by_sa
) (private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
, ike_sa_entry_t
**entry
);
178 * @brief Felete an entry from the linked list.
180 * @param this calling object
181 * @param entry entry to delete
183 * - SUCCESS when found,
184 * - NOT_FOUND when no such ike_sa_id in list
186 status_t (*delete_entry
) (private_ike_sa_manager_t
*this, ike_sa_entry_t
*entry
);
189 * Lock for exclusivly accessing the manager.
191 pthread_mutex_t mutex
;
194 * Logger used for this IKE SA Manager.
199 * Linked list with entries for the ike_sa_t objects.
201 linked_list_t
*ike_sa_list
;
204 * Next SPI, needed for incremental creation of SPIs.
210 * Implementation of private_ike_sa_manager_t.get_entry_by_id.
212 static status_t
get_entry_by_id(private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
, ike_sa_entry_t
**entry
)
214 linked_list_t
*list
= this->ike_sa_list
;
215 iterator_t
*iterator
;
218 /* create iterator over list of ike_sa's */
219 iterator
= list
->create_iterator(list
, TRUE
);
224 while (iterator
->has_next(iterator
))
226 ike_sa_entry_t
*current
;
228 iterator
->current(iterator
, (void**)¤t
);
229 if (current
->ike_sa_id
->get_responder_spi(current
->ike_sa_id
) == 0)
231 /* seems to be a half ready ike_sa */
232 if ((current
->ike_sa_id
->get_initiator_spi(current
->ike_sa_id
) == ike_sa_id
->get_initiator_spi(ike_sa_id
))
233 && (ike_sa_id
->is_initiator(ike_sa_id
) == current
->ike_sa_id
->is_initiator(current
->ike_sa_id
)))
235 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Found entry by initiator spi %d",ike_sa_id
->get_initiator_spi(ike_sa_id
));
241 else if (ike_sa_id
->get_responder_spi(ike_sa_id
) == 0)
243 if ((current
->ike_sa_id
->get_initiator_spi(current
->ike_sa_id
) == ike_sa_id
->get_initiator_spi(ike_sa_id
))
244 && (ike_sa_id
->is_initiator(ike_sa_id
) == current
->ike_sa_id
->is_initiator(current
->ike_sa_id
)))
246 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Found entry by initiator spi %d",ike_sa_id
->get_initiator_spi(ike_sa_id
));
252 if (current
->ike_sa_id
->equals(current
->ike_sa_id
, ike_sa_id
))
254 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Found entry by full ID");
261 iterator
->destroy(iterator
);
266 * Implementation of private_ike_sa_manager_t.get_entry_by_sa.
268 static status_t
get_entry_by_sa(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
, ike_sa_entry_t
**entry
)
270 linked_list_t
*list
= this->ike_sa_list
;
271 iterator_t
*iterator
;
274 iterator
= list
->create_iterator(list
, TRUE
);
279 while (iterator
->has_next(iterator
))
281 ike_sa_entry_t
*current
;
282 iterator
->current(iterator
, (void**)¤t
);
283 /* only pointers are compared */
284 if (current
->ike_sa
== ike_sa
)
286 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Found entry by pointer");
292 iterator
->destroy(iterator
);
298 * Implementation of private_ike_sa_manager_s.delete_entry.
300 static status_t
delete_entry(private_ike_sa_manager_t
*this, ike_sa_entry_t
*entry
)
302 linked_list_t
*list
= this->ike_sa_list
;
303 iterator_t
*iterator
;
306 iterator
= list
->create_iterator(list
, TRUE
);
310 while (iterator
->has_next(iterator
))
312 ike_sa_entry_t
*current
;
313 iterator
->current(iterator
, (void**)¤t
);
314 if (current
== entry
)
316 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Found entry by pointer. Going to delete it.");
317 iterator
->remove(iterator
);
318 entry
->destroy(entry
);
323 iterator
->destroy(iterator
);
329 * Implementation of private_ike_sa_manager_t.get_next_spi.
331 static u_int64_t
get_next_spi(private_ike_sa_manager_t
*this)
334 if (this->next_spi
== 0) {
335 /* TODO handle overflow,
336 * delete all SAs or so
339 return this->next_spi
;
343 * Implementation of of ike_sa_manager.create_and_checkout.
345 static void create_and_checkout(private_ike_sa_manager_t
*this,ike_sa_t
**ike_sa
)
347 u_int64_t initiator_spi
;
348 ike_sa_entry_t
*new_ike_sa_entry
;
349 ike_sa_id_t
*new_ike_sa_id
;
351 initiator_spi
= this->get_next_spi(this);
352 new_ike_sa_id
= ike_sa_id_create(0, 0, TRUE
);
353 new_ike_sa_id
->set_initiator_spi(new_ike_sa_id
, initiator_spi
);
356 new_ike_sa_entry
= ike_sa_entry_create(new_ike_sa_id
);
357 new_ike_sa_id
->destroy(new_ike_sa_id
);
359 /* each access is locked */
360 pthread_mutex_lock(&(this->mutex
));
362 this->ike_sa_list
->insert_last(this->ike_sa_list
, new_ike_sa_entry
);
364 /* check ike_sa out */
365 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"New IKE_SA created and added to list of known IKE_SA's");
366 new_ike_sa_entry
->checked_out
= TRUE
;
367 *ike_sa
= new_ike_sa_entry
->ike_sa
;
369 pthread_mutex_unlock(&(this->mutex
));
373 * Implementation of of ike_sa_manager.checkout.
375 static status_t
checkout(private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
, ike_sa_t
**ike_sa
)
377 bool responder_spi_set
;
378 bool initiator_spi_set
;
379 bool original_initiator
;
382 /* each access is locked */
383 pthread_mutex_lock(&(this->mutex
));
385 responder_spi_set
= (FALSE
!= ike_sa_id
->get_responder_spi(ike_sa_id
));
386 initiator_spi_set
= (FALSE
!= ike_sa_id
->get_initiator_spi(ike_sa_id
));
387 original_initiator
= ike_sa_id
->is_initiator(ike_sa_id
);
389 if ((initiator_spi_set
&& responder_spi_set
) ||
390 ((initiator_spi_set
&& !responder_spi_set
) && (original_initiator
)))
392 /* we SHOULD have an IKE_SA for these SPIs in the list,
393 * if not, we can't handle the request...
395 ike_sa_entry_t
*entry
;
396 /* look for the entry */
397 if (this->get_entry_by_id(this, ike_sa_id
, &entry
) == SUCCESS
)
399 /* can we give this ike_sa out to new requesters?*/
400 if (entry
->driveout_new_threads
)
402 this->logger
->log(this->logger
,CONTROL
|LEVEL1
,"Drive out new thread for existing IKE_SA");
408 /* is this IKE_SA already checked out ??
409 * are we welcome to get this SA ? */
410 while (entry
->checked_out
&& !entry
->driveout_waiting_threads
)
412 /* so wait until we can get it for us.
413 * we register us as waiting.
415 entry
->waiting_threads
++;
416 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
417 entry
->waiting_threads
--;
420 /* hm, a deletion request forbids us to get this SA, go home */
421 if (entry
->driveout_waiting_threads
)
423 /* we must signal here, others are interested that we leave */
424 pthread_cond_signal(&(entry
->condvar
));
425 this->logger
->log(this->logger
,CONTROL
|LEVEL1
,"Drive out waiting thread for existing IKE_SA");
430 this->logger
->log(this->logger
,CONTROL
|LEVEL2
,"IKE SA successfully checked out");
431 /* ok, this IKE_SA is finally ours */
432 entry
->checked_out
= TRUE
;
433 *ike_sa
= entry
->ike_sa
;
434 /* DON'T use return, we must unlock the mutex! */
441 this->logger
->log(this->logger
,ERROR
| LEVEL1
,"IKE SA not stored in known IKE_SA list");
442 /* looks like there is no such IKE_SA, better luck next time... */
443 /* DON'T use return, we must unlock the mutex! */
447 else if ((initiator_spi_set
&& !responder_spi_set
) && (!original_initiator
))
449 /* an IKE_SA_INIT from an another endpoint,
450 * he is the initiator.
451 * For simplicity, we do NOT check for retransmitted
452 * IKE_SA_INIT-Requests here, so EVERY single IKE_SA_INIT-
453 * Request (even a retransmitted one) will result in a
454 * IKE_SA. This could be improved...
456 u_int64_t responder_spi
;
457 ike_sa_entry_t
*new_ike_sa_entry
;
460 /* set SPIs, we are the responder */
461 responder_spi
= this->get_next_spi(this);
463 /* we also set arguments spi, so its still valid */
464 ike_sa_id
->set_responder_spi(ike_sa_id
, responder_spi
);
467 new_ike_sa_entry
= ike_sa_entry_create(ike_sa_id
);
469 this->ike_sa_list
->insert_last(this->ike_sa_list
, new_ike_sa_entry
);
471 /* check ike_sa out */
472 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"IKE_SA added to list of known IKE_SA's");
473 new_ike_sa_entry
->checked_out
= TRUE
;
474 *ike_sa
= new_ike_sa_entry
->ike_sa
;
480 /* responder set, initiator not: here is something seriously wrong! */
481 this->logger
->log(this->logger
,ERROR
| LEVEL1
, "Invalid IKE_SA SPI's");
482 /* DON'T use return, we must unlock the mutex! */
483 retval
= INVALID_ARG
;
486 pthread_mutex_unlock(&(this->mutex
));
487 /* OK, unlocked... */
492 * Implementation of of ike_sa_manager.checkout_by_hosts.
494 static status_t
checkout_by_hosts(private_ike_sa_manager_t
*this, host_t
*me
, host_t
*other
, ike_sa_t
**ike_sa
)
496 iterator_t
*iterator
;
497 ike_sa_id_t
*ike_sa_id
= NULL
;
499 pthread_mutex_lock(&(this->mutex
));
501 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
502 while (iterator
->has_next(iterator
))
504 ike_sa_entry_t
*current
;
505 host_t
*sa_me
, *sa_other
;
507 iterator
->current(iterator
, (void**)¤t
);
508 sa_me
= current
->ike_sa
->get_my_host(current
->ike_sa
);
509 sa_other
= current
->ike_sa
->get_other_host(current
->ike_sa
);
511 /* one end may be default/any, but not both */
512 if (me
->is_default_route(me
))
514 if (other
->is_default_route(other
))
518 if (other
->equals(other
, sa_other
))
521 ike_sa_id
= current
->ike_sa_id
;
524 else if (other
->is_default_route(other
))
526 if (me
->equals(me
, sa_me
))
529 ike_sa_id
= current
->ike_sa_id
;
534 if (me
->equals(me
, sa_me
) && other
->equals(other
, sa_other
))
537 ike_sa_id
= current
->ike_sa_id
;
541 iterator
->destroy(iterator
);
542 pthread_mutex_unlock(&(this->mutex
));
546 /* checkout is done in the checkout function, since its rather complex */
547 return checkout(this, ike_sa_id
, ike_sa
);
553 * Implementation of ike_sa_manager_t.get_ike_sa_list.
555 linked_list_t
*get_ike_sa_list(private_ike_sa_manager_t
* this)
558 iterator_t
*iterator
;
560 pthread_mutex_lock(&(this->mutex
));
562 list
= linked_list_create();
563 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
564 while (iterator
->has_next(iterator
))
566 ike_sa_entry_t
*entry
;
567 iterator
->current(iterator
, (void**)&entry
);
568 list
->insert_last(list
, (void*)entry
->ike_sa_id
->clone(entry
->ike_sa_id
));
570 iterator
->destroy(iterator
);
572 pthread_mutex_unlock(&(this->mutex
));
577 * Implementation of ike_sa_manager_t.log_status.
579 static void log_status(private_ike_sa_manager_t
* this, logger_t
* logger
, char* name
)
581 iterator_t
*iterator
;
583 pthread_mutex_lock(&(this->mutex
));
585 iterator
= this->ike_sa_list
->create_iterator(this->ike_sa_list
, TRUE
);
586 while (iterator
->has_next(iterator
))
588 ike_sa_entry_t
*entry
;
589 iterator
->current(iterator
, (void**)&entry
);
590 entry
->ike_sa
->log_status(entry
->ike_sa
, logger
, name
);
592 iterator
->destroy(iterator
);
594 pthread_mutex_unlock(&(this->mutex
));
598 * Implementation of ike_sa_manager_t.checkin.
600 static status_t
checkin(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
)
602 /* to check the SA back in, we look for the pointer of the ike_sa
604 * We can't search by SPI's since the MAY have changed (e.g. on reception
605 * of a IKE_SA_INIT response). Updating of the SPI MAY be necessary...
608 ike_sa_entry_t
*entry
;
610 pthread_mutex_lock(&(this->mutex
));
612 /* look for the entry */
613 if (this->get_entry_by_sa(this, ike_sa
, &entry
) == SUCCESS
)
615 /* ike_sa_id must be updated */
616 entry
->ike_sa_id
->replace_values(entry
->ike_sa_id
, ike_sa
->get_id(ike_sa
));
617 /* signal waiting threads */
618 entry
->checked_out
= FALSE
;
619 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"Checkin of IKE_SA successful.");
620 pthread_cond_signal(&(entry
->condvar
));
625 this->logger
->log(this->logger
,ERROR
,"Fatal Error: Tried to checkin nonexisting IKE_SA");
626 /* this SA is no more, this REALLY should not happen */
629 pthread_mutex_unlock(&(this->mutex
));
635 * Implementation of ike_sa_manager_t.checkin_and_delete.
637 static status_t
checkin_and_delete(private_ike_sa_manager_t
*this, ike_sa_t
*ike_sa
)
639 /* deletion is a bit complex, we must garant that no thread is waiting for
641 * We take this SA from the list, and start signaling while threads
642 * are in the condvar.
644 ike_sa_entry_t
*entry
;
647 pthread_mutex_lock(&(this->mutex
));
649 if (this->get_entry_by_sa(this, ike_sa
, &entry
) == SUCCESS
)
651 /* mark it, so now new threads can acquire this SA */
652 entry
->driveout_new_threads
= TRUE
;
653 /* additionaly, drive out waiting threads */
654 entry
->driveout_waiting_threads
= TRUE
;
656 /* wait until all workers have done their work */
657 while (entry
->waiting_threads
> 0)
659 /* let the other threads do some work*/
660 pthread_cond_signal(&(entry
->condvar
));
661 /* and the nice thing, they will wake us again when their work is done */
662 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
664 /* ok, we are alone now, no threads waiting in the entry's condvar */
665 this->delete_entry(this, entry
);
666 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"Checkin and delete of IKE_SA successful");
671 this->logger
->log(this->logger
,ERROR
,"Fatal Error: Tried to checkin and delete nonexisting IKE_SA");
675 pthread_mutex_unlock(&(this->mutex
));
680 * Implementation of ike_sa_manager_t.delete.
682 static status_t
delete(private_ike_sa_manager_t
*this, ike_sa_id_t
*ike_sa_id
)
684 /* deletion is a bit complex, we must garant that no thread is waiting for
686 * We take this SA from the list, and start signaling while threads
687 * are in the condvar.
689 ike_sa_entry_t
*entry
;
692 pthread_mutex_lock(&(this->mutex
));
694 if (this->get_entry_by_id(this, ike_sa_id
, &entry
) == SUCCESS
)
696 /* mark it, so now new threads can acquire this SA */
697 entry
->driveout_new_threads
= TRUE
;
699 /* wait until all workers have done their work */
700 while (entry
->waiting_threads
)
703 pthread_cond_signal(&(entry
->condvar
));
704 /* and the nice thing, they will wake us again when their work is done */
705 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
707 /* ok, we are alone now, no threads waiting in the entry's condvar */
708 this->delete_entry(this, entry
);
709 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"Delete of IKE_SA successful");
714 this->logger
->log(this->logger
,ERROR
,"Fatal Error: Tried to delete nonexisting IKE_SA");
718 pthread_mutex_unlock(&(this->mutex
));
723 * Implementation of ike_sa_manager_t.destroy.
725 static void destroy(private_ike_sa_manager_t
*this)
727 /* destroy all list entries */
728 linked_list_t
*list
= this->ike_sa_list
;
729 iterator_t
*iterator
;
730 ike_sa_entry_t
*entry
;
732 pthread_mutex_lock(&(this->mutex
));
734 this->logger
->log(this->logger
,CONTROL
| LEVEL1
,"Going to destroy IKE_SA manager and all managed IKE_SA's");
736 /* Step 1: drive out all waiting threads */
737 iterator
= list
->create_iterator(list
, TRUE
);
739 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Set driveout flags for all stored IKE_SA's");
740 while (iterator
->has_next(iterator
))
742 iterator
->current(iterator
, (void**)&entry
);
743 /* do not accept new threads, drive out waiting threads */
744 entry
->driveout_new_threads
= TRUE
;
745 entry
->driveout_waiting_threads
= TRUE
;
748 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Wait for all threads to leave IKE_SA's");
749 /* Step 2: wait until all are gone */
750 iterator
->reset(iterator
);
751 while (iterator
->has_next(iterator
))
753 iterator
->current(iterator
, (void**)&entry
);
754 while (entry
->waiting_threads
)
757 pthread_cond_signal(&(entry
->condvar
));
758 /* go sleeping until they are gone */
759 pthread_cond_wait(&(entry
->condvar
), &(this->mutex
));
762 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"Delete all IKE_SA's");
763 /* Step 3: delete all entries */
764 iterator
->destroy(iterator
);
766 while (list
->get_count(list
) > 0)
768 list
->get_first(list
, (void**)&entry
);
769 this->delete_entry(this, entry
);
772 this->logger
->log(this->logger
,CONTROL
| LEVEL2
,"IKE_SA's deleted");
773 pthread_mutex_unlock(&(this->mutex
));
779 * Described in header.
781 ike_sa_manager_t
*ike_sa_manager_create()
783 private_ike_sa_manager_t
*this = malloc_thing(private_ike_sa_manager_t
);
785 /* assign public functions */
786 this->public.destroy
= (void(*)(ike_sa_manager_t
*))destroy
;
787 this->public.create_and_checkout
= (void(*)(ike_sa_manager_t
*,ike_sa_t
**))create_and_checkout
;
788 this->public.checkout
= (status_t(*)(ike_sa_manager_t
*, ike_sa_id_t
*,ike_sa_t
**))checkout
;
789 this->public.checkout_by_hosts
= (status_t(*)(ike_sa_manager_t
*,host_t
*,host_t
*,ike_sa_t
**))checkout_by_hosts
;
790 this->public.get_ike_sa_list
= (linked_list_t
*(*)(ike_sa_manager_t
*))get_ike_sa_list
;
791 this->public.log_status
= (void(*)(ike_sa_manager_t
*,logger_t
*,char*))log_status
;
792 this->public.checkin
= (status_t(*)(ike_sa_manager_t
*,ike_sa_t
*))checkin
;
793 this->public.delete = (status_t(*)(ike_sa_manager_t
*,ike_sa_id_t
*))delete;
794 this->public.checkin_and_delete
= (status_t(*)(ike_sa_manager_t
*,ike_sa_t
*))checkin_and_delete
;
796 /* initialize private functions */
797 this->get_next_spi
= get_next_spi
;
798 this->get_entry_by_sa
= get_entry_by_sa
;
799 this->get_entry_by_id
= get_entry_by_id
;
800 this->delete_entry
= delete_entry
;
802 /* initialize private variables */
803 this->logger
= logger_manager
->get_logger(logger_manager
, IKE_SA_MANAGER
);
805 this->ike_sa_list
= linked_list_create();
807 pthread_mutex_init(&(this->mutex
), NULL
);
811 return (ike_sa_manager_t
*)this;