my_id, GNUNET_i2s (sender),
ntohs (((struct GNUNET_MessageHeader *) msg)->type),
distance);
+ if (sender_address_len == (2 * sizeof(struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "plugin_transport_dv", "Parsed sender address: %s:%s\n", GNUNET_i2s((struct GNUNET_PeerIdentity *)sender_address), GNUNET_h2s(&((struct GNUNET_PeerIdentity *)&sender_address[sizeof(struct GNUNET_PeerIdentity)])->hashPubKey));
+ }
+
GNUNET_free_non_null (my_id);
#endif
- struct GNUNET_ATS_Information ats[2];
+ struct GNUNET_ATS_Information ats[1];
ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
ats[0].value = htonl (distance);
- ats[1].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
- ats[1].value = htonl (0);
plugin->env->receive (plugin->env->cls, sender,
(struct GNUNET_MessageHeader *) msg,
- (const struct GNUNET_ATS_Information *) &ats, 2, NULL,
+ (const struct GNUNET_ATS_Information *) &ats, 1, NULL,
sender_address, sender_address_len);
}
}
return GNUNET_SYSERR;
}
+
return GNUNET_OK;
}
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE 1
#define TEST_ALL GNUNET_NO
* @return connected transport distance
*/
static uint32_t
-get_atsi_distance (const struct GNUNET_ATS_Information *atsi)
+get_atsi_distance (const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
{
- while ((ntohl (atsi->type) != GNUNET_ATS_ARRAY_TERMINATOR) &&
- (ntohl (atsi->type) != GNUNET_ATS_QUALITY_NET_DISTANCE))
- atsi++;
- if (ntohl (atsi->type) == GNUNET_ATS_ARRAY_TERMINATOR)
- {
- GNUNET_break (0);
- /* FIXME: we do not have distance data? Assume direct neighbor. */
- return 1;
- }
- return ntohl (atsi->value);
+ unsigned int i;
+
+ for (i = 0; i < atsi_count; i++)
+ {
+ if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
+ return ntohl (atsi->value);
+ }
+
+ GNUNET_break (0);
+ /* FIXME: we do not have distance data? Assume direct neighbor. */
+ return 1;
}
+
static int
-process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
+process_mtype (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct TestMessageContext *pos = cls;
struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message;
return GNUNET_OK;
#if VERBOSE
- distance = get_atsi_distance (atsi);
+ distance = get_atsi_distance (atsi, atsi_count);
#endif
GNUNET_assert (0 ==
memcmp (peer, &pos->peer1->id,
GNUNET_i2s (peer), ntohs (message->type), ntohl (msg->uid),
distance);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Total messages received %d, expected %d.\n",
+ "Total OTHER messages received %d, expected %d.\n",
total_other_messages, total_other_expected_messages);
#endif
}
(total_other_messages == 0))
{
GNUNET_SCHEDULER_cancel (die_task);
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling timeout from DV connections.\n");
+#endif
die_task =
GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
"waiting for DV peers to connect!");
- /*
- * if ((num_peers == 3) && (total_other_expected_messages == 2))
- * {
- * GNUNET_SCHEDULER_add_now (&send_other_messages, NULL);
- * }
- * else
- * {
- * GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
- * } */
}
else if ((total_other_expected_messages > 0) &&
(total_other_messages == total_other_expected_messages))
* @param cls closure
* @param peer peer identity this notification is about
* @param atsi performance data for the connection
+ * @param atsi_count number of ATS information included
*/
static void
connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct TestMessageContext *pos = cls;
* @param cls closure
* @param peer peer identity this notification is about
* @param atsi performance data for the connection
+ * @param atsi_count number of atsi datums
*/
static void
connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct TestMessageContext *pos = cls;
*
* @param cls closure
* @param peer peer identity this notification is about
- * @param latency reported latency of the connection with 'other'
- * @param distance reported distance (DV) to 'other'
+ * @param atsi performance data about this peer's connection
+ * @param atsi_count number of atsi datums
+ *
*/
static void
all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_TESTING_Daemon *d = cls;
struct GNUNET_TESTING_Daemon *second_daemon;
if (0 == memcmp (&d->id, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
second_shortname = GNUNET_strdup (GNUNET_i2s (peer));
- distance = get_atsi_distance (atsi);
+ distance = get_atsi_distance (atsi, atsi_count);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,