-skeletons for transport-ng
[oweals/gnunet.git] / src / include / gnunet_mq_lib.h
index 0bc8307f78145a6f5fbd24717ab3278b2631e209..7da5aa7787db8d721b38f580a6aa4a2c4e1b7873 100644 (file)
@@ -117,6 +117,12 @@ GNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh,
                               uint16_t base_size);
 
 
+/**
+ * Opaque handle to an envelope.
+ */
+struct GNUNET_MQ_Envelope;
+
+
 /**
  * Implementation of the #GNUNET_MQ_msg_nested_mh macro.
  *
@@ -138,11 +144,6 @@ GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp,
  */
 struct GNUNET_MQ_Handle;
 
-/**
- * Opaque handle to an envelope.
- */
-struct GNUNET_MQ_Envelope;
-
 
 /**
  * Error codes for the queue.
@@ -411,6 +412,16 @@ GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp,
                 uint16_t type);
 
 
+/**
+ * Create a new envelope by copying an existing message.
+ *
+ * @param hdr header of the message to copy
+ * @return envelope containing @a hdr
+ */
+struct GNUNET_MQ_Envelope *
+GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr);
+
+
 /**
  * Discard the message queue message, free all
  * allocated resources. Must be called in the event
@@ -423,7 +434,17 @@ GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm);
 
 
 /**
- * Send a message with the give message queue.
+ * Obtain the current length of the message queue.
+ *
+ * @param mq queue to inspect
+ * @return number of queued, non-transmitted messages
+ */
+unsigned int
+GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq);
+
+
+/**
+ * Send a message with the given message queue.
  * May only be called once per message.
  *
  * @param mq message queue
@@ -434,6 +455,18 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
                struct GNUNET_MQ_Envelope *ev);
 
 
+/**
+ * Send a copy of a message with the given message queue.
+ * Can be called repeatedly on the same envelope.
+ *
+ * @param mq message queue
+ * @param ev the envelope with the message to send.
+ */
+void
+GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq,
+                     const struct GNUNET_MQ_Envelope *ev);
+
+
 /**
  * Cancel sending the message. Message must have been sent with
  * #GNUNET_MQ_send before.  May not be called after the notify sent