grab latency data
authorChristian Grothoff <christian@grothoff.org>
Tue, 30 Nov 2010 14:23:35 +0000 (14:23 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 30 Nov 2010 14:23:35 +0000 (14:23 +0000)
src/fs/gnunet-service-fs.c

index 0ed9299e60895982c692bd395af4b117823af42b..f02e85bba2f944799e5ec169e0df564e09c6e2a4 100644 (file)
@@ -39,6 +39,7 @@
 #include "gnunet_protocols.h"
 #include "gnunet_signatures.h"
 #include "gnunet_statistics_service.h"
+#include "gnunet_transport_service.h"
 #include "gnunet_util_lib.h"
 #include "gnunet-service-fs_indexing.h"
 #include "fs.h"
@@ -1582,8 +1583,17 @@ destroy_pending_request (struct PendingRequest *pr)
 static struct GNUNET_TIME_Relative
 get_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
-  /* FIXME: extract latency data from 'atsi' */
-  return GNUNET_TIME_UNIT_SECONDS;
+  while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
+         (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) )
+    atsi++;
+  if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) 
+    {
+      GNUNET_break (0);
+      /* how can we not have latency data? */
+      return GNUNET_TIME_UNIT_SECONDS;
+    }
+  return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+                                       ntohl (atsi->value));
 }