diff options
Diffstat (limited to 'src/transport/test_transport_api_manipulation_send_tcp.c')
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp.c | 105 |
1 files changed, 67 insertions, 38 deletions
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 0a52556ab..a1f9055ea 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -85,6 +85,7 @@ static struct GNUNET_TIME_Relative dur_normal; | |||
85 | static struct GNUNET_TIME_Absolute start_delayed; | 85 | static struct GNUNET_TIME_Absolute start_delayed; |
86 | static struct GNUNET_TIME_Relative dur_delayed; | 86 | static struct GNUNET_TIME_Relative dur_delayed; |
87 | 87 | ||
88 | |||
88 | static void | 89 | static void |
89 | end () | 90 | end () |
90 | { | 91 | { |
@@ -104,6 +105,7 @@ end () | |||
104 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 105 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
105 | } | 106 | } |
106 | 107 | ||
108 | |||
107 | static void | 109 | static void |
108 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 110 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
109 | { | 111 | { |
@@ -160,6 +162,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | static void | 162 | static void |
161 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 163 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
162 | 164 | ||
165 | |||
163 | static void | 166 | static void |
164 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 167 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
165 | const struct GNUNET_MessageHeader *message) | 168 | const struct GNUNET_MessageHeader *message) |
@@ -173,13 +176,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
173 | t = p2; | 176 | t = p2; |
174 | GNUNET_assert (t != NULL); | 177 | GNUNET_assert (t != NULL); |
175 | 178 | ||
176 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 179 | { |
180 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
177 | 181 | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
179 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 183 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
180 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, | 184 | p->no, |
181 | GNUNET_i2s (&t->id)); | 185 | ps, |
182 | GNUNET_free (ps); | 186 | ntohs (message->type), |
187 | ntohs (message->size), | ||
188 | t->no, | ||
189 | GNUNET_i2s (&t->id)); | ||
190 | GNUNET_free (ps); | ||
191 | } | ||
183 | 192 | ||
184 | if ((TEST_MESSAGE_TYPE == ntohs (message->type)) && | 193 | if ((TEST_MESSAGE_TYPE == ntohs (message->type)) && |
185 | (TEST_MESSAGE_SIZE == ntohs (message->size))) | 194 | (TEST_MESSAGE_SIZE == ntohs (message->size))) |
@@ -252,21 +261,24 @@ notify_ready (void *cls, size_t size, void *buf) | |||
252 | } | 261 | } |
253 | 262 | ||
254 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 263 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
255 | if (buf != NULL) | 264 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
265 | hdr = buf; | ||
266 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
267 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
268 | |||
256 | { | 269 | { |
257 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 270 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
258 | hdr = buf; | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | hdr->size = htons (TEST_MESSAGE_SIZE); | 272 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
260 | hdr->type = htons (TEST_MESSAGE_TYPE); | 273 | p2->no, |
274 | ps, | ||
275 | ntohs (hdr->type), | ||
276 | ntohs (hdr->size), | ||
277 | p->no, | ||
278 | GNUNET_i2s (&p->id)); | ||
279 | GNUNET_free (ps); | ||
261 | } | 280 | } |
262 | 281 | ||
263 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
265 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
266 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
267 | GNUNET_i2s (&p->id)); | ||
268 | GNUNET_free (ps); | ||
269 | |||
270 | return TEST_MESSAGE_SIZE; | 282 | return TEST_MESSAGE_SIZE; |
271 | } | 283 | } |
272 | 284 | ||
@@ -291,7 +303,6 @@ sendtask (void *cls, | |||
291 | receiver_s); | 303 | receiver_s); |
292 | GNUNET_free (receiver_s); | 304 | GNUNET_free (receiver_s); |
293 | 305 | ||
294 | |||
295 | if (0 == messages_recv) | 306 | if (0 == messages_recv) |
296 | { | 307 | { |
297 | start_normal = GNUNET_TIME_absolute_get (); | 308 | start_normal = GNUNET_TIME_absolute_get (); |
@@ -325,23 +336,27 @@ static void | |||
325 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 336 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
326 | { | 337 | { |
327 | static int c; | 338 | static int c; |
328 | |||
329 | c++; | ||
330 | struct PeerContext *p = cls; | 339 | struct PeerContext *p = cls; |
331 | struct PeerContext *t = NULL; | 340 | struct PeerContext *t = NULL; |
332 | 341 | ||
342 | c++; | ||
333 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 343 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
334 | t = p1; | 344 | t = p1; |
335 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 345 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
336 | t = p2; | 346 | t = p2; |
337 | GNUNET_assert (t != NULL); | 347 | GNUNET_assert (t != NULL); |
338 | 348 | ||
339 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 349 | { |
350 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
340 | 351 | ||
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
342 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 353 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
343 | t->no, GNUNET_i2s (peer)); | 354 | p->no, |
344 | GNUNET_free (ps); | 355 | ps, |
356 | t->no, | ||
357 | GNUNET_i2s (peer)); | ||
358 | GNUNET_free (ps); | ||
359 | } | ||
345 | } | 360 | } |
346 | 361 | ||
347 | 362 | ||
@@ -349,17 +364,23 @@ static void | |||
349 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 364 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
350 | { | 365 | { |
351 | struct PeerContext *p = cls; | 366 | struct PeerContext *p = cls; |
352 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
353 | 367 | ||
354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 368 | { |
355 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | 369 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
356 | GNUNET_i2s (peer)); | ||
357 | 370 | ||
358 | GNUNET_free (ps); | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
372 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
373 | p->no, | ||
374 | ps, | ||
375 | GNUNET_i2s (peer)); | ||
376 | GNUNET_free (ps); | ||
377 | } | ||
359 | 378 | ||
360 | if (th != NULL) | 379 | if (th != NULL) |
380 | { | ||
361 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 381 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
362 | th = NULL; | 382 | th = NULL; |
383 | } | ||
363 | } | 384 | } |
364 | 385 | ||
365 | 386 | ||
@@ -367,12 +388,18 @@ static void | |||
367 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 388 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
368 | { | 389 | { |
369 | cc = NULL; | 390 | cc = NULL; |
370 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
371 | 391 | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 392 | { |
373 | "Peers connected: %u (%s) <-> %u (%s)\n", | 393 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
374 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 394 | |
375 | GNUNET_free (p1_c); | 395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
396 | "Peers connected: %u (%s) <-> %u (%s)\n", | ||
397 | p1->no, | ||
398 | p1_c, | ||
399 | p2->no, | ||
400 | GNUNET_i2s (&p2->id)); | ||
401 | GNUNET_free (p1_c); | ||
402 | } | ||
376 | 403 | ||
377 | s_connected = GNUNET_YES; | 404 | s_connected = GNUNET_YES; |
378 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 405 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -385,7 +412,9 @@ start_cb (struct PeerContext *p, void *cls) | |||
385 | static int started; | 412 | static int started; |
386 | started++; | 413 | started++; |
387 | 414 | ||
388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
416 | "Peer %u (`%s') started\n", | ||
417 | p->no, | ||
389 | GNUNET_i2s (&p->id)); | 418 | GNUNET_i2s (&p->id)); |
390 | 419 | ||
391 | if (started != 2) | 420 | if (started != 2) |