aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tool
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-16 08:20:16 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-16 08:20:16 +0000
commitc2d8df6aa4fe7852599b5673f95b3504ba35a40f (patch)
tree6e7501841bc35f58ae0a81f5d9652b4a9fd7d91a /src/ats-tool
parent838ed7f52d45e6545942c7c0d3b9e284ee4475e5 (diff)
downloadgnunet-c2d8df6aa4fe7852599b5673f95b3504ba35a40f.tar.gz
gnunet-c2d8df6aa4fe7852599b5673f95b3504ba35a40f.zip
minor code cleanups, doxygen
Diffstat (limited to 'src/ats-tool')
-rw-r--r--src/ats-tool/gnunet-ats.c352
1 files changed, 281 insertions, 71 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 1055057dd..6a34f4e15 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -28,16 +28,34 @@
28#include "gnunet_ats_service.h" 28#include "gnunet_ats_service.h"
29#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
30 30
31/**
32 * FIXME
33 */
31#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) 34#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
32 35
36/**
37 * FIXME
38 */
33#define BIG_M_STRING "unlimited" 39#define BIG_M_STRING "unlimited"
34 40
35/** 41/**
36 * Final status code. 42 * Final status code.
37 */ 43 */
38static int ret; 44static int ret;
45
46/**
47 * FIXME
48 */
39static int results; 49static int results;
50
51/**
52 * FIXME
53 */
40static int resolve_addresses_numeric; 54static int resolve_addresses_numeric;
55
56/**
57 * FIXME
58 */
41static int receive_done; 59static int receive_done;
42 60
43/** 61/**
@@ -45,8 +63,19 @@ static int receive_done;
45 */ 63 */
46static char *pid_str; 64static char *pid_str;
47 65
66/**
67 * FIXME
68 */
48static char *type_str; 69static char *type_str;
70
71/**
72 * FIXME
73 */
49static unsigned int value; 74static unsigned int value;
75
76/**
77 * FIXME
78 */
50static int pending; 79static int pending;
51 80
52/** 81/**
@@ -79,46 +108,129 @@ static int op_print_quotas;
79 */ 108 */
80static int op_monitor; 109static int op_monitor;
81 110
111/**
112 * FIXME
113 */
82static struct GNUNET_ATS_PerformanceHandle *ph; 114static struct GNUNET_ATS_PerformanceHandle *ph;
83 115
116/**
117 * FIXME
118 */
84static struct GNUNET_ATS_AddressListHandle *alh; 119static struct GNUNET_ATS_AddressListHandle *alh;
85 120
121/**
122 * FIXME
123 */
86static struct GNUNET_CONFIGURATION_Handle *cfg; 124static struct GNUNET_CONFIGURATION_Handle *cfg;
87 125
126/**
127 * FIXME
128 */
88static GNUNET_SCHEDULER_TaskIdentifier end_task; 129static GNUNET_SCHEDULER_TaskIdentifier end_task;
89 130
131/**
132 * FIXME
133 */
90static struct GNUNET_CONTAINER_MultiPeerMap *addresses; 134static struct GNUNET_CONTAINER_MultiPeerMap *addresses;
91 135
92 136
137/**
138 * Structure used to remember all pending address resolutions.
139 * We keep address information in here while we talk to transport
140 * to map the address to a string.
141 */
93struct PendingResolutions 142struct PendingResolutions
94{ 143{
144 /**
145 * Kept in a DLL.
146 */
95 struct PendingResolutions *next; 147 struct PendingResolutions *next;
148
149 /**
150 * Kept in a DLL.
151 */
96 struct PendingResolutions *prev; 152 struct PendingResolutions *prev;
97 153
154 /**
155 * Copy of the address we are resolving.
156 */
98 struct GNUNET_HELLO_Address *address; 157 struct GNUNET_HELLO_Address *address;
99 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
100 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
101 158
159 /**
160 * Handle to the transport request to convert the address
161 * to a string.
162 */
163 struct GNUNET_TRANSPORT_AddressToStringContext *tats_ctx;
164
165 /**
166 * Array of performance data.
167 */
102 struct GNUNET_ATS_Information *ats; 168 struct GNUNET_ATS_Information *ats;
169
170 /**
171 * Length of the @e ats array.
172 */
103 uint32_t ats_count; 173 uint32_t ats_count;
104 174
105 struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx; 175 /**
176 * Amount of outbound bandwidth assigned by ATS.
177 */
178 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
179
180 /**
181 * Amount of inbound bandwidth assigned by ATS.
182 */
183 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
184
185 /**
186 * Is this an active address?
187 */
188 int active;
106}; 189};
107 190
191
192/**
193 * Information we keep for an address. Used to avoid
194 * printing the same data multiple times.
195 */
108struct ATSAddress 196struct ATSAddress
109{ 197{
198 /**
199 * Address information.
200 */
110 struct GNUNET_HELLO_Address *address; 201 struct GNUNET_HELLO_Address *address;
202
203 /**
204 * Current outbound bandwidth.
205 */
111 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; 206 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
207
208 /**
209 * Current inbound bandwidth.
210 */
112 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; 211 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
113}; 212};
114 213
115 214
116 215/**
216 * Head of list of pending resolution requests.
217 */
117static struct PendingResolutions *head; 218static struct PendingResolutions *head;
118 219
220/**
221 * Tail of list of pending resolution requests.
222 */
119static struct PendingResolutions *tail; 223static struct PendingResolutions *tail;
120 224
121 225
226/**
227 * Free address corresponding to a given peer.
228 *
229 * @param cls NULL
230 * @param key peer identity
231 * @param value the `struct ATSAddress *` to be freed
232 * @return #GNUNET_YES (always)
233 */
122static int 234static int
123free_addr_it (void *cls, 235free_addr_it (void *cls,
124 const struct GNUNET_PeerIdentity *key, 236 const struct GNUNET_PeerIdentity *key,
@@ -136,6 +248,12 @@ free_addr_it (void *cls,
136} 248}
137 249
138 250
251/**
252 * Task run on shutdown.
253 *
254 * @param cls NULL
255 * @param tc scheduler context
256 */
139static void 257static void
140end (void *cls, 258end (void *cls,
141 const struct GNUNET_SCHEDULER_TaskContext *tc) 259 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -167,24 +285,46 @@ end (void *cls,
167 GNUNET_free(pr); 285 GNUNET_free(pr);
168 pending++; 286 pending++;
169 } 287 }
170 288 GNUNET_CONTAINER_multipeermap_iterate (addresses,
171 GNUNET_CONTAINER_multipeermap_iterate(addresses, &free_addr_it, NULL); 289 &free_addr_it,
172 GNUNET_CONTAINER_multipeermap_destroy(addresses); 290 NULL);
291 GNUNET_CONTAINER_multipeermap_destroy (addresses);
292 addresses = NULL;
173 293
174 if (0 < pending) 294 if (0 < pending)
175 fprintf (stderr, _("%u address resolutions had a timeout\n"), pending); 295 FPRINTF (stderr,
296 _("%u address resolutions had a timeout\n"),
297 pending);
176 if (op_list_used || op_list_all) 298 if (op_list_used || op_list_all)
177 fprintf (stderr, _("ATS returned results for %u addresses\n"), results); 299 FPRINTF (stderr,
300 _("ATS returned results for %u addresses\n"),
301 results);
178 ret = 0; 302 ret = 0;
179} 303}
180 304
181 305
306/**
307 * Function to call with a textual representation of an address. This
308 * function will be called several times with different possible
309 * textual representations, and a last time with @address being NULL
310 * to signal the end of the iteration. Note that @address NULL
311 * always is the last call, regardless of the value in @a res.
312 *
313 * @param cls closure, a `struct PendingResolutions *`
314 * @param address NULL on end of iteration,
315 * otherwise 0-terminated printable UTF-8 string,
316 * in particular an empty string if @a res is #GNUNET_NO
317 * @param res result of the address to string conversion:
318 * if #GNUNET_OK: conversion successful
319 * if #GNUNET_NO: address was invalid (or not supported)
320 * if #GNUNET_SYSERR: communication error (IPC error)
321 */
182static void 322static void
183transport_addr_to_str_cb (void *cls, 323transport_addr_to_str_cb (void *cls,
184 const char *address, 324 const char *address,
185 int res) 325 int res)
186{ 326{
187 struct PendingResolutions * pr = cls; 327 struct PendingResolutions *pr = cls;
188 char *ats_str; 328 char *ats_str;
189 char *ats_tmp; 329 char *ats_tmp;
190 char *ats_prop_arr[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings; 330 char *ats_prop_arr[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
@@ -194,16 +334,6 @@ transport_addr_to_str_cb (void *cls,
194 uint32_t ats_value; 334 uint32_t ats_value;
195 uint32_t network; 335 uint32_t network;
196 336
197 if (res == GNUNET_SYSERR)
198 {
199 fprintf (stderr,
200 "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n",
201 GNUNET_i2s (&pr->address->peer),
202 pr->address->transport_name,
203 pr->address->address_length);
204 return;
205 }
206
207 if (NULL == address) 337 if (NULL == address)
208 { 338 {
209 /* We're done */ 339 /* We're done */
@@ -219,11 +349,33 @@ transport_addr_to_str_cb (void *cls,
219 GNUNET_SCHEDULER_cancel (end_task); 349 GNUNET_SCHEDULER_cancel (end_task);
220 end_task = GNUNET_SCHEDULER_add_now (end, NULL); 350 end_task = GNUNET_SCHEDULER_add_now (end, NULL);
221 } 351 }
222 352 return;
353 }
354 switch (res)
355 {
356 case GNUNET_SYSERR:
357 FPRINTF (stderr,
358 "Failed to convert address for peer `%s' plugin `%s' length %lu to string (communication error)\n",
359 GNUNET_i2s (&pr->address->peer),
360 pr->address->transport_name,
361 pr->address->address_length);
362 return;
363 case GNUNET_NO:
364 FPRINTF (stderr,
365 "Failed to convert address for peer `%s' plugin `%s' length %lu to string (address invalid or not supported)\n",
366 GNUNET_i2s (&pr->address->peer),
367 pr->address->transport_name,
368 pr->address->address_length);
369 return;
370 case GNUNET_OK:
371 /* continues below */
372 break;
373 default:
374 GNUNET_break (0);
223 return; 375 return;
224 } 376 }
225 377
226 ats_str = GNUNET_strdup(""); 378 ats_str = GNUNET_strdup ("");
227 network = GNUNET_ATS_NET_UNSPECIFIED; 379 network = GNUNET_ATS_NET_UNSPECIFIED;
228 for (c = 0; c < pr->ats_count; c++) 380 for (c = 0; c < pr->ats_count; c++)
229 { 381 {
@@ -234,7 +386,7 @@ transport_addr_to_str_cb (void *cls,
234 386
235 if (ats_type > GNUNET_ATS_PropertyCount) 387 if (ats_type > GNUNET_ATS_PropertyCount)
236 { 388 {
237 fprintf (stderr, 389 FPRINTF (stderr,
238 "Invalid ATS property type %u %u for address %s\n", 390 "Invalid ATS property type %u %u for address %s\n",
239 ats_type, 391 ats_type,
240 pr->ats[c].type, 392 pr->ats[c].type,
@@ -271,7 +423,7 @@ transport_addr_to_str_cb (void *cls,
271 GNUNET_free(ats_prop_value); 423 GNUNET_free(ats_prop_value);
272 } 424 }
273 425
274 fprintf (stderr, 426 FPRINTF (stderr,
275 _("Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"), 427 _("Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
276 GNUNET_i2s (&pr->address->peer), 428 GNUNET_i2s (&pr->address->peer),
277 pr->address->transport_name, 429 pr->address->transport_name,
@@ -304,7 +456,7 @@ struct AddressFindCtx
304/** 456/**
305 * Find address corresponding to a given peer. 457 * Find address corresponding to a given peer.
306 * 458 *
307 * @param cls the `struct AddressFindCtx` 459 * @param cls the `struct AddressFindCtx *`
308 * @param key peer identity 460 * @param key peer identity
309 * @param value the `struct ATSAddress *` for an existing address 461 * @param value the `struct ATSAddress *` for an existing address
310 * @return #GNUNET_NO if we found a match, #GNUNET_YES if not 462 * @return #GNUNET_NO if we found a match, #GNUNET_YES if not
@@ -322,7 +474,6 @@ find_address_it (void *cls,
322 actx->res = exist; 474 actx->res = exist;
323 return GNUNET_NO; 475 return GNUNET_NO;
324 } 476 }
325
326 return GNUNET_YES; 477 return GNUNET_YES;
327} 478}
328 479
@@ -431,16 +582,28 @@ ats_perf_mon_cb (void *cls,
431} 582}
432 583
433 584
585/**
586 * Signature of a function that is called with QoS information about an address.
587 *
588 * @param cls closure (NULL)
589 * @param address the address, NULL if ATS service was disconnected
590 * @param active is this address actively used to maintain a connection
591 to a peer
592 * @param bandwidth_out assigned outbound bandwidth for the connection
593 * @param bandwidth_in assigned inbound bandwidth for the connection
594 * @param ats performance data for the address (as far as known)
595 * @param ats_count number of performance records in @a ats
596 */
434static void 597static void
435ats_perf_cb(void *cls, 598ats_perf_cb (void *cls,
436 const struct GNUNET_HELLO_Address *address, 599 const struct GNUNET_HELLO_Address *address,
437 int active, 600 int active,
438 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 601 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
439 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 602 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
440 const struct GNUNET_ATS_Information *ats, 603 const struct GNUNET_ATS_Information *ats,
441 uint32_t ats_count) 604 uint32_t ats_count)
442{ 605{
443 struct PendingResolutions * pr; 606 struct PendingResolutions *pr;
444 607
445 if (NULL == address) 608 if (NULL == address)
446 { 609 {
@@ -467,18 +630,26 @@ ats_perf_cb(void *cls,
467 pr->address = GNUNET_HELLO_address_copy (address); 630 pr->address = GNUNET_HELLO_address_copy (address);
468 pr->bandwidth_in = bandwidth_in; 631 pr->bandwidth_in = bandwidth_in;
469 pr->bandwidth_out = bandwidth_out; 632 pr->bandwidth_out = bandwidth_out;
633 pr->active = active;
470 pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address, 634 pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address,
471 resolve_addresses_numeric, 635 resolve_addresses_numeric,
472 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 636 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
473 transport_addr_to_str_cb, pr); 637 &transport_addr_to_str_cb, pr);
474 GNUNET_CONTAINER_DLL_insert(head, tail, pr); 638 GNUNET_CONTAINER_DLL_insert (head, tail, pr);
475 results++; 639 results++;
476 pending++; 640 pending++;
477} 641}
478 642
479 643
644/**
645 * Print information about the quotas configured for the various
646 * network scopes.
647 *
648 * @param cfg configuration to obtain quota information from
649 * @return total number of ATS network types known
650 */
480static unsigned int 651static unsigned int
481print_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg) 652print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
482{ 653{
483 char *network_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; 654 char *network_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
484 char * entry_in = NULL; 655 char * entry_in = NULL;
@@ -492,17 +663,24 @@ print_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg)
492 for (c = 0; (c < GNUNET_ATS_NetworkTypeCount); c++) 663 for (c = 0; (c < GNUNET_ATS_NetworkTypeCount); c++)
493 { 664 {
494 665
495 GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); 666 GNUNET_asprintf (&entry_out,
496 GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); 667 "%s_QUOTA_OUT",
668 network_str[c]);
669 GNUNET_asprintf (&entry_in,
670 "%s_QUOTA_IN",
671 network_str[c]);
497 672
498 /* quota out */ 673 /* quota out */
499 if (GNUNET_OK 674 if (GNUNET_OK ==
500 == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", entry_out, 675 GNUNET_CONFIGURATION_get_value_string (cfg,
501 &quota_out_str)) 676 "ats",
677 entry_out,
678 &quota_out_str))
502 { 679 {
503 if (0 == strcmp (quota_out_str, BIG_M_STRING) 680 if (0 == strcmp (quota_out_str, BIG_M_STRING)
504 || (GNUNET_SYSERR 681 || (GNUNET_SYSERR ==
505 == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &quota_out))) 682 GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str,
683 &quota_out)))
506 quota_out = UINT32_MAX; 684 quota_out = UINT32_MAX;
507 685
508 GNUNET_free(quota_out_str); 686 GNUNET_free(quota_out_str);
@@ -510,34 +688,41 @@ print_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg)
510 } 688 }
511 else 689 else
512 { 690 {
513 fprintf (stderr, "Outbound quota for network `%11s' not configured!\n", 691 FPRINTF (stderr,
514 network_str[c]); 692 "Outbound quota for network `%11s' not configured!\n",
693 network_str[c]);
515 GNUNET_asprintf (&quota_out_str, "-"); 694 GNUNET_asprintf (&quota_out_str, "-");
516 } 695 }
517 GNUNET_free(entry_out); 696 GNUNET_free(entry_out);
518 697
519 /* quota in */ 698 /* quota in */
520 if (GNUNET_OK 699 if (GNUNET_OK ==
521 == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", entry_in, 700 GNUNET_CONFIGURATION_get_value_string (cfg,
522 &quota_in_str)) 701 "ats",
702 entry_in,
703 &quota_in_str))
523 { 704 {
524 if (0 == strcmp (quota_in_str, BIG_M_STRING) 705 if (0 == strcmp (quota_in_str, BIG_M_STRING)
525 || (GNUNET_SYSERR 706 || (GNUNET_SYSERR ==
526 == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &quota_in))) 707 GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &quota_in)))
527 quota_in = UINT32_MAX; 708 quota_in = UINT32_MAX;
528 GNUNET_free(quota_in_str); 709 GNUNET_free(quota_in_str);
529 GNUNET_asprintf (&quota_in_str, "%llu", quota_in); 710 GNUNET_asprintf (&quota_in_str, "%llu", quota_in);
530 } 711 }
531 else 712 else
532 { 713 {
533 fprintf (stderr, "Inbound quota for network `%11s' not configured!\n", 714 FPRINTF (stderr,
534 network_str[c]); 715 "Inbound quota for network `%11s' not configured!\n",
716 network_str[c]);
535 GNUNET_asprintf (&quota_in_str, "-"); 717 GNUNET_asprintf (&quota_in_str, "-");
536 } 718 }
537 GNUNET_free(entry_in); 719 GNUNET_free(entry_in);
538 720
539 fprintf (stderr, _("Quota for network `%11s' (in/out): %10s / %10s\n"), 721 FPRINTF (stderr,
540 network_str[c], quota_in_str, quota_out_str); 722 _("Quota for network `%11s' (in/out): %10s / %10s\n"),
723 network_str[c],
724 quota_in_str,
725 quota_out_str);
541 GNUNET_free(quota_out_str); 726 GNUNET_free(quota_out_str);
542 GNUNET_free(quota_in_str); 727 GNUNET_free(quota_in_str);
543 } 728 }
@@ -545,8 +730,16 @@ print_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg)
545} 730}
546 731
547 732
733/**
734 * Function called with the result from the test if ATS is
735 * running. Runs the actual main logic.
736 *
737 * @param cls the `struct GNUNET_CONFIGURATION_Handle *`
738 * @param result result of the test, #GNUNET_YES if ATS is running
739 */
548static void 740static void
549testservice_ats(void *cls, int result) 741testservice_ats (void *cls,
742 int result)
550{ 743{
551 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 744 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
552 struct GNUNET_PeerIdentity pid; 745 struct GNUNET_PeerIdentity pid;
@@ -557,7 +750,9 @@ testservice_ats(void *cls, int result)
557 750
558 if (GNUNET_YES != result) 751 if (GNUNET_YES != result)
559 { 752 {
560 FPRINTF (stderr, _("Service `%s' is not running\n"), "ats"); 753 FPRINTF (stderr,
754 _("Service `%s' is not running\n"),
755 "ats");
561 return; 756 return;
562 } 757 }
563 758
@@ -580,8 +775,12 @@ testservice_ats(void *cls, int result)
580 if ((1 < c)) 775 if ((1 < c))
581 { 776 {
582 FPRINTF (stderr, 777 FPRINTF (stderr,
583 _("Please select one operation : %s or %s or %s or %s or %s\n"), 778 _("Please select one operation : %s or %s or %s or %s or %s\n"),
584 "--used", "--all", "--monitor", "--preference", "--quotas"); 779 "--used",
780 "--all",
781 "--monitor",
782 "--preference",
783 "--quotas");
585 return; 784 return;
586 } 785 }
587 if ((0 == c)) 786 if ((0 == c))
@@ -596,7 +795,8 @@ testservice_ats(void *cls, int result)
596 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); 795 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
597 if (NULL == ph) 796 if (NULL == ph)
598 { 797 {
599 fprintf (stderr, 798 FPRINTF (stderr,
799 "%s",
600 _("Cannot connect to ATS service, exiting...\n")); 800 _("Cannot connect to ATS service, exiting...\n"));
601 return; 801 return;
602 } 802 }
@@ -605,7 +805,8 @@ testservice_ats(void *cls, int result)
605 (NULL == pid_str) ? NULL : &pid, GNUNET_YES, ats_perf_cb, NULL); 805 (NULL == pid_str) ? NULL : &pid, GNUNET_YES, ats_perf_cb, NULL);
606 if (NULL == alh) 806 if (NULL == alh)
607 { 807 {
608 fprintf (stderr, 808 FPRINTF (stderr,
809 "%s",
609 _("Cannot issue request to ATS service, exiting...\n")); 810 _("Cannot issue request to ATS service, exiting...\n"));
610 end_task = GNUNET_SCHEDULER_add_now (&end, NULL); 811 end_task = GNUNET_SCHEDULER_add_now (&end, NULL);
611 return; 812 return;
@@ -618,14 +819,16 @@ testservice_ats(void *cls, int result)
618 { 819 {
619 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); 820 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
620 if (NULL == ph) 821 if (NULL == ph)
621 fprintf (stderr, 822 FPRINTF (stderr,
823 "%s",
622 _("Cannot connect to ATS service, exiting...\n")); 824 _("Cannot connect to ATS service, exiting...\n"));
623 825
624 alh = GNUNET_ATS_performance_list_addresses (ph, 826 alh = GNUNET_ATS_performance_list_addresses (ph,
625 (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL); 827 (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL);
626 if (NULL == alh) 828 if (NULL == alh)
627 { 829 {
628 fprintf (stderr, 830 FPRINTF (stderr,
831 "%s",
629 _("Cannot issue request to ATS service, exiting...\n")); 832 _("Cannot issue request to ATS service, exiting...\n"));
630 end_task = GNUNET_SCHEDULER_add_now (&end, NULL); 833 end_task = GNUNET_SCHEDULER_add_now (&end, NULL);
631 return; 834 return;
@@ -640,7 +843,8 @@ testservice_ats(void *cls, int result)
640 &ats_perf_mon_cb, 843 &ats_perf_mon_cb,
641 NULL); 844 NULL);
642 if (NULL == ph) 845 if (NULL == ph)
643 fprintf (stderr, 846 FPRINTF (stderr,
847 "%s",
644 _("Cannot connect to ATS service, exiting...\n")); 848 _("Cannot connect to ATS service, exiting...\n"));
645 end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 849 end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
646 &end, 850 &end,
@@ -651,13 +855,15 @@ testservice_ats(void *cls, int result)
651 { 855 {
652 if (NULL == type_str) 856 if (NULL == type_str)
653 { 857 {
654 fprintf (stderr, 858 FPRINTF (stderr,
859 "%s",
655 _("No preference type given!\n")); 860 _("No preference type given!\n"));
656 return; 861 return;
657 } 862 }
658 if (NULL == pid_str) 863 if (NULL == pid_str)
659 { 864 {
660 fprintf (stderr, 865 FPRINTF (stderr,
866 "%s",
661 _("No peer given!\n")); 867 _("No peer given!\n"));
662 return; 868 return;
663 } 869 }
@@ -674,14 +880,17 @@ testservice_ats(void *cls, int result)
674 type = GNUNET_ATS_PREFERENCE_BANDWIDTH; 880 type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
675 else 881 else
676 { 882 {
677 FPRINTF (stderr, "%s", _("Valid type required\n")); 883 FPRINTF (stderr,
884 "%s",
885 _("Valid type required\n"));
678 return; 886 return;
679 } 887 }
680 888
681 /* set */ 889 /* set */
682 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); 890 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
683 if (NULL == ph) 891 if (NULL == ph)
684 fprintf (stderr, 892 FPRINTF (stderr,
893 "%s",
685 _("Cannot connect to ATS service, exiting...\n")); 894 _("Cannot connect to ATS service, exiting...\n"));
686 895
687 GNUNET_ATS_performance_change_preference (ph, &pid, type, (double) value, 896 GNUNET_ATS_performance_change_preference (ph, &pid, type, (double) value,
@@ -724,7 +933,8 @@ run (void *cls,
724 * @return 0 ok, 1 on error 933 * @return 0 ok, 1 on error
725 */ 934 */
726int 935int
727main(int argc, char * const *argv) 936main (int argc,
937 char * const *argv)
728{ 938{
729 int res; 939 int res;
730 940