]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
move plugin wildcard input key generation into core
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>
Thu, 15 Dec 2005 14:07:15 +0000 (14:07 +0000)
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>
Thu, 15 Dec 2005 14:07:15 +0000 (14:07 +0000)
include/ulogd/ulogd.h
output/ulogd_output_OPRINT.c
src/ulogd.c

index 7e71ca7176ac68da083ebca3898caf2236df2e92..a8628dbbe3e2eb00fed3200ab3187559577efad5 100644 (file)
@@ -217,6 +217,7 @@ void __ulogd_log(int level, char *file, int line, const char *message, ...);
 #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
index e8b8d0ec10ca63562d93896e049838fae17e129a..07364b66ba70a1f946b764ee346f3b5735bf1a28 100644 (file)
@@ -137,43 +137,15 @@ static void sighup_handler_print(struct ulogd_pluginstance *upi, int signal)
 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;
-
-       /* 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. */
-
-       /* 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];
-       }
+       int ret;
 
-       config_parse_file(upi->id, upi->config_kset);
+       ret = ulogd_wildcard_inputkeys(upi);
+       if (ret < 0)
+               return ret;
 
-       /* the count needs to be per-instance */
-       upi->input.num_keys = num_keys;
+       ret = config_parse_file(upi->id, upi->config_kset);
+       if (ret < 0)
+               return ret;
 
        return 0;
 }
index f10a0084632ccf709cabdcf61c353b3310aacf96..1acfa3363b3b6ba05ad317a0c91f1ed1383caa5d 100644 (file)
@@ -180,6 +180,51 @@ int ulogd_key_size(struct ulogd_key *key)
        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 
  ***********************************************************************/