*/
typedef int
(*GNUNET_MESH_MessageCallback) (void *cls,
- const struct GNUNET_MESH_Tunnel *tunnel,
+ struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_TRANSPORT_ATS_Information *atsi);
const struct GNUNET_MESH_MessageHandler *handlers);
+/**
+ * Get the peer on the other side of this tunnel if it is just one. Return NULL otherwise
+ *
+ * @param tunnel the tunnel
+ * @return the peer or NULL
+ */
+const struct GNUNET_PeerIdentity*
+GNUNET_MESH_get_peer(const struct GNUNET_MESH_Tunnel* tunnel);
+
+
/**
* Disconnect from the mesh service.
*
GNUNET_MESH_TunnelEndHandler *cleaner;
};
+static void
+send_end_connect(void* cls,
+ const struct GNUNET_SCHEDULER_TaskContext* tc)
+{
+ struct GNUNET_MESH_Tunnel* tunnel = cls;
+
+ tunnel->connect_handler(tunnel->handler_cls, NULL, NULL);
+}
+
+static void
+send_self_connect(void* cls,
+ const struct GNUNET_SCHEDULER_TaskContext* tc)
+{
+ struct GNUNET_MESH_Tunnel* tunnel = cls;
+
+ tunnel->connect_handler(tunnel->handler_cls, &tunnel->handle->myself, NULL);
+ GNUNET_SCHEDULER_add_now(send_end_connect, tunnel);
+}
+
static void
core_startup (void *cls,
struct GNUNET_CORE_Handle *core,
tunnel);
tunnel->tunnel.connect_handler (tunnel->tunnel.handler_cls,
peer, atsi);
+ GNUNET_SCHEDULER_add_now(send_end_connect, tunnel);
tunnel = next;
}
else
handle->established_tunnels.tail,
handle->established_tunnels.tail,
tunnel);
- connect_handler (handler_cls, &handle->myself, NULL);
+ GNUNET_SCHEDULER_add_now(send_self_connect, tunnel);
}
else
{
return &tunnel->tunnel;
}
+const struct GNUNET_PeerIdentity*
+GNUNET_MESH_get_peer(const struct GNUNET_MESH_Tunnel* tunnel)
+{
+ return &tunnel->peer;
+}
+
static size_t
core_notify(void* cls, size_t size, void* buf)
{