aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tool
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-05 21:33:58 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-05 21:33:58 +0000
commita998e0abbd220035bdb333388da229852980e2cc (patch)
treeaddf062abb3cc68ab1103a415fbdec315dd54a63 /src/ats-tool
parent4ce2d673d41ad8a8b9e5389b5b97ecb5e77f190d (diff)
downloadgnunet-a998e0abbd220035bdb333388da229852980e2cc.tar.gz
gnunet-a998e0abbd220035bdb333388da229852980e2cc.zip
-cleaning up client api to test for service availability
Diffstat (limited to 'src/ats-tool')
-rw-r--r--src/ats-tool/gnunet-ats.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 2e61247bb..f8ecd3aad 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009--2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -80,14 +80,14 @@ static int op_print_quotas;
80static int op_monitor; 80static int op_monitor;
81 81
82 82
83
84static struct GNUNET_ATS_PerformanceHandle *ph; 83static struct GNUNET_ATS_PerformanceHandle *ph;
85 84
86struct GNUNET_ATS_AddressListHandle *alh; 85static struct GNUNET_ATS_AddressListHandle *alh;
87 86
88static struct GNUNET_CONFIGURATION_Handle *cfg; 87static struct GNUNET_CONFIGURATION_Handle *cfg;
89 88
90GNUNET_SCHEDULER_TaskIdentifier end_task; 89static GNUNET_SCHEDULER_TaskIdentifier end_task;
90
91 91
92struct PendingResolutions 92struct PendingResolutions
93{ 93{
@@ -104,11 +104,15 @@ struct PendingResolutions
104 struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx; 104 struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx;
105}; 105};
106 106
107struct PendingResolutions *head;
108struct PendingResolutions *tail;
109 107
110void end (void *cls, 108static struct PendingResolutions *head;
111 const struct GNUNET_SCHEDULER_TaskContext *tc) 109
110static struct PendingResolutions *tail;
111
112
113static void
114end (void *cls,
115 const struct GNUNET_SCHEDULER_TaskContext *tc)
112{ 116{
113 struct PendingResolutions * pr; 117 struct PendingResolutions * pr;
114 struct PendingResolutions * next; 118 struct PendingResolutions * next;
@@ -145,7 +149,8 @@ void end (void *cls,
145} 149}
146 150
147 151
148void transport_addr_to_str_cb (void *cls, const char *address) 152static void
153transport_addr_to_str_cb (void *cls, const char *address)
149{ 154{
150 struct PendingResolutions * pr = cls; 155 struct PendingResolutions * pr = cls;
151 char *ats_str; 156 char *ats_str;
@@ -156,11 +161,10 @@ void transport_addr_to_str_cb (void *cls, const char *address)
156 uint32_t ats_type; 161 uint32_t ats_type;
157 uint32_t ats_value; 162 uint32_t ats_value;
158 uint32_t network; 163 uint32_t network;
164
159 if (NULL != address) 165 if (NULL != address)
160 { 166 {
161 ats_str = GNUNET_strdup(""); 167 ats_str = GNUNET_strdup("");
162
163
164 for (c = 0; c < pr->ats_count; c++) 168 for (c = 0; c < pr->ats_count; c++)
165 { 169 {
166 ats_tmp = ats_str; 170 ats_tmp = ats_str;
@@ -220,17 +224,18 @@ void transport_addr_to_str_cb (void *cls, const char *address)
220 } 224 }
221} 225}
222 226
223void ats_perf_cb (void *cls, 227
224 const struct GNUNET_HELLO_Address *address, 228static void
225 int active, 229ats_perf_cb (void *cls,
226 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 230 const struct GNUNET_HELLO_Address *address,
227 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 231 int active,
228 const struct GNUNET_ATS_Information *ats, 232 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
229 uint32_t ats_count) 233 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
234 const struct GNUNET_ATS_Information *ats,
235 uint32_t ats_count)
230{ 236{
231 struct PendingResolutions * pr; 237 struct PendingResolutions * pr;
232 238
233
234 if (NULL != address) 239 if (NULL != address)
235 { 240 {
236 pr = GNUNET_malloc (sizeof (struct PendingResolutions) + 241 pr = GNUNET_malloc (sizeof (struct PendingResolutions) +
@@ -325,30 +330,30 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
325} 330}
326 331
327 332
328 333static void
329void testservice_ats (void *cls, 334testservice_ats (void *cls,
330 const struct GNUNET_SCHEDULER_TaskContext *tc) 335 int result)
331{ 336{
332 struct GNUNET_PeerIdentity pid;
333 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 337 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
338 struct GNUNET_PeerIdentity pid;
334 unsigned int c; 339 unsigned int c;
335 unsigned int type; 340 unsigned int type;
336 341
337 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 342 if (GNUNET_YES != result)
338 { 343 {
339 FPRINTF (stderr, _("Service `%s' is not running\n"), "ats"); 344 FPRINTF (stderr, _("Service `%s' is not running\n"), "ats");
340 return; 345 return;
341 } 346 }
342 347
343 results = 0; 348 results = 0;
344 349
345 if (NULL != pid_str) 350 if (NULL != pid_str)
346 { 351 {
347 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (pid_str, &pid.hashPubKey)) 352 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (pid_str, &pid.hashPubKey))
348 { 353 {
349 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), pid_str); 354 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), pid_str);
350 return; 355 return;
351 } 356 }
352 } 357 }
353 358
354 c = op_list_all + op_list_used + op_monitor + op_set_pref; 359 c = op_list_all + op_list_used + op_monitor + op_set_pref;