From: xrs Date: Sat, 29 Feb 2020 14:54:52 +0000 (+0100) Subject: add request for peer information X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=28074776fde60f2efa0210f02a5ef59f8e3e4e2b;p=oweals%2Fgnunet.git add request for peer information --- diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 1b74eade2..f489ca56d 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -57,18 +57,45 @@ #define TESTPROGAM_NAME "test-cadet-channel-resumption" #define PORTNAME "cadet_port" +/** + * Testbed operation for connecting to the services. + */ struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; +/** + * Testbed operation for requesting peer information. + */ +struct GNUNET_TESTBED_Operation *testbed_info_req[2]; + /** * Port name kown by the two peers. */ static struct GNUNET_HashCode hashed_portname; +/** + * Result of the test. + */ static int test_result = 0; // FIXME: temp cnt static int cnt = 0; +/** + * Structure for storing information of testbed peers. + */ +struct testbed_peers +{ + /** + * Index of the peer. + */ + int index; + + /** + * Peer Identity. + */ + struct GNUNET_PeerIdentity id; +} testbed_peers[2]; + /****************************** TEST LOGIC ********************************/ // TBD @@ -93,17 +120,33 @@ disconnect_from_peer (void *cls, GNUNET_CADET_disconnect (cadet); } +static void +handle_channel_destroy (void *cls, + const struct GNUNET_CADET_Channel *channel) +{ +} + static void * setup_initiating_peer (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CADET_Handle *cadet; + struct GNUNET_PeerIdentity *destination; + struct GNUNET_CADET_Channel *channel; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_initiating_peer()\n"); cadet = GNUNET_CADET_connect (cfg); + channel = GNUNET_CADET_channel_create (cadet, + NULL, + destination, + &hashed_portname, + NULL, + &handle_channel_destroy, + NULL); + if (NULL == cadet) GNUNET_SCHEDULER_shutdown (); @@ -161,6 +204,22 @@ check_test_readyness (void *cls, GNUNET_SCHEDULER_shutdown (); } + +static void +process_info_req (void *cb_cls, + struct GNUNET_TESTBED_Operation *op, + const struct GNUNET_TESTBED_PeerInformation *pinfo, + const char *emsg) +{ + struct testbed_peers *testbed_peer = cb_cls; + struct GNUNET_PeerIdentity id = testbed_peer->id; + + GNUNET_memcpy (&id, pinfo->result.id, sizeof (struct GNUNET_PeerIdentity)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer %s ready\n", GNUNET_i2s (&id)); + + // TODO: connect_to_peer_services +} + static void connect_to_peers (void *cls, struct GNUNET_TESTBED_RunHandle *h, @@ -173,6 +232,18 @@ connect_to_peers (void *cls, GNUNET_assert (0 == links_failed); + for (int i=0; i