aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_manipulation_recv_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_manipulation_recv_tcp.c')
-rw-r--r--src/transport/test_transport_api_manipulation_recv_tcp.c124
1 files changed, 82 insertions, 42 deletions
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c
index 8a820fa16..48e0fe418 100644
--- a/src/transport/test_transport_api_manipulation_recv_tcp.c
+++ b/src/transport/test_transport_api_manipulation_recv_tcp.c
@@ -264,27 +264,32 @@ notify_ready (void *cls, size_t size, void *buf)
264 } 264 }
265 265
266 GNUNET_assert (size >= TEST_MESSAGE_SIZE); 266 GNUNET_assert (size >= TEST_MESSAGE_SIZE);
267 if (buf != NULL) 267 memset (buf, '\0', TEST_MESSAGE_SIZE);
268 hdr = buf;
269 hdr->size = htons (TEST_MESSAGE_SIZE);
270 hdr->type = htons (TEST_MESSAGE_TYPE);
271
268 { 272 {
269 memset (buf, '\0', TEST_MESSAGE_SIZE); 273 char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
270 hdr = buf;
271 hdr->size = htons (TEST_MESSAGE_SIZE);
272 hdr->type = htons (TEST_MESSAGE_TYPE);
273 }
274 274
275 char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); 275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 276 "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
277 "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", 277 p2->no,
278 p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, 278 ps,
279 GNUNET_i2s (&p->id)); 279 ntohs (hdr->type),
280 GNUNET_free (ps); 280 ntohs (hdr->size),
281 p->no,
282 GNUNET_i2s (&p->id));
283 GNUNET_free (ps);
284 }
281 285
282 return TEST_MESSAGE_SIZE; 286 return TEST_MESSAGE_SIZE;
283} 287}
284 288
285 289
286static void 290static void
287sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 291sendtask (void *cls,
292 const struct GNUNET_SCHEDULER_TaskContext *tc)
288{ 293{
289 send_task = NULL; 294 send_task = NULL;
290 295
@@ -300,22 +305,26 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
300 305
301 if (0 == messages_recv) 306 if (0 == messages_recv)
302 { 307 {
303 start_normal = GNUNET_TIME_absolute_get(); 308 start_normal = GNUNET_TIME_absolute_get();
304 } 309 }
305 if (1 == messages_recv) 310 if (1 == messages_recv)
306 { 311 {
307 start_delayed = GNUNET_TIME_absolute_get(); 312 start_delayed = GNUNET_TIME_absolute_get();
308 } 313 }
309 314
310 s_sending = GNUNET_YES; 315 s_sending = GNUNET_YES;
311 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, TEST_MESSAGE_SIZE, 316 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
312 TIMEOUT_TRANSMIT, &notify_ready, 317 &p1->id,
318 TEST_MESSAGE_SIZE,
319 TIMEOUT_TRANSMIT,
320 &notify_ready,
313 p1); 321 p1);
314} 322}
315 323
316 324
317static void 325static void
318notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 326notify_connect (void *cls,
327 const struct GNUNET_PeerIdentity *peer)
319{ 328{
320 static int c; 329 static int c;
321 330
@@ -329,42 +338,63 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
329 t = p2; 338 t = p2;
330 GNUNET_assert (t != NULL); 339 GNUNET_assert (t != NULL);
331 340
332 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 341 {
342 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
333 343
334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
335 "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, 345 "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
336 t->no, GNUNET_i2s (peer)); 346 p->no,
337 GNUNET_free (ps); 347 ps,
348 t->no,
349 GNUNET_i2s (peer));
350 GNUNET_free (ps);
351 }
338} 352}
339 353
340 354
341static void 355static void
342notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 356notify_disconnect (void *cls,
357 const struct GNUNET_PeerIdentity *peer)
343{ 358{
344 struct PeerContext *p = cls; 359 struct PeerContext *p = cls;
345 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
346 360
347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 361 {
348 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, 362 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
349 GNUNET_i2s (peer));
350 363
351 GNUNET_free (ps); 364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
365 "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
366 p->no,
367 ps,
368 GNUNET_i2s (peer));
369 GNUNET_free (ps);
370 }
352 371
353 if (th != NULL) 372 if (th != NULL)
373 {
354 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 374 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
355 th = NULL; 375 th = NULL;
376 }
356} 377}
357 378
358 379
359static void 380static void
360testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 381testing_connect_cb (struct PeerContext *p1,
382 struct PeerContext *p2,
383 void *cls)
361{ 384{
362 cc = NULL; 385 cc = NULL;
363 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
364 386
365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", 387 {
366 p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); 388 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
367 GNUNET_free (p1_c); 389
390 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
391 "Peers connected: %u (%s) <-> %u (%s)\n",
392 p1->no,
393 p1_c,
394 p2->no,
395 GNUNET_i2s (&p2->id));
396 GNUNET_free (p1_c);
397 }
368 398
369 s_connected = GNUNET_YES; 399 s_connected = GNUNET_YES;
370 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); 400 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
@@ -377,21 +407,31 @@ start_cb (struct PeerContext *p, void *cls)
377 static int started; 407 static int started;
378 started++; 408 started++;
379 409
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
411 "Peer %u (`%s') started\n",
412 p->no,
381 GNUNET_i2s (&p->id)); 413 GNUNET_i2s (&p->id));
382 414
383 if (started != 2) 415 if (started != 2)
384 return; 416 return;
385 else 417 else
386 s_started = GNUNET_YES; 418 s_started = GNUNET_YES;
387 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 419 {
420 char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
388 421
389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
390 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 423 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
391 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 424 p1->no,
392 GNUNET_free (sender_c); 425 sender_c,
426 p2->no,
427 GNUNET_i2s (&p2->id));
428 GNUNET_free (sender_c);
429 }
393 430
394 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 431 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
432 p1,
433 p2,
434 &testing_connect_cb,
395 NULL); 435 NULL);
396 436
397} 437}