summaryrefslogtreecommitdiff
path: root/epan/wmem/wmem_map_int.h
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2014-04-21 20:30:06 -0400
committerEvan Huus <eapache@gmail.com>2014-04-23 12:42:26 +0000
commit9ba4c6e0916a9a40885827864da6353e1572e3b6 (patch)
tree5d63f5cd97ceecacf6abc31533a5f663b881c0fd /epan/wmem/wmem_map_int.h
parent268104a1ddd476632b84008f33f70ec11cd95fc3 (diff)
downloadwireshark-9ba4c6e0916a9a40885827864da6353e1572e3b6.tar.gz
Hash map implementation for wmem.
This has two expected uses: - Many current users of wmem_tree don't actually need the predecessor lookup it provides (the lookup_le function family). A hash map provides straight insertion and lookup much more efficiently than a wmem_tree when predecessor lookup isn't needed. - Many current users of glib's hash table and hash functions use untrusted data for keys, making them vulnerable to algorithmic complexity attacks. Care has been taken to make this implementation secure against such attacks, so it should be used whenever data is untrusted. In my benchmarks it is measurably slower than GHashTable, but not excessively so. Given the additional security it provides this seems like a reasonable trade-off (and it is still faster than a wmem_tree). Change-Id: I2d67a0d06029f14c153eaa42d5cfc774aefd9918 Reviewed-on: https://code.wireshark.org/review/1272 Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/wmem/wmem_map_int.h')
-rw-r--r--epan/wmem/wmem_map_int.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/epan/wmem/wmem_map_int.h b/epan/wmem/wmem_map_int.h
new file mode 100644
index 0000000000..2ba68e1c8a
--- /dev/null
+++ b/epan/wmem/wmem_map_int.h
@@ -0,0 +1,52 @@
+/* wmem_map_int.h
+ * Definitions for the Wireshark Memory Manager Hash Map Internals
+ * Copyright 2014, Evan Huus <eapache@gmail.com>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __WMEM_MAP_INT_H__
+#define __WMEM_MAP_INT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+WS_DLL_LOCAL
+void
+wmem_init_hashing(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __WMEM_MAP_INT_H__ */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */