#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE 1
#define TEST_ALL GNUNET_NO
#define MTYPE 12345
+GNUNET_NETWORK_STRUCT_BEGIN
+
struct GNUNET_TestMessage
{
/**
*/
uint32_t uid;
};
+GNUNET_NETWORK_STRUCT_END
struct PeerContext
{
#endif
if (dotOutFile != NULL)
{
- fprintf (dotOutFile, "}");
- fclose (dotOutFile);
+ FPRINTF (dotOutFile, "%s", "}");
+ FCLOSE (dotOutFile);
}
ok = 0;
if (dotOutFile != NULL)
{
- fprintf (dotOutFile, "}");
- fclose (dotOutFile);
+ FPRINTF (dotOutFile, "%s", "}");
+ FCLOSE (dotOutFile);
}
}
* @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)
+ unsigned int i;
+
+ for (i = 0; i < atsi_count; i++)
{
- GNUNET_break (0);
- /* FIXME: we do not have distance data? Assume direct neighbor. */
- return 1;
+ if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
+ return ntohl (atsi->value);
}
- 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,
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;
*/
pos->peer2handle =
GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2,
- &connect_notify_peer2, NULL, NULL,
- GNUNET_YES, NULL, GNUNET_YES, handlers);
+ &connect_notify_peer2, NULL, NULL, GNUNET_YES,
+ NULL, GNUNET_YES, handlers);
}
}
*/
pos->peer1handle =
GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
- &connect_notify_peer1, NULL, NULL, GNUNET_NO,
- NULL, GNUNET_NO, no_handlers);
+ &connect_notify_peer1, NULL, NULL, GNUNET_NO, NULL,
+ GNUNET_NO, no_handlers);
GNUNET_assert (pos->peer1handle != NULL);
*
* @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,
if (dotOutFile != NULL)
{
if (distance == 1)
- fprintf (dotOutFile, "\tn%s -- n%s;\n", d->shortname, second_shortname);
+ FPRINTF (dotOutFile, "\tn%s -- n%s;\n", d->shortname, second_shortname);
else if (distance == 2)
- fprintf (dotOutFile, "\tn%s -- n%s [color=blue];\n", d->shortname,
+ FPRINTF (dotOutFile, "\tn%s -- n%s [color=blue];\n", d->shortname,
second_shortname);
else if (distance == 3)
- fprintf (dotOutFile, "\tn%s -- n%s [color=red];\n", d->shortname,
+ FPRINTF (dotOutFile, "\tn%s -- n%s [color=red];\n", d->shortname,
second_shortname);
else if (distance == 4)
- fprintf (dotOutFile, "\tn%s -- n%s [color=green];\n", d->shortname,
+ FPRINTF (dotOutFile, "\tn%s -- n%s [color=green];\n", d->shortname,
second_shortname);
else
- fprintf (dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname,
+ FPRINTF (dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname,
second_shortname);
}
GNUNET_free (second_shortname);
new_peer = GNUNET_malloc (sizeof (struct PeerContext));
new_peer->peer_handle =
- GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL,
- NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
+ GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL, NULL,
+ GNUNET_NO, NULL, GNUNET_NO, no_handlers);
new_peer->daemon = d;
new_peer->next = all_peers;
all_peers = new_peer;
dotOutFile = fopen (dotOutFileName, "w");
if (dotOutFile != NULL)
{
- fprintf (dotOutFile, "strict graph G {\n");
+ FPRINTF (dotOutFile, "%s", "strict graph G {\n");
}
#if VERBOSE
"connect_topology_option_modifier",
&connect_topology_option_modifier_string))
{
- if (sscanf
+ if (SSCANF
(connect_topology_option_modifier_string, "%lf",
&connect_topology_option_modifier) != 1)
{