- code cleaned up
[strongswan.git] / Source / charon / sa / ike_sa_manager.c
1 /**
2 * @file ike_sa_manager.c
3 *
4 * @brief Implementation of ike_sa_mananger_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #include <pthread.h>
24 #include <string.h>
25
26 #include "ike_sa_manager.h"
27
28 #include <daemon.h>
29 #include <sa/ike_sa_id.h>
30 #include <utils/allocator.h>
31 #include <utils/logger.h>
32 #include <utils/logger_manager.h>
33 #include <utils/linked_list.h>
34
35 typedef struct ike_sa_entry_t ike_sa_entry_t;
36
37 /**
38 * An entry in the linked list, contains IKE_SA, locking and lookup data.
39 */
40 struct ike_sa_entry_t {
41 /**
42 * destructor, also destroys ike_sa
43 */
44 status_t (*destroy) (ike_sa_entry_t *this);
45 /**
46 * Number of threads waiting for this ike_sa
47 */
48 int waiting_threads;
49 /**
50 * condvar where threads can wait until it's free again
51 */
52 pthread_cond_t condvar;
53 /**
54 * is this ike_sa currently checked out?
55 */
56 bool checked_out;
57 /**
58 * Does this SA drives out new threads?
59 */
60 bool driveout_new_threads;
61 /**
62 * Does this SA drives out waiting threads?
63 */
64 bool driveout_waiting_threads;
65 /**
66 * identifiaction of ike_sa (SPIs)
67 */
68 ike_sa_id_t *ike_sa_id;
69 /**
70 * the contained ike_sa
71 */
72 ike_sa_t *ike_sa;
73 };
74
75 /**
76 * Implements ike_sa_entry_t.destroy.
77 */
78 static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
79 {
80 /* also destroy IKE SA */
81 this->ike_sa->destroy(this->ike_sa);
82 this->ike_sa_id->destroy(this->ike_sa_id);
83 allocator_free(this);
84 return SUCCESS;
85 }
86
87 /**
88 * @brief creates a new entry for the ike_sa list
89 *
90 * This constructor additionaly creates a new and empty SA.
91 *
92 * @param ike_sa_id the associated ike_sa_id_t, will be cloned
93 * @return created entry, with ike_sa and ike_sa_id
94 */
95 static ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id)
96 {
97 ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t);
98
99 /* destroy function */
100 this->destroy = ike_sa_entry_destroy;
101
102 this->waiting_threads = 0;
103 pthread_cond_init(&(this->condvar), NULL);
104
105 /* we set checkout flag when we really give it out */
106 this->checked_out = FALSE;
107 this->driveout_new_threads = FALSE;
108 this->driveout_waiting_threads = FALSE;
109
110 /* ike_sa_id is always cloned */
111 this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
112
113 /* create new ike_sa */
114 this->ike_sa = ike_sa_create(ike_sa_id);
115
116 return this;
117 }
118
119 typedef struct private_ike_sa_manager_t private_ike_sa_manager_t;
120
121 /**
122 * Additional private members to ike_sa_manager_t
123 */
124 struct private_ike_sa_manager_t {
125 /**
126 * Public members
127 */
128 ike_sa_manager_t public;
129
130 /**
131 * @brief get next spi
132 *
133 * we give out SPIs incremental.
134 *
135 * @param this the ike_sa_manager
136 * @return the next spi
137 */
138 u_int64_t (*get_next_spi) (private_ike_sa_manager_t *this);
139
140 /**
141 * @brief find the ike_sa_entry in the list by SPIs.
142 *
143 * This function simply iterates over the linked list. A hash-table
144 * would be more efficient when storing a lot of IKE_SAs...
145 *
146 * @param this the ike_sa_manager containing the list
147 * @param ike_sa_id id of the ike_sa, containing SPIs
148 * @param entry[out] pointer to set to the found entry
149 * @return
150 * - SUCCESS when found,
151 * - NOT_FOUND when no such ike_sa_id in list
152 */
153 status_t (*get_entry_by_id) (private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id, ike_sa_entry_t **entry);
154
155 /**
156 * @brief find the ike_sa_entry in the list by pointer to SA.
157 *
158 * This function simply iterates over the linked list. A hash-table
159 * would be more efficient when storing a lot of IKE_SAs...
160 *
161 * @param this the ike_sa_manager containing the list
162 * @param ike_sa pointer to the ike_sa
163 * @param entry[out] pointer to set to the found entry
164 * @return
165 * - SUCCESS when found,
166 * - NOT_FOUND when no such ike_sa_id in list
167 */
168 status_t (*get_entry_by_sa) (private_ike_sa_manager_t *this, ike_sa_t *ike_sa, ike_sa_entry_t **entry);
169
170 /**
171 * @brief delete an entry from the linked list
172 *
173 * @param this the ike_sa_manager containing the list
174 * @param entry entry to delete
175 * @return
176 * - SUCCESS when found,
177 * - NOT_FOUND when no such ike_sa_id in list
178 */
179 status_t (*delete_entry) (private_ike_sa_manager_t *this, ike_sa_entry_t *entry);
180
181 /**
182 * lock for exclusivly accessing the manager
183 */
184 pthread_mutex_t mutex;
185
186 /**
187 * Logger used for this IKE SA Manager
188 */
189 logger_t *logger;
190
191 /**
192 * Linked list with entries for the ike_sa
193 */
194 linked_list_t *ike_sa_list;
195
196 /**
197 * Next SPI, needed for incremental creation of SPIs
198 */
199 u_int64_t next_spi;
200 };
201
202 /**
203 * Implements private_ike_sa_manager_t.get_entry_by_id.
204 */
205 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)
206 {
207 linked_list_t *list = this->ike_sa_list;
208 iterator_t *iterator;
209 status_t status;
210
211 /* create iterator over list of ike_sa's */
212 iterator = list->create_iterator(list, TRUE);
213
214 /* default status */
215 status = NOT_FOUND;
216
217 while (iterator->has_next(iterator))
218 {
219 ike_sa_entry_t *current;
220
221 iterator->current(iterator, (void**)&current);
222 if (current->ike_sa_id->get_responder_spi(current->ike_sa_id) == 0)
223 {
224 /* seems to be a half ready ike_sa */
225 if ((current->ike_sa_id->get_initiator_spi(current->ike_sa_id) == ike_sa_id->get_initiator_spi(ike_sa_id))
226 && (ike_sa_id->is_initiator(ike_sa_id) == current->ike_sa_id->is_initiator(current->ike_sa_id)))
227 {
228 this->logger->log(this->logger,CONTROL | LEVEL2,"Found entry by initiator spi %d",ike_sa_id->get_initiator_spi(ike_sa_id));
229 *entry = current;
230 status = SUCCESS;
231 break;
232 }
233 }
234 else if (ike_sa_id->get_responder_spi(ike_sa_id) == 0)
235 {
236 if ((current->ike_sa_id->get_initiator_spi(current->ike_sa_id) == ike_sa_id->get_initiator_spi(ike_sa_id))
237 && (ike_sa_id->is_initiator(ike_sa_id) == current->ike_sa_id->is_initiator(current->ike_sa_id)))
238 {
239 this->logger->log(this->logger,CONTROL | LEVEL2,"Found entry by initiator spi %d",ike_sa_id->get_initiator_spi(ike_sa_id));
240 *entry = current;
241 status = SUCCESS;
242 break;
243 }
244 }
245 if (current->ike_sa_id->equals(current->ike_sa_id, ike_sa_id))
246 {
247 this->logger->log(this->logger,CONTROL | LEVEL2,"Found entry by full ID");
248 *entry = current;
249 status = SUCCESS;
250 break;
251 }
252 }
253
254 iterator->destroy(iterator);
255 return status;
256 }
257
258 /**
259 * Implements private_ike_sa_manager_t.get_entry_by_sa.
260 */
261 static status_t get_entry_by_sa(private_ike_sa_manager_t *this, ike_sa_t *ike_sa, ike_sa_entry_t **entry)
262 {
263 linked_list_t *list = this->ike_sa_list;
264 iterator_t *iterator;
265 status_t status;
266
267 iterator = list->create_iterator(list, TRUE);
268
269 /* default status */
270 status = NOT_FOUND;
271
272 while (iterator->has_next(iterator))
273 {
274 ike_sa_entry_t *current;
275 iterator->current(iterator, (void**)&current);
276 /* only pointers are compared */
277 if (current->ike_sa == ike_sa)
278 {
279 this->logger->log(this->logger,CONTROL | LEVEL2,"Found entry by pointer");
280 *entry = current;
281 status = SUCCESS;
282 break;
283 }
284 }
285 iterator->destroy(iterator);
286
287 return status;
288 }
289
290 /**
291 * Implements private_ike_sa_manager_s.delete_entry.
292 */
293 static status_t delete_entry(private_ike_sa_manager_t *this, ike_sa_entry_t *entry)
294 {
295 linked_list_t *list = this->ike_sa_list;
296 iterator_t *iterator;
297 status_t status;
298
299 iterator = list->create_iterator(list, TRUE);
300
301 status = NOT_FOUND;
302
303 while (iterator->has_next(iterator))
304 {
305 ike_sa_entry_t *current;
306 iterator->current(iterator, (void**)&current);
307 if (current == entry)
308 {
309 this->logger->log(this->logger,CONTROL | LEVEL2,"Found entry by pointer. Going to delete it.");
310 iterator->remove(iterator);
311 entry->destroy(entry);
312 status = SUCCESS;
313 break;
314 }
315 }
316 iterator->destroy(iterator);
317 return status;
318 }
319
320
321 /**
322 * Implements private_ike_sa_manager_t.get_next_spi.
323 */
324 static u_int64_t get_next_spi(private_ike_sa_manager_t *this)
325 {
326 this->next_spi++;
327 if (this->next_spi == 0) {
328 /* TODO handle overflow,
329 * delete all SAs or so
330 */
331 }
332 return this->next_spi;
333 }
334
335 /**
336 * Implementation of ike_sa_manager.create_and_checkout.
337 */
338 static void create_and_checkout(private_ike_sa_manager_t *this,ike_sa_t **ike_sa)
339 {
340 u_int64_t initiator_spi;
341 ike_sa_entry_t *new_ike_sa_entry;
342 ike_sa_id_t *new_ike_sa_id;
343
344 initiator_spi = this->get_next_spi(this);
345 new_ike_sa_id = ike_sa_id_create(0, 0, TRUE);
346 new_ike_sa_id->set_initiator_spi(new_ike_sa_id, initiator_spi);
347
348 /* create entry */
349 new_ike_sa_entry = ike_sa_entry_create(new_ike_sa_id);
350 new_ike_sa_id->destroy(new_ike_sa_id);
351
352 /* each access is locked */
353 pthread_mutex_lock(&(this->mutex));
354
355 this->ike_sa_list->insert_last(this->ike_sa_list, new_ike_sa_entry);
356
357 /* check ike_sa out */
358 this->logger->log(this->logger,CONTROL | LEVEL1 ,"New IKE_SA created and added to list of known IKE_SA's");
359 new_ike_sa_entry->checked_out = TRUE;
360 *ike_sa = new_ike_sa_entry->ike_sa;
361
362 pthread_mutex_unlock(&(this->mutex));
363 }
364
365 /**
366 * Implementation of ike_sa_manager.checkout.
367 */
368 static status_t checkout(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id, ike_sa_t **ike_sa)
369 {
370 bool responder_spi_set;
371 bool initiator_spi_set;
372 bool original_initiator;
373 status_t retval;
374
375 /* each access is locked */
376 pthread_mutex_lock(&(this->mutex));
377
378 responder_spi_set = (FALSE != ike_sa_id->get_responder_spi(ike_sa_id));
379 initiator_spi_set = (FALSE != ike_sa_id->get_initiator_spi(ike_sa_id));
380 original_initiator = ike_sa_id->is_initiator(ike_sa_id);
381
382 if ((initiator_spi_set && responder_spi_set) ||
383 ((initiator_spi_set && !responder_spi_set) && (original_initiator)))
384 {
385 /* we SHOULD have an IKE_SA for these SPIs in the list,
386 * if not, we can't handle the request...
387 */
388 ike_sa_entry_t *entry;
389 /* look for the entry */
390 if (this->get_entry_by_id(this, ike_sa_id, &entry) == SUCCESS)
391 {
392 /* can we give this ike_sa out to new requesters?*/
393 if (entry->driveout_new_threads)
394 {
395 this->logger->log(this->logger,CONTROL|LEVEL1,"Drive out new thread for existing IKE_SA");
396 /* no we can't */
397 retval = NOT_FOUND;
398 }
399 else
400 {
401 /* is this IKE_SA already checked out ??
402 * are we welcome to get this SA ? */
403 while (entry->checked_out && !entry->driveout_waiting_threads)
404 {
405 /* so wait until we can get it for us.
406 * we register us as waiting.
407 */
408 entry->waiting_threads++;
409 pthread_cond_wait(&(entry->condvar), &(this->mutex));
410 entry->waiting_threads--;
411 }
412
413 /* hm, a deletion request forbids us to get this SA, go home */
414 if (entry->driveout_waiting_threads)
415 {
416 /* we must signal here, others are interested that we leave */
417 pthread_cond_signal(&(entry->condvar));
418 this->logger->log(this->logger,CONTROL|LEVEL1,"Drive out waiting thread for existing IKE_SA");
419 retval = NOT_FOUND;
420 }
421 else
422 {
423 this->logger->log(this->logger,CONTROL|LEVEL2,"IKE SA successfully checked out");
424 /* ok, this IKE_SA is finally ours */
425 entry->checked_out = TRUE;
426 *ike_sa = entry->ike_sa;
427 /* DON'T use return, we must unlock the mutex! */
428 retval = SUCCESS;
429 }
430 }
431 }
432 else
433 {
434 this->logger->log(this->logger,ERROR | LEVEL1,"IKE SA not stored in known IKE_SA list");
435 /* looks like there is no such IKE_SA, better luck next time... */
436 /* DON'T use return, we must unlock the mutex! */
437 retval = NOT_FOUND;
438 }
439 }
440 else if ((initiator_spi_set && !responder_spi_set) && (!original_initiator))
441 {
442 /* an IKE_SA_INIT from an another endpoint,
443 * he is the initiator.
444 * For simplicity, we do NOT check for retransmitted
445 * IKE_SA_INIT-Requests here, so EVERY single IKE_SA_INIT-
446 * Request (even a retransmitted one) will result in a
447 * IKE_SA. This could be improved...
448 */
449 u_int64_t responder_spi;
450 ike_sa_entry_t *new_ike_sa_entry;
451
452
453 /* set SPIs, we are the responder */
454 responder_spi = this->get_next_spi(this);
455
456 /* we also set arguments spi, so its still valid */
457 ike_sa_id->set_responder_spi(ike_sa_id, responder_spi);
458
459 /* create entry */
460 new_ike_sa_entry = ike_sa_entry_create(ike_sa_id);
461
462 this->ike_sa_list->insert_last(this->ike_sa_list, new_ike_sa_entry);
463
464 /* check ike_sa out */
465 this->logger->log(this->logger,CONTROL | LEVEL1 ,"IKE_SA added to list of known IKE_SA's");
466 new_ike_sa_entry->checked_out = TRUE;
467 *ike_sa = new_ike_sa_entry->ike_sa;
468
469 retval = CREATED;
470 }
471 else
472 {
473 /* responder set, initiator not: here is something seriously wrong! */
474 this->logger->log(this->logger,ERROR | LEVEL1, "Invalid IKE_SA SPI's");
475 /* DON'T use return, we must unlock the mutex! */
476 retval = INVALID_ARG;
477 }
478
479 pthread_mutex_unlock(&(this->mutex));
480 /* OK, unlocked... */
481 return retval;
482 }
483
484 /**
485 * Implements ike_sa_manager_t.checkin.
486 */
487 static status_t checkin(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
488 {
489 /* to check the SA back in, we look for the pointer of the ike_sa
490 * in all entries.
491 * We can't search by SPI's since the MAY have changed (e.g. on reception
492 * of a IKE_SA_INIT response). Updating of the SPI MAY be necessary...
493 */
494 status_t retval;
495 ike_sa_entry_t *entry;
496
497 pthread_mutex_lock(&(this->mutex));
498
499 /* look for the entry */
500 if (this->get_entry_by_sa(this, ike_sa, &entry) == SUCCESS)
501 {
502 /* ike_sa_id must be updated */
503 entry->ike_sa_id->replace_values(entry->ike_sa_id, ike_sa->get_id(ike_sa));
504 /* signal waiting threads */
505 entry->checked_out = FALSE;
506 this->logger->log(this->logger,CONTROL | LEVEL1,"Checkin of IKE_SA successful.");
507 pthread_cond_signal(&(entry->condvar));
508 retval = SUCCESS;
509 }
510 else
511 {
512 this->logger->log(this->logger,ERROR,"Fatal Error: Tried to checkin nonexisting IKE_SA");
513 /* this SA is no more, this RELEVEL3Y should not happen */
514 retval = NOT_FOUND;
515 }
516 pthread_mutex_unlock(&(this->mutex));
517 return retval;
518 }
519
520
521 /**
522 * Implements ike_sa_manager_t.checkin_and_delete.
523 */
524 static status_t checkin_and_delete(private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
525 {
526 /* deletion is a bit complex, we must garant that no thread is waiting for
527 * this SA.
528 * We take this SA from the list, and start signaling while threads
529 * are in the condvar.
530 */
531 ike_sa_entry_t *entry;
532 status_t retval;
533
534 pthread_mutex_lock(&(this->mutex));
535
536 if (this->get_entry_by_sa(this, ike_sa, &entry) == SUCCESS)
537 {
538 /* mark it, so now new threads can acquire this SA */
539 entry->driveout_new_threads = TRUE;
540 /* additionaly, drive out waiting threads */
541 entry->driveout_waiting_threads = TRUE;
542
543 /* wait until all workers have done their work */
544 while (entry->waiting_threads > 0)
545 {
546 /* let the other threads do some work*/
547 pthread_cond_signal(&(entry->condvar));
548 /* and the nice thing, they will wake us again when their work is done */
549 pthread_cond_wait(&(entry->condvar), &(this->mutex));
550 }
551 /* ok, we are alone now, no threads waiting in the entry's condvar */
552 this->delete_entry(this, entry);
553 this->logger->log(this->logger,CONTROL | LEVEL1,"Checkin and delete of IKE_SA successful");
554 retval = SUCCESS;
555 }
556 else
557 {
558 this->logger->log(this->logger,ERROR,"Fatal Error: Tried to checkin and delete nonexisting IKE_SA");
559 retval = NOT_FOUND;
560 }
561
562 pthread_mutex_unlock(&(this->mutex));
563 return retval;
564 }
565
566 /**
567 * Implements ike_sa_manager_t.delete.
568 */
569 static status_t delete(private_ike_sa_manager_t *this, ike_sa_id_t *ike_sa_id)
570 {
571 /* deletion is a bit complex, we must garant that no thread is waiting for
572 * this SA.
573 * We take this SA from the list, and start signaling while threads
574 * are in the condvar.
575 */
576 ike_sa_entry_t *entry;
577 status_t retval;
578
579 pthread_mutex_lock(&(this->mutex));
580
581 if (this->get_entry_by_id(this, ike_sa_id, &entry) == SUCCESS)
582 {
583 /* mark it, so now new threads can acquire this SA */
584 entry->driveout_new_threads = TRUE;
585
586 /* wait until all workers have done their work */
587 while (entry->waiting_threads)
588 {
589 /* wake up all */
590 pthread_cond_signal(&(entry->condvar));
591 /* and the nice thing, they will wake us again when their work is done */
592 pthread_cond_wait(&(entry->condvar), &(this->mutex));
593 }
594 /* ok, we are alone now, no threads waiting in the entry's condvar */
595 this->delete_entry(this, entry);
596 this->logger->log(this->logger,CONTROL | LEVEL1,"Delete of IKE_SA successful");
597 retval = SUCCESS;
598 }
599 else
600 {
601 this->logger->log(this->logger,ERROR,"Fatal Error: Tried to delete nonexisting IKE_SA");
602 retval = NOT_FOUND;
603 }
604
605 pthread_mutex_unlock(&(this->mutex));
606 return retval;
607 }
608
609 /**
610 * Implements ike_sa_manager_t.destroy.
611 */
612 static void destroy(private_ike_sa_manager_t *this)
613 {
614 /* destroy all list entries */
615 linked_list_t *list = this->ike_sa_list;
616 iterator_t *iterator;
617 ike_sa_entry_t *entry;
618
619 pthread_mutex_lock(&(this->mutex));
620
621 this->logger->log(this->logger,CONTROL | LEVEL1,"Going to destroy IKE_SA manager and all managed IKE_SA's");
622
623 /* Step 1: drive out all waiting threads */
624 iterator = list->create_iterator(list, TRUE);
625
626 this->logger->log(this->logger,CONTROL | LEVEL2,"Set driveout flags for all stored IKE_SA's");
627 while (iterator->has_next(iterator))
628 {
629 iterator->current(iterator, (void**)&entry);
630 /* do not accept new threads, drive out waiting threads */
631 entry->driveout_new_threads = TRUE;
632 entry->driveout_waiting_threads = TRUE;
633 }
634
635 this->logger->log(this->logger,CONTROL | LEVEL2,"Wait for all threads to leave IKE_SA's");
636 /* Step 2: wait until all are gone */
637 iterator->reset(iterator);
638 while (iterator->has_next(iterator))
639 {
640 iterator->current(iterator, (void**)&entry);
641 while (entry->waiting_threads)
642 {
643 /* wake up all */
644 pthread_cond_signal(&(entry->condvar));
645 /* go sleeping until they are gone */
646 pthread_cond_wait(&(entry->condvar), &(this->mutex));
647 }
648 }
649 this->logger->log(this->logger,CONTROL | LEVEL2,"Delete all IKE_SA's");
650 /* Step 3: delete all entries */
651 iterator->destroy(iterator);
652
653 while (list->get_count(list) > 0)
654 {
655 list->get_first(list, (void**)&entry);
656 this->delete_entry(this, entry);
657 }
658 list->destroy(list);
659 this->logger->log(this->logger,CONTROL | LEVEL2,"IKE_SA's deleted");
660 pthread_mutex_unlock(&(this->mutex));
661
662 /* destroy logger at end */
663 charon->logger_manager->destroy_logger(charon->logger_manager,this->logger);
664
665 allocator_free(this);
666 }
667
668 /*
669 * Described in header
670 */
671 ike_sa_manager_t *ike_sa_manager_create()
672 {
673 private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t);
674
675 /* assign public functions */
676 this->public.destroy = (void(*)(ike_sa_manager_t*))destroy;
677 this->public.create_and_checkout = (void(*)(ike_sa_manager_t*, ike_sa_t **sa))create_and_checkout;
678 this->public.checkout = (status_t(*)(ike_sa_manager_t*, ike_sa_id_t *sa_id, ike_sa_t **sa))checkout;
679 this->public.checkin = (status_t(*)(ike_sa_manager_t*, ike_sa_t *sa))checkin;
680 this->public.delete = (status_t(*)(ike_sa_manager_t*, ike_sa_id_t *sa_id))delete;
681 this->public.checkin_and_delete = (status_t(*)(ike_sa_manager_t*, ike_sa_t *ike_sa))checkin_and_delete;
682
683 /* initialize private functions */
684 this->get_next_spi = get_next_spi;
685 this->get_entry_by_sa = get_entry_by_sa;
686 this->get_entry_by_id = get_entry_by_id;
687 this->delete_entry = delete_entry;
688
689 /* initialize private variables */
690 this->logger = charon->logger_manager->create_logger(charon->logger_manager,IKE_SA_MANAGER,NULL);
691
692 this->ike_sa_list = linked_list_create();
693
694 pthread_mutex_init(&(this->mutex), NULL);
695
696 this->next_spi = 0;
697
698 return (ike_sa_manager_t*)this;
699 }