gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15119 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r15119 - gnunet/src/vpn
Date: Fri, 29 Apr 2011 15:13:50 +0200

Author: toelke
Date: 2011-04-29 15:13:50 +0200 (Fri, 29 Apr 2011)
New Revision: 15119

Modified:
   gnunet/src/vpn/gnunet-daemon-exit.c
Log:
better hashing for the connection-tracking in the -exit

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-04-29 13:13:49 UTC (rev 15118)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-04-29 13:13:50 UTC (rev 15119)
@@ -194,6 +194,19 @@
     GNUNET_free(state);
 }
 
+static void
+hash_redirect_info(GNUNET_HashCode* hash, struct redirect_info* u_i, size_t 
addrlen)
+{
+
+  /* the gnunet hashmap only uses the first 32bit of the hash
+   *
+   * build the hash out of the last two bytes of the address and the 2 bytes of
+   * the port
+   */
+  memcpy(&hash, &u_i->pt, sizeof(u_i->pt));
+  memcpy(((unsigned char*)&hash)+2, u_i->addr+(addrlen-2), 2);
+}
+
 /**
  * cls is the pointer to a GNUNET_MessageHeader that is
  * followed by the service-descriptor and the udp-packet that should be sent;
@@ -233,9 +246,8 @@
   u_i.pt = udp->dpt;
 
   /* get tunnel and service-descriptor from this */
-  /* FIXME better hashing */
   GNUNET_HashCode hash;
-  GNUNET_CRYPTO_hash (&u_i, sizeof (struct redirect_info), &hash);
+  hash_redirect_info(&hash, &u_i, addrlen);
 
   struct redirect_state *state =
     GNUNET_CONTAINER_multihashmap_get (udp_connections, &hash);
@@ -317,10 +329,10 @@
   memcpy (&u_i.addr, dadr, addrlen);
   u_i.pt = tcp->dpt;
 
-  /* FIXME better hashing */
   /* get tunnel and service-descriptor from this */
   GNUNET_HashCode hash;
-  GNUNET_CRYPTO_hash (&u_i, sizeof (struct redirect_info), &hash);
+  hash_redirect_info(&hash, &u_i, addrlen);
+
   struct redirect_state *state =
     GNUNET_CONTAINER_multihashmap_get (tcp_connections, &hash);
 
@@ -880,9 +892,7 @@
       break;
     }
 
-  /* FIXME better hashing */
-  GNUNET_CRYPTO_hash (&state->redirect_info, sizeof (struct redirect_info),
-                      &state->hash);
+  hash_redirect_info(&state->hash, &state->redirect_info, serv->version == 4 ? 
4 : 16);
 
   if (GNUNET_NO ==
       GNUNET_CONTAINER_multihashmap_contains (tcp_connections, &state->hash))
@@ -984,9 +994,7 @@
       break;
     }
 
-  /* FIXME better hashing */
-  GNUNET_CRYPTO_hash (&state->redirect_info, sizeof (struct redirect_info),
-                      &state->hash);
+  hash_redirect_info(&state->hash, &state->redirect_info, serv->version == 4 ? 
4 : 16);
 
   if (GNUNET_NO ==
       GNUNET_CONTAINER_multihashmap_contains (udp_connections, &state->hash))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]