+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: peer %s connected\n", GNUNET_i2s (peer));
+
+ if (0 == memcmp (&d2->id, peer, sizeof (d2->id)) && (long) cls == 1L)
+ ok++;
+ if (test == MULTICAST && 0 == memcmp (&d3->id, peer, sizeof (d3->id)) &&
+ (long) cls == 1L)
+ ok++;
+ switch (test)
+ {
+ case UNICAST:
+ dest = &d2->id;
+ break;
+ case MULTICAST:
+ peers_in_tunnel++;
+ if (peers_in_tunnel < 2)
+ return;
+ dest = NULL;
+ break;
+ default:
+ return;
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
+ {
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: Sending data...\n");
+ peers_responded = 0;
+ GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
+ GNUNET_TIME_UNIT_FOREVER_REL, dest,
+ sizeof (struct GNUNET_MessageHeader),
+ &tmt_rdy, (void *) 1L);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: Disconnect already run?\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: Aborting...\n");
+ }
+ return;
+}
+
+
+static void
+do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: test_task\n");
+ if (test == MULTICAST)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: add peer 3\n");
+ GNUNET_MESH_peer_request_connect_add (t, &d3->id);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: add peer 2\n");
+ GNUNET_MESH_peer_request_connect_add (t, &d2->id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "***************** test: schedule timeout in 30s\n");
+ if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
+ {
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 30),
+ &disconnect_mesh_peers, NULL);
+ }
+}
+
+
+/**
+ * Prototype of a callback function indicating that two peers
+ * are currently connected.
+ *
+ * @param cls closure
+ * @param first peer id for first daemon
+ * @param second peer id for the second daemon
+ * @param distance distance between the connected peers
+ * @param emsg error message (NULL on success)
+ */
+void
+topo_cb (void *cls, const struct GNUNET_PeerIdentity *first,
+ const struct GNUNET_PeerIdentity *second, const char *emsg)
+{
+ GNUNET_PEER_Id p1;
+ GNUNET_PEER_Id p2;
+ struct GNUNET_PeerIdentity id;
+
+ GNUNET_PEER_resolve (1, &id);
+ p1 = GNUNET_PEER_search (first);
+ if (p1 == pid1)
+ {
+ p2 = GNUNET_PEER_search (second);
+ if (p2 == 0 || p2 > num_peers)