X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_fragmentation_lib.h;h=e56091c55c06cd6bb7d5050d6bf57fd81aa02048;hb=360d7afad50d1af425a20e89419d2063a6a0e220;hp=e91e74c6f759ac099ef85be5d954013827869c3e;hpb=c94be01c832866f9c0169963c658e36dd3329cc2;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h index e91e74c6f..e56091c55 100644 --- a/src/include/gnunet_fragmentation_lib.h +++ b/src/include/gnunet_fragmentation_lib.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2009, 2011 Christian Grothoff (and other contributing authors) + Copyright (C) 2009, 2011, 2015 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,15 +14,20 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** - * @file include/gnunet_fragmentation_lib.h - * @brief library to help fragment messages * @author Christian Grothoff * - * TODO: consider additional flow-control for sending from + * @file + * Library to help fragment messages + * + * @defgroup fragmentation Fragmentation library + * Library to help fragment messages + * @{ + * + * @todo Consider additional flow-control for sending from * fragmentation based on continuations. */ @@ -51,28 +56,31 @@ struct GNUNET_FRAGMENT_Context; /** * Function that is called with messages created by the fragmentation * module. In the case of the 'proc' callback of the - * GNUNET_FRAGMENT_context_create function, this function must - * eventually call 'GNUNET_FRAGMENT_context_transmission_done'. + * #GNUNET_FRAGMENT_context_create() function, this function must + * eventually call #GNUNET_FRAGMENT_context_transmission_done(). * * @param cls closure * @param msg the message that was created */ -typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, - const struct GNUNET_MessageHeader *msg); +typedef void +(*GNUNET_FRAGMENT_MessageProcessor) (void *cls, + const struct GNUNET_MessageHeader *msg); /** * Create a fragmentation context for the given message. - * Fragments the message into fragments of size "mtu" or - * less. Calls 'proc' on each un-acknowledged fragment, - * using both the expected 'delay' between messages and - * acknowledgements and the given 'tracker' to guide the - * frequency of calls to 'proc'. + * Fragments the message into fragments of size @a mtu or + * less. Calls @a proc on each un-acknowledged fragment, + * using both the expected @a msg_delay between messages and + * acknowledgements and the given @a tracker to guide the + * frequency of calls to @a proc. * * @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 +89,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); /** @@ -106,13 +115,14 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc); * * @param fc fragmentation context * @param msg acknowledgement message we received - * @return GNUNET_OK if this ack completes the work of the 'fc' + * @return #GNUNET_OK if this ack completes the work of the 'fc' * (all fragments have been received); - * GNUNET_NO if more messages are pending - * GNUNET_SYSERR if this ack is not valid for this 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 +130,25 @@ 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) + */ +void +GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc, + struct GNUNET_TIME_Relative *msg_delay, + struct GNUNET_TIME_Relative *ack_delay); + + +/** + * Convert an ACK message to a printable format suitable for logging. + * + * @param ack message to print + * @return ack in human-readable format */ -struct GNUNET_TIME_Relative -GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc); +const char * +GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack); /** @@ -143,19 +167,20 @@ 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 + * @param cls closure for @a proc and @a ackp * @param proc function to call with defragmented messages * @param ackp function to call with acknowledgements (to send * back to the other side) @@ -163,11 +188,11 @@ 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); /** @@ -184,11 +209,14 @@ GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc); * * @param dc the context * @param msg the message that was received - * @return GNUNET_OK on success, GNUNET_NO if this was a duplicate, GNUNET_SYSERR on error + * @return #GNUNET_OK on success, + * #GNUNET_NO if this was a duplicate, + * #GNUNET_SYSERR on error */ 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 */ @@ -198,5 +226,6 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, } #endif -/* end of gnunet_fragmentation_lib.h */ #endif + +/** @} */ /* end of group */