#define SPEED_ACK 4
#define SPEED_MIN 5
#define SPEED_NOBUF 6
+#define P2P_SIGNAL 10
/**
* Which test are we running?
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- fprintf(stderr, "b");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
}
long line = (long) cls;
unsigned int i;
- fprintf(stderr, "a");
for (i = 0; i < 3; i++)
if (NULL != t_op[i])
{
}
+/**
+ * Abort test: schedule disconnect and shutdown immediately
+ *
+ * @param line Line in the code the abort is requested from (__LINE__).
+ */
void
abort_test (long line)
{
{
GNUNET_SCHEDULER_cancel (disconnect_task);
}
- disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
- &disconnect_mesh_peers,
- (void *) line);
+ disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
+ &disconnect_mesh_peers,
+ (void *) line);
}
/**
else
{
tunnel = t;
- destination = p_id[1];
+ destination = p_id[2];
}
th = GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
GNUNET_TIME_UNIT_FOREVER_REL,
if (size < size_payload || NULL == buf)
{
GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"size %u, buf %p, data_sent %u, data_received %u\n",
size,
buf,
switch (client)
{
- case 1L:
+ case 0L:
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
peers_responded++;
if (test == MULTICAST && peers_responded < 2)
return GNUNET_OK;
break;
- case 2L:
case 3L:
+ case 4L:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Leaf client %li got a message.\n",
client);
- client = 2L;
+ client = 4L;
break;
default:
GNUNET_assert (0);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: (%u)\n", ntohl (*data));
if (SPEED == test && GNUNET_YES == test_backwards)
{
- expected_target_client = 1L;
+ expected_target_client = 0L;
}
else
{
- expected_target_client = 2L;
+ expected_target_client = 4L;
}
if (GNUNET_NO == initialized)
start_time = GNUNET_TIME_absolute_get ();
if (SPEED == test)
{
- GNUNET_assert (2L == client);
+ GNUNET_assert (4L == client);
GNUNET_SCHEDULER_add_now (&data_task, NULL);
return GNUNET_OK;
}
}
- if (client == expected_target_client) // Normally 2 or 3
+ if (client == expected_target_client) // Normally 3 or 4
{
data_received++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
return GNUNET_OK;
}
}
- else // Normally 1
+ else // Normally 0
{
if (test == SPEED_ACK || test == SPEED)
{
return GNUNET_OK;
show_end_data();
}
- GNUNET_MESH_tunnel_destroy (t);
- t = NULL;
+ if (test == P2P_SIGNAL)
+ {
+ GNUNET_MESH_tunnel_destroy (incoming_t);
+ incoming_t = NULL;
+ }
+ else
+ {
+ GNUNET_MESH_tunnel_destroy (t);
+ t = NULL;
+ }
}
if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
GNUNET_i2s (initiator), (long) cls);
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
- if ((long) cls == 2L)
+ if ((long) cls == 4L)
incoming_t = tunnel;
else if ((long) cls == 3L)
incoming_t2 = tunnel;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Incoming tunnel disconnected at peer %d\n",
i);
- if (2L == i)
+ if (4L == i)
{
ok++;
incoming_t = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"peer %s disconnected\n",
GNUNET_i2s (peer));
+ if (P2P_SIGNAL == test)
+ {
+ ok ++;
+ if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
+ {
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ }
+ disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
+ (void *) __LINE__);
+ }
return;
}
struct GNUNET_PeerIdentity *dest;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "peer %s connected\n", GNUNET_i2s (peer));
+ "%ld peer %s connected\n", i, GNUNET_i2s (peer));
- if (0 == memcmp (p_id[1], peer, sizeof (struct GNUNET_PeerIdentity)) &&
- i == 1L)
+ if (0 == memcmp (p_id[2], peer, sizeof (struct GNUNET_PeerIdentity)) &&
+ i == 0L)
{
ok++;
}
if (test == MULTICAST &&
- 0 == memcmp (p_id[2], peer, sizeof (struct GNUNET_PeerIdentity)) &&
- i == 1L)
+ 0 == memcmp (p_id[1], peer, sizeof (struct GNUNET_PeerIdentity)) &&
+ i == 0L)
{
ok++;
}
switch (test)
{
case UNICAST:
+ case P2P_SIGNAL:
case SPEED:
case SPEED_ACK:
// incoming_t is NULL unless we send a relevant data packet
- dest = p_id[1];
+ dest = p_id[2];
break;
case MULTICAST:
peers_in_tunnel++;
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "add peer 2\n");
- GNUNET_MESH_peer_request_connect_add (t, p_id[1]);
+ GNUNET_MESH_peer_request_connect_add (t, p_id[2]);
if (test == MULTICAST)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"add peer 3\n");
- GNUNET_MESH_peer_request_connect_add (t, p_id[2]);
+ GNUNET_MESH_peer_request_connect_add (t, p_id[1]);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
{
GNUNET_SCHEDULER_cancel (disconnect_task);
- disconnect_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &disconnect_mesh_peers,
- (void *) __LINE__);
}
+ disconnect_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &disconnect_mesh_peers,
+ (void *) __LINE__);
}
/**
long i = (long) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
- t_op[i] = NULL;
if (NULL == pinfo || NULL != emsg)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
return;
}
p_id[i] = pinfo->result.id;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
p_ids++;
if ((MULTICAST == test && p_ids < 3) || p_ids < 2)
return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&do_test, NULL);
}
peers_running = num_peers;
h1 = meshes[0];
h2 = meshes[num_peers - 1];
- t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L);
+ t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 0L);
if (SPEED_MIN == test)
{
GNUNET_MESH_tunnel_speed_min(t);
t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
GNUNET_TESTBED_PIT_IDENTITY,
&pi_cb, (void *) 0L);
- t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
+ t_op[2] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
GNUNET_TESTBED_PIT_IDENTITY,
- &pi_cb, (void *) 1L);
+ &pi_cb, (void *) 2L);
if (MULTICAST == test)
{
h3 = meshes[num_peers - 2];
- t_op[2] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 2],
+ t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 2],
GNUNET_TESTBED_PIT_IDENTITY,
- &pi_cb, (void *) 2L);
+ &pi_cb, (void *) 1L);
+ }
+ else
+ {
+ t_op[1] = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
}
test_name = "multicast";
ok_goal = 10;
}
+ else if (strstr (argv[0], "test_mesh_small_signal") != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
+ test = P2P_SIGNAL;
+ test_name = "signal";
+ ok_goal = 5;
+ }
else if (strstr (argv[0], "test_mesh_small_speed_ack") != NULL)
{
/* Each peer is supposed to generate the following callbacks:
}
p_ids = 0;
- GNUNET_MESH_TEST_run (test_name,
+ GNUNET_MESH_TEST_run ("test_mesh_small",
"test_mesh_small.conf",
5,
&tmain,