summaryrefslogtreecommitdiff
path: root/src/libimcv/imcv.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
commit6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (patch)
tree009fc492961e13860d2a4bc2de8caf2bbe2975e7 /src/libimcv/imcv.c
parentc83921a2b566aa9d55d8ccc7258f04fca6292ee6 (diff)
downloadvyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.tar.gz
vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.zip
Imported Upstream version 5.1.0
Diffstat (limited to 'src/libimcv/imcv.c')
-rw-r--r--src/libimcv/imcv.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/libimcv/imcv.c b/src/libimcv/imcv.c
index 6cee0ad8f..b5862daee 100644
--- a/src/libimcv/imcv.c
+++ b/src/libimcv/imcv.c
@@ -22,7 +22,9 @@
#include <syslog.h>
-#define IMCV_DEBUG_LEVEL 1
+#define IMCV_DEBUG_LEVEL 1
+#define IMCV_DEFAULT_POLICY_SCRIPT "ipsec _imv_policy"
+
/**
* PA-TNC attribute manager
@@ -30,6 +32,11 @@
pa_tnc_attr_manager_t *imcv_pa_tnc_attributes;
/**
+ * Global IMV database
+ */
+imv_database_t *imcv_db;
+
+/**
* Reference count for libimcv
*/
static refcount_t libimcv_ref = 0;
@@ -88,7 +95,7 @@ static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
/**
* Described in header.
*/
-bool libimcv_init(void)
+bool libimcv_init(bool is_imv)
{
/* initialize libstrongswan library only once */
if (lib)
@@ -117,8 +124,9 @@ bool libimcv_init(void)
dbg = imcv_dbg;
openlog("imcv", 0, LOG_DAEMON);
- if (!lib->plugins->load(lib->plugins, NULL,
- "sha1 sha2 random nonce gmp pubkey x509"))
+ if (!lib->plugins->load(lib->plugins,
+ lib->settings->get_str(lib->settings, "libimcv.load",
+ "random nonce gmp pubkey x509")))
{
library_deinit();
return FALSE;
@@ -128,12 +136,27 @@ bool libimcv_init(void)
if (libimcv_ref == 0)
{
+ char *uri, *script;
+
/* initialize the PA-TNC attribute manager */
imcv_pa_tnc_attributes = pa_tnc_attr_manager_create();
imcv_pa_tnc_attributes->add_vendor(imcv_pa_tnc_attributes, PEN_IETF,
ietf_attr_create_from_data, ietf_attr_names);
imcv_pa_tnc_attributes->add_vendor(imcv_pa_tnc_attributes, PEN_ITA,
ita_attr_create_from_data, ita_attr_names);
+
+ /* attach global IMV database */
+ if (is_imv)
+ {
+ uri = lib->settings->get_str(lib->settings,
+ "libimcv.database", NULL);
+ script = lib->settings->get_str(lib->settings,
+ "libimcv.policy_script", IMCV_DEFAULT_POLICY_SCRIPT);
+ if (uri)
+ {
+ imcv_db = imv_database_create(uri, script);
+ }
+ }
DBG1(DBG_LIB, "libimcv initialized");
}
ref_get(&libimcv_ref);
@@ -151,6 +174,8 @@ void libimcv_deinit(void)
imcv_pa_tnc_attributes->remove_vendor(imcv_pa_tnc_attributes, PEN_IETF);
imcv_pa_tnc_attributes->remove_vendor(imcv_pa_tnc_attributes, PEN_ITA);
DESTROY_IF(imcv_pa_tnc_attributes);
+ imcv_pa_tnc_attributes = NULL;
+ DESTROY_IF(imcv_db);
DBG1(DBG_LIB, "libimcv terminated");
}
if (ref_put(&libstrongswan_ref))