gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24995 - gnunet/src/ats-tool


From: gnunet
Subject: [GNUnet-SVN] r24995 - gnunet/src/ats-tool
Date: Fri, 16 Nov 2012 14:06:51 +0100

Author: wachs
Date: 2012-11-16 14:06:51 +0100 (Fri, 16 Nov 2012)
New Revision: 24995

Modified:
   gnunet/src/ats-tool/gnunet-ats.c
Log:
print ats information

Modified: gnunet/src/ats-tool/gnunet-ats.c
===================================================================
--- gnunet/src/ats-tool/gnunet-ats.c    2012-11-16 11:44:01 UTC (rev 24994)
+++ gnunet/src/ats-tool/gnunet-ats.c    2012-11-16 13:06:51 UTC (rev 24995)
@@ -61,6 +61,9 @@
   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
 
+  struct GNUNET_ATS_Information *ats;
+  uint32_t ats_count;
+
   struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx;
 };
 
@@ -70,11 +73,23 @@
 void transport_addr_to_str_cb (void *cls, const char *address)
 {
   struct PendingResolutions * pr = cls;
+  char *ats_str;
+  char *ats_tmp;
+  unsigned int c;
   if (NULL != address)
   {
-      fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bandwidth out: 
%u Bytes/s, bandwidth in %u Bytes/s\n"),
+      ats_str = GNUNET_strdup("");
+      for (c = 0; c <  pr->ats_count; c++)
+      {
+          ats_tmp = ats_str;
+          GNUNET_asprintf (&ats_str, "%s%u %u ", ats_tmp, 
ntohl(pr->ats[c].type), ntohl(pr->ats[c].value));
+          GNUNET_free (ats_tmp);
+      }
+
+      fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bw out: %u 
Bytes/s, bw in %u Bytes/s, %s\n"),
         GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address,
-        ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__));
+        ntohl (pr->bandwidth_out.value__), ntohl 
(pr->bandwidth_in.value__),ats_str);
+      GNUNET_free (ats_str);
   }
   else if (NULL != pr)
   {
@@ -102,7 +117,13 @@
 {
   struct PendingResolutions * pr;
 
-  pr = GNUNET_malloc (sizeof (struct PendingResolutions));
+  pr = GNUNET_malloc (sizeof (struct PendingResolutions) +
+                      ats_count * sizeof (struct GNUNET_ATS_Information));
+
+  pr->ats_count = ats_count;
+  pr->ats = (struct GNUNET_ATS_Information *) &pr[1];
+  if (ats_count > 0)
+    memcpy (pr->ats, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
   pr->address = GNUNET_HELLO_address_copy (address);
   pr->bandwidth_in = bandwidth_in;
   pr->bandwidth_out = bandwidth_out;




reply via email to

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