diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-16 14:11:07 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-16 14:11:07 +0000 |
commit | fefe7e30ec57df396375b0f6d26c6581a1916704 (patch) | |
tree | 9aae84196285465b5ba273bdee5902cd83125285 /src/ats-tool | |
parent | a692bdacf59e0f6406428610fcb9af53864cc8a3 (diff) | |
download | gnunet-fefe7e30ec57df396375b0f6d26c6581a1916704.tar.gz gnunet-fefe7e30ec57df396375b0f6d26c6581a1916704.zip |
print ats properties
Diffstat (limited to 'src/ats-tool')
-rw-r--r-- | src/ats-tool/gnunet-ats.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 73e017fc1..0543549aa 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -75,17 +75,49 @@ void transport_addr_to_str_cb (void *cls, const char *address) | |||
75 | struct PendingResolutions * pr = cls; | 75 | struct PendingResolutions * pr = cls; |
76 | char *ats_str; | 76 | char *ats_str; |
77 | char *ats_tmp; | 77 | char *ats_tmp; |
78 | char *ats_prop_arr[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings; | ||
79 | char *ats_net_arr[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; | ||
80 | char *ats_prop_value; | ||
78 | unsigned int c; | 81 | unsigned int c; |
82 | uint32_t ats_type; | ||
83 | uint32_t ats_value; | ||
84 | |||
79 | if (NULL != address) | 85 | if (NULL != address) |
80 | { | 86 | { |
81 | ats_str = GNUNET_strdup(""); | 87 | ats_str = GNUNET_strdup(""); |
82 | for (c = 0; c < pr->ats_count; c++) | 88 | for (c = 0; c < pr->ats_count; c++) |
83 | { | 89 | { |
84 | ats_tmp = ats_str; | 90 | ats_tmp = ats_str; |
85 | GNUNET_asprintf (&ats_str, "%s%u %u ", ats_tmp, ntohl(pr->ats[c].type), ntohl(pr->ats[c].value)); | 91 | |
92 | ats_type = ntohl(pr->ats[c].type); | ||
93 | ats_value = ntohl(pr->ats[c].value); | ||
94 | |||
95 | if (ats_type > GNUNET_ATS_PropertyCount) | ||
96 | { | ||
97 | GNUNET_break (0); | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | switch (ats_type) { | ||
102 | case GNUNET_ATS_NETWORK_TYPE: | ||
103 | if (ats_value > GNUNET_ATS_NetworkTypeCount) | ||
104 | { | ||
105 | GNUNET_break (0); | ||
106 | continue; | ||
107 | } | ||
108 | GNUNET_asprintf (&ats_prop_value, "%s", ats_net_arr[ats_value]); | ||
109 | break; | ||
110 | default: | ||
111 | GNUNET_asprintf (&ats_prop_value, "%u", ats_value); | ||
112 | break; | ||
113 | } | ||
114 | |||
115 | GNUNET_asprintf (&ats_str, "%s%s=%s, ", ats_tmp, ats_prop_arr[ats_type] , ats_prop_value); | ||
86 | GNUNET_free (ats_tmp); | 116 | GNUNET_free (ats_tmp); |
117 | GNUNET_free (ats_prop_value); | ||
87 | } | 118 | } |
88 | 119 | ||
120 | |||
89 | fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"), | 121 | fprintf (stderr, _("Peer `%s' plugin `%s', address `%s', bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"), |
90 | GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address, | 122 | GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address, |
91 | ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__),ats_str); | 123 | ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__),ats_str); |