-only notify AFTER sending is really close to finished, not before
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_tunnel.h
index 2c57b9e142052612bf89de1bf0384e0d5d5f734f..d4be562a2556c99e3990895b248b2595e6d193b9 100644 (file)
@@ -93,6 +93,9 @@ struct MeshTunnel3;
 #include "gnunet-service-mesh_connection.h"
 #include "gnunet-service-mesh_peer.h"
 
+/**
+ * Handle for messages queued but not yet sent.
+ */
 struct MeshTunnel3Queue;
 
 /**
@@ -101,13 +104,12 @@ struct MeshTunnel3Queue;
  * @param cls Closure.
  * @param t Tunnel this message was on.
  * @param type Type of message sent.
- * @param fwd Was this a FWD going message?
  * @param size Size of the message.
  */
 typedef void (*GMT_sent) (void *cls,
                           struct MeshTunnel3 *t,
                           struct MeshTunnel3Queue *q,
-                          uint16_t type, int fwd, size_t size);
+                          uint16_t type, size_t size);
 
 
 /******************************************************************************/
@@ -349,6 +351,18 @@ GMT_unchoke_channels (struct MeshTunnel3 *t);
 void
 GMT_send_connection_acks (struct MeshTunnel3 *t);
 
+/**
+ * Cancel a previously sent message while it's in the queue.
+ *
+ * ONLY can be called before the continuation given to the send function
+ * is called. Once the continuation is called, the message is no longer in the
+ * queue.
+ *
+ * @param q Handle to the queue.
+ */
+void
+GMT_cancel (struct MeshTunnel3Queue *q);
+
 /**
  * Sends an already built message on a tunnel, encrypting it and
  * choosing the best connection.
@@ -357,12 +371,16 @@ GMT_send_connection_acks (struct MeshTunnel3 *t);
  * @param t Tunnel on which this message is transmitted.
  * @param ch Channel on which this message is transmitted.
  * @param fwd Is this a fwd message on @c ch?
+ * @param cont Continuation to call once message is really sent.
+ * @param cls Closure for @c cont.
+ *
+ * @return Handle to cancel message. NULL if @c cont is NULL.
  */
-void
+struct MeshTunnel3Queue *
 GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                            struct MeshTunnel3 *t,
-                           struct MeshChannel *ch,
-                           int fwd);
+                           struct MeshChannel *ch, int fwd,
+                           GMT_sent cont, void *cls);
 
 /**
  * Is the tunnel directed towards the local peer?