diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/transport/gnunet-transport-profiler.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/gnunet-transport-profiler.c')
-rw-r--r-- | src/transport/gnunet-transport-profiler.c | 529 |
1 files changed, 265 insertions, 264 deletions
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index 9451f95da..b09361d14 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -34,7 +34,8 @@ | |||
34 | #include "gnunet_transport_service.h" | 34 | #include "gnunet_transport_service.h" |
35 | 35 | ||
36 | 36 | ||
37 | struct Iteration { | 37 | struct Iteration |
38 | { | ||
38 | struct Iteration *next; | 39 | struct Iteration *next; |
39 | struct Iteration *prev; | 40 | struct Iteration *prev; |
40 | struct GNUNET_TIME_Absolute start; | 41 | struct GNUNET_TIME_Absolute start; |
@@ -53,7 +54,7 @@ struct Iteration { | |||
53 | * Timeout for a connections | 54 | * Timeout for a connections |
54 | */ | 55 | */ |
55 | #define CONNECT_TIMEOUT \ | 56 | #define CONNECT_TIMEOUT \ |
56 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) | 57 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
57 | 58 | ||
58 | /** | 59 | /** |
59 | * Benchmarking block size in bye | 60 | * Benchmarking block size in bye |
@@ -160,7 +161,7 @@ static unsigned int verbosity; | |||
160 | * @param cls NULL | 161 | * @param cls NULL |
161 | */ | 162 | */ |
162 | static void | 163 | static void |
163 | shutdown_task(void *cls) | 164 | shutdown_task (void *cls) |
164 | { | 165 | { |
165 | struct Iteration *icur; | 166 | struct Iteration *icur; |
166 | struct Iteration *inext; | 167 | struct Iteration *inext; |
@@ -173,28 +174,28 @@ shutdown_task(void *cls) | |||
173 | float stddev_duration; | 174 | float stddev_duration; |
174 | 175 | ||
175 | if (NULL != ats_sh) | 176 | if (NULL != ats_sh) |
176 | { | 177 | { |
177 | GNUNET_ATS_connectivity_suggest_cancel(ats_sh); | 178 | GNUNET_ATS_connectivity_suggest_cancel (ats_sh); |
178 | ats_sh = NULL; | 179 | ats_sh = NULL; |
179 | } | 180 | } |
180 | if (NULL != bl_handle) | 181 | if (NULL != bl_handle) |
181 | { | 182 | { |
182 | GNUNET_TRANSPORT_blacklist_cancel(bl_handle); | 183 | GNUNET_TRANSPORT_blacklist_cancel (bl_handle); |
183 | bl_handle = NULL; | 184 | bl_handle = NULL; |
184 | } | 185 | } |
185 | if (NULL != ats) | 186 | if (NULL != ats) |
186 | { | 187 | { |
187 | GNUNET_ATS_connectivity_done(ats); | 188 | GNUNET_ATS_connectivity_done (ats); |
188 | ats = NULL; | 189 | ats = NULL; |
189 | } | 190 | } |
190 | if (NULL != handle) | 191 | if (NULL != handle) |
191 | { | 192 | { |
192 | GNUNET_TRANSPORT_core_disconnect(handle); | 193 | GNUNET_TRANSPORT_core_disconnect (handle); |
193 | handle = NULL; | 194 | handle = NULL; |
194 | } | 195 | } |
195 | 196 | ||
196 | if (verbosity > 0) | 197 | if (verbosity > 0) |
197 | fprintf(stdout, "\n"); | 198 | fprintf (stdout, "\n"); |
198 | 199 | ||
199 | /* Output format: | 200 | /* Output format: |
200 | * All time values in ms | 201 | * All time values in ms |
@@ -202,95 +203,95 @@ shutdown_task(void *cls) | |||
202 | * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */ | 203 | * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */ |
203 | 204 | ||
204 | if (benchmark_send) | 205 | if (benchmark_send) |
206 | { | ||
207 | /* First iteration to calculcate avg and stddev */ | ||
208 | iterations = 0; | ||
209 | avg_duration = 0; | ||
210 | avg_rate = 0.0; | ||
211 | |||
212 | inext = ihead; | ||
213 | while (NULL != (icur = inext)) | ||
205 | { | 214 | { |
206 | /* First iteration to calculcate avg and stddev */ | 215 | inext = icur->next; |
207 | iterations = 0; | 216 | icur->rate = ((benchmark_count * benchmark_size) / 1024) |
208 | avg_duration = 0; | 217 | / ((float) icur->dur.rel_value_us / (1000 * 1000)); |
209 | avg_rate = 0.0; | 218 | if (verbosity > 0) |
210 | 219 | fprintf (stdout, | |
211 | inext = ihead; | 220 | _ ("%llu B in %llu ms == %.2f KB/s!\n"), |
212 | while (NULL != (icur = inext)) | 221 | ((long long unsigned int) benchmark_count * benchmark_size), |
213 | { | 222 | ((long long unsigned int) icur->dur.rel_value_us / 1000), |
214 | inext = icur->next; | 223 | (float) icur->rate); |
215 | icur->rate = ((benchmark_count * benchmark_size) / 1024) / | 224 | |
216 | ((float)icur->dur.rel_value_us / (1000 * 1000)); | 225 | avg_duration += icur->dur.rel_value_us / (1000); |
217 | if (verbosity > 0) | 226 | avg_rate += icur->rate; |
218 | fprintf(stdout, | 227 | iterations++; |
219 | _("%llu B in %llu ms == %.2f KB/s!\n"), | ||
220 | ((long long unsigned int)benchmark_count * benchmark_size), | ||
221 | ((long long unsigned int)icur->dur.rel_value_us / 1000), | ||
222 | (float)icur->rate); | ||
223 | |||
224 | avg_duration += icur->dur.rel_value_us / (1000); | ||
225 | avg_rate += icur->rate; | ||
226 | iterations++; | ||
227 | } | ||
228 | if (0 == iterations) | ||
229 | iterations = 1; /* avoid division by zero */ | ||
230 | /* Calculate average rate */ | ||
231 | avg_rate /= iterations; | ||
232 | /* Calculate average duration */ | ||
233 | avg_duration /= iterations; | ||
234 | |||
235 | stddev_rate = 0; | ||
236 | stddev_duration = 0; | ||
237 | inext = ihead; | ||
238 | while (NULL != (icur = inext)) | ||
239 | { | ||
240 | inext = icur->next; | ||
241 | stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate)); | ||
242 | stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) * | ||
243 | ((icur->dur.rel_value_us / 1000) - avg_duration)); | ||
244 | } | ||
245 | /* Calculate standard deviation rate */ | ||
246 | stddev_rate = stddev_rate / iterations; | ||
247 | stddev_rate = sqrtf(stddev_rate); | ||
248 | |||
249 | /* Calculate standard deviation duration */ | ||
250 | stddev_duration = stddev_duration / iterations; | ||
251 | stddev_duration = sqrtf(stddev_duration); | ||
252 | |||
253 | /* Output */ | ||
254 | fprintf(stdout, | ||
255 | "%u;%u;%llu;%llu;%.2f;%.2f", | ||
256 | benchmark_count, | ||
257 | benchmark_size, | ||
258 | avg_duration, | ||
259 | (unsigned long long)stddev_duration, | ||
260 | avg_rate, | ||
261 | stddev_rate); | ||
262 | |||
263 | inext = ihead; | ||
264 | while (NULL != (icur = inext)) | ||
265 | { | ||
266 | inext = icur->next; | ||
267 | GNUNET_CONTAINER_DLL_remove(ihead, itail, icur); | ||
268 | |||
269 | fprintf(stdout, | ||
270 | ";%llu;%.2f", | ||
271 | (long long unsigned int)(icur->dur.rel_value_us / 1000), | ||
272 | icur->rate); | ||
273 | |||
274 | GNUNET_free(icur); | ||
275 | } | ||
276 | } | 228 | } |
277 | #if 0 | 229 | if (0 == iterations) |
278 | if (benchmark_receive) | 230 | iterations = 1; /* avoid division by zero */ |
231 | /* Calculate average rate */ | ||
232 | avg_rate /= iterations; | ||
233 | /* Calculate average duration */ | ||
234 | avg_duration /= iterations; | ||
235 | |||
236 | stddev_rate = 0; | ||
237 | stddev_duration = 0; | ||
238 | inext = ihead; | ||
239 | while (NULL != (icur = inext)) | ||
279 | { | 240 | { |
280 | duration = GNUNET_TIME_absolute_get_duration(start_time); | 241 | inext = icur->next; |
281 | fprintf(stdout, | 242 | stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate)); |
282 | "Received %llu bytes/s (%llu bytes in %s)\n", | 243 | stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) |
283 | 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), | 244 | * ((icur->dur.rel_value_us / 1000) - avg_duration)); |
284 | traffic_received, | ||
285 | GNUNET_STRINGS_relative_time_to_string(duration, GNUNET_YES)); | ||
286 | } | 245 | } |
246 | /* Calculate standard deviation rate */ | ||
247 | stddev_rate = stddev_rate / iterations; | ||
248 | stddev_rate = sqrtf (stddev_rate); | ||
249 | |||
250 | /* Calculate standard deviation duration */ | ||
251 | stddev_duration = stddev_duration / iterations; | ||
252 | stddev_duration = sqrtf (stddev_duration); | ||
253 | |||
254 | /* Output */ | ||
255 | fprintf (stdout, | ||
256 | "%u;%u;%llu;%llu;%.2f;%.2f", | ||
257 | benchmark_count, | ||
258 | benchmark_size, | ||
259 | avg_duration, | ||
260 | (unsigned long long) stddev_duration, | ||
261 | avg_rate, | ||
262 | stddev_rate); | ||
263 | |||
264 | inext = ihead; | ||
265 | while (NULL != (icur = inext)) | ||
266 | { | ||
267 | inext = icur->next; | ||
268 | GNUNET_CONTAINER_DLL_remove (ihead, itail, icur); | ||
269 | |||
270 | fprintf (stdout, | ||
271 | ";%llu;%.2f", | ||
272 | (long long unsigned int) (icur->dur.rel_value_us / 1000), | ||
273 | icur->rate); | ||
274 | |||
275 | GNUNET_free (icur); | ||
276 | } | ||
277 | } | ||
278 | #if 0 | ||
279 | if (benchmark_receive) | ||
280 | { | ||
281 | duration = GNUNET_TIME_absolute_get_duration (start_time); | ||
282 | fprintf (stdout, | ||
283 | "Received %llu bytes/s (%llu bytes in %s)\n", | ||
284 | 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), | ||
285 | traffic_received, | ||
286 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); | ||
287 | } | ||
287 | #endif | 288 | #endif |
288 | fprintf(stdout, "\n"); | 289 | fprintf (stdout, "\n"); |
289 | } | 290 | } |
290 | 291 | ||
291 | 292 | ||
292 | static void | 293 | static void |
293 | iteration_done(); | 294 | iteration_done (); |
294 | 295 | ||
295 | 296 | ||
296 | /** | 297 | /** |
@@ -305,66 +306,66 @@ iteration_done(); | |||
305 | * @return number of bytes written to @a buf | 306 | * @return number of bytes written to @a buf |
306 | */ | 307 | */ |
307 | static void | 308 | static void |
308 | send_msg(void *cls) | 309 | send_msg (void *cls) |
309 | { | 310 | { |
310 | struct GNUNET_MQ_Envelope *env; | 311 | struct GNUNET_MQ_Envelope *env; |
311 | struct GNUNET_MessageHeader *m; | 312 | struct GNUNET_MessageHeader *m; |
312 | 313 | ||
313 | if (NULL == mq) | 314 | if (NULL == mq) |
314 | return; | 315 | return; |
315 | env = GNUNET_MQ_msg_extra(m, benchmark_size, GNUNET_MESSAGE_TYPE_DUMMY); | 316 | env = GNUNET_MQ_msg_extra (m, benchmark_size, GNUNET_MESSAGE_TYPE_DUMMY); |
316 | memset(&m[1], 52, benchmark_size - sizeof(struct GNUNET_MessageHeader)); | 317 | memset (&m[1], 52, benchmark_size - sizeof(struct GNUNET_MessageHeader)); |
317 | 318 | ||
318 | if (itail->msgs_sent < benchmark_count) | 319 | if (itail->msgs_sent < benchmark_count) |
319 | { | 320 | { |
320 | GNUNET_MQ_notify_sent(env, &send_msg, NULL); | 321 | GNUNET_MQ_notify_sent (env, &send_msg, NULL); |
321 | } | 322 | } |
322 | else | 323 | else |
323 | { | 324 | { |
324 | iteration_done(); | 325 | iteration_done (); |
325 | } | 326 | } |
326 | GNUNET_MQ_send(mq, env); | 327 | GNUNET_MQ_send (mq, env); |
327 | if ((verbosity > 0) && (0 == itail->msgs_sent % 10)) | 328 | if ((verbosity > 0) && (0 == itail->msgs_sent % 10)) |
328 | fprintf(stdout, "."); | 329 | fprintf (stdout, "."); |
329 | } | 330 | } |
330 | 331 | ||
331 | 332 | ||
332 | static void | 333 | static void |
333 | iteration_start() | 334 | iteration_start () |
334 | { | 335 | { |
335 | struct Iteration *icur; | 336 | struct Iteration *icur; |
336 | 337 | ||
337 | ret = 0; | 338 | ret = 0; |
338 | if (!benchmark_send) | 339 | if (! benchmark_send) |
339 | return; | 340 | return; |
340 | benchmark_running = GNUNET_YES; | 341 | benchmark_running = GNUNET_YES; |
341 | icur = GNUNET_new(struct Iteration); | 342 | icur = GNUNET_new (struct Iteration); |
342 | GNUNET_CONTAINER_DLL_insert_tail(ihead, itail, icur); | 343 | GNUNET_CONTAINER_DLL_insert_tail (ihead, itail, icur); |
343 | icur->start = GNUNET_TIME_absolute_get(); | 344 | icur->start = GNUNET_TIME_absolute_get (); |
344 | if (verbosity > 0) | 345 | if (verbosity > 0) |
345 | fprintf( | 346 | fprintf ( |
346 | stdout, | 347 | stdout, |
347 | "\nStarting benchmark, starting to send %u messages in %u byte blocks\n", | 348 | "\nStarting benchmark, starting to send %u messages in %u byte blocks\n", |
348 | benchmark_count, | 349 | benchmark_count, |
349 | benchmark_size); | 350 | benchmark_size); |
350 | send_msg(NULL); | 351 | send_msg (NULL); |
351 | } | 352 | } |
352 | 353 | ||
353 | 354 | ||
354 | static void | 355 | static void |
355 | iteration_done() | 356 | iteration_done () |
356 | { | 357 | { |
357 | static int it_count = 0; | 358 | static int it_count = 0; |
358 | 359 | ||
359 | it_count++; | 360 | it_count++; |
360 | itail->dur = GNUNET_TIME_absolute_get_duration(itail->start); | 361 | itail->dur = GNUNET_TIME_absolute_get_duration (itail->start); |
361 | if (it_count == benchmark_iterations) | 362 | if (it_count == benchmark_iterations) |
362 | { | 363 | { |
363 | benchmark_running = GNUNET_NO; | 364 | benchmark_running = GNUNET_NO; |
364 | GNUNET_SCHEDULER_shutdown(); | 365 | GNUNET_SCHEDULER_shutdown (); |
365 | return; | 366 | return; |
366 | } | 367 | } |
367 | iteration_start(); | 368 | iteration_start (); |
368 | } | 369 | } |
369 | 370 | ||
370 | 371 | ||
@@ -378,20 +379,20 @@ iteration_done() | |||
378 | * @return NULL | 379 | * @return NULL |
379 | */ | 380 | */ |
380 | static void * | 381 | static void * |
381 | notify_connect(void *cls, | 382 | notify_connect (void *cls, |
382 | const struct GNUNET_PeerIdentity *peer, | 383 | const struct GNUNET_PeerIdentity *peer, |
383 | struct GNUNET_MQ_Handle *m) | 384 | struct GNUNET_MQ_Handle *m) |
384 | { | 385 | { |
385 | if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 386 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
386 | { | 387 | { |
387 | fprintf(stdout, "Connected to different peer `%s'\n", GNUNET_i2s(&pid)); | 388 | fprintf (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid)); |
388 | return NULL; | 389 | return NULL; |
389 | } | 390 | } |
390 | 391 | ||
391 | if (verbosity > 0) | 392 | if (verbosity > 0) |
392 | fprintf(stdout, "Successfully connected to `%s'\n", GNUNET_i2s(&pid)); | 393 | fprintf (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid)); |
393 | mq = m; | 394 | mq = m; |
394 | iteration_start(); | 395 | iteration_start (); |
395 | return NULL; | 396 | return NULL; |
396 | } | 397 | } |
397 | 398 | ||
@@ -405,20 +406,20 @@ notify_connect(void *cls, | |||
405 | * @param internal_cls NULL | 406 | * @param internal_cls NULL |
406 | */ | 407 | */ |
407 | static void | 408 | static void |
408 | notify_disconnect(void *cls, | 409 | notify_disconnect (void *cls, |
409 | const struct GNUNET_PeerIdentity *peer, | 410 | const struct GNUNET_PeerIdentity *peer, |
410 | void *internal_cls) | 411 | void *internal_cls) |
411 | { | 412 | { |
412 | if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 413 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
413 | return; | 414 | return; |
414 | mq = NULL; | 415 | mq = NULL; |
415 | if (GNUNET_YES == benchmark_running) | 416 | if (GNUNET_YES == benchmark_running) |
416 | { | 417 | { |
417 | fprintf(stdout, | 418 | fprintf (stdout, |
418 | "Disconnected from peer `%s' while benchmarking\n", | 419 | "Disconnected from peer `%s' while benchmarking\n", |
419 | GNUNET_i2s(&pid)); | 420 | GNUNET_i2s (&pid)); |
420 | return; | 421 | return; |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | 425 | ||
@@ -430,7 +431,7 @@ notify_disconnect(void *cls, | |||
430 | * @return #GNUNET_OK | 431 | * @return #GNUNET_OK |
431 | */ | 432 | */ |
432 | static int | 433 | static int |
433 | check_dummy(void *cls, const struct GNUNET_MessageHeader *message) | 434 | check_dummy (void *cls, const struct GNUNET_MessageHeader *message) |
434 | { | 435 | { |
435 | return GNUNET_OK; /* all messages are fine */ | 436 | return GNUNET_OK; /* all messages are fine */ |
436 | } | 437 | } |
@@ -443,26 +444,26 @@ check_dummy(void *cls, const struct GNUNET_MessageHeader *message) | |||
443 | * @param message the message | 444 | * @param message the message |
444 | */ | 445 | */ |
445 | static void | 446 | static void |
446 | handle_dummy(void *cls, const struct GNUNET_MessageHeader *message) | 447 | handle_dummy (void *cls, const struct GNUNET_MessageHeader *message) |
447 | { | 448 | { |
448 | if (!benchmark_receive) | 449 | if (! benchmark_receive) |
449 | return; | 450 | return; |
450 | if (verbosity > 0) | 451 | if (verbosity > 0) |
451 | fprintf(stdout, | 452 | fprintf (stdout, |
452 | "Received %u bytes\n", | 453 | "Received %u bytes\n", |
453 | (unsigned int)ntohs(message->size)); | 454 | (unsigned int) ntohs (message->size)); |
454 | } | 455 | } |
455 | 456 | ||
456 | 457 | ||
457 | static int | 458 | static int |
458 | blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer) | 459 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer) |
459 | { | 460 | { |
460 | if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 461 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
461 | { | 462 | { |
462 | if (verbosity > 0) | 463 | if (verbosity > 0) |
463 | fprintf(stdout, "Denying connection to `%s'\n", GNUNET_i2s(peer)); | 464 | fprintf (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer)); |
464 | return GNUNET_SYSERR; | 465 | return GNUNET_SYSERR; |
465 | } | 466 | } |
466 | return GNUNET_OK; | 467 | return GNUNET_OK; |
467 | } | 468 | } |
468 | 469 | ||
@@ -476,92 +477,92 @@ blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer) | |||
476 | * @param mycfg configuration | 477 | * @param mycfg configuration |
477 | */ | 478 | */ |
478 | static void | 479 | static void |
479 | run(void *cls, | 480 | run (void *cls, |
480 | char *const *args, | 481 | char *const *args, |
481 | const char *cfgfile, | 482 | const char *cfgfile, |
482 | const struct GNUNET_CONFIGURATION_Handle *mycfg) | 483 | const struct GNUNET_CONFIGURATION_Handle *mycfg) |
483 | { | 484 | { |
484 | struct GNUNET_MQ_MessageHandler handlers[] = | 485 | struct GNUNET_MQ_MessageHandler handlers[] = |
485 | { GNUNET_MQ_hd_var_size(dummy, | 486 | { GNUNET_MQ_hd_var_size (dummy, |
486 | GNUNET_MESSAGE_TYPE_DUMMY, | 487 | GNUNET_MESSAGE_TYPE_DUMMY, |
487 | struct GNUNET_MessageHeader, | 488 | struct GNUNET_MessageHeader, |
488 | NULL), | 489 | NULL), |
489 | GNUNET_MQ_handler_end() }; | 490 | GNUNET_MQ_handler_end () }; |
490 | 491 | ||
491 | cfg = (struct GNUNET_CONFIGURATION_Handle *)mycfg; | 492 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; |
492 | 493 | ||
493 | ret = 1; | 494 | ret = 1; |
494 | if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size) | 495 | if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size) |
495 | { | 496 | { |
496 | fprintf(stderr, "Message size too big!\n"); | 497 | fprintf (stderr, "Message size too big!\n"); |
497 | return; | 498 | return; |
498 | } | 499 | } |
499 | 500 | ||
500 | if (NULL == cpid) | 501 | if (NULL == cpid) |
501 | { | 502 | { |
502 | fprintf(stderr, "No peer identity given\n"); | 503 | fprintf (stderr, "No peer identity given\n"); |
503 | return; | 504 | return; |
504 | } | 505 | } |
505 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string(cpid, | 506 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, |
506 | strlen(cpid), | 507 | strlen (cpid), |
507 | &pid.public_key)) | 508 | &pid.public_key)) |
508 | { | 509 | { |
509 | fprintf(stderr, "Failed to parse peer identity `%s'\n", cpid); | 510 | fprintf (stderr, "Failed to parse peer identity `%s'\n", cpid); |
510 | return; | 511 | return; |
511 | } | 512 | } |
512 | if (1 == benchmark_send) | 513 | if (1 == benchmark_send) |
513 | { | 514 | { |
514 | if (verbosity > 0) | 515 | if (verbosity > 0) |
515 | fprintf(stderr, | 516 | fprintf (stderr, |
516 | "Trying to send %u messages with size %u to peer `%s'\n", | 517 | "Trying to send %u messages with size %u to peer `%s'\n", |
517 | benchmark_count, | 518 | benchmark_count, |
518 | benchmark_size, | 519 | benchmark_size, |
519 | GNUNET_i2s(&pid)); | 520 | GNUNET_i2s (&pid)); |
520 | } | 521 | } |
521 | else if (1 == benchmark_receive) | 522 | else if (1 == benchmark_receive) |
522 | { | 523 | { |
523 | fprintf(stderr, | 524 | fprintf (stderr, |
524 | "Trying to receive messages from peer `%s'\n", | 525 | "Trying to receive messages from peer `%s'\n", |
525 | GNUNET_i2s(&pid)); | 526 | GNUNET_i2s (&pid)); |
526 | } | 527 | } |
527 | else | 528 | else |
528 | { | 529 | { |
529 | fprintf(stderr, "No operation given\n"); | 530 | fprintf (stderr, "No operation given\n"); |
530 | return; | 531 | return; |
531 | } | 532 | } |
532 | 533 | ||
533 | ats = GNUNET_ATS_connectivity_init(cfg); | 534 | ats = GNUNET_ATS_connectivity_init (cfg); |
534 | if (NULL == ats) | 535 | if (NULL == ats) |
535 | { | 536 | { |
536 | fprintf(stderr, "Failed to connect to ATS service\n"); | 537 | fprintf (stderr, "Failed to connect to ATS service\n"); |
537 | ret = 1; | 538 | ret = 1; |
538 | return; | 539 | return; |
539 | } | 540 | } |
540 | 541 | ||
541 | handle = GNUNET_TRANSPORT_core_connect(cfg, | 542 | handle = GNUNET_TRANSPORT_core_connect (cfg, |
542 | NULL, | 543 | NULL, |
543 | handlers, | 544 | handlers, |
544 | NULL, | 545 | NULL, |
545 | ¬ify_connect, | 546 | ¬ify_connect, |
546 | ¬ify_disconnect, | 547 | ¬ify_disconnect, |
547 | NULL); | 548 | NULL); |
548 | if (NULL == handle) | 549 | if (NULL == handle) |
549 | { | 550 | { |
550 | fprintf(stderr, "Failed to connect to transport service\n"); | 551 | fprintf (stderr, "Failed to connect to transport service\n"); |
551 | GNUNET_ATS_connectivity_done(ats); | 552 | GNUNET_ATS_connectivity_done (ats); |
552 | ats = NULL; | 553 | ats = NULL; |
553 | ret = 1; | 554 | ret = 1; |
554 | return; | 555 | return; |
555 | } | 556 | } |
556 | 557 | ||
557 | bl_handle = GNUNET_TRANSPORT_blacklist(cfg, &blacklist_cb, NULL); | 558 | bl_handle = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, NULL); |
558 | ats_sh = GNUNET_ATS_connectivity_suggest(ats, &pid, 1); | 559 | ats_sh = GNUNET_ATS_connectivity_suggest (ats, &pid, 1); |
559 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); | 560 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
560 | } | 561 | } |
561 | 562 | ||
562 | 563 | ||
563 | int | 564 | int |
564 | main(int argc, char *const *argv) | 565 | main (int argc, char *const *argv) |
565 | { | 566 | { |
566 | int res; | 567 | int res; |
567 | 568 | ||
@@ -571,50 +572,50 @@ main(int argc, char *const *argv) | |||
571 | benchmark_running = GNUNET_NO; | 572 | benchmark_running = GNUNET_NO; |
572 | 573 | ||
573 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 574 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
574 | GNUNET_GETOPT_option_flag('s', | 575 | GNUNET_GETOPT_option_flag ('s', |
575 | "send", | 576 | "send", |
576 | gettext_noop("send data to peer"), | 577 | gettext_noop ("send data to peer"), |
577 | &benchmark_send), | 578 | &benchmark_send), |
578 | GNUNET_GETOPT_option_flag('r', | 579 | GNUNET_GETOPT_option_flag ('r', |
579 | "receive", | 580 | "receive", |
580 | gettext_noop("receive data from peer"), | 581 | gettext_noop ("receive data from peer"), |
581 | &benchmark_receive), | 582 | &benchmark_receive), |
582 | GNUNET_GETOPT_option_uint('i', | 583 | GNUNET_GETOPT_option_uint ('i', |
583 | "iterations", | 584 | "iterations", |
584 | NULL, | 585 | NULL, |
585 | gettext_noop("iterations"), | 586 | gettext_noop ("iterations"), |
586 | &benchmark_iterations), | 587 | &benchmark_iterations), |
587 | GNUNET_GETOPT_option_uint('n', | 588 | GNUNET_GETOPT_option_uint ('n', |
588 | "number", | 589 | "number", |
589 | NULL, | 590 | NULL, |
590 | gettext_noop("number of messages to send"), | 591 | gettext_noop ("number of messages to send"), |
591 | &benchmark_count), | 592 | &benchmark_count), |
592 | GNUNET_GETOPT_option_uint('m', | 593 | GNUNET_GETOPT_option_uint ('m', |
593 | "messagesize", | 594 | "messagesize", |
594 | NULL, | 595 | NULL, |
595 | gettext_noop("message size to use"), | 596 | gettext_noop ("message size to use"), |
596 | &benchmark_size), | 597 | &benchmark_size), |
597 | GNUNET_GETOPT_option_string('p', | 598 | GNUNET_GETOPT_option_string ('p', |
598 | "peer", | 599 | "peer", |
599 | "PEER", | 600 | "PEER", |
600 | gettext_noop("peer identity"), | 601 | gettext_noop ("peer identity"), |
601 | &cpid), | 602 | &cpid), |
602 | GNUNET_GETOPT_option_verbose(&verbosity), | 603 | GNUNET_GETOPT_option_verbose (&verbosity), |
603 | GNUNET_GETOPT_OPTION_END | 604 | GNUNET_GETOPT_OPTION_END |
604 | }; | 605 | }; |
605 | 606 | ||
606 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 607 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
607 | return 2; | 608 | return 2; |
608 | 609 | ||
609 | res = | 610 | res = |
610 | GNUNET_PROGRAM_run(argc, | 611 | GNUNET_PROGRAM_run (argc, |
611 | argv, | 612 | argv, |
612 | "gnunet-transport", | 613 | "gnunet-transport", |
613 | gettext_noop("Direct access to transport service."), | 614 | gettext_noop ("Direct access to transport service."), |
614 | options, | 615 | options, |
615 | &run, | 616 | &run, |
616 | NULL); | 617 | NULL); |
617 | GNUNET_free((void *)argv); | 618 | GNUNET_free ((void *) argv); |
618 | if (GNUNET_OK == res) | 619 | if (GNUNET_OK == res) |
619 | return ret; | 620 | return ret; |
620 | return 1; | 621 | return 1; |