HA sync plugin stub
authorMartin Willi <martin@strongswan.org>
Fri, 24 Oct 2008 08:06:22 +0000 (08:06 +0000)
committerMartin Willi <martin@revosec.ch>
Wed, 7 Apr 2010 11:55:11 +0000 (13:55 +0200)
configure.in
src/charon/plugins/ha_sync/Makefile.am [new file with mode: 0644]
src/charon/plugins/ha_sync/ha_sync_plugin.c [new file with mode: 0644]
src/charon/plugins/ha_sync/ha_sync_plugin.h [new file with mode: 0644]

index 47d56b4..848fcdc 100644 (file)
@@ -143,6 +143,7 @@ ARG_ENABL_SET([agent],          [enables the ssh-agent signing plugin.])
 ARG_ENABL_SET([uci],            [enable OpenWRT UCI configuration plugin.])
 ARG_ENABL_SET([android],        [enable Android specific plugin.])
 ARG_ENABL_SET([nm],             [enable NetworkManager plugin.])
+ARG_ENABL_SET([ha],             [enable high availability cluster plugin.])
 ARG_ENABL_SET([vstr],           [enforce using the Vstr string library to replace glibc-like printf hooks.])
 ARG_ENABL_SET([monolithic],     [build monolithic version of libstrongswan that includes all enabled plugins. Similarly, the plugins of charon are assembled in libcharon.])
 
@@ -809,6 +810,7 @@ AM_CONDITIONAL(USE_DHCP, test x$dhcp = xtrue)
 AM_CONDITIONAL(USE_RESOLVE, test x$resolve = xtrue)
 AM_CONDITIONAL(USE_UNIT_TESTS, test x$unit_tests = xtrue)
 AM_CONDITIONAL(USE_LOAD_TESTER, test x$load_tester = xtrue)
+AM_CONDITIONAL(USE_HA, test x$ha = xtrue)
 AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
 AM_CONDITIONAL(USE_EAP_SIM_FILE, test x$eap_sim_file = xtrue)
 AM_CONDITIONAL(USE_EAP_SIMAKA_PSEUDONYM, test x$eap_simaka_pseudonym = xtrue)
@@ -941,6 +943,7 @@ AC_OUTPUT(
        src/libcharon/plugins/medcli/Makefile
        src/libcharon/plugins/nm/Makefile
        src/libcharon/plugins/uci/Makefile
+       src/libcharon/plugins/ha_sync/Makefile
        src/libcharon/plugins/android/Makefile
        src/libcharon/plugins/stroke/Makefile
        src/libcharon/plugins/updown/Makefile
diff --git a/src/charon/plugins/ha_sync/Makefile.am b/src/charon/plugins/ha_sync/Makefile.am
new file mode 100644 (file)
index 0000000..fc122c0
--- /dev/null
@@ -0,0 +1,9 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
+
+AM_CFLAGS = -rdynamic
+
+plugin_LTLIBRARIES = libstrongswan-ha-sync.la
+libstrongswan_ha_sync_la_SOURCES = ha_sync_plugin.h ha_sync_plugin.c
+libstrongswan_ha_sync_la_LDFLAGS = -module
+
diff --git a/src/charon/plugins/ha_sync/ha_sync_plugin.c b/src/charon/plugins/ha_sync/ha_sync_plugin.c
new file mode 100644 (file)
index 0000000..40e5f18
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * $Id$
+ */
+
+#include "ha_sync_plugin.h"
+
+#include <daemon.h>
+#include <config/child_cfg.h>
+
+typedef struct private_ha_sync_plugin_t private_ha_sync_plugin_t;
+
+/**
+ * private data of ha_sync plugin
+ */
+struct private_ha_sync_plugin_t {
+
+       /**
+        * implements plugin interface
+        */
+       ha_sync_plugin_t public;
+
+       /**
+        * Listener interface, listens to CHILD_SA state changes
+        */
+       listener_t listener;
+};
+
+/**
+ * Listener implementation
+ */
+static bool child_state_change(listener_t *this, ike_sa_t *ike_sa,
+                                                          child_sa_t *child_sa, child_sa_state_t state)
+{
+       if (state == CHILD_INSTALLED)
+       {
+               chunk_t chunk;
+
+               chunk = child_sa->serialize(child_sa);
+               DBG1(DBG_IKE, "NEW CHILD: %B", &chunk);
+
+               chunk_clear(&chunk);
+       }
+       return TRUE;
+}
+
+/**
+ * Implementation of plugin_t.destroy
+ */
+static void destroy(private_ha_sync_plugin_t *this)
+{
+       charon->bus->remove_listener(charon->bus, &this->listener);
+       free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *plugin_create()
+{
+       private_ha_sync_plugin_t *this = malloc_thing(private_ha_sync_plugin_t);
+
+       this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+
+       memset(&this->listener, 0, sizeof(listener_t));
+       this->listener.child_state_change = child_state_change;
+
+       charon->bus->add_listener(charon->bus, &this->listener);
+
+       return &this->public.plugin;
+}
+
diff --git a/src/charon/plugins/ha_sync/ha_sync_plugin.h b/src/charon/plugins/ha_sync/ha_sync_plugin.h
new file mode 100644 (file)
index 0000000..9dae812
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * $Id$
+ */
+
+/**
+ * @defgroup ha_sync ha_sync
+ * @ingroup cplugins
+ *
+ * @defgroup ha_sync_plugin ha_sync_plugin
+ * @{ @ingroup ha_sync
+ */
+
+#ifndef HA_SYNC_PLUGIN_H_
+#define HA_SYNC_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct ha_sync_plugin_t ha_sync_plugin_t;
+
+/**
+ * Plugin to synchronize state in a high availability cluster.
+ */
+struct ha_sync_plugin_t {
+
+       /**
+        * implements plugin interface
+        */
+       plugin_t plugin;
+};
+
+/**
+ * Create a ha_sync_plugin instance.
+ */
+plugin_t *plugin_create();
+
+#endif /* HA_SYNC_PLUGIN_H_ @}*/