aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-02-16 11:32:39 -0800
committerGuy Harris <guy@alum.mit.edu>2015-02-16 19:33:57 +0000
commitcfb1bc3bb44d6b5a12eac28905b02e6a3a60d17b (patch)
tree6e75b150888d6a67bd76af6dc667527b809ca770
parent4765bbc2a906a6ce4f141aa5beb46c553b4667bd (diff)
Put the 64-bit hash routines into a common file.
Some or all are used by the Infiniband, MBIM, and RSVD dissectors; put them into a common source file, with a header for them, and just include the header in the dissectors. Change-Id: I724f0c2232ba751ccbd491222af6f03bafd6d63c Reviewed-on: https://code.wireshark.org/review/7182 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/CMakeLists.txt1
-rw-r--r--epan/Makefile.common2
-rw-r--r--epan/dissectors/packet-infiniband.c19
-rw-r--r--epan/dissectors/packet-mbim.c9
-rw-r--r--epan/dissectors/packet-rsvd.c1
-rw-r--r--epan/g_int64_hash_routines.c77
-rw-r--r--epan/g_int64_hash_routines.h43
7 files changed, 126 insertions, 26 deletions
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index 5a6756cd95..bdc988ca53 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -1589,6 +1589,7 @@ set(LIBWIRESHARK_FILES
frame_data_sequence.c
frequency-utils.c
funnel.c
+ g_int64_hash_routines.c
gcp.c
geoip_db.c
golay.c
diff --git a/epan/Makefile.common b/epan/Makefile.common
index 28ace26330..99a0bb3aff 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -57,6 +57,7 @@ LIBWIRESHARK_SRC = \
frame_data_sequence.c \
frequency-utils.c \
funnel.c \
+ g_int64_hash_routines.c \
gcp.c \
geoip_db.c \
golay.c \
@@ -195,6 +196,7 @@ LIBWIRESHARK_INCLUDES = \
frame_data_sequence.h \
frequency-utils.h \
funnel.h \
+ g_int64_hash_routines.h \
garrayfix.h \
gcp.h \
geoip_db.h \
diff --git a/epan/dissectors/packet-infiniband.c b/epan/dissectors/packet-infiniband.c
index 350c895233..33fe8ea7be 100644
--- a/epan/dissectors/packet-infiniband.c
+++ b/epan/dissectors/packet-infiniband.c
@@ -25,13 +25,13 @@
#include "config.h"
-
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/conversation.h>
#include <epan/prefs.h>
#include <epan/etypes.h>
#include <epan/show_exception.h>
+#include <epan/g_int64_hash_routines.h>
#include <wiretap/erf.h>
#include "packet-infiniband.h"
@@ -1489,23 +1489,6 @@ static heur_dissector_list_t heur_dissectors_cm_private;
/* ----- This sections contains various utility functions indirectly related to Infiniband dissection ---- */
-/* g_int64_hash, g_int64_equal are defined starting glib 2.22 - otherwise, we'll have to
- provide them ourselves! */
-#if !GLIB_CHECK_VERSION(2,22,0)
-guint
-g_int64_hash (gconstpointer v)
-{
- return (guint) *(const gint64*) v;
-}
-
-gboolean
-g_int64_equal (gconstpointer v1,
- gconstpointer v2)
-{
- return *((const gint64*) v1) == *((const gint64*) v2);
-}
-#endif
-
static void table_destroy_notify(gpointer data) {
g_free(data);
}
diff --git a/epan/dissectors/packet-mbim.c b/epan/dissectors/packet-mbim.c
index a1390168be..ebc693eb18 100644
--- a/epan/dissectors/packet-mbim.c
+++ b/epan/dissectors/packet-mbim.c
@@ -35,20 +35,13 @@
#include <epan/reassemble.h>
#include <epan/to_str.h>
#include <epan/strutil.h>
+#include <epan/g_int64_hash_routines.h>
#include "packet-gsm_a_common.h"
#include "packet-gsm_map.h"
#include "packet-usb.h"
#include "packet-mbim.h"
-#if !GLIB_CHECK_VERSION(2,22,0)
-static gboolean
-g_int64_equal(gconstpointer v1, gconstpointer v2)
-{
- return *((const gint64*) v1) == *((const gint64*) v2);
-}
-#endif
-
void proto_register_mbim(void);
void proto_reg_handoff_mbim(void);
diff --git a/epan/dissectors/packet-rsvd.c b/epan/dissectors/packet-rsvd.c
index f5049d9a14..d19c9d5958 100644
--- a/epan/dissectors/packet-rsvd.c
+++ b/epan/dissectors/packet-rsvd.c
@@ -30,6 +30,7 @@
#include <epan/conversation.h>
#include <epan/packet.h>
+#include <epan/g_int64_hash_routines.h>
#include "packet-scsi.h"
void proto_reg_handoff_rsvd(void);
diff --git a/epan/g_int64_hash_routines.c b/epan/g_int64_hash_routines.c
new file mode 100644
index 0000000000..606da7409c
--- /dev/null
+++ b/epan/g_int64_hash_routines.c
@@ -0,0 +1,77 @@
+/* g_int64_hash_routines.h
+ * Definition of gint64 hash table routines absent from GLib < 2.22
+ *
+ * From:
+ *
+ * GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include <epan/g_int64_hash_routines.h>
+
+#if !GLIB_CHECK_VERSION(2,22,0)
+/**
+ * g_int64_equal:
+ * @v1: a pointer to a #gint64 key
+ * @v2: a pointer to a #gint64 key to compare with @v1
+ *
+ * Compares the two #gint64 values being pointed to and returns
+ * %TRUE if they are equal.
+ * It can be passed to g_hash_table_new() as the @key_equal_func
+ * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
+ * #GHashTable.
+ *
+ * Returns: %TRUE if the two keys match.
+ *
+ * Since: 2.22
+ */
+gboolean
+g_int64_equal (gconstpointer v1,
+ gconstpointer v2)
+{
+ return *((const gint64*) v1) == *((const gint64*) v2);
+}
+
+/**
+ * g_int64_hash:
+ * @v: a pointer to a #gint64 key
+ *
+ * Converts a pointer to a #gint64 to a hash value.
+ *
+ * It can be passed to g_hash_table_new() as the @hash_func parameter,
+ * when using non-%NULL pointers to 64-bit integer values as keys in a
+ * #GHashTable.
+ *
+ * Returns: a hash value corresponding to the key.
+ *
+ * Since: 2.22
+ */
+guint
+g_int64_hash (gconstpointer v)
+{
+ return (guint) *(const gint64*) v;
+}
+
+#endif /* !GLIB_CHECK_VERSION(2,22,0) */
diff --git a/epan/g_int64_hash_routines.h b/epan/g_int64_hash_routines.h
new file mode 100644
index 0000000000..e606ebec5d
--- /dev/null
+++ b/epan/g_int64_hash_routines.h
@@ -0,0 +1,43 @@
+/* g_int64_hash_routines.h
+ * Declaration of gint64 hash table routines absent from GLib < 2.22
+ *
+ * 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 __G_INT64_HASH_ROUTINES_H__
+#define __G_INT64_HASH_ROUTINES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib.h>
+
+/* g_int64_hash, g_int64_equal are defined starting glib 2.22 - otherwise,
+ we have to provide them ourselves */
+#if !GLIB_CHECK_VERSION(2,22,0)
+guint
+g_int64_hash (gconstpointer v);
+
+gboolean
+g_int64_equal (gconstpointer v1,
+ gconstpointer v2)
+#endif /* !GLIB_CHECK_VERSION(2,22,0) */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* g_int64_hash_routines.h */