Introduce TKM specific charon daemon (charon-tkm)
[strongswan.git] / src / charon-tkm / src / tkm / tkm.c
1 /*
2 * Copyright (C) 2012 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
4 * Hochschule fuer Technik Rapperswil
5 *
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>.
10 *
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
14 * for more details.
15 */
16
17 #include "tkm.h"
18
19 typedef struct private_tkm_t private_tkm_t;
20
21 /**
22 * Private additions to tkm_t.
23 */
24 struct private_tkm_t {
25
26 /**
27 * Public members of tkm_t.
28 */
29 tkm_t public;
30 };
31
32 /**
33 * Single instance of tkm_t.
34 */
35 tkm_t *tkm = NULL;
36
37 /**
38 * Described in header.
39 */
40 bool tkm_init()
41 {
42 private_tkm_t *this;
43
44 INIT(this,
45 .public = {
46 .idmgr = tkm_id_manager_create(),
47 },
48 );
49 tkm = &this->public;
50
51 return TRUE;
52 }
53
54 /**
55 * Described in header.
56 */
57 void tkm_deinit()
58 {
59 if (!tkm)
60 {
61 return;
62 }
63 private_tkm_t *this = (private_tkm_t*)tkm;
64 this->public.idmgr->destroy(this->public.idmgr);
65 free(this);
66 tkm = NULL;
67 }