aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_fragmentation_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-09 11:54:47 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-09 11:54:47 +0000
commit3883c9b973ddcbdc88d9807dbe4252a56ece5f92 (patch)
treeb54d5edf45cbeeb4031aa029210eec6019f7ff73 /src/include/gnunet_fragmentation_lib.h
parent1a39ba90f5af8341431c49f0dc9931d3c86de7a2 (diff)
downloadgnunet-3883c9b973ddcbdc88d9807dbe4252a56ece5f92.tar.gz
gnunet-3883c9b973ddcbdc88d9807dbe4252a56ece5f92.zip
new fragmentation API design - with retransmit
Diffstat (limited to 'src/include/gnunet_fragmentation_lib.h')
-rw-r--r--src/include/gnunet_fragmentation_lib.h104
1 files changed, 78 insertions, 26 deletions
diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h
index 5c08b2f69..b2ba064f8 100644
--- a/src/include/gnunet_fragmentation_lib.h
+++ b/src/include/gnunet_fragmentation_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -26,7 +26,8 @@
26#ifndef GNUNET_FRAGMENTATION_LIB_H 26#ifndef GNUNET_FRAGMENTATION_LIB_H
27#define GNUNET_FRAGMENTATION_LIB_H 27#define GNUNET_FRAGMENTATION_LIB_H
28 28
29#include "gnunet_common.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_bandwidth_lib.h"
30#include "gnunet_statistics_service.h" 31#include "gnunet_statistics_service.h"
31 32
32#ifdef __cplusplus 33#ifdef __cplusplus
@@ -37,6 +38,13 @@ extern "C"
37#endif 38#endif
38#endif 39#endif
39 40
41
42/**
43 * Fragmentation context.
44 */
45struct GNUNET_FRAGMENT_Context;
46
47
40/** 48/**
41 * Function that is called with messages 49 * Function that is called with messages
42 * created by the fragmentation module. 50 * created by the fragmentation module.
@@ -45,61 +53,105 @@ extern "C"
45 * @param msg the message that was created 53 * @param msg the message that was created
46 */ 54 */
47typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, 55typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
48 const struct 56 const struct GNUNET_MessageHeader *msg);
49 GNUNET_MessageHeader * msg);
50 57
51 58
52/** 59/**
53 * Fragment an over-sized message. 60 * Create a fragmentation context for the given message.
61 * Fragments the message into fragments of size "mtu" or
62 * less. Calls 'proc' on each un-acknowledged fragment,
63 * using both the expected 'delay' between messages and
64 * acknowledgements and the given 'tracker' to guide the
65 * frequency of calls to 'proc'.
54 * 66 *
67 * @param stats statistics context
68 * @param mtu the maximum message size for each fragment
69 * @param tracker bandwidth tracker to use for flow control (can be NULL)
70 * @param delay expected delay between fragment transmission
71 * and ACK based on previous messages
55 * @param msg the message to fragment 72 * @param msg the message to fragment
56 * @param mtu the maximum message size 73 * @param proc function to call for each fragment to transmit
57 * @param proc function to call for each fragment
58 * @param proc_cls closure for proc 74 * @param proc_cls closure for proc
75 * @return the fragmentation context
76 */
77struct GNUNET_FRAGMENT_Context *
78GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
79 uint16_t mtu,
80 struct GNUNET_BANDWIDTH_Tracker *tracker,
81 struct GNUNET_TIME_Relative delay,
82 const struct GNUNET_MessageHeader *msg,
83 GNUNET_FRAGMENT_MessageProcessor proc,
84 void *proc_cls);
85
86
87/**
88 * Process an acknowledgement message we got from the other
89 * side (to control re-transmits).
90 *
91 * @param fc fragmentation context
92 * @param msg acknowledgement message we received
93 * @return GNUNET_OK if this ack completes the work of the 'fc'
94 * (all fragments have been received);
95 * GNUNET_NO if more messages are pending
96 * GNUNET_SYSERR if this ack is not valid for this fc
59 */ 97 */
60void GNUNET_FRAGMENT_fragment (const struct GNUNET_MessageHeader *msg, 98int GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
61 uint16_t mtu, 99 const struct GNUNET_MessageHeader *msg);
62 GNUNET_FRAGMENT_MessageProcessor proc, 100
63 void *proc_cls); 101
102/**
103 * Destroy the given fragmentation context (stop calling 'proc', free
104 * resources).
105 *
106 * @param fc fragmentation context
107 * @return average delay between transmission and ACK for the
108 * last message, FOREVER if the message was not fully transmitted
109 */
110struct GNUNET_TIME_Relative
111GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc);
112
64 113
65/** 114/**
66 * Defragmentation context. 115 * Defragmentation context.
67 */ 116 */
68struct GNUNET_FRAGMENT_Context; 117struct GNUNET_DEFRAGMENT_Context;
118
69 119
70/** 120/**
71 * Create a defragmentation context. 121 * Create a defragmentation context.
72 * 122 *
73 * @param stats statistics context 123 * @param stats statistics context
124 * @param cls closure for proc and ackp
74 * @param proc function to call with defragmented messages 125 * @param proc function to call with defragmented messages
75 * @param proc_cls closure for proc 126 * @param ackp function to call with acknowledgements (to send
127 * back to the other side)
76 * @return the defragmentation context 128 * @return the defragmentation context
77 */ 129 */
78struct GNUNET_FRAGMENT_Context *GNUNET_FRAGMENT_context_create (struct 130struct GNUNET_DEFRAGMENT_Context *
79 GNUNET_STATISTICS_Handle 131GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
80 *stats, 132 void *cls,
81 GNUNET_FRAGMENT_MessageProcessor 133 GNUNET_FRAGMENT_MessageProcessor proc,
82 proc, 134 GNUNET_FRAGMENT_MessageProcessor ackp);
83 void
84 *proc_cls);
85 135
86 136
87/** 137/**
88 * Destroy the given defragmentation context. 138 * Destroy the given defragmentation context.
139 *
140 * @param dc defragmentation context
89 */ 141 */
90void GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *ctx); 142void
143GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc);
91 144
92 145
93/** 146/**
94 * We have received a fragment. Process it. 147 * We have received a fragment. Process it.
95 * 148 *
96 * @param ctx the context 149 * @param dc the context
97 * @param sender who transmitted the fragment
98 * @param msg the message that was received 150 * @param msg the message that was received
99 */ 151 */
100void GNUNET_FRAGMENT_process (struct GNUNET_FRAGMENT_Context *ctx, 152void
101 const struct GNUNET_PeerIdentity *sender, 153GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
102 const struct GNUNET_MessageHeader *msg); 154 const struct GNUNET_MessageHeader *msg);
103 155
104 156
105#if 0 /* keep Emacsens' auto-indent happy */ 157#if 0 /* keep Emacsens' auto-indent happy */