Initialize TKM client library in tkm.c
This commit is contained in:
committed by
Tobias Brunner
parent
559fe48c50
commit
3d2746309e
@@ -32,7 +32,7 @@
|
|||||||
#include <utils/backtrace.h>
|
#include <utils/backtrace.h>
|
||||||
#include <threading/thread.h>
|
#include <threading/thread.h>
|
||||||
|
|
||||||
#include <tkm/client.h>
|
#include "tkm.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PID file, in which charon-tkm stores its process id
|
* PID file, in which charon-tkm stores its process id
|
||||||
@@ -294,8 +294,12 @@ int main(int argc, char *argv[])
|
|||||||
goto deinit;
|
goto deinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize TKM client lib */
|
/* initialize TKM client */
|
||||||
tkmlib_init();
|
if (!tkm_init())
|
||||||
|
{
|
||||||
|
DBG1(DBG_DMN, "init of TKM client failed - aborting %s", dmn_name);
|
||||||
|
goto deinit;
|
||||||
|
}
|
||||||
|
|
||||||
/* add handler for SEGV and ILL,
|
/* add handler for SEGV and ILL,
|
||||||
* INT and TERM are handled by sigwait() in run() */
|
* INT and TERM are handled by sigwait() in run() */
|
||||||
@@ -320,11 +324,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
unlink_pidfile();
|
unlink_pidfile();
|
||||||
status = 0;
|
status = 0;
|
||||||
tkmlib_final();
|
|
||||||
|
|
||||||
deinit:
|
deinit:
|
||||||
libcharon_deinit();
|
libcharon_deinit();
|
||||||
libhydra_deinit();
|
libhydra_deinit();
|
||||||
library_deinit();
|
library_deinit();
|
||||||
|
tkm_deinit();
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,13 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <tkm/client.h>
|
||||||
|
#include <tkm/constants.h>
|
||||||
|
|
||||||
#include "tkm.h"
|
#include "tkm.h"
|
||||||
|
|
||||||
|
#define IKE_SOCKET "/tmp/tkm.rpc.ike"
|
||||||
|
|
||||||
typedef struct private_tkm_t private_tkm_t;
|
typedef struct private_tkm_t private_tkm_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +46,20 @@ bool tkm_init()
|
|||||||
{
|
{
|
||||||
private_tkm_t *this;
|
private_tkm_t *this;
|
||||||
|
|
||||||
|
/* initialize TKM client library */
|
||||||
|
tkmlib_init();
|
||||||
|
if (ike_init(IKE_SOCKET) != TKM_OK)
|
||||||
|
{
|
||||||
|
tkmlib_final();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ike_tkm_reset() != TKM_OK)
|
||||||
|
{
|
||||||
|
tkmlib_final();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.idmgr = tkm_id_manager_create(),
|
.idmgr = tkm_id_manager_create(),
|
||||||
@@ -62,6 +81,8 @@ void tkm_deinit()
|
|||||||
}
|
}
|
||||||
private_tkm_t *this = (private_tkm_t*)tkm;
|
private_tkm_t *this = (private_tkm_t*)tkm;
|
||||||
this->public.idmgr->destroy(this->public.idmgr);
|
this->public.idmgr->destroy(this->public.idmgr);
|
||||||
|
|
||||||
|
tkmlib_final();
|
||||||
free(this);
|
free(this);
|
||||||
tkm = NULL;
|
tkm = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,17 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include "tkm.h"
|
||||||
|
|
||||||
#include "test_runner.h"
|
#include "test_runner.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
if (!tkm_init())
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Could not connect to TKM, aborting tests\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
int number_failed;
|
int number_failed;
|
||||||
Suite *s = suite_create("TKM tests");
|
Suite *s = suite_create("TKM tests");
|
||||||
suite_add_tcase(s, make_id_manager_tests());
|
suite_add_tcase(s, make_id_manager_tests());
|
||||||
@@ -30,6 +35,7 @@ int main(void)
|
|||||||
srunner_run_all(sr, CK_NORMAL);
|
srunner_run_all(sr, CK_NORMAL);
|
||||||
number_failed = srunner_ntests_failed(sr);
|
number_failed = srunner_ntests_failed(sr);
|
||||||
|
|
||||||
|
tkm_deinit();
|
||||||
srunner_free(sr);
|
srunner_free(sr);
|
||||||
|
|
||||||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|||||||
Reference in New Issue
Block a user