gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19005 - in gnunet/src: nse util


From: gnunet
Subject: [GNUnet-SVN] r19005 - in gnunet/src: nse util
Date: Thu, 5 Jan 2012 16:10:46 +0100

Author: grothoff
Date: 2012-01-05 16:10:46 +0100 (Thu, 05 Jan 2012)
New Revision: 19005

Modified:
   gnunet/src/nse/gnunet-service-nse.c
   gnunet/src/nse/nse_api.c
   gnunet/src/util/common_endian.c
Log:
-try converting doubles to network byte order

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2012-01-05 14:45:24 UTC (rev 19004)
+++ gnunet/src/nse/gnunet-service-nse.c 2012-01-05 15:10:46 UTC (rev 19005)
@@ -385,11 +385,12 @@
   em->header.type = htons (GNUNET_MESSAGE_TYPE_NSE_ESTIMATE);
   em->reserved = htonl (0);
   em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
-  em->size_estimate = mean - 0.332747;
+  double se = mean - 0.332747;
   nsize = log2 (GNUNET_CONTAINER_multihashmap_size (peers) + 1);
   if (em->size_estimate < nsize)
-    em->size_estimate = nsize;
-  em->std_deviation = std_dev;
+    se = nsize;
+  em->size_estimate = GNUNET_hton_double (se);
+  em->std_deviation = GNUNET_hton_double (std_dev);
   GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)",
                          (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO);
 }

Modified: gnunet/src/nse/nse_api.c
===================================================================
--- gnunet/src/nse/nse_api.c    2012-01-05 14:45:24 UTC (rev 19004)
+++ gnunet/src/nse/nse_api.c    2012-01-05 15:10:46 UTC (rev 19005)
@@ -120,7 +120,8 @@
   }
   client_msg = (const struct GNUNET_NSE_ClientMessage *) msg;
   h->recv_cb (h->recv_cb_cls, GNUNET_TIME_absolute_ntoh 
(client_msg->timestamp),
-              client_msg->size_estimate, client_msg->std_deviation);
+              GNUNET_ntoh_double (client_msg->size_estimate), 
+             GNUNET_ntoh_double (client_msg->std_deviation));
   GNUNET_CLIENT_receive (h->client, &message_handler, h,
                          GNUNET_TIME_UNIT_FOREVER_REL);
 }

Modified: gnunet/src/util/common_endian.c
===================================================================
--- gnunet/src/util/common_endian.c     2012-01-05 14:45:24 UTC (rev 19004)
+++ gnunet/src/util/common_endian.c     2012-01-05 15:10:46 UTC (rev 19005)
@@ -50,5 +50,33 @@
 }
 
 
+double 
+GNUNET_hton_double (double d) 
+{
+  double res;
+  unsigned int *in = (unsigned int *) &d;
+  unsigned int *out = (unsigned int *) &res;
 
+  out[0] = htonl(in[0]);
+  out[1] = htonl(in[1]);
+ 
+  return res;
+}
+
+
+double 
+GNUNET_ntoh_double (double d) 
+{
+  double res;
+  unsigned int *in = (unsigned int *) &d;
+  unsigned int *out = (unsigned int *) &res;
+
+  out[0] = ntohl(in[0]);
+  out[1] = ntohl(in[1]);
+ 
+  return res;
+}
+
+
+
 /* end of common_endian.c */




reply via email to

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