2 * Copyright (C) 2012-2014 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
5 * Copyright (C) secunet Security Networks AG
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 #include <tkm/client.h>
21 #include <tkm/constants.h>
25 #define IKE_SOCKET "/tmp/tkm.rpc.ike"
26 #define EES_SOCKET "/tmp/tkm.rpc.ees"
28 typedef struct private_tkm_t private_tkm_t
;
30 extern result_type
ees_server_init(const char * const address
);
31 extern void ees_server_finalize(void);
32 extern void ehandler_init(void);
35 * Private additions to tkm_t.
37 struct private_tkm_t
{
40 * Public members of tkm_t.
46 * Single instance of tkm_t.
51 * Described in header.
56 active_requests_type max_requests
;
57 char *ikesock
, *eessock
;
60 /* initialize TKM client library */
64 ikesock
= lib
->settings
->get_str(lib
->settings
, "%s.ike_socket", IKE_SOCKET
,
66 if (ike_init(ikesock
) != TKM_OK
)
71 DBG1(DBG_DMN
, "connected to TKM via socket '%s'", ikesock
);
73 eessock
= lib
->settings
->get_str(lib
->settings
, "%s.ees_socket", EES_SOCKET
,
75 ees_server_init(eessock
);
76 DBG1(DBG_DMN
, "serving EES requests on socket '%s'", eessock
);
78 if (ike_tkm_reset() != TKM_OK
)
80 ees_server_finalize();
85 /* get limits from tkm */
86 if (ike_tkm_limits(&max_requests
, &limits
[TKM_CTX_NONCE
], &limits
[TKM_CTX_DH
],
87 &limits
[TKM_CTX_CC
], &limits
[TKM_CTX_AE
],
88 &limits
[TKM_CTX_ISA
], &limits
[TKM_CTX_ESA
]) != TKM_OK
)
90 ees_server_finalize();
97 .idmgr
= tkm_id_manager_create(limits
),
98 .chunk_map
= tkm_chunk_map_create(),
99 .sad
= tkm_kernel_sad_create(),
108 * Described in header.
116 private_tkm_t
*this = (private_tkm_t
*)tkm
;
117 this->public.idmgr
->destroy(this->public.idmgr
);
118 this->public.chunk_map
->destroy(this->public.chunk_map
);
119 this->public.sad
->destroy(this->public.sad
);
121 ees_server_finalize();