revert to standard TNCC/TNCS Initialization function
[strongswan.git] / src / libcharon / plugins / tnc_imc / tnc_imc_plugin.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "tnc_imc_plugin.h"
17
18 #include <libtnctncc.h>
19
20 #include <daemon.h>
21
22 METHOD(plugin_t, destroy, void,
23 tnc_imc_plugin_t *this)
24 {
25 libtnc_tncc_Terminate();
26 free(this);
27 }
28
29 /*
30 * see header file
31 */
32 plugin_t *tnc_imc_plugin_create()
33 {
34 char *tnc_config, *pref_lang;
35 tnc_imc_plugin_t *this;
36
37 INIT(this,
38 .plugin = {
39 .destroy = _destroy,
40 },
41 );
42
43 pref_lang = lib->settings->get_str(lib->settings,
44 "charon.plugins.tnc-imc.preferred_language", "en");
45 tnc_config = lib->settings->get_str(lib->settings,
46 "charon.plugins.tnc-imc.tnc_config", "/etc/tnc_config");
47
48 if (libtnc_tncc_Initialize(tnc_config) != TNC_RESULT_SUCCESS)
49 {
50 free(this);
51 DBG1(DBG_IKE, "TNC IMC initialization failed");
52 return NULL;
53 }
54
55 return &this->plugin;
56 }
57