aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tool
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-19 13:55:36 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-19 13:55:36 +0000
commit819dd2547e8d11d094fe83a39667559e54e181c6 (patch)
tree0f90632e1d3d5b41dedacceee1533b966d2eaecb /src/ats-tool
parent8f4f3b2de0a5288fd6b68219f7ec0e2073f5017e (diff)
downloadgnunet-819dd2547e8d11d094fe83a39667559e54e181c6.tar.gz
gnunet-819dd2547e8d11d094fe83a39667559e54e181c6.zip
using new api
Diffstat (limited to 'src/ats-tool')
-rw-r--r--src/ats-tool/gnunet-ats.c115
1 files changed, 62 insertions, 53 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 57db9f011..56f8a17ac 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -173,7 +173,7 @@ end(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173} 173}
174 174
175static void 175static void
176transport_addr_to_str_cb(void *cls, const char *address) 176transport_addr_to_str_cb(void *cls, const char *address, int res)
177{ 177{
178 struct PendingResolutions * pr = cls; 178 struct PendingResolutions * pr = cls;
179 char *ats_str; 179 char *ats_str;
@@ -185,58 +185,7 @@ transport_addr_to_str_cb(void *cls, const char *address)
185 uint32_t ats_value; 185 uint32_t ats_value;
186 uint32_t network; 186 uint32_t network;
187 187
188 if (NULL != address) 188 if (NULL == address)
189 {
190 ats_str = GNUNET_strdup("");
191 network = GNUNET_ATS_NET_UNSPECIFIED;
192 for (c = 0; c < pr->ats_count; c++)
193 {
194 ats_tmp = ats_str;
195
196 ats_type = ntohl (pr->ats[c].type);
197 ats_value = ntohl (pr->ats[c].value);
198
199 if (ats_type > GNUNET_ATS_PropertyCount)
200 {
201 fprintf (stderr, "Invalid ATS property type %u %u for address %s\n", ats_type, pr->ats[c].type,
202 address);
203 continue;
204 }
205
206 switch (ats_type)
207 {
208 case GNUNET_ATS_NETWORK_TYPE:
209 if (ats_value > GNUNET_ATS_NetworkTypeCount)
210 {
211 GNUNET_break(0);
212 continue;
213 }
214 network = ats_value;
215 GNUNET_asprintf (&ats_prop_value, "%s",
216 GNUNET_ATS_print_network_type (ats_value));
217 break;
218 default:
219 GNUNET_asprintf (&ats_prop_value, "%u", ats_value);
220 break;
221 }
222 if ((verbose) && (ats_type < GNUNET_ATS_PropertyCount))
223 {
224 GNUNET_asprintf (&ats_str, "%s%s=%s, ", ats_tmp, ats_prop_arr[ats_type],
225 ats_prop_value);
226 GNUNET_free(ats_tmp);
227 }
228 GNUNET_free(ats_prop_value);
229 }
230
231 fprintf (stderr,
232 _("Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
233 GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address,
234 GNUNET_ATS_print_network_type (network),
235 ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__),
236 ats_str);
237 GNUNET_free(ats_str);
238 }
239 else
240 { 189 {
241 /* We're done */ 190 /* We're done */
242 GNUNET_CONTAINER_DLL_remove(head, tail, pr); 191 GNUNET_CONTAINER_DLL_remove(head, tail, pr);
@@ -251,7 +200,67 @@ transport_addr_to_str_cb(void *cls, const char *address)
251 GNUNET_SCHEDULER_cancel (end_task); 200 GNUNET_SCHEDULER_cancel (end_task);
252 end_task = GNUNET_SCHEDULER_add_now (end, NULL ); 201 end_task = GNUNET_SCHEDULER_add_now (end, NULL );
253 } 202 }
203
204 return;
254 } 205 }
206
207 if (res == GNUNET_SYSERR)
208 {
209 fprintf (stderr, "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n",
210 GNUNET_i2s (&pr->address->peer),
211 pr->address->transport_name,
212 pr->address->address_length );
213 return;
214 }
215
216 ats_str = GNUNET_strdup("");
217 network = GNUNET_ATS_NET_UNSPECIFIED;
218 for (c = 0; c < pr->ats_count; c++)
219 {
220 ats_tmp = ats_str;
221
222 ats_type = ntohl (pr->ats[c].type);
223 ats_value = ntohl (pr->ats[c].value);
224
225 if (ats_type > GNUNET_ATS_PropertyCount)
226 {
227 fprintf (stderr, "Invalid ATS property type %u %u for address %s\n", ats_type, pr->ats[c].type,
228 address);
229 continue;
230 }
231
232 switch (ats_type)
233 {
234 case GNUNET_ATS_NETWORK_TYPE:
235 if (ats_value > GNUNET_ATS_NetworkTypeCount)
236 {
237 GNUNET_break(0);
238 continue;
239 }
240 network = ats_value;
241 GNUNET_asprintf (&ats_prop_value, "%s",
242 GNUNET_ATS_print_network_type (ats_value));
243 break;
244 default:
245 GNUNET_asprintf (&ats_prop_value, "%u", ats_value);
246 break;
247 }
248 if ((verbose) && (ats_type < GNUNET_ATS_PropertyCount))
249 {
250 GNUNET_asprintf (&ats_str, "%s%s=%s, ", ats_tmp, ats_prop_arr[ats_type],
251 ats_prop_value);
252 GNUNET_free(ats_tmp);
253 }
254 GNUNET_free(ats_prop_value);
255 }
256
257 fprintf (stderr,
258 _("Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
259 GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address,
260 GNUNET_ATS_print_network_type (network),
261 ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__),
262 ats_str);
263 GNUNET_free(ats_str);
255} 264}
256 265
257 266