ARG_WITH_SUBST([ipseclibdir], [${libdir%/}/ipsec], [set installation path for ipsec libraries])
ARG_WITH_SUBST([plugindir], [${ipseclibdir%/}/plugins], [set the installation path of plugins])
ARG_WITH_SUBST([imcvdir], [${ipseclibdir%/}/imcvs], [set the installation path of IMC and IMV dynamic librariers])
-ARG_WITH_SUBST([nm-ca-dir], [/usr/share/ca-certificates], [directory the NM plugin uses to look up trusted root certificates])
+ARG_WITH_SUBST([nm-ca-dir], [/usr/share/ca-certificates], [directory the NM backend uses to look up trusted root certificates])
ARG_WITH_SUBST([linux-headers], [\${top_srcdir}/src/include], [set directory of linux header files to use])
ARG_WITH_SUBST([routing-table], [220], [set routing table to use for IPsec routes])
ARG_WITH_SUBST([routing-table-prio], [220], [set priority for IPsec routing table])
ADD_PLUGIN([tnccs-dynamic], [c charon])
ADD_PLUGIN([medsrv], [c charon])
ADD_PLUGIN([medcli], [c charon])
-ADD_PLUGIN([nm], [c charon])
ADD_PLUGIN([dhcp], [c charon])
ADD_PLUGIN([android], [c charon])
ADD_PLUGIN([ha], [c charon])
AM_CONDITIONAL(USE_STROKE, test x$stroke = xtrue)
AM_CONDITIONAL(USE_MEDSRV, test x$medsrv = xtrue)
AM_CONDITIONAL(USE_MEDCLI, test x$medcli = xtrue)
-AM_CONDITIONAL(USE_NM, test x$nm = xtrue)
AM_CONDITIONAL(USE_UCI, test x$uci = xtrue)
AM_CONDITIONAL(USE_ANDROID, test x$android = xtrue)
AM_CONDITIONAL(USE_MAEMO, test x$maemo = xtrue)
src/libcharon/plugins/sql/Makefile
src/libcharon/plugins/medsrv/Makefile
src/libcharon/plugins/medcli/Makefile
- src/libcharon/plugins/nm/Makefile
src/libcharon/plugins/addrblock/Makefile
src/libcharon/plugins/uci/Makefile
src/libcharon/plugins/ha/Makefile
ipsec_PROGRAMS = charon-nm
charon_nm_SOURCES = \
-charon-nm.c
+charon-nm.c \
+nm/nm_backend.c nm/nm_backend.h \
+nm/nm_creds.c nm/nm_creds.h \
+nm/nm_handler.c nm/nm_handler.h \
+nm/nm_service.c nm/nm_service.h
INCLUDES = \
-I$(top_srcdir)/src/libstrongswan \
-I$(top_srcdir)/src/libhydra \
- -I$(top_srcdir)/src/libcharon
+ -I$(top_srcdir)/src/libcharon \
+ ${nm_CFLAGS}
AM_CFLAGS = \
-DIPSEC_DIR=\"${ipsecdir}\" \
-DIPSEC_PIDDIR=\"${piddir}\" \
+ -DNM_CA_DIR=\"${nm_ca_dir}\" \
-DPLUGINS=\""${nm_plugins}\""
charon_nm_LDADD = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
$(top_builddir)/src/libhydra/libhydra.la \
$(top_builddir)/src/libcharon/libcharon.la \
- -lm $(PTHREADLIB) $(DLLIB)
+ -lm $(PTHREADLIB) $(DLLIB) ${nm_LIBS}
#include <utils/backtrace.h>
#include <threading/thread.h>
+#include <nm/nm_backend.h>
+
/**
* Hook in library for debugging messages
*/
goto deinit;
}
+ /* load NM backend */
+ if (!nm_backend_init())
+ {
+ DBG1(DBG_DMN, "failed to initialize NetworkManager backend - aborting charon-nm");
+ goto deinit_nm;
+ }
+
if (!drop_capabilities())
{
DBG1(DBG_DMN, "capability dropping failed - aborting charon-nm");
- goto deinit;
+ goto deinit_nm;
}
/* add handler for SEGV and ILL,
status = 0;
+deinit_nm:
+ nm_backend_deinit();
deinit:
libcharon_deinit();
libhydra_deinit();
/*
+ * Copyright (C) 2012 Tobias Brunner
* Copyright (C) 2008-2009 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* for more details.
*/
-#include "nm_plugin.h"
#include "nm_service.h"
#include "nm_creds.h"
#include "nm_handler.h"
#define CAP_DAC_OVERRIDE 1
-typedef struct private_nm_plugin_t private_nm_plugin_t;
+typedef struct nm_backend_t nm_backend_t;
/**
- * private data of nm plugin
+ * Data for the NetworkManager backend.
*/
-struct private_nm_plugin_t {
-
- /**
- * implements plugin interface
- */
- nm_plugin_t public;
+struct nm_backend_t {
/**
* NetworkManager service (VPNPlugin)
nm_handler_t *handler;
};
+/**
+ * Global (but private) instance of the NM backend.
+ */
+static nm_backend_t *nm_backend = NULL;
+
/**
* NM plugin processing routine, creates and handles NMVPNPlugin
*/
-static job_requeue_t run(private_nm_plugin_t *this)
+static job_requeue_t run(nm_backend_t *this)
{
this->loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(this->loop);
return JOB_REQUEUE_NONE;
}
-METHOD(plugin_t, get_name, char*,
- private_nm_plugin_t *this)
+/*
+ * see header file
+ */
+void nm_backend_deinit()
{
- return "nm";
-}
+ nm_backend_t *this = nm_backend;
-METHOD(plugin_t, destroy, void,
- private_nm_plugin_t *this)
-{
+ if (!this)
+ {
+ return;
+ }
if (this->loop)
{
if (g_main_loop_is_running(this->loop))
this->creds->destroy(this->creds);
this->handler->destroy(this->handler);
free(this);
+
+ nm_backend = NULL;
}
/*
* see header file
*/
-plugin_t *nm_plugin_create()
+bool nm_backend_init()
{
- private_nm_plugin_t *this;
+ nm_backend_t *this;
g_type_init ();
if (!g_thread_supported())
}
INIT(this,
- .public = {
- .plugin = {
- .get_name = _get_name,
- .reload = (void*)return_false,
- .destroy = _destroy,
- },
- },
.creds = nm_creds_create(),
.handler = nm_handler_create(),
);
this->plugin = nm_strongswan_plugin_new(this->creds, this->handler);
+ nm_backend = this;
hydra->attributes->add_handler(hydra->attributes, &this->handler->handler);
lib->credmgr->add_set(lib->credmgr, &this->creds->set);
if (!this->plugin)
{
DBG1(DBG_CFG, "DBUS binding failed");
- destroy(this);
- return NULL;
+ nm_backend_deinit();
+ return FALSE;
}
/* bypass file permissions to read from users ssh-agent */
lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create_with_prio((callback_job_cb_t)run,
this, NULL, NULL, JOB_PRIO_CRITICAL));
-
- return &this->public.plugin;
+ return TRUE;
}
/*
- * Copyright (C) 2008 Martin Willi
+ * Copyright (C) 2012 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
*/
/**
+ * @defgroup charon-nm charon-nm
+ *
* @defgroup nm nm
- * @ingroup cplugins
+ * @ingroup charon-nm
*
- * @defgroup nm_plugin nm_plugin
+ * @defgroup nm_backend nm_backend
* @{ @ingroup nm
*/
-#ifndef NM_PLUGIN_H_
-#define NM_PLUGIN_H_
-
-#include <plugins/plugin.h>
-
-typedef struct nm_plugin_t nm_plugin_t;
+#ifndef NM_BACKEND_H_
+#define NM_BACKEND_H_
/**
- * NetworkManager integration plugin.
+ * Initialize the NetworkManager backend.
+ *
+ * @return TRUE, if initialization was successful
*/
-struct nm_plugin_t {
+bool nm_backend_init();
- /**
- * implements plugin interface
- */
- plugin_t plugin;
-};
+/**
+ * Deinitialize the NetworkManager backend.
+ */
+void nm_backend_deinit();
-#endif /** NM_PLUGIN_H_ @}*/
+#endif /** NM_BACKEND_H_ @}*/
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
priv->plugin = NM_VPN_PLUGIN(plugin);
- memset(&priv->listener.log, 0, sizeof(listener_t));
+ memset(&priv->listener, 0, sizeof(listener_t));
priv->listener.child_updown = child_updown;
priv->listener.ike_rekey = ike_rekey;
}
endif
endif
-if USE_NM
- SUBDIRS += plugins/nm
-if MONOLITHIC
- libcharon_la_LIBADD += plugins/nm/libstrongswan-nm.la
-endif
-endif
-
if USE_DHCP
SUBDIRS += plugins/dhcp
if MONOLITHIC
+++ /dev/null
-
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
- -I$(top_srcdir)/src/libcharon ${nm_CFLAGS}
-
-AM_CFLAGS = -rdynamic \
- -DNM_CA_DIR=\"${nm_ca_dir}\"
-
-if MONOLITHIC
-noinst_LTLIBRARIES = libstrongswan-nm.la
-else
-plugin_LTLIBRARIES = libstrongswan-nm.la
-endif
-
-libstrongswan_nm_la_SOURCES = \
- nm_plugin.h nm_plugin.c \
- nm_service.h nm_service.c \
- nm_creds.h nm_creds.c \
- nm_handler.h nm_handler.c
-
-libstrongswan_nm_la_LDFLAGS = -module -avoid-version
-libstrongswan_nm_la_LIBADD = ${nm_LIBS}