diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-27 04:05:12 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-27 04:05:12 +0100 |
commit | d3f013aba71486c121800d279cd1d3af4425c412 (patch) | |
tree | c86bfc9d800e04bda51e68b3041db1d954f43737 /src/cadet/gnunet-cadet.c | |
parent | 20c42b92b71cb31bc5ed9cc4e4ff32efbd95aae4 (diff) | |
download | gnunet-d3f013aba71486c121800d279cd1d3af4425c412.tar.gz gnunet-d3f013aba71486c121800d279cd1d3af4425c412.zip |
more work towards fixing #5385
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r-- | src/cadet/gnunet-cadet.c | 123 |
1 files changed, 49 insertions, 74 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index b36113318..3386f7464 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012, 2017 GNUnet e.V. | 3 | Copyright (C) 2012, 2017, 2019 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -102,6 +102,16 @@ static struct GNUNET_CADET_Handle *mh; | |||
102 | static const struct GNUNET_CONFIGURATION_Handle *my_cfg; | 102 | static const struct GNUNET_CONFIGURATION_Handle *my_cfg; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Active get path operation. | ||
106 | */ | ||
107 | static struct GNUNET_CADET_GetPath *gpo; | ||
108 | |||
109 | /** | ||
110 | * Active peer listing operation. | ||
111 | */ | ||
112 | struct GNUNET_CADET_PeersLister *plo; | ||
113 | |||
114 | /** | ||
105 | * Channel handle. | 115 | * Channel handle. |
106 | */ | 116 | */ |
107 | static struct GNUNET_CADET_Channel *ch; | 117 | static struct GNUNET_CADET_Channel *ch; |
@@ -210,6 +220,16 @@ shutdown_task (void *cls) | |||
210 | { | 220 | { |
211 | GNUNET_CADET_channel_destroy (ch); | 221 | GNUNET_CADET_channel_destroy (ch); |
212 | ch = NULL; | 222 | ch = NULL; |
223 | } | ||
224 | if (NULL != gpo) | ||
225 | { | ||
226 | GNUNET_CADET_get_path_cancel (gpo); | ||
227 | gpo = NULL; | ||
228 | } | ||
229 | if (NULL != plo) | ||
230 | { | ||
231 | GNUNET_CADET_list_peers_cancel (plo); | ||
232 | plo = NULL; | ||
213 | } | 233 | } |
214 | if (NULL != mh) | 234 | if (NULL != mh) |
215 | { | 235 | { |
@@ -496,93 +516,52 @@ handle_data (void *cls, | |||
496 | * After last peer has been reported, an additional call with NULL is done. | 516 | * After last peer has been reported, an additional call with NULL is done. |
497 | * | 517 | * |
498 | * @param cls Closure. | 518 | * @param cls Closure. |
499 | * @param peer Peer, or NULL on "EOF". | 519 | * @param ple information about peer, or NULL on "EOF". |
500 | * @param tunnel Do we have a tunnel towards this peer? | ||
501 | * @param n_paths Number of known paths towards this peer. | ||
502 | * @param best_path How long is the best path? | ||
503 | * (0 = unknown, 1 = ourselves, 2 = neighbor) | ||
504 | */ | 520 | */ |
505 | static void | 521 | static void |
506 | peers_callback (void *cls, | 522 | peers_callback (void *cls, |
507 | const struct GNUNET_PeerIdentity *peer, | 523 | const struct GNUNET_CADET_PeerListEntry *ple) |
508 | int tunnel, | ||
509 | unsigned int n_paths, | ||
510 | unsigned int best_path) | ||
511 | { | 524 | { |
512 | if (NULL == peer) | 525 | if (NULL == ple) |
513 | { | 526 | { |
527 | plo = NULL; | ||
514 | GNUNET_SCHEDULER_shutdown(); | 528 | GNUNET_SCHEDULER_shutdown(); |
515 | return; | 529 | return; |
516 | } | 530 | } |
517 | FPRINTF (stdout, | 531 | FPRINTF (stdout, |
518 | "%s tunnel: %c, paths: %u\n", | 532 | "%s tunnel: %c, paths: %u\n", |
519 | GNUNET_i2s_full (peer), | 533 | GNUNET_i2s_full (&ple->peer), |
520 | tunnel ? 'Y' : 'N', | 534 | ple->have_tunnel ? 'Y' : 'N', |
521 | n_paths); | 535 | ple->n_paths); |
522 | } | 536 | } |
523 | 537 | ||
524 | 538 | ||
525 | /** | 539 | /** |
526 | * Method called to retrieve information about a specific peer | 540 | * Method called to retrieve information about paths to a specific peer |
527 | * known to the service. | 541 | * known to the service. |
528 | * | 542 | * |
529 | * @param cls Closure. | 543 | * @param cls Closure. |
530 | * @param peer Peer ID. | 544 | * @param ppd path detail |
531 | * @param tunnel Do we have a tunnel towards this peer? #GNUNET_YES/#GNUNET_NO | ||
532 | * @param neighbor Is this a direct neighbor? #GNUNET_YES/#GNUNET_NO | ||
533 | * @param n_paths Number of paths known towards peer. | ||
534 | * @param paths Array of PEER_IDs representing all paths to reach the peer. | ||
535 | * Each path starts with the local peer. | ||
536 | * Each path ends with the destination peer (given in @c peer). | ||
537 | */ | 545 | */ |
538 | static void | 546 | static void |
539 | peer_callback (void *cls, | 547 | path_callback (void *cls, |
540 | const struct GNUNET_PeerIdentity *peer, | 548 | const struct GNUNET_CADET_PeerPathDetail *ppd) |
541 | int tunnel, | ||
542 | int neighbor, | ||
543 | unsigned int n_paths, | ||
544 | const struct GNUNET_PeerIdentity *paths, | ||
545 | int offset, | ||
546 | int finished_with_paths) | ||
547 | { | 549 | { |
548 | unsigned int i; | 550 | if (NULL == ppd) |
549 | const struct GNUNET_PeerIdentity *p; | ||
550 | |||
551 | |||
552 | if (GNUNET_YES == finished_with_paths) | ||
553 | { | 551 | { |
552 | gpo = NULL; | ||
554 | GNUNET_SCHEDULER_shutdown(); | 553 | GNUNET_SCHEDULER_shutdown(); |
555 | return; | 554 | return; |
556 | } | 555 | } |
557 | 556 | FPRINTF (stdout, | |
558 | if (offset == 0){ | 557 | "Path of length %u: ", |
559 | FPRINTF (stdout, | 558 | ppd->path_length); |
560 | "%s [TUNNEL: %s, NEIGHBOR: %s, PATHS: %u]\n", | 559 | for (unsigned int i = 0; i < ppd->path_length; i++) |
561 | GNUNET_i2s_full (peer), | ||
562 | tunnel ? "Y" : "N", | ||
563 | neighbor ? "Y" : "N", | ||
564 | n_paths); | ||
565 | }else{ | ||
566 | p = paths; | ||
567 | FPRINTF (stdout, | ||
568 | "Indirekt path with offset %u: ", | ||
569 | offset); | ||
570 | for (i = 0; i <= offset && NULL != p;) | ||
571 | { | ||
572 | FPRINTF (stdout, | ||
573 | "%s ", | ||
574 | GNUNET_i2s (p)); | ||
575 | i++; | ||
576 | p++; | ||
577 | } | ||
578 | |||
579 | FPRINTF (stdout, | 560 | FPRINTF (stdout, |
580 | "\n"); | 561 | "%s ", |
581 | 562 | GNUNET_i2s (&ppd->path[i])); | |
582 | } | 563 | FPRINTF (stdout, |
583 | 564 | "\n"); | |
584 | |||
585 | |||
586 | } | 565 | } |
587 | 566 | ||
588 | 567 | ||
@@ -669,11 +648,9 @@ static void | |||
669 | get_peers (void *cls) | 648 | get_peers (void *cls) |
670 | { | 649 | { |
671 | job = NULL; | 650 | job = NULL; |
672 | #if FIXME5385 | 651 | plo = GNUNET_CADET_list_peers (my_cfg, |
673 | GNUNET_CADET_list_peers (my_cfg, | 652 | &peers_callback, |
674 | &peers_callback, | 653 | NULL); |
675 | NULL); | ||
676 | #endif | ||
677 | } | 654 | } |
678 | 655 | ||
679 | 656 | ||
@@ -699,12 +676,10 @@ show_peer (void *cls) | |||
699 | GNUNET_SCHEDULER_shutdown(); | 676 | GNUNET_SCHEDULER_shutdown(); |
700 | return; | 677 | return; |
701 | } | 678 | } |
702 | #if FIXME5385 | 679 | gpo = GNUNET_CADET_get_path (my_cfg, |
703 | GNUNET_CADET_get_peer (my_cfg, | 680 | &pid, |
704 | &pid, | 681 | &path_callback, |
705 | &peer_callback, | 682 | NULL); |
706 | NULL); | ||
707 | #endif | ||
708 | } | 683 | } |
709 | 684 | ||
710 | 685 | ||