You may not use g_int64_hash() or g_int64_equal(), as they are not
authorGuy Harris <guy@alum.mit.edu>
Tue, 26 Oct 2010 08:31:16 +0000 (08:31 -0000)
committerGuy Harris <guy@alum.mit.edu>
Tue, 26 Oct 2010 08:31:16 +0000 (08:31 -0000)
present in the minimum version of GLib that we support.  Create a
ieee802154_long_addr structure for long addresses, create hash
routines for those addresses, and use them.

svn path=/trunk/; revision=34651

epan/dissectors/packet-ieee802154.c
epan/dissectors/packet-ieee802154.h

index 1f10f91ac5a681b96466d4e73869652bd0eef7ea..463b17f1d8117fe6c158948b6ae07cdbf391e404 100644 (file)
@@ -2226,6 +2226,18 @@ gboolean ieee802154_short_addr_equal(gconstpointer a, gconstpointer b)
            (((ieee802154_short_addr *)a)->addr == ((ieee802154_short_addr *)b)->addr);
 }
 
+/* Key hash function. */
+guint ieee802154_long_addr_hash(gconstpointer key)
+{
+    return (((ieee802154_long_addr *)key)->addr) & 0xFFFFFFFF;
+}
+
+/* Key equal function. */
+gboolean ieee802154_long_addr_equal(gconstpointer a, gconstpointer b)
+{
+    return (((ieee802154_long_addr *)a)->addr == ((ieee802154_long_addr *)b)->addr);
+}
+
 /*FUNCTION:------------------------------------------------------
  *  NAME
  *      ieee802154_addr_update
@@ -2821,9 +2833,7 @@ proto_init_ieee802154(void)
 
     /* Create the hash tables. */
     ieee802154_addr.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal);
-#if GLIB_CHECK_VERSION(2,22,0)
-    ieee802154_addr.long_table = g_hash_table_new(g_int64_hash, g_int64_equal);
-#endif
+    ieee802154_addr.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal);
     /* Re-load the hash table from the static address UAT. */
     for (i=0; (i<num_static_addrs) && (static_addrs); i++) {
         ieee802154_addr_update(&ieee802154_addr,(guint16)static_addrs[i].addr16, (guint16)static_addrs[i].pan,
index 8cbce7aa4b177765c559402e6b4f8b8470c93c71..25c7d4275a7abe56ed45c433fe80829c16e7ba1b 100644 (file)
@@ -216,6 +216,11 @@ typedef struct {
     guint16     addr;
 } ieee802154_short_addr;
 
+/* Key used by the long address hash table. */
+typedef struct {
+    guint64     addr;
+} ieee802154_long_addr;
+
 /* A mapping record for a frame, pointed to by hash table */
 typedef struct {
     int         proto; /* protocol that created this record */