From: Eric Leblond <eric@inl.fr>
To: netfilter-devel@vger.kernel.org
Cc: Eric Leblond <eric@inl.fr>
Subject: [PATCH 05/34] Add --info option which displays information about plugin.
Date: Sat, 2 Feb 2008 22:24:00 +0100 [thread overview]
Message-ID: <12019874703998-git-send-email-eric@inl.fr> (raw)
In-Reply-To: <12019874702005-git-send-email-eric@inl.fr>
It is difficult to find how to configure a plugin. This patch adds an info
option which can be used to display:
* Name
* Configuration variables
* Input keys
* Output keys
Output exemple:
/opt/ulogd2/sbin/ulogd --info /opt/ulogd2/lib/ulogd/ulogd_filter_IFINDEX.so
Name: IFINDEX
Input keys:
Key: oob.ifindex_in (unsigned int 32)
Key: oob.ifindex_out (unsigned int 32)
Output keys:
Key: oob.in (string)
Key: oob.out (string)
Signed-off-by: Eric leblond <eric@inl.fr>
---
:100644 100644 ca5fb06... e1eb951... M src/ulogd.c
src/ulogd.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 133 insertions(+), 8 deletions(-)
diff --git a/src/ulogd.c b/src/ulogd.c
index ca5fb06..e1eb951 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -78,6 +78,8 @@ static char *ulogd_configfile = ULOGD_CONFIGFILE;
static char *ulogd_logfile = ULOGD_LOGFILE_DEFAULT;
static FILE syslog_dummy;
+static int info_mode = 0;
+
/* linked list for all registered plugins */
static LLIST_HEAD(ulogd_plugins);
static LLIST_HEAD(ulogd_pi_stacks);
@@ -231,21 +233,137 @@ static struct ulogd_plugin *find_plugin(const char *name)
return NULL;
}
+char *type_to_string(int type)
+{
+ switch (type) {
+ case ULOGD_RET_INT8:
+ return strdup("int 8");
+ break;
+ case ULOGD_RET_INT16:
+ return strdup("int 16");
+ break;
+ case ULOGD_RET_INT32:
+ return strdup("int 32");
+ break;
+ case ULOGD_RET_INT64:
+ return strdup("int 64");
+ break;
+ case ULOGD_RET_UINT8:
+ return strdup("unsigned int 8");
+ break;
+ case ULOGD_RET_UINT16:
+ return strdup("unsigned int 16");
+ break;
+ case ULOGD_RET_UINT32:
+ return strdup("unsigned int 32");
+ break;
+ case ULOGD_RET_UINT64:
+ return strdup("unsigned int 64");
+ break;
+ case ULOGD_RET_BOOL:
+ return strdup("boolean");
+ break;
+ case ULOGD_RET_IPADDR:
+ return strdup("IPv4 addr");
+ break;
+ case ULOGD_RET_IP6ADDR:
+ return strdup("IPv6 addr");
+ break;
+ case ULOGD_RET_STRING:
+ return strdup("string");
+ break;
+ case ULOGD_RET_RAW:
+ return strdup("raw data");
+ break;
+ default:
+ return strdup("Unknown type");
+ }
+}
+
+
+void get_plugin_infos(struct ulogd_plugin *me)
+{
+ int i;
+ printf("Name: %s\n", me->name);
+ if (me->config_kset) {
+ printf("Config options:\n");
+ for(i = 0; i < me->config_kset->num_ces; i++) {
+ printf("\tVar: %s (", me->config_kset->ces[i].key);
+ switch (me->config_kset->ces[i].type) {
+ case CONFIG_TYPE_STRING:
+ printf("String");
+ printf(", Default: %s", me->config_kset->ces[i].u.value);
+ break;
+ case CONFIG_TYPE_INT:
+ printf("Integer");
+ printf(", Default: %d", me->config_kset->ces[i].u.value);
+ break;
+ case CONFIG_TYPE_CALLBACK:
+ printf("Callback");
+ break;
+ default:
+ printf("Unknown");
+ break;
+ }
+ if (me->config_kset->ces[i].options == CONFIG_OPT_MANDATORY) {
+ printf(", Mandatory");
+ }
+ printf(")\n");
+ }
+ }
+ printf("Input keys:\n");
+ if (me->input.type != ULOGD_DTYPE_SOURCE) {
+ if (me->input.num_keys == 0) {
+ printf("\tNo statically defined keys\n");
+ } else {
+ for(i = 0; i < me->input.num_keys; i++) {
+ char *tstring = type_to_string(me->input.keys[i].type);
+ printf("\tKey: %s (%s)\n",
+ me->input.keys[i].name,
+ tstring);
+ free(tstring);
+ }
+ }
+ } else {
+ printf("\tInput plugin, No keys\n");
+ }
+ printf("Output keys:\n");
+ if (me->output.type != ULOGD_DTYPE_SINK) {
+ if (me->output.num_keys == 0) {
+ printf("\tNo statically defined keys\n");
+ } else {
+ for(i = 0; i < me->output.num_keys; i++) {
+ char *tstring = type_to_string(me->output.keys[i].type);
+ printf("\tKey: %s (%s)\n",
+ me->output.keys[i].name,
+ tstring);
+ free(tstring);
+ }
+ }
+ } else {
+ printf("\tOutput plugin, No keys\n");
+ }
+}
+
/* the function called by all plugins for registering themselves */
void ulogd_register_plugin(struct ulogd_plugin *me)
{
if (strcmp(me->version, ULOGD_VERSION)) {
ulogd_log(ULOGD_NOTICE, "plugin `%s' has incompatible version %s\n",
- me->version);
+ me->version);
return;
}
- if (find_plugin(me->name)) {
- ulogd_log(ULOGD_NOTICE, "plugin `%s' already registered\n",
- me->name);
- exit(EXIT_FAILURE);
+ if (info_mode == 0) {
+ if (find_plugin(me->name)) {
+ ulogd_log(ULOGD_NOTICE, "plugin `%s' already registered\n",
+ me->name);
+ exit(EXIT_FAILURE);
+ }
+ ulogd_log(ULOGD_NOTICE, "registering plugin `%s'\n", me->name);
+ llist_add(&me->list, &ulogd_plugins);
+ } else {
+ get_plugin_infos(me);
}
- ulogd_log(ULOGD_NOTICE, "registering plugin `%s'\n", me->name);
- llist_add(&me->list, &ulogd_plugins);
}
/***********************************************************************
@@ -853,6 +971,7 @@ static void print_usage(void)
printf("\t-d --daemon\tDaemonize (fork into background)\n");
printf("\t-c --configfile\tUse alternative Configfile\n");
printf("\t-u --uid\tChange UID/GID\n");
+ printf("\t-i --info\tDisplay infos about plugin\n");
}
static struct option opts[] = {
@@ -861,6 +980,7 @@ static struct option opts[] = {
{ "help", 0, NULL, 'h' },
{ "configfile", 1, NULL, 'c'},
{ "uid", 1, NULL, 'u' },
+ { "info", 1, NULL, 'i'},
{ 0 }
};
@@ -875,7 +995,7 @@ int main(int argc, char* argv[])
gid_t gid = 0;
- while ((argch = getopt_long(argc, argv, "c:dh::Vu:", opts, NULL)) != -1) {
+ while ((argch = getopt_long(argc, argv, "c:dh::Vu:i:", opts, NULL)) != -1) {
switch (argch) {
default:
case '?':
@@ -916,6 +1036,11 @@ int main(int argc, char* argv[])
uid = pw->pw_uid;
gid = pw->pw_gid;
break;
+ case 'i':
+ info_mode = 1;
+ load_plugin(optarg);
+ exit(0);
+ break;
}
}
--
1.5.2.5
next prev parent reply other threads:[~2008-02-02 22:16 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-02 21:23 [ULOGD RFC PATCH 0/34] Eric Leblond
2008-02-02 21:23 ` [PATCH 01/34] Introduce new SQL schema Eric Leblond
2008-02-02 21:23 ` [PATCH 02/34] [Resend] Do not propagate one conntrack event via 2 messages Eric Leblond
2008-02-02 21:23 ` [PATCH 03/34] Use an enum to clarify code Eric Leblond
2008-02-02 21:23 ` [PATCH 04/34] Adapt printflow for one conntrack entry per line format Eric Leblond
2008-02-02 21:24 ` Eric Leblond [this message]
2008-02-02 21:24 ` [PATCH 06/34] New version of SQL schema Eric Leblond
2008-02-02 21:24 ` [PATCH 07/34] Changed sighup_handler_print to fallback to continue using old descriptor on new file opening failure Eric Leblond
2008-02-02 21:24 ` [PATCH 08/34] Added explicit null termination of the hostname buffer Eric Leblond
2008-02-02 21:24 ` [PATCH 09/34] For OPRINT, changed sighup_handler_print to fallback to continue using old descriptor on new file opening failure Eric Leblond
2008-02-02 21:24 ` [PATCH 10/34] Add some missing line break Eric Leblond
2008-02-02 21:24 ` [PATCH 11/34] Put O at the real end of the string Eric Leblond
2008-02-02 21:24 ` [PATCH 12/34] Changed to show pcap file name when open failed Eric Leblond
2008-02-02 21:24 ` [PATCH 13/34] Display filename in the other error case Eric Leblond
2008-02-02 21:24 ` [PATCH 14/34] Request at least autoconf 2.50 (needed for large file support macro) Eric Leblond
2008-02-02 21:24 ` [PATCH 15/34] MySQL client library does not reconnect automatically since 5.0 Eric Leblond
2008-02-02 21:24 ` [PATCH 16/34] Introduce IP2STR module which convert IP to string Eric Leblond
2008-02-02 21:24 ` [PATCH 17/34] Suppress key relative to IPv6 address Eric Leblond
2008-02-02 21:24 ` [PATCH 18/34] Update schema for PostgreSQL Eric Leblond
2008-02-02 21:24 ` [PATCH 19/34] Fix options for pgsql module Eric Leblond
2008-02-02 21:24 ` [PATCH 20/34] Mark ID as inactive (sequence in pg schema) Eric Leblond
2008-02-02 21:24 ` [PATCH 21/34] Add IP2BIN module: convert IP address to binary string Eric Leblond
2008-02-02 21:24 ` [PATCH 22/34] Fix description and indenting Eric Leblond
2008-02-02 21:24 ` [PATCH 23/34] Print RAW as raw string Eric Leblond
2008-02-02 21:24 ` [PATCH 24/34] Fix IPv4 output Eric Leblond
2008-02-02 21:24 ` [PATCH 25/34] Set oob.family as VALID key Eric Leblond
2008-02-02 21:24 ` [PATCH 26/34] Modify IPv6 parser to fill oob_family Eric Leblond
2008-02-02 21:24 ` [PATCH 27/34] Free insertion function result (mysql) Eric Leblond
2008-02-02 21:24 ` [PATCH 28/34] Update SQL schema Eric Leblond
2008-02-02 21:24 ` [PATCH 29/34] Fix some place were oob_family was used instead of _oob_family Eric Leblond
2008-02-02 21:24 ` [PATCH 30/34] Convert SQL procedure to function call Eric Leblond
2008-02-02 21:24 ` [PATCH 31/34] Switch from INNER JOIN to LEFT JOIN in ulog view Eric Leblond
2008-02-02 21:24 ` [PATCH 32/34] Add state extension Eric Leblond
2008-02-02 21:24 ` [PATCH 33/34] ULOGD_RET_IPADDR is for IPv4 or IPv6 address: fix description Eric Leblond
2008-02-02 21:24 ` [PATCH 34/34] Modify insert functions to accept standard integers to avoid casts Eric Leblond
2008-02-03 12:28 ` Pablo Neira Ayuso
2008-02-03 12:29 ` [PATCH 33/34] ULOGD_RET_IPADDR is for IPv4 or IPv6 address: fix description Pablo Neira Ayuso
2008-02-03 12:27 ` [PATCH 32/34] Add state extension Pablo Neira Ayuso
2008-02-03 12:26 ` [PATCH 31/34] Switch from INNER JOIN to LEFT JOIN in ulog view Pablo Neira Ayuso
2008-02-03 12:26 ` [PATCH 30/34] Convert SQL procedure to function call Pablo Neira Ayuso
2008-02-03 12:24 ` [PATCH 29/34] Fix some place were oob_family was used instead of _oob_family Pablo Neira Ayuso
2008-02-03 12:23 ` [PATCH 28/34] Update SQL schema Pablo Neira Ayuso
2008-02-03 12:22 ` [PATCH 27/34] Free insertion function result (mysql) Pablo Neira Ayuso
2008-02-03 12:21 ` [PATCH 26/34] Modify IPv6 parser to fill oob_family Pablo Neira Ayuso
2008-02-03 12:17 ` [PATCH 25/34] Set oob.family as VALID key Pablo Neira Ayuso
2008-02-03 12:10 ` [PATCH 24/34] Fix IPv4 output Pablo Neira Ayuso
2008-02-03 17:36 ` Eric Leblond
2008-02-03 12:09 ` [PATCH 23/34] Print RAW as raw string Pablo Neira Ayuso
2008-02-03 12:07 ` [PATCH 22/34] Fix description and indenting Pablo Neira Ayuso
2008-02-03 12:04 ` [PATCH 21/34] Add IP2BIN module: convert IP address to binary string Pablo Neira Ayuso
2008-02-03 12:02 ` [PATCH 20/34] Mark ID as inactive (sequence in pg schema) Pablo Neira Ayuso
2008-02-03 12:01 ` [PATCH 19/34] Fix options for pgsql module Pablo Neira Ayuso
2008-02-03 11:59 ` [PATCH 18/34] Update schema for PostgreSQL Pablo Neira Ayuso
2008-02-03 11:59 ` [PATCH 17/34] Suppress key relative to IPv6 address Pablo Neira Ayuso
2008-02-03 11:55 ` [PATCH 16/34] Introduce IP2STR module which convert IP to string Pablo Neira Ayuso
2008-02-03 11:45 ` [PATCH 15/34] MySQL client library does not reconnect automatically since 5.0 Pablo Neira Ayuso
2008-02-03 11:44 ` [PATCH 14/34] Request at least autoconf 2.50 (needed for large file support macro) Pablo Neira Ayuso
2008-02-03 11:43 ` [PATCH 13/34] Display filename in the other error case Pablo Neira Ayuso
2008-02-03 11:42 ` [PATCH 12/34] Changed to show pcap file name when open failed Pablo Neira Ayuso
2008-02-03 11:41 ` [PATCH 11/34] Put O at the real end of the string Pablo Neira Ayuso
2008-02-03 11:40 ` [PATCH 10/34] Add some missing line break Pablo Neira Ayuso
2008-02-03 11:38 ` [PATCH 09/34] For OPRINT, changed sighup_handler_print to fallback to continue using old descriptor on new file opening failure Pablo Neira Ayuso
2008-02-03 11:36 ` [PATCH 08/34] Added explicit null termination of the hostname buffer Pablo Neira Ayuso
2008-02-03 11:35 ` [PATCH 07/34] Changed sighup_handler_print to fallback to continue using old descriptor on new file opening failure Pablo Neira Ayuso
2008-02-03 11:34 ` [PATCH 06/34] New version of SQL schema Pablo Neira Ayuso
2008-02-03 11:30 ` [PATCH 05/34] Add --info option which displays information about plugin Pablo Neira Ayuso
2008-02-03 11:25 ` [PATCH 04/34] Adapt printflow for one conntrack entry per line format Pablo Neira Ayuso
2008-02-03 11:23 ` [PATCH 03/34] Use an enum to clarify code Pablo Neira Ayuso
2008-02-03 9:27 ` [PATCH 02/34] [Resend] Do not propagate one conntrack event via 2 messages Holger Eitzenberger
2008-02-03 11:53 ` Eric Leblond
2008-02-19 14:05 ` Eric Leblond
2008-02-19 15:31 ` Pablo Neira Ayuso
2008-02-19 15:49 ` [ULOGD2 PATCH] Sends one message for each connection event instead of two Eric Leblond
2008-02-19 16:01 ` Pablo Neira Ayuso
2008-02-03 11:22 ` [PATCH 01/34] Introduce new SQL schema Pablo Neira Ayuso
2008-02-03 11:50 ` Eric Leblond
2008-02-03 11:57 ` Eric Leblond
2008-02-03 12:17 ` Pablo Neira Ayuso
2008-02-06 10:04 ` [PATCH] Use index2name capabilities of libnfnetlink in IFINDEX filter Eric Leblond
2008-02-07 6:45 ` Pablo Neira Ayuso
2008-02-03 12:14 ` [PATCH 01/34] Introduce new SQL schema Pablo Neira Ayuso
2008-02-03 12:37 ` Holger Eitzenberger
2008-02-03 17:34 ` Pierre Chifflier
2008-02-03 23:54 ` Pablo Neira Ayuso
2008-02-03 0:32 ` [ULOGD RFC PATCH 0/34] Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12019874703998-git-send-email-eric@inl.fr \
--to=eric@inl.fr \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.