diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-12-07 15:09:29 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-12-07 15:09:29 +0000 |
commit | 811e9e592ec037114b016889609f59d19f414011 (patch) | |
tree | 837d1eb538f926aafc9c6a1d78da06aa613d196d /src/dv/test_transport_api_dv.c | |
parent | dc7c73c5b7bff9940bd404cf74f58c56345ab6f0 (diff) | |
download | gnunet-811e9e592ec037114b016889609f59d19f414011.tar.gz gnunet-811e9e592ec037114b016889609f59d19f414011.zip |
initial dv changes for atsi information handling, test case BROKEN
Diffstat (limited to 'src/dv/test_transport_api_dv.c')
-rw-r--r-- | src/dv/test_transport_api_dv.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index d4c7eef2c..47b35a358 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_NO | 28 | #define VERBOSE GNUNET_YES |
29 | 29 | ||
30 | #define TEST_ALL GNUNET_NO | 30 | #define TEST_ALL GNUNET_NO |
31 | 31 | ||
@@ -385,18 +385,44 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
385 | static void | 385 | static void |
386 | send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc); | 386 | send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc); |
387 | 387 | ||
388 | /** | ||
389 | * Get distance information from 'atsi'. | ||
390 | * | ||
391 | * @param atsi performance data | ||
392 | * @return connected transport distance | ||
393 | */ | ||
394 | static uint32_t | ||
395 | get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
396 | { | ||
397 | while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) && | ||
398 | (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) ) | ||
399 | atsi++; | ||
400 | if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) | ||
401 | { | ||
402 | GNUNET_break (0); | ||
403 | /* FIXME: we do not have distance data? Assume direct neighbor. */ | ||
404 | return 1; | ||
405 | } | ||
406 | return ntohl (atsi->value); | ||
407 | } | ||
408 | |||
388 | static int | 409 | static int |
389 | process_mtype (void *cls, | 410 | process_mtype (void *cls, |
390 | const struct GNUNET_PeerIdentity *peer, | 411 | const struct GNUNET_PeerIdentity *peer, |
391 | const struct GNUNET_MessageHeader *message, | 412 | const struct GNUNET_MessageHeader *message, |
392 | struct GNUNET_TIME_Relative latency, | 413 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
393 | uint32_t distance) | ||
394 | { | 414 | { |
395 | struct TestMessageContext *pos = cls; | 415 | struct TestMessageContext *pos = cls; |
396 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; | 416 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; |
417 | #if VERBOSE | ||
418 | uint32_t distance; | ||
419 | #endif | ||
397 | if (pos->uid != ntohl(msg->uid)) | 420 | if (pos->uid != ntohl(msg->uid)) |
398 | return GNUNET_OK; | 421 | return GNUNET_OK; |
399 | 422 | ||
423 | #if VERBOSE | ||
424 | distance = get_atsi_distance(atsi); | ||
425 | #endif | ||
400 | GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct GNUNET_PeerIdentity))); | 426 | GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct GNUNET_PeerIdentity))); |
401 | if (total_other_expected_messages == 0) | 427 | if (total_other_expected_messages == 0) |
402 | { | 428 | { |
@@ -530,14 +556,12 @@ init_notify_peer1 (void *cls, | |||
530 | */ | 556 | */ |
531 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, | 557 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, |
532 | 1, | 558 | 1, |
533 | TIMEOUT, | ||
534 | pos, | 559 | pos, |
535 | &init_notify_peer2, | 560 | &init_notify_peer2, |
536 | NULL, | 561 | NULL, |
537 | NULL, | 562 | NULL, |
538 | NULL, NULL, | 563 | NULL, NULL, |
539 | GNUNET_YES, NULL, GNUNET_YES, handlers); | 564 | GNUNET_YES, NULL, GNUNET_YES, handlers); |
540 | |||
541 | } | 565 | } |
542 | 566 | ||
543 | 567 | ||
@@ -569,7 +593,6 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
569 | */ | 593 | */ |
570 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, | 594 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, |
571 | 1, | 595 | 1, |
572 | TIMEOUT, | ||
573 | pos, | 596 | pos, |
574 | &init_notify_peer1, | 597 | &init_notify_peer1, |
575 | NULL, NULL, | 598 | NULL, NULL, |
@@ -801,8 +824,7 @@ create_topology () | |||
801 | static void all_connect_handler (void *cls, | 824 | static void all_connect_handler (void *cls, |
802 | const struct | 825 | const struct |
803 | GNUNET_PeerIdentity * peer, | 826 | GNUNET_PeerIdentity * peer, |
804 | struct GNUNET_TIME_Relative latency, | 827 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
805 | uint32_t distance) | ||
806 | { | 828 | { |
807 | struct GNUNET_TESTING_Daemon *d = cls; | 829 | struct GNUNET_TESTING_Daemon *d = cls; |
808 | struct GNUNET_TESTING_Daemon *second_daemon; | 830 | struct GNUNET_TESTING_Daemon *second_daemon; |
@@ -810,6 +832,9 @@ static void all_connect_handler (void *cls, | |||
810 | #if !TEST_ALL | 832 | #if !TEST_ALL |
811 | struct TestMessageContext *temp_context; | 833 | struct TestMessageContext *temp_context; |
812 | #endif | 834 | #endif |
835 | uint32_t distance; | ||
836 | distance = get_atsi_distance(atsi); | ||
837 | |||
813 | #if VERBOSE | 838 | #if VERBOSE |
814 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", | 839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", |
815 | d->shortname, | 840 | d->shortname, |
@@ -884,7 +909,6 @@ peers_started_callback (void *cls, | |||
884 | new_peer = GNUNET_malloc(sizeof(struct PeerContext)); | 909 | new_peer = GNUNET_malloc(sizeof(struct PeerContext)); |
885 | new_peer->peer_handle = GNUNET_CORE_connect(cfg, | 910 | new_peer->peer_handle = GNUNET_CORE_connect(cfg, |
886 | 1, | 911 | 1, |
887 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
888 | d, NULL, | 912 | d, NULL, |
889 | &all_connect_handler, | 913 | &all_connect_handler, |
890 | NULL, NULL, NULL, | 914 | NULL, NULL, NULL, |