]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
added listplugins support to pluto and whack
authorAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 26 Oct 2011 08:31:48 +0000 (10:31 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 26 Oct 2011 08:31:48 +0000 (10:31 +0200)
src/pluto/Makefile.am
src/pluto/plugin_list.c [new file with mode: 0644]
src/pluto/plugin_list.h [new file with mode: 0644]
src/pluto/rcv_whack.c
src/whack/whack.c
src/whack/whack.h

index 4689305585fb266cb93326b6aadece54077530b7..68ba16346008623c29ec5d457d54adc9e98f8afe 100644 (file)
@@ -39,6 +39,7 @@ nat_traversal.c nat_traversal.h \
 ocsp.c ocsp.h \
 packet.c packet.h \
 pkcs7.c pkcs7.h \
+plugin_list.c plugin_list.h \
 pluto.c pluto.h \
 plutomain.c \
 rcv_whack.c rcv_whack.h \
diff --git a/src/pluto/plugin_list.c b/src/pluto/plugin_list.c
new file mode 100644 (file)
index 0000000..d6ace1d
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 Martin Willi, revosec AG
+ * Copyright (C) 2011 Andreas Steffen, HSR 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.
+ */
+
+#include <whack.h>
+
+#include <library.h>
+#include <utils/linked_list.h>
+
+/**
+ * List loaded plugin information
+ */
+void plugin_list(void)
+{
+       plugin_feature_t *features, *fp;
+       enumerator_t *enumerator;
+       linked_list_t *list;
+       plugin_t *plugin;
+       int count, i;
+       bool loaded;
+       char *str;
+
+       whack_log(RC_COMMENT, " ");
+       whack_log(RC_COMMENT, "List of loaded Plugins:");
+       whack_log(RC_COMMENT, " ");
+
+       enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
+       while (enumerator->enumerate(enumerator, &plugin, &list))
+       {
+               whack_log(RC_COMMENT, "%s:", plugin->get_name(plugin));
+               if (plugin->get_features)
+               {
+                       count = plugin->get_features(plugin, &features);
+                       for (i = 0; i < count; i++)
+                       {
+                               str = plugin_feature_get_string(&features[i]);
+                               switch (features[i].kind)
+                               {
+                                       case FEATURE_PROVIDE:
+                                               fp = &features[i];
+                                               loaded = list->find_first(list, NULL,
+                                                                                                 (void**)&fp) == SUCCESS;
+                                               whack_log(RC_COMMENT, "    %s%s",
+                                                                 str, loaded ? "" : " (not loaded)");
+                                               break;
+                                       case FEATURE_DEPENDS:
+                                               whack_log(RC_COMMENT, "        %s", str);
+                                               break;
+                                       case FEATURE_SDEPEND:
+                                               whack_log(RC_COMMENT, "        %s(soft)", str);
+                                               break;
+                                       default:
+                                               break;
+                               }
+                               free(str);
+                       }
+               }
+       }
+       enumerator->destroy(enumerator);
+}
diff --git a/src/pluto/plugin_list.h b/src/pluto/plugin_list.h
new file mode 100644 (file)
index 0000000..62e4a16
--- /dev/null
@@ -0,0 +1,21 @@
+/* Generates a list of all loaded plugins and their dependencies
+ * Copyright (C) 2011 Andreas Steffen
+ * HSR 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.
+ */
+
+#ifndef _PLUGIN_LIST_H
+#define _PLUGIN_LIST_H
+
+extern void plugin_list(void);
+
+#endif /* _PLUGIN_LIST_H */
index 94b07bd756af407e8f99abcc70f4d978a44cf759..0a7b33ab50bb18f889e92d21325c8fb36aec41f9 100644 (file)
@@ -57,6 +57,7 @@
 #include "myid.h"
 #include "kernel_alg.h"
 #include "ike_alg.h"
+#include "plugin_list.h"
 #include "whack_attribute.h"
 
 /* helper variables and function to decode strings from whack message */
@@ -557,6 +558,11 @@ void whack_handle(int whackctlfd)
                kernel_alg_list();
        }
 
+       if (msg.whack_list & LIST_PLUGINS)
+       {
+               plugin_list();
+       }
+
        if (msg.whack_key)
        {
                /* add a public key */
index b277a68e54fe6aeb2551efd856c65d269a615ed9..a7945d6d83fb9db107bc85783b87572e5d2d4dc2 100644 (file)
@@ -207,6 +207,7 @@ static void help(void)
                        " [--listcrls]"
                        " [--listocsp]"
                        " [--listcards]"
+                       " [--listplugins]"
                        " [--listall]"
                        "\n\n"
                "purge: whack"
@@ -379,6 +380,7 @@ enum {
        LST_CRLS,
        LST_OCSP,
        LST_CARDS,
+       LST_PLUGINS,
        LST_ALL,
 
 #   define LST_LAST LST_ALL     /* last list option */
@@ -571,6 +573,7 @@ static const struct option long_opts[] = {
        { "listcrls", no_argument, NULL, LST_CRLS + OO },
        { "listocsp", no_argument, NULL, LST_OCSP + OO },
        { "listcards", no_argument, NULL, LST_CARDS + OO },
+       { "listplugins", no_argument, NULL, LST_PLUGINS + OO },
        { "listall", no_argument, NULL, LST_ALL + OO },
 
        /* options for an end description */
@@ -1234,6 +1237,7 @@ int main(int argc, char **argv)
                case LST_CRLS:          /* --listcrls */
                case LST_OCSP:          /* --listocsp */
                case LST_CARDS:         /* --listcards */
+               case LST_PLUGINS:       /* --listplugins */
                        msg.whack_list |= LELEM(c - LST_ALGS);
                        continue;
 
index f8e6a9a8824f520ca23e0a3c295a7f768f912c9b..c92eaf3cf99d5b3bc8d9ce707f1e0093c66f0a61 100644 (file)
@@ -333,8 +333,9 @@ enum rc_type {
 #define LIST_CRLS       0x0200  /* list all crls */
 #define LIST_OCSP       0x0400  /* list all ocsp cache entries */
 #define LIST_CARDS      0x0800  /* list all smartcard records */
+#define LIST_PLUGINS    0x1000  /* list all plugins with dependencies */
 
-#define LIST_ALL        LRANGES(LIST_ALGS, LIST_CARDS)  /* all list options */
+#define LIST_ALL        LRANGES(LIST_ALGS, LIST_PLUGINS) /* all list options */
 
 /* options of whack --reread*** command */