summaryrefslogtreecommitdiffstats
path: root/include/ulogd/hash.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-06-02 01:36:48 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2008-06-02 01:36:48 +0200
commitf72bf0ed59d14270d7b820626f9c7a7c67f40c00 (patch)
tree89a99f9d371bf9c96851b66a1d16e6c69f73b811 /include/ulogd/hash.h
parente4f0bd0a93e4777abea99fe7a33d50fd74b57aba (diff)
rework NFCT to use a generic hashtable
This patch introduces a generic hashtable to store the nf_conntrack objects. The objects are identified by the original and reply tuples instead of the conntrack ID which is not dumped in the event message of linux kernel < 2.6.25. This patch also fixes the NFCT_MSG_* by NFCT_T_* which is the appropriate message type tag.
Diffstat (limited to 'include/ulogd/hash.h')
-rw-r--r--include/ulogd/hash.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/ulogd/hash.h b/include/ulogd/hash.h
new file mode 100644
index 0000000..45d2f48
--- /dev/null
+++ b/include/ulogd/hash.h
@@ -0,0 +1,48 @@
+#ifndef _NF_SET_HASH_H_
+#define _NF_SET_HASH_H_
+
+#include <unistd.h>
+#include "slist.h"
+#include <ulogd/linuxlist.h>
+
+#include <stdint.h>
+
+struct hashtable;
+struct hashtable_node;
+
+struct hashtable {
+ uint32_t hashsize;
+ uint32_t limit;
+ uint32_t count;
+ uint32_t initval;
+ uint32_t datasize;
+
+ uint32_t (*hash)(const void *data, struct hashtable *table);
+ int (*compare)(const void *data1, const void *data2);
+
+ struct slist_head members[0];
+};
+
+struct hashtable_node {
+ struct slist_head head;
+ char data[0];
+};
+
+struct hashtable_node *hashtable_alloc_node(int datasize, void *data);
+void hashtable_destroy_node(struct hashtable_node *h);
+
+struct hashtable *
+hashtable_create(int hashsize, int limit, int datasize,
+ uint32_t (*hash)(const void *data, struct hashtable *table),
+ int (*compare)(const void *data1, const void *data2));
+void hashtable_destroy(struct hashtable *h);
+
+void *hashtable_add(struct hashtable *table, void *data);
+void *hashtable_get(struct hashtable *table, const void *data);
+int hashtable_del(struct hashtable *table, void *data);
+int hashtable_flush(struct hashtable *table);
+int hashtable_iterate(struct hashtable *table, void *data,
+ int (*iterate)(void *data1, void *data2));
+unsigned int hashtable_counter(const struct hashtable *table);
+
+#endif