aboutsummaryrefslogtreecommitdiff
path: root/src/dv/test_transport_api_dv.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-12-07 17:18:53 +0000
committerNathan S. Evans <evans@in.tum.de>2010-12-07 17:18:53 +0000
commit0bb2e2d462b67cc2c6372de8b524f23245ab8926 (patch)
tree75f7d41651b2583166e6334f5089dbb83cf2e0f3 /src/dv/test_transport_api_dv.c
parent811e9e592ec037114b016889609f59d19f414011 (diff)
downloadgnunet-0bb2e2d462b67cc2c6372de8b524f23245ab8926.tar.gz
gnunet-0bb2e2d462b67cc2c6372de8b524f23245ab8926.zip
fixes for DV with new transport distance and core changes over the past few weeks
Diffstat (limited to 'src/dv/test_transport_api_dv.c')
-rw-r--r--src/dv/test_transport_api_dv.c117
1 files changed, 80 insertions, 37 deletions
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index 47b35a358..c37448342 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -25,7 +25,7 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27 27
28#define VERBOSE GNUNET_YES 28#define VERBOSE GNUNET_NO
29 29
30#define TEST_ALL GNUNET_NO 30#define TEST_ALL GNUNET_NO
31 31
@@ -502,66 +502,111 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
502 {NULL, 0, 0} 502 {NULL, 0, 0}
503}; 503};
504 504
505/**
506 * Notify of all peer1's peers, once peer 2 is found, schedule connect
507 * to peer two for message send.
508 *
509 * @param cls closure
510 * @param peer peer identity this notification is about
511 * @param atsi performance data for the connection
512 */
513static void connect_notify_peer2 (void *cls,
514 const struct
515 GNUNET_PeerIdentity *peer,
516 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
517{
518 struct TestMessageContext *pos = cls;
519
520 if (0 == memcmp(&pos->peer1->id, peer, sizeof(struct GNUNET_PeerIdentity)))
521 {
522#if VERBOSE
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
524 "Core connection from `%s' to `%4s' verfied, sending message!\n",
525 GNUNET_i2s(&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey));
526#endif
527 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
528 0,
529 TIMEOUT,
530 &pos->peer2->id,
531 sizeof (struct GNUNET_TestMessage),
532 &transmit_ready, pos))
533 {
534 /* This probably shouldn't happen, but it does (timing issue?) */
535 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
536 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
537 GNUNET_i2s (&pos->peer2->id));
538 transmit_ready_failed++;
539 total_other_expected_messages--;
540 }
541 else
542 {
543 transmit_ready_scheduled++;
544 }
545 }
546}
547
505static void 548static void
506init_notify_peer2 (void *cls, 549init_notify_peer2 (void *cls,
507 struct GNUNET_CORE_Handle *server, 550 struct GNUNET_CORE_Handle *server,
508 const struct GNUNET_PeerIdentity *my_identity, 551 const struct GNUNET_PeerIdentity *my_identity,
509 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 552 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
510{ 553{
511 struct TestMessageContext *pos = cls;
512
513#if VERBOSE 554#if VERBOSE
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
515 "Core connection to `%4s' established, scheduling message send\n", 556 "Core connection to `%4s' established, awaiting connections.\n",
516 GNUNET_i2s (my_identity)); 557 GNUNET_i2s (my_identity));
517#endif 558#endif
518 total_server_connections++; 559 total_server_connections++;
560}
519 561
520 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 562/**
521 0, 563 * Notify of all peer1's peers, once peer 2 is found, schedule connect
522 TIMEOUT, 564 * to peer two for message send.
523 &pos->peer2->id, 565 *
524 sizeof (struct GNUNET_TestMessage), 566 * @param cls closure
525 &transmit_ready, pos)) 567 * @param peer peer identity this notification is about
568 * @param atsi performance data for the connection
569 */
570static void connect_notify_peer1 (void *cls,
571 const struct
572 GNUNET_PeerIdentity *peer,
573 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
574{
575 struct TestMessageContext *pos = cls;
576
577 if (0 == memcmp(&pos->peer2->id, peer, sizeof(struct GNUNET_PeerIdentity)))
526 { 578 {
579#if VERBOSE
527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
528 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 581 "Core connection from `%s' to `%4s' verified.\n",
529 GNUNET_i2s (&pos->peer2->id)); 582 GNUNET_i2s(&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
530 transmit_ready_failed++; 583#endif
531 } 584 /*
532 else 585 * Connect to the receiving peer
533 { 586 */
534 transmit_ready_scheduled++; 587 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
588 1,
589 pos,
590 &init_notify_peer2,
591 &connect_notify_peer2,
592 NULL,
593 NULL, NULL,
594 GNUNET_YES, NULL, GNUNET_YES, handlers);
535 } 595 }
536} 596}
537 597
538
539static void 598static void
540init_notify_peer1 (void *cls, 599init_notify_peer1 (void *cls,
541 struct GNUNET_CORE_Handle *server, 600 struct GNUNET_CORE_Handle *server,
542 const struct GNUNET_PeerIdentity *my_identity, 601 const struct GNUNET_PeerIdentity *my_identity,
543 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 602 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
544{ 603{
545 struct TestMessageContext *pos = cls;
546 total_server_connections++; 604 total_server_connections++;
547
548#if VERBOSE 605#if VERBOSE
549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
550 "Core connection to `%4s' established, setting up handles\n", 607 "Core connection to `%4s' established, awaiting connections...\n",
551 GNUNET_i2s (my_identity)); 608 GNUNET_i2s (my_identity));
552#endif 609#endif
553
554 /*
555 * Connect to the receiving peer
556 */
557 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
558 1,
559 pos,
560 &init_notify_peer2,
561 NULL,
562 NULL,
563 NULL, NULL,
564 GNUNET_YES, NULL, GNUNET_YES, handlers);
565} 610}
566 611
567 612
@@ -595,7 +640,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
595 1, 640 1,
596 pos, 641 pos,
597 &init_notify_peer1, 642 &init_notify_peer1,
598 NULL, NULL, 643 &connect_notify_peer1,
644 NULL,
599 NULL, 645 NULL,
600 NULL, 646 NULL,
601 GNUNET_NO, NULL, GNUNET_NO, no_handlers); 647 GNUNET_NO, NULL, GNUNET_NO, no_handlers);
@@ -718,9 +764,7 @@ topology_callback (void *cls,
718 temp_context->uid = total_connections; 764 temp_context->uid = total_connections;
719 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 765 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
720 test_messages = temp_context; 766 test_messages = temp_context;
721
722 expected_messages++; 767 expected_messages++;
723
724 } 768 }
725#if VERBOSE 769#if VERBOSE
726 else 770 else
@@ -864,7 +908,6 @@ static void all_connect_handler (void *cls,
864 } 908 }
865#endif 909#endif
866 910
867
868 if (dotOutFile != NULL) 911 if (dotOutFile != NULL)
869 { 912 {
870 if (distance == 1) 913 if (distance == 1)