aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-16 13:06:51 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-16 13:06:51 +0000
commit8e13c09bafa9ef36c83955f82d883d47e597ca78 (patch)
tree9141764bf42d4a745c999769dfb05fd72c50a502
parent57dc1a4ec314043cfdbf6e5a0bcf3c4ca103ddec (diff)
downloadgnunet-8e13c09bafa9ef36c83955f82d883d47e597ca78.tar.gz
gnunet-8e13c09bafa9ef36c83955f82d883d47e597ca78.zip
print ats information
-rw-r--r--src/ats-tool/gnunet-ats.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index a9a8073b0..73e017fc1 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -61,6 +61,9 @@ struct PendingResolutions
61 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; 61 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
62 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; 62 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
63 63
64 struct GNUNET_ATS_Information *ats;
65 uint32_t ats_count;
66
64 struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx; 67 struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx;
65}; 68};
66 69
@@ -70,11 +73,23 @@ struct PendingResolutions *tail;
70void transport_addr_to_str_cb (void *cls, const char *address) 73void transport_addr_to_str_cb (void *cls, const char *address)
71{ 74{
72 struct PendingResolutions * pr = cls; 75 struct PendingResolutions * pr = cls;
76 char *ats_str;
77 char *ats_tmp;
78 unsigned int c;
73 if (NULL != address) 79 if (NULL != address)
74 { 80 {
75 fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bandwidth out: %u Bytes/s, bandwidth in %u Bytes/s\n"), 81 ats_str = GNUNET_strdup("");
82 for (c = 0; c < pr->ats_count; c++)
83 {
84 ats_tmp = ats_str;
85 GNUNET_asprintf (&ats_str, "%s%u %u ", ats_tmp, ntohl(pr->ats[c].type), ntohl(pr->ats[c].value));
86 GNUNET_free (ats_tmp);
87 }
88
89 fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
76 GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address, 90 GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address,
77 ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__)); 91 ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__),ats_str);
92 GNUNET_free (ats_str);
78 } 93 }
79 else if (NULL != pr) 94 else if (NULL != pr)
80 { 95 {
@@ -102,7 +117,13 @@ void ats_perf_cb (void *cls,
102{ 117{
103 struct PendingResolutions * pr; 118 struct PendingResolutions * pr;
104 119
105 pr = GNUNET_malloc (sizeof (struct PendingResolutions)); 120 pr = GNUNET_malloc (sizeof (struct PendingResolutions) +
121 ats_count * sizeof (struct GNUNET_ATS_Information));
122
123 pr->ats_count = ats_count;
124 pr->ats = (struct GNUNET_ATS_Information *) &pr[1];
125 if (ats_count > 0)
126 memcpy (pr->ats, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
106 pr->address = GNUNET_HELLO_address_copy (address); 127 pr->address = GNUNET_HELLO_address_copy (address);
107 pr->bandwidth_in = bandwidth_in; 128 pr->bandwidth_in = bandwidth_in;
108 pr->bandwidth_out = bandwidth_out; 129 pr->bandwidth_out = bandwidth_out;