[netfilter-cvslog] r6326 - in branches/ulog/ulogd2: include/ulogd
output src
laforge at netfilter.org
laforge at netfilter.org
Thu Dec 15 15:07:16 CET 2005
Author: laforge at netfilter.org
Date: 2005-12-15 15:07:15 +0100 (Thu, 15 Dec 2005)
New Revision: 6326
Modified:
branches/ulog/ulogd2/include/ulogd/ulogd.h
branches/ulog/ulogd2/output/ulogd_output_OPRINT.c
branches/ulog/ulogd2/src/ulogd.c
Log:
move plugin wildcard input key generation into core
Modified: branches/ulog/ulogd2/include/ulogd/ulogd.h
===================================================================
--- branches/ulog/ulogd2/include/ulogd/ulogd.h 2005-12-15 13:15:26 UTC (rev 6325)
+++ branches/ulog/ulogd2/include/ulogd/ulogd.h 2005-12-15 14:07:15 UTC (rev 6326)
@@ -217,6 +217,7 @@
#define SET_NEEDED(x) (x.flags |= ULOGD_RETF_NEEDED)
int ulogd_key_size(struct ulogd_key *key);
+int ulogd_wildcard_inputkeys(struct ulogd_pluginstance *upi);
/***********************************************************************
* file descriptor handling
Modified: branches/ulog/ulogd2/output/ulogd_output_OPRINT.c
===================================================================
--- branches/ulog/ulogd2/output/ulogd_output_OPRINT.c 2005-12-15 13:15:26 UTC (rev 6325)
+++ branches/ulog/ulogd2/output/ulogd_output_OPRINT.c 2005-12-15 14:07:15 UTC (rev 6326)
@@ -137,44 +137,16 @@
static int oprint_configure(struct ulogd_pluginstance *upi,
struct ulogd_pluginstance_stack *stack)
{
- struct ulogd_pluginstance *pi_cur;
- unsigned int num_keys = 0;
- unsigned int index = 0;
+ int ret;
- /* ok, this is a bit tricky, and probably requires some documentation.
- * Since we are a output plugin (SINK), we can only be the last one
- * in the stack. Therefore, all other (input/filter) plugins, area
- * already linked into the stack. This means, we can iterate over them,
- * get a list of all the keys, and create one input key for every output
- * key that any of the upstream plugins provide. By the time we resolve
- * the inter-key pointers, everything will work as expected. */
+ ret = ulogd_wildcard_inputkeys(upi);
+ if (ret < 0)
+ return ret;
- /* first pass: count keys */
- llist_for_each_entry(pi_cur, &stack->list, list) {
- ulogd_log(ULOGD_DEBUG, "iterating over pluginstance '%s'\n",
- pi_cur->id);
- num_keys += pi_cur->plugin->output.num_keys;
- }
+ ret = config_parse_file(upi->id, upi->config_kset);
+ if (ret < 0)
+ return ret;
- ulogd_log(ULOGD_DEBUG, "allocating %u input keys\n", num_keys);
- upi->input.keys = malloc(sizeof(struct ulogd_key) * num_keys);
- if (!upi->input.keys)
- return -ENOMEM;
-
- /* second pass: copy key names */
- llist_for_each_entry(pi_cur, &stack->list, list) {
- struct ulogd_key *cur;
- int i;
-
- for (i = 0; i < pi_cur->plugin->output.num_keys; i++)
- upi->input.keys[index++] = pi_cur->output.keys[i];
- }
-
- config_parse_file(upi->id, upi->config_kset);
-
- /* the count needs to be per-instance */
- upi->input.num_keys = num_keys;
-
return 0;
}
Modified: branches/ulog/ulogd2/src/ulogd.c
===================================================================
--- branches/ulog/ulogd2/src/ulogd.c 2005-12-15 13:15:26 UTC (rev 6325)
+++ branches/ulog/ulogd2/src/ulogd.c 2005-12-15 14:07:15 UTC (rev 6326)
@@ -180,6 +180,51 @@
return ret;
}
+int ulogd_wildcard_inputkeys(struct ulogd_pluginstance *upi)
+{
+ struct ulogd_pluginstance_stack *stack = upi->stack;
+ struct ulogd_pluginstance *pi_cur;
+ unsigned int num_keys = 0;
+ unsigned int index = 0;
+
+ /* ok, this is a bit tricky, and probably requires some documentation.
+ * Since we are a output plugin (SINK), we can only be the last one
+ * in the stack. Therefore, all other (input/filter) plugins, area
+ * already linked into the stack. This means, we can iterate over them,
+ * get a list of all the keys, and create one input key for every output
+ * key that any of the upstream plugins provide. By the time we resolve
+ * the inter-key pointers, everything will work as expected. */
+
+ if (upi->input.keys)
+ free(upi->input.keys);
+
+ /* first pass: count keys */
+ llist_for_each_entry(pi_cur, &stack->list, list) {
+ ulogd_log(ULOGD_DEBUG, "iterating over pluginstance '%s'\n",
+ pi_cur->id);
+ num_keys += pi_cur->plugin->output.num_keys;
+ }
+
+ ulogd_log(ULOGD_DEBUG, "allocating %u input keys\n", num_keys);
+ upi->input.keys = malloc(sizeof(struct ulogd_key) * num_keys);
+ if (!upi->input.keys)
+ return -ENOMEM;
+
+ /* second pass: copy key names */
+ llist_for_each_entry(pi_cur, &stack->list, list) {
+ struct ulogd_key *cur;
+ int i;
+
+ for (i = 0; i < pi_cur->plugin->output.num_keys; i++)
+ upi->input.keys[index++] = pi_cur->output.keys[i];
+ }
+
+ upi->input.num_keys = num_keys;
+
+ return 0;
+}
+
+
/***********************************************************************
* PLUGIN MANAGEMENT
***********************************************************************/
More information about the netfilter-cvslog
mailing list