#include <stdio.h>
#include "platform.h"
#include "mesh_test_lib.h"
-#include "gnunet_mesh_service_enc.h"
+#include "gnunet_mesh_service.h"
#include <gauger.h>
#define FORWARD 1
#define SPEED 3
#define SPEED_ACK 4
-#define SPEED_NOBUF 6
#define SPEED_REL 8
#define P2P_SIGNAL 10
/**
* Shut down peergroup, clean up.
- *
+ *
* @param cls Closure (unused).
* @param tc Task Context.
*/
/**
* Disconnect from mesh services af all peers, call shutdown.
- *
+ *
* @param cls Closure (unused).
* @param tc Task Context.
*/
/**
* Abort test: schedule disconnect and shutdown immediately
- *
+ *
* @param line Line in the code the abort is requested from (__LINE__).
*/
static void
/**
* Transmit ready callback.
- *
+ *
* @param cls Closure (message type).
* @param size Size of the tranmist buffer.
* @param buf Pointer to the beginning of the buffer.
- *
+ *
* @return Number of bytes written to buf.
*/
static size_t
/**
* Task to schedule a new data transmission.
- *
+ *
* @param cls Closure (peer #).
* @param tc Task Context.
*/
"tmt_rdy called, filling buffer\n");
if (size < size_payload || NULL == buf)
{
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_break (ok >= ok_goal - 2);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"size %u, buf %p, data_sent %u, data_received %u\n",
size,
buf,
GNUNET_SCHEDULER_add_now (&data_task, NULL);
}
}
-
+
return size_payload;
}
* @param channel New handle to the channel.
* @param initiator Peer that started the channel.
* @param port Port this channel is connected to.
+ * @param options channel option flags
* @return Initial channel context for the channel
* (can be NULL -- that's not an error).
*/
static void *
incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port)
+ uint32_t port, enum GNUNET_MESH_ChannelOption options)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Incoming channel from %s to peer %d\n",
if (4L == i)
{
ok++;
+ GNUNET_break (channel == incoming_ch);
incoming_ch = NULL;
}
- else if (0L == i && P2P_SIGNAL == test)
+ else if (0L == i)
{
- ok ++;
+ if (P2P_SIGNAL == test)
+ {
+ ok ++;
+ }
+ GNUNET_break (channel == ch);
ch = NULL;
}
else
/**
* START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
- *
+ *
* Testcase continues when the root receives confirmation of connected peers,
* on callback funtion ch.
- *
+ *
* @param cls Closure (unsued).
* @param tc Task Context.
*/
static void
do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- int nobuf;
- int rel;
+ enum GNUNET_MESH_ChannelOption flags;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "add peer 2\n");
{
GNUNET_SCHEDULER_cancel (disconnect_task);
}
- if (SPEED_NOBUF == test)
- {
- test = SPEED;
- nobuf = GNUNET_YES;
- }
- else
- nobuf = GNUNET_NO;
+ flags = GNUNET_MESH_OPTION_DEFAULT;
if (SPEED_REL == test)
{
test = SPEED;
- rel = GNUNET_YES;
+ flags |= GNUNET_MESH_OPTION_RELIABLE;
}
- else
- rel = GNUNET_NO;
- ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, nobuf, rel);
+ ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, flags);
disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
&disconnect_mesh_peers,
data_received = 0;
data_sent = 0;
GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_TIME_UNIT_FOREVER_REL,
size_payload, &tmt_rdy, (void *) 1L);
}
*/
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
ok_goal = TOTAL_PACKETS + 4;
- if (strstr (argv[0], "_nobuf") != NULL)
- {
- test = SPEED_NOBUF;
- test_name = "speed nobuf";
- }
- else if (strstr (argv[0], "_reliable") != NULL)
+ if (strstr (argv[0], "_reliable") != NULL)
{
test = SPEED_REL;
test_name = "speed reliable";