aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_fragmentation_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_fragmentation_lib.h')
-rw-r--r--src/include/gnunet_fragmentation_lib.h235
1 files changed, 0 insertions, 235 deletions
diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h
deleted file mode 100644
index c8e99826a..000000000
--- a/src/include/gnunet_fragmentation_lib.h
+++ /dev/null
@@ -1,235 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2009, 2011, 2015 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @addtogroup Backbone
22 * @{
23 *
24 * @author Christian Grothoff
25 *
26 * @file
27 * Library to help fragment messages
28 *
29 * @defgroup fragmentation Fragmentation library
30 * Library to help fragment messages
31 * @{
32 *
33 * @todo Consider additional flow-control for sending from
34 * fragmentation based on continuations.
35 */
36
37#ifndef GNUNET_FRAGMENTATION_LIB_H
38#define GNUNET_FRAGMENTATION_LIB_H
39
40
41#include "gnunet_util_lib.h"
42#include "gnunet_statistics_service.h"
43
44#ifdef __cplusplus
45extern "C"
46{
47#if 0 /* keep Emacsens' auto-indent happy */
48}
49#endif
50#endif
51
52
53/**
54 * Fragmentation context.
55 */
56struct GNUNET_FRAGMENT_Context;
57
58
59/**
60 * Function that is called with messages created by the fragmentation
61 * module. In the case of the 'proc' callback of the
62 * #GNUNET_FRAGMENT_context_create() function, this function must
63 * eventually call #GNUNET_FRAGMENT_context_transmission_done().
64 *
65 * @param cls closure
66 * @param msg the message that was created
67 */
68typedef void
69(*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
70 const struct GNUNET_MessageHeader *msg);
71
72
73/**
74 * Create a fragmentation context for the given message.
75 * Fragments the message into fragments of size @a mtu or
76 * less. Calls @a proc on each un-acknowledged fragment,
77 * using both the expected @a msg_delay between messages and
78 * acknowledgements and the given @a tracker to guide the
79 * frequency of calls to @a proc.
80 *
81 * @param stats statistics context
82 * @param mtu the maximum message size for each fragment
83 * @param tracker bandwidth tracker to use for flow control (can be NULL)
84 * @param msg_delay initial delay to insert between fragment transmissions
85 * based on previous messages
86 * @param ack_delay expected delay between fragment transmission
87 * and ACK based on previous messages
88 * @param msg the message to fragment
89 * @param proc function to call for each fragment to transmit
90 * @param proc_cls closure for proc
91 * @return the fragmentation context
92 */
93struct GNUNET_FRAGMENT_Context *
94GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
95 uint16_t mtu,
96 struct GNUNET_BANDWIDTH_Tracker *tracker,
97 struct GNUNET_TIME_Relative msg_delay,
98 struct GNUNET_TIME_Relative ack_delay,
99 const struct GNUNET_MessageHeader *msg,
100 GNUNET_FRAGMENT_MessageProcessor proc,
101 void *proc_cls);
102
103
104/**
105 * Continuation to call from the 'proc' function after the fragment
106 * has been transmitted (and hence the next fragment can now be
107 * given to proc).
108 *
109 * @param fc fragmentation context
110 */
111void
112GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc);
113
114
115/**
116 * Process an acknowledgement message we got from the other
117 * side (to control re-transmits).
118 *
119 * @param fc fragmentation context
120 * @param msg acknowledgement message we received
121 * @return #GNUNET_OK if this ack completes the work of the 'fc'
122 * (all fragments have been received);
123 * #GNUNET_NO if more messages are pending
124 * #GNUNET_SYSERR if this ack is not valid for this fc
125 */
126int
127GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
128 const struct GNUNET_MessageHeader *msg);
129
130
131/**
132 * Destroy the given fragmentation context (stop calling 'proc', free
133 * resources).
134 *
135 * @param fc fragmentation context
136 * @param msg_delay where to store average delay between individual message transmissions the
137 * last message (OUT only)
138 * @param ack_delay where to store average delay between transmission and ACK for the
139 * last message, set to FOREVER if the message was not fully transmitted (OUT only)
140 */
141void
142GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc,
143 struct GNUNET_TIME_Relative *msg_delay,
144 struct GNUNET_TIME_Relative *ack_delay);
145
146
147/**
148 * Convert an ACK message to a printable format suitable for logging.
149 *
150 * @param ack message to print
151 * @return ack in human-readable format
152 */
153const char *
154GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack);
155
156
157/**
158 * Defragmentation context (one per connection).
159 */
160struct GNUNET_DEFRAGMENT_Context;
161
162
163/**
164 * Function that is called with acknowledgement messages created by
165 * the fragmentation module. Acknowledgements are cumulative,
166 * so it is OK to only transmit the 'latest' ack message for the same
167 * message ID.
168 *
169 * @param cls closure
170 * @param id unique message ID (modulo collisions)
171 * @param msg the message that was created
172 */
173typedef void
174(*GNUNET_DEFRAGMENT_AckProcessor) (void *cls,
175 uint32_t id,
176 const struct GNUNET_MessageHeader *msg);
177
178
179/**
180 * Create a defragmentation context.
181 *
182 * @param stats statistics context
183 * @param mtu the maximum message size for each fragment
184 * @param num_msgs how many fragmented messages
185 * to we defragment at most at the same time?
186 * @param cls closure for @a proc and @a ackp
187 * @param proc function to call with defragmented messages
188 * @param ackp function to call with acknowledgements (to send
189 * back to the other side)
190 * @return the defragmentation context
191 */
192struct GNUNET_DEFRAGMENT_Context *
193GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
194 uint16_t mtu,
195 unsigned int num_msgs,
196 void *cls,
197 GNUNET_FRAGMENT_MessageProcessor proc,
198 GNUNET_DEFRAGMENT_AckProcessor ackp);
199
200
201/**
202 * Destroy the given defragmentation context.
203 *
204 * @param dc defragmentation context
205 */
206void
207GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc);
208
209
210/**
211 * We have received a fragment. Process it.
212 *
213 * @param dc the context
214 * @param msg the message that was received
215 * @return #GNUNET_OK on success,
216 * #GNUNET_NO if this was a duplicate,
217 * #GNUNET_SYSERR on error
218 */
219int
220GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
221 const struct GNUNET_MessageHeader *msg);
222
223
224#if 0 /* keep Emacsens' auto-indent happy */
225{
226#endif
227#ifdef __cplusplus
228}
229#endif
230
231#endif
232
233/** @} */ /* end of group */
234
235/** @} */ /* end of group addition */