added listplugins support to pluto and whack

This commit is contained in:
Andreas Steffen
2011-10-26 10:31:48 +02:00
parent 1f73f5c5c4
commit 473c477978
6 changed files with 105 additions and 1 deletions
+1
View 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 \
+71
View File
@@ -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);
}
+21
View File
@@ -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 */
+6
View 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 */
+4
View 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;
+2 -1
View 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 */