aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-04-29 13:13:51 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-04-29 13:13:51 +0000
commit2b69c99ba198eecfcc1ce8202e834e9e6aa84840 (patch)
tree00f768b6859509f77a8c60329b68efc977acf275 /src/vpn
parent829a8f6820744897bbfa7d8ab25aeafcd9ba26d5 (diff)
downloadgnunet-2b69c99ba198eecfcc1ce8202e834e9e6aa84840.tar.gz
gnunet-2b69c99ba198eecfcc1ce8202e834e9e6aa84840.zip
Better hashing for the services in -exit
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-daemon-exit.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c
index 7ef9e6a36..3e49a3290 100644
--- a/src/vpn/gnunet-daemon-exit.c
+++ b/src/vpn/gnunet-daemon-exit.c
@@ -274,12 +274,9 @@ udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen,
274 memcpy ((GNUNET_HashCode *) (desc + 1), &state->desc, 274 memcpy ((GNUNET_HashCode *) (desc + 1), &state->desc,
275 sizeof (GNUNET_HashCode)); 275 sizeof (GNUNET_HashCode));
276 *desc = ntohs (udp->spt); 276 *desc = ntohs (udp->spt);
277 GNUNET_HashCode hash;
278 //FIXME better hashing
279 GNUNET_CRYPTO_hash (desc, sizeof (GNUNET_HashCode) + 2, &hash);
280 GNUNET_assert (GNUNET_OK == 277 GNUNET_assert (GNUNET_OK ==
281 GNUNET_CONTAINER_multihashmap_put (udp_services, 278 GNUNET_CONTAINER_multihashmap_put (udp_services,
282 &hash, serv, 279 (GNUNET_HashCode*)desc, serv,
283 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 280 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
284 281
285 state->serv = serv; 282 state->serv = serv;
@@ -484,8 +481,6 @@ read_service_conf (void *cls, const char *section, const char *option,
484 481
485 *desc = local_port; 482 *desc = local_port;
486 483
487 GNUNET_CRYPTO_hash (desc, sizeof (GNUNET_HashCode) + 2, &hash);
488
489 struct redirect_service *serv = 484 struct redirect_service *serv =
490 GNUNET_malloc (sizeof (struct redirect_service)); 485 GNUNET_malloc (sizeof (struct redirect_service));
491 memset (serv, 0, sizeof (struct redirect_service)); 486 memset (serv, 0, sizeof (struct redirect_service));
@@ -531,16 +526,15 @@ read_service_conf (void *cls, const char *section, const char *option,
531 *((unsigned long long *) (desc + 1))); 526 *((unsigned long long *) (desc + 1)));
532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store with key2 %x\n", 527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store with key2 %x\n",
533 *((unsigned long long *) &hash)); 528 *((unsigned long long *) &hash));
534 //FIXME better hashing
535 if (UDP == proto) 529 if (UDP == proto)
536 GNUNET_assert (GNUNET_OK == 530 GNUNET_assert (GNUNET_OK ==
537 GNUNET_CONTAINER_multihashmap_put (udp_services, 531 GNUNET_CONTAINER_multihashmap_put (udp_services,
538 &hash, serv, 532 (GNUNET_HashCode*)desc, serv,
539 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 533 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
540 else 534 else
541 GNUNET_assert (GNUNET_OK == 535 GNUNET_assert (GNUNET_OK ==
542 GNUNET_CONTAINER_multihashmap_put (tcp_services, 536 GNUNET_CONTAINER_multihashmap_put (tcp_services,
543 &hash, serv, 537 (GNUNET_HashCode*)desc, serv,
544 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 538 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
545 539
546 } 540 }
@@ -836,10 +830,8 @@ receive_tcp_service (void *cls,
836 830
837 memcpy (tcp_desc + 1, desc, sizeof (GNUNET_HashCode)); 831 memcpy (tcp_desc + 1, desc, sizeof (GNUNET_HashCode));
838 *tcp_desc = ntohs (pkt->dpt); 832 *tcp_desc = ntohs (pkt->dpt);
839 //FIXME better hashing
840 GNUNET_CRYPTO_hash (tcp_desc, sizeof (GNUNET_HashCode) + 2, &hash);
841 struct redirect_service *serv = 833 struct redirect_service *serv =
842 GNUNET_CONTAINER_multihashmap_get (tcp_services, &hash); 834 GNUNET_CONTAINER_multihashmap_get (tcp_services, (GNUNET_HashCode*)tcp_desc);
843 if (NULL == serv) 835 if (NULL == serv)
844 { 836 {
845 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 837 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -938,10 +930,8 @@ receive_udp_service (void *cls,
938 uint16_t *udp_desc = alloca (sizeof (GNUNET_HashCode) + 2); 930 uint16_t *udp_desc = alloca (sizeof (GNUNET_HashCode) + 2);
939 memcpy (udp_desc + 1, desc, sizeof (GNUNET_HashCode)); 931 memcpy (udp_desc + 1, desc, sizeof (GNUNET_HashCode));
940 *udp_desc = ntohs (pkt->dpt); 932 *udp_desc = ntohs (pkt->dpt);
941 //FIXME better hashing
942 GNUNET_CRYPTO_hash (udp_desc, sizeof (GNUNET_HashCode) + 2, &hash);
943 struct redirect_service *serv = 933 struct redirect_service *serv =
944 GNUNET_CONTAINER_multihashmap_get (udp_services, &hash); 934 GNUNET_CONTAINER_multihashmap_get (udp_services, (GNUNET_HashCode*)udp_desc);
945 if (NULL == serv) 935 if (NULL == serv)
946 { 936 {
947 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 937 GNUNET_log (GNUNET_ERROR_TYPE_INFO,