diff options
author | t3sserakt <t3ss@posteo.de> | 2018-06-25 23:46:01 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2018-06-25 23:46:01 +0200 |
commit | 1aac0fdeaa4af2c7b14b81f0a90f0465b9c681f4 (patch) | |
tree | c965610083cc4079d812b9c78165995177d78fb2 /src/cadet/gnunet-service-cadet.c | |
parent | 23644d2ef3a3c0299b681e68a7122bc5becff322 (diff) | |
download | gnunet-1aac0fdeaa4af2c7b14b81f0a90f0465b9c681f4.tar.gz gnunet-1aac0fdeaa4af2c7b14b81f0a90f0465b9c681f4.zip |
bug 5228: made gnunet-cadet -p work as intended
Diffstat (limited to 'src/cadet/gnunet-service-cadet.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet.c | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index 38037e92f..dd693731f 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -822,7 +822,7 @@ get_all_peers_iterator (void *cls, | |||
822 | struct GNUNET_CADET_LocalInfoPeer *msg; | 822 | struct GNUNET_CADET_LocalInfoPeer *msg; |
823 | 823 | ||
824 | env = GNUNET_MQ_msg (msg, | 824 | env = GNUNET_MQ_msg (msg, |
825 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); | 825 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); |
826 | msg->destination = *peer; | 826 | msg->destination = *peer; |
827 | msg->paths = htons (GCP_count_paths (p)); | 827 | msg->paths = htons (GCP_count_paths (p)); |
828 | msg->tunnel = htons (NULL != GCP_get_tunnel (p, | 828 | msg->tunnel = htons (NULL != GCP_get_tunnel (p, |
@@ -892,6 +892,11 @@ path_info_iterator (void *cls, | |||
892 | env = GNUNET_MQ_msg_extra (resp, | 892 | env = GNUNET_MQ_msg_extra (resp, |
893 | path_size, | 893 | path_size, |
894 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER); | 894 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER); |
895 | |||
896 | |||
897 | resp->offset = htons(off); | ||
898 | resp->finished_with_paths = htons(0); | ||
899 | |||
895 | id = (struct GNUNET_PeerIdentity *) &resp[1]; | 900 | id = (struct GNUNET_PeerIdentity *) &resp[1]; |
896 | 901 | ||
897 | /* Don't copy first peer. First peer is always the local one. Last | 902 | /* Don't copy first peer. First peer is always the local one. Last |
@@ -905,6 +910,45 @@ path_info_iterator (void *cls, | |||
905 | return GNUNET_YES; | 910 | return GNUNET_YES; |
906 | } | 911 | } |
907 | 912 | ||
913 | /** | ||
914 | * Getting summary information about the number of paths and if a tunnel exists, | ||
915 | * and the indirect paths to a peer, if there are ones. | ||
916 | * | ||
917 | * @param cls Closure (). | ||
918 | * @param peer Peer ID (tunnel remote peer). | ||
919 | * @param value Peer info. | ||
920 | * @return #GNUNET_YES, to keep iterating. | ||
921 | */ | ||
922 | static void | ||
923 | get_peer_info (void *cls, | ||
924 | const struct GNUNET_PeerIdentity *peer, | ||
925 | struct CadetPeer *p) | ||
926 | { | ||
927 | struct CadetClient *c = cls; | ||
928 | struct GNUNET_MQ_Envelope *env; | ||
929 | struct GNUNET_CADET_LocalInfoPeer *msg; | ||
930 | |||
931 | |||
932 | env = GNUNET_MQ_msg (msg, | ||
933 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER); | ||
934 | |||
935 | msg->offset = htons(0); | ||
936 | msg->destination = *peer; | ||
937 | msg->paths = htons (GCP_count_paths (p)); | ||
938 | msg->tunnel = htons (NULL != GCP_get_tunnel (p, | ||
939 | GNUNET_NO)); | ||
940 | msg->finished_with_paths = htons(0); | ||
941 | |||
942 | GNUNET_MQ_send (c->mq, | ||
943 | env); | ||
944 | |||
945 | GCP_iterate_indirect_paths(p, | ||
946 | &path_info_iterator, | ||
947 | c->mq); | ||
948 | |||
949 | } | ||
950 | |||
951 | |||
908 | 952 | ||
909 | /** | 953 | /** |
910 | * Handler for client's SHOW_PEER request. | 954 | * Handler for client's SHOW_PEER request. |
@@ -919,19 +963,23 @@ handle_show_peer (void *cls, | |||
919 | struct CadetClient *c = cls; | 963 | struct CadetClient *c = cls; |
920 | struct CadetPeer *p; | 964 | struct CadetPeer *p; |
921 | struct GNUNET_MQ_Envelope *env; | 965 | struct GNUNET_MQ_Envelope *env; |
922 | struct GNUNET_MessageHeader *resp; | 966 | struct GNUNET_CADET_LocalInfoPeer *resp; |
923 | 967 | ||
924 | p = GCP_get (&msg->peer, | 968 | p = GCP_get (&msg->peer, |
925 | GNUNET_NO); | 969 | GNUNET_NO); |
926 | if (NULL != p) | 970 | if (NULL != p){ |
927 | GCP_iterate_paths (p, | 971 | get_peer_info(c, &(msg->peer), p); |
928 | &path_info_iterator, | 972 | } |
929 | c->mq); | 973 | |
930 | /* Send message with 0/0 to indicate the end */ | 974 | |
931 | env = GNUNET_MQ_msg (resp, | 975 | env = GNUNET_MQ_msg (resp, |
932 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER_END); | 976 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER); |
977 | resp->finished_with_paths = htons(1); | ||
978 | resp->destination = msg->peer; | ||
979 | |||
933 | GNUNET_MQ_send (c->mq, | 980 | GNUNET_MQ_send (c->mq, |
934 | env); | 981 | env); |
982 | |||
935 | GNUNET_SERVICE_client_continue (c->client); | 983 | GNUNET_SERVICE_client_continue (c->client); |
936 | } | 984 | } |
937 | 985 | ||