implementing 0003268
[oweals/gnunet.git] / src / include / gnunet_fragmentation_lib.h
index e91e74c6f759ac099ef85be5d954013827869c3e..b0220186774aa7ffa9424b2d2bfe6ad9159c805e 100644 (file)
@@ -58,7 +58,8 @@ struct GNUNET_FRAGMENT_Context;
  * @param msg the message that was created
  */
 typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
-                                                  const struct GNUNET_MessageHeader *msg);
+                                                  const struct
+                                                  GNUNET_MessageHeader * msg);
 
 
 /**
@@ -72,7 +73,9 @@ typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
  * @param stats statistics context
  * @param mtu the maximum message size for each fragment
  * @param tracker bandwidth tracker to use for flow control (can be NULL)
- * @param delay expected delay between fragment transmission
+ * @param msg_delay initial delay to insert between fragment transmissions
+ *              based on previous messages
+ * @param ack_delay expected delay between fragment transmission
  *              and ACK based on previous messages
  * @param msg the message to fragment
  * @param proc function to call for each fragment to transmit
@@ -81,12 +84,13 @@ typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
  */
 struct GNUNET_FRAGMENT_Context *
 GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
-                               uint16_t mtu,
-                               struct GNUNET_BANDWIDTH_Tracker *tracker,
-                               struct GNUNET_TIME_Relative delay,
-                               const struct GNUNET_MessageHeader *msg,
-                               GNUNET_FRAGMENT_MessageProcessor proc,
-                               void *proc_cls);
+                                uint16_t mtu,
+                                struct GNUNET_BANDWIDTH_Tracker *tracker,
+                                struct GNUNET_TIME_Relative msg_delay,
+                                struct GNUNET_TIME_Relative ack_delay,
+                                const struct GNUNET_MessageHeader *msg,
+                                GNUNET_FRAGMENT_MessageProcessor proc,
+                                void *proc_cls);
 
 
 /**
@@ -111,8 +115,9 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc);
  *         GNUNET_NO if more messages are pending
  *         GNUNET_SYSERR if this ack is not valid for this fc
  */
-int GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
-                                const struct GNUNET_MessageHeader *msg);
+int
+GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
+                             const struct GNUNET_MessageHeader *msg);
 
 
 /**
@@ -120,11 +125,15 @@ int GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
  * resources).
  *
  * @param fc fragmentation context
- * @return average delay between transmission and ACK for the
- *         last message, FOREVER if the message was not fully transmitted
+ * @param msg_delay where to store average delay between individual message transmissions the
+ *         last message (OUT only)
+ * @param ack_delay where to store average delay between transmission and ACK for the
+ *         last message, set to FOREVER if the message was not fully transmitted (OUT only)
  */
-struct GNUNET_TIME_Relative
-GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc);
+void
+GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc,
+                                struct GNUNET_TIME_Relative *msg_delay,
+                                struct GNUNET_TIME_Relative *ack_delay);
 
 
 /**
@@ -143,16 +152,16 @@ struct GNUNET_DEFRAGMENT_Context;
  * @param id unique message ID (modulo collisions)
  * @param msg the message that was created
  */
-typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls,
-                                               uint32_t id,
-                                               const struct GNUNET_MessageHeader *msg);
+typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id,
+                                                const struct
+                                                GNUNET_MessageHeader * msg);
 
 
 /**
  * Create a defragmentation context.
  *
  * @param stats statistics context
- * @param mtu the maximum message size for each fragment 
+ * @param mtu the maximum message size for each fragment
  * @param num_msgs how many fragmented messages
  *                 to we defragment at most at the same time?
  * @param cls closure for proc and ackp
@@ -163,11 +172,10 @@ typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls,
  */
 struct GNUNET_DEFRAGMENT_Context *
 GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
-                                 uint16_t mtu,
-                                 unsigned int num_msgs,
-                                 void *cls,
-                                 GNUNET_FRAGMENT_MessageProcessor proc,
-                                 GNUNET_DEFRAGMENT_AckProcessor ackp);
+                                  uint16_t mtu, unsigned int num_msgs,
+                                  void *cls,
+                                  GNUNET_FRAGMENT_MessageProcessor proc,
+                                  GNUNET_DEFRAGMENT_AckProcessor ackp);
 
 
 /**
@@ -188,7 +196,7 @@ GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc);
  */
 int
 GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
-                                   const struct GNUNET_MessageHeader *msg);
+                                    const struct GNUNET_MessageHeader *msg);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */