aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxrs <xrs@mail36.net>2020-02-29 15:54:52 +0100
committerxrs <xrs@mail36.net>2020-05-21 22:46:48 +0200
commit28074776fde60f2efa0210f02a5ef59f8e3e4e2b (patch)
treee32ca3d16041c4b4b7b4ec2a93398ee37c137d81
parente40fc4fcf9bce6bc735a9cb37d4b6949381fed90 (diff)
downloadgnunet-28074776fde60f2efa0210f02a5ef59f8e3e4e2b.tar.gz
gnunet-28074776fde60f2efa0210f02a5ef59f8e3e4e2b.zip
add request for peer information
-rw-r--r--src/cadet/test_cadeT.c71
1 files changed, 71 insertions, 0 deletions
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 @@
57#define TESTPROGAM_NAME "test-cadet-channel-resumption" 57#define TESTPROGAM_NAME "test-cadet-channel-resumption"
58#define PORTNAME "cadet_port" 58#define PORTNAME "cadet_port"
59 59
60/**
61 * Testbed operation for connecting to the services.
62 */
60struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; 63struct GNUNET_TESTBED_Operation *testbed_to_svc[2];
61 64
62/** 65/**
66 * Testbed operation for requesting peer information.
67 */
68struct GNUNET_TESTBED_Operation *testbed_info_req[2];
69
70/**
63 * Port name kown by the two peers. 71 * Port name kown by the two peers.
64 */ 72 */
65static struct GNUNET_HashCode hashed_portname; 73static struct GNUNET_HashCode hashed_portname;
66 74
75/**
76 * Result of the test.
77 */
67static int test_result = 0; 78static int test_result = 0;
68 79
69// FIXME: temp cnt 80// FIXME: temp cnt
70static int cnt = 0; 81static int cnt = 0;
71 82
83/**
84 * Structure for storing information of testbed peers.
85 */
86struct testbed_peers
87{
88 /**
89 * Index of the peer.
90 */
91 int index;
92
93 /**
94 * Peer Identity.
95 */
96 struct GNUNET_PeerIdentity id;
97} testbed_peers[2];
98
72/****************************** TEST LOGIC ********************************/ 99/****************************** TEST LOGIC ********************************/
73 100
74// TBD 101// TBD
@@ -93,17 +120,33 @@ disconnect_from_peer (void *cls,
93 GNUNET_CADET_disconnect (cadet); 120 GNUNET_CADET_disconnect (cadet);
94} 121}
95 122
123static void
124handle_channel_destroy (void *cls,
125 const struct GNUNET_CADET_Channel *channel)
126{
127}
128
96static void * 129static void *
97setup_initiating_peer (void *cls, 130setup_initiating_peer (void *cls,
98 const struct GNUNET_CONFIGURATION_Handle *cfg) 131 const struct GNUNET_CONFIGURATION_Handle *cfg)
99{ 132{
100 133
101 struct GNUNET_CADET_Handle *cadet; 134 struct GNUNET_CADET_Handle *cadet;
135 struct GNUNET_PeerIdentity *destination;
136 struct GNUNET_CADET_Channel *channel;
102 137
103 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_initiating_peer()\n"); 138 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_initiating_peer()\n");
104 139
105 cadet = GNUNET_CADET_connect (cfg); 140 cadet = GNUNET_CADET_connect (cfg);
106 141
142 channel = GNUNET_CADET_channel_create (cadet,
143 NULL,
144 destination,
145 &hashed_portname,
146 NULL,
147 &handle_channel_destroy,
148 NULL);
149
107 if (NULL == cadet) 150 if (NULL == cadet)
108 GNUNET_SCHEDULER_shutdown (); 151 GNUNET_SCHEDULER_shutdown ();
109 152
@@ -161,6 +204,22 @@ check_test_readyness (void *cls,
161 GNUNET_SCHEDULER_shutdown (); 204 GNUNET_SCHEDULER_shutdown ();
162} 205}
163 206
207
208static void
209process_info_req (void *cb_cls,
210 struct GNUNET_TESTBED_Operation *op,
211 const struct GNUNET_TESTBED_PeerInformation *pinfo,
212 const char *emsg)
213{
214 struct testbed_peers *testbed_peer = cb_cls;
215 struct GNUNET_PeerIdentity id = testbed_peer->id;
216
217 GNUNET_memcpy (&id, pinfo->result.id, sizeof (struct GNUNET_PeerIdentity));
218 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer %s ready\n", GNUNET_i2s (&id));
219
220 // TODO: connect_to_peer_services
221}
222
164static void 223static void
165connect_to_peers (void *cls, 224connect_to_peers (void *cls,
166 struct GNUNET_TESTBED_RunHandle *h, 225 struct GNUNET_TESTBED_RunHandle *h,
@@ -173,6 +232,18 @@ connect_to_peers (void *cls,
173 232
174 GNUNET_assert (0 == links_failed); 233 GNUNET_assert (0 == links_failed);
175 234
235 for (int i=0; i<num_peers; i++)
236 testbed_peers[i].index = i;
237
238 testbed_info_req[0] = GNUNET_TESTBED_peer_get_information (peers[0],
239 GNUNET_TESTBED_PIT_IDENTITY,
240 &process_info_req,
241 &testbed_peers[0]);
242 testbed_info_req[1] = GNUNET_TESTBED_peer_get_information (peers[1],
243 GNUNET_TESTBED_PIT_IDENTITY,
244 &process_info_req,
245 &testbed_peers[1]);
246
176 247
177 testbed_to_svc[1] = GNUNET_TESTBED_service_connect (NULL, peers[1], 248 testbed_to_svc[1] = GNUNET_TESTBED_service_connect (NULL, peers[1],
178 "cadet", 249 "cadet",