summaryrefslogtreecommitdiff
path: root/src/libtnccs
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-02-07 13:27:27 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-02-07 13:27:27 +0100
commit7585facf05d927eb6df3929ce09ed5e60d905437 (patch)
treee4d14b4dc180db20356b6b01ce0112f3a2d7897e /src/libtnccs
parentc1343b3278cdf99533b7902744d15969f9d6fdc1 (diff)
downloadvyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.tar.gz
vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.zip
Imported Upstream version 5.0.2
Diffstat (limited to 'src/libtnccs')
-rw-r--r--src/libtnccs/Makefile.in32
-rw-r--r--src/libtnccs/tnc/imc/imc_manager.h26
-rw-r--r--src/libtnccs/tnc/imv/imv_manager.h25
-rw-r--r--src/libtnccs/tnc/tnc.c52
-rw-r--r--src/libtnccs/tnc/tnccs/tnccs_manager.c2
5 files changed, 100 insertions, 37 deletions
diff --git a/src/libtnccs/Makefile.in b/src/libtnccs/Makefile.in
index 5eac73ab0..1e9f639f8 100644
--- a/src/libtnccs/Makefile.in
+++ b/src/libtnccs/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -73,6 +73,12 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
am__installdirs = "$(DESTDIR)$(ipseclibdir)"
LTLIBRARIES = $(ipseclib_LTLIBRARIES)
libtnccs_la_DEPENDENCIES = $(top_builddir)/src/libtncif/libtncif.la
@@ -116,6 +122,7 @@ CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLIB = @DLLIB@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -143,6 +150,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQLCFLAG = @MYSQLCFLAG@
MYSQLCONFIG = @MYSQLCONFIG@
@@ -170,6 +178,7 @@ RANLIB = @RANLIB@
RTLIB = @RTLIB@
RUBY = @RUBY@
RUBYINCLUDE = @RUBYINCLUDE@
+RUBYLIB = @RUBYLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
@@ -182,6 +191,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
@@ -235,7 +245,6 @@ libexecdir = @libexecdir@
linux_headers = @linux_headers@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
maemo_CFLAGS = @maemo_CFLAGS@
maemo_LIBS = @maemo_LIBS@
manager_plugins = @manager_plugins@
@@ -359,7 +368,7 @@ clean-ipseclibLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
-libtnccs.la: $(libtnccs_la_OBJECTS) $(libtnccs_la_DEPENDENCIES)
+libtnccs.la: $(libtnccs_la_OBJECTS) $(libtnccs_la_DEPENDENCIES) $(EXTRA_libtnccs_la_DEPENDENCIES)
$(LINK) -rpath $(ipseclibdir) $(libtnccs_la_OBJECTS) $(libtnccs_la_LIBADD) $(LIBS)
mostlyclean-compile:
@@ -527,10 +536,15 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
mostlyclean-generic:
clean-generic:
diff --git a/src/libtnccs/tnc/imc/imc_manager.h b/src/libtnccs/tnc/imc/imc_manager.h
index 25e0efe9d..db033c4c0 100644
--- a/src/libtnccs/tnc/imc/imc_manager.h
+++ b/src/libtnccs/tnc/imc/imc_manager.h
@@ -55,7 +55,31 @@ struct imc_manager_t {
* @param path path of the IMC dynamic library file
* @return TRUE if loading succeeded
*/
- bool (*load)(imc_manager_t *this, char *name, char *path);
+ bool (*load)(imc_manager_t *this, char *name, char *path);
+
+ /**
+ * Load and initialize an IMC from a set of TNC IMC functions.
+ *
+ * @param name name of the IMC
+ * @param initialize TNC_IMC_InitializePointer
+ * @param notify_connection_change TNC_IMC_NotifyConnectionChangePointer
+ * @param begin_handshake TNC_IMC_BeginHandshakePointer
+ * @param receive_message TNC_IMC_ReceiveMessagePointer
+ * @param receive_message_long TNC_IMC_ReceiveMessageLongPointer
+ * @param batch_ending TNC_IMC_BatchEndingPointer
+ * @param terminate TNC_IMC_TerminatePointer
+ * @param provide_bind_function TNC_IMC_ProvideBindFunctionPointer
+ * @return TRUE if loading succeeded
+ */
+ bool (*load_from_functions)(imc_manager_t *this, char *name,
+ TNC_IMC_InitializePointer initialize,
+ TNC_IMC_NotifyConnectionChangePointer notify_connection_change,
+ TNC_IMC_BeginHandshakePointer begin_handshake,
+ TNC_IMC_ReceiveMessagePointer receive_message,
+ TNC_IMC_ReceiveMessageLongPointer receive_message_long,
+ TNC_IMC_BatchEndingPointer batch_ending,
+ TNC_IMC_TerminatePointer terminate,
+ TNC_IMC_ProvideBindFunctionPointer provide_bind_function);
/**
* Check if an IMC with a given ID is registered with the IMC manager
diff --git a/src/libtnccs/tnc/imv/imv_manager.h b/src/libtnccs/tnc/imv/imv_manager.h
index 43f40973c..7772b7e08 100644
--- a/src/libtnccs/tnc/imv/imv_manager.h
+++ b/src/libtnccs/tnc/imv/imv_manager.h
@@ -56,8 +56,31 @@ struct imv_manager_t {
* @param path path of the IMV dynamic library file
* @return TRUE if loading succeeded
*/
- bool (*load)(imv_manager_t *this, char *name, char *path);
+ bool (*load)(imv_manager_t *this, char *name, char *path);
+ /**
+ * Load and initialize an IMV from a set of TNC IMC functions.
+ *
+ * @param name name of the IMV
+ * @param initialize TNC_IMV_InitializePointer
+ * @param notify_connection_change TNC_IMV_NotifyConnectionChangePointer
+ * @param receive_message TNC_IMV_ReceiveMessagePointer
+ * @param receive_message_long TNC_IMV_ReceiveMessageLongPointer
+ * @param solicit_recommendation TNC_IMV_SolicitRecommendationPointer
+ * @param batch_ending TNC_IMV_BatchEndingPointer
+ * @param terminate TNC_IMV_TerminatePointer
+ * @param provide_bind_function TNC_IMV_ProvideBindFunctionPointer
+ * @return TRUE if loading succeeded
+ */
+ bool (*load_from_functions)(imv_manager_t *this, char *name,
+ TNC_IMV_InitializePointer initialize,
+ TNC_IMV_NotifyConnectionChangePointer notify_connection_change,
+ TNC_IMV_ReceiveMessagePointer receive_message,
+ TNC_IMV_ReceiveMessageLongPointer receive_message_long,
+ TNC_IMV_SolicitRecommendationPointer solicit_recommendation,
+ TNC_IMV_BatchEndingPointer batch_ending,
+ TNC_IMV_TerminatePointer terminate,
+ TNC_IMV_ProvideBindFunctionPointer provide_bind_function);
/**
* Check if an IMV with a given ID is registered with the IMV manager
diff --git a/src/libtnccs/tnc/tnc.c b/src/libtnccs/tnc/tnc.c
index 7c0ee4132..769b9fa54 100644
--- a/src/libtnccs/tnc/tnc.c
+++ b/src/libtnccs/tnc/tnc.c
@@ -23,7 +23,7 @@
#include <fcntl.h>
#include <utils/lexparser.h>
-#include <debug.h>
+#include <utils/debug.h>
typedef struct private_tnc_t private_tnc_t;
@@ -40,6 +40,11 @@ struct private_tnc_t {
* Public members of tnc_t.
*/
tnc_t public;
+
+ /**
+ * Number of times we have been initialized
+ */
+ refcount_t ref;
};
/**
@@ -54,9 +59,17 @@ void libtnccs_init(void)
{
private_tnc_t *this;
+ if (tnc)
+ { /* already initialized, increase refcount */
+ this = (private_tnc_t*)tnc;
+ ref_get(&this->ref);
+ return;
+ }
+
INIT(this,
.public = {
},
+ .ref = 1,
);
tnc = &this->public;
@@ -69,6 +82,11 @@ void libtnccs_deinit(void)
{
private_tnc_t *this = (private_tnc_t*)tnc;
+ if (!this || !ref_put(&this->ref))
+ { /* have more users */
+ return;
+ }
+
free(this);
tnc = NULL;
}
@@ -145,9 +163,7 @@ static bool load_imcvs_from_config(char *filename, bool is_imc)
}
/* copy the IMC/IMV name */
- name = malloc(token.len + 1);
- memcpy(name, token.ptr, token.len);
- name[token.len] = '\0';
+ name = strndup(token.ptr, token.len);
/* advance to the IMC/IMV path and extract it */
if (!eat_whitespace(&line))
@@ -162,9 +178,7 @@ static bool load_imcvs_from_config(char *filename, bool is_imc)
}
/* copy the IMC/IMV path */
- path = malloc(token.len + 1);
- memcpy(path, token.ptr, token.len);
- path[token.len] = '\0';
+ path = strndup(token.ptr, token.len);
/* load and register an IMC/IMV instance */
if (is_imc)
@@ -175,6 +189,8 @@ static bool load_imcvs_from_config(char *filename, bool is_imc)
{
success = tnc->imvs->load(tnc->imvs, name, path);
}
+ free(name);
+ free(path);
if (!success)
{
break;
@@ -243,24 +259,10 @@ bool tnc_manager_register(plugin_t *plugin, plugin_feature_t *feature,
if (load_imcvs)
{
- char *tnc_config;
-
- tnc_config = lib->settings->get_str(lib->settings,
- "libtnccs.tnc_config", "/etc/tnc_config");
- if (!load_imcvs_from_config(tnc_config, is_imc))
- {
- if (is_imc)
- {
- tnc->imcs->destroy(tnc->imcs);
- tnc->imcs = NULL;
- }
- else
- {
- tnc->imvs->destroy(tnc->imvs);
- tnc->imvs = NULL;
- }
- return FALSE;
- }
+ load_imcvs_from_config(
+ lib->settings->get_str(lib->settings,
+ "libtnccs.tnc_config", "/etc/tnc_config"),
+ is_imc);
}
}
return TRUE;
diff --git a/src/libtnccs/tnc/tnccs/tnccs_manager.c b/src/libtnccs/tnc/tnccs/tnccs_manager.c
index fa91bfb21..fca4b2584 100644
--- a/src/libtnccs/tnc/tnccs/tnccs_manager.c
+++ b/src/libtnccs/tnc/tnccs/tnccs_manager.c
@@ -17,7 +17,7 @@
#include "tnc/tnc.h"
-#include <debug.h>
+#include <utils/debug.h>
/**
* See header