diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-09 11:54:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-09 11:54:47 +0000 |
commit | 3883c9b973ddcbdc88d9807dbe4252a56ece5f92 (patch) | |
tree | b54d5edf45cbeeb4031aa029210eec6019f7ff73 | |
parent | 1a39ba90f5af8341431c49f0dc9931d3c86de7a2 (diff) | |
download | gnunet-3883c9b973ddcbdc88d9807dbe4252a56ece5f92.tar.gz gnunet-3883c9b973ddcbdc88d9807dbe4252a56ece5f92.zip |
new fragmentation API design - with retransmit
-rw-r--r-- | src/fragmentation/Makefile.am | 23 | ||||
-rw-r--r-- | src/fragmentation/defragmentation_new.c | 109 | ||||
-rw-r--r-- | src/fragmentation/fragmentation.h | 52 | ||||
-rw-r--r-- | src/fragmentation/fragmentation_new.c | 195 | ||||
-rw-r--r-- | src/include/gnunet_fragmentation_lib.h | 104 |
5 files changed, 446 insertions, 37 deletions
diff --git a/src/fragmentation/Makefile.am b/src/fragmentation/Makefile.am index 5b1367260..15e356fcc 100644 --- a/src/fragmentation/Makefile.am +++ b/src/fragmentation/Makefile.am | |||
@@ -11,20 +11,21 @@ endif | |||
11 | lib_LTLIBRARIES = libgnunetfragmentation.la | 11 | lib_LTLIBRARIES = libgnunetfragmentation.la |
12 | 12 | ||
13 | libgnunetfragmentation_la_SOURCES = \ | 13 | libgnunetfragmentation_la_SOURCES = \ |
14 | fragmentation.c | 14 | fragmentation_new.c \ |
15 | defragmentation_new.c | ||
15 | libgnunetfragmentation_la_LIBADD = \ | 16 | libgnunetfragmentation_la_LIBADD = \ |
16 | $(top_builddir)/src/util/libgnunetutil.la | 17 | $(top_builddir)/src/util/libgnunetutil.la |
17 | 18 | ||
18 | check_PROGRAMS = \ | 19 | #check_PROGRAMS = \ |
19 | test_fragmentation | 20 | # test_fragmentation |
20 | 21 | ||
21 | if ENABLE_TEST_RUN | 22 | #if ENABLE_TEST_RUN |
22 | TESTS = $(check_PROGRAMS) | 23 | #TESTS = $(check_PROGRAMS) |
23 | endif | 24 | #endif |
24 | 25 | ||
25 | test_fragmentation_SOURCES = \ | 26 | #test_fragmentation_SOURCES = \ |
26 | test_frag_ji.c | 27 | # test_frag_ji.c |
27 | test_fragmentation_LDADD = \ | 28 | #test_fragmentation_LDADD = \ |
28 | $(top_builddir)/src/fragmentation/libgnunetfragmentation.la \ | 29 | # $(top_builddir)/src/fragmentation/libgnunetfragmentation.la \ |
29 | $(top_builddir)/src/util/libgnunetutil.la | 30 | # $(top_builddir)/src/util/libgnunetutil.la |
30 | 31 | ||
diff --git a/src/fragmentation/defragmentation_new.c b/src/fragmentation/defragmentation_new.c new file mode 100644 index 000000000..8fdc334d9 --- /dev/null +++ b/src/fragmentation/defragmentation_new.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file src/fragmentation/defragmentation_new.c | ||
22 | * @brief library to help defragment messages | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_fragmentation_lib.h" | ||
27 | #include "fragmentation.h" | ||
28 | |||
29 | /** | ||
30 | * Defragmentation context. | ||
31 | */ | ||
32 | struct GNUNET_DEFRAGMENT_Context | ||
33 | { | ||
34 | |||
35 | /** | ||
36 | * For statistics. | ||
37 | */ | ||
38 | struct GNUNET_STATISTICS_Handle *stats; | ||
39 | |||
40 | /** | ||
41 | * Closure for 'proc' and 'ackp'. | ||
42 | */ | ||
43 | void *cls; | ||
44 | |||
45 | /** | ||
46 | * Function to call with defragmented messages. | ||
47 | */ | ||
48 | GNUNET_FRAGMENT_MessageProcessor proc; | ||
49 | |||
50 | /** | ||
51 | * Function to call with acknowledgements. | ||
52 | */ | ||
53 | GNUNET_FRAGMENT_MessageProcessor ackp; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Create a defragmentation context. | ||
59 | * | ||
60 | * @param stats statistics context | ||
61 | * @param cls closure for proc and ackp | ||
62 | * @param proc function to call with defragmented messages | ||
63 | * @param ackp function to call with acknowledgements (to send | ||
64 | * back to the other side) | ||
65 | * @return the defragmentation context | ||
66 | */ | ||
67 | struct GNUNET_DEFRAGMENT_Context * | ||
68 | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | ||
69 | void *cls, | ||
70 | GNUNET_FRAGMENT_MessageProcessor proc, | ||
71 | GNUNET_FRAGMENT_MessageProcessor ackp) | ||
72 | { | ||
73 | struct GNUNET_DEFRAGMENT_Context *dc; | ||
74 | |||
75 | dc = GNUNET_malloc (sizeof (struct GNUNET_DEFRAGMENT_Context)); | ||
76 | dc->stats = stats; | ||
77 | dc->cls = cls; | ||
78 | dc->proc = proc; | ||
79 | dc->ackp = ackp; | ||
80 | return dc; | ||
81 | } | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Destroy the given defragmentation context. | ||
86 | * | ||
87 | * @param dc defragmentation context | ||
88 | */ | ||
89 | void | ||
90 | GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc) | ||
91 | { | ||
92 | GNUNET_free (dc); | ||
93 | } | ||
94 | |||
95 | |||
96 | /** | ||
97 | * We have received a fragment. Process it. | ||
98 | * | ||
99 | * @param dc the context | ||
100 | * @param msg the message that was received | ||
101 | */ | ||
102 | void | ||
103 | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, | ||
104 | const struct GNUNET_MessageHeader *msg) | ||
105 | { | ||
106 | } | ||
107 | |||
108 | /* end of defragmentation_new.c */ | ||
109 | |||
diff --git a/src/fragmentation/fragmentation.h b/src/fragmentation/fragmentation.h new file mode 100644 index 000000000..e9b3faba5 --- /dev/null +++ b/src/fragmentation/fragmentation.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file src/fragmentation/fragmentation.h | ||
22 | * @brief library to help fragment messages | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #ifndef FRAGMENTATION_H | ||
26 | #define FRAGMENTATION_H | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_fragmentation_lib.h" | ||
29 | |||
30 | /** | ||
31 | * Header for a message fragment. | ||
32 | */ | ||
33 | struct FragmentHeader | ||
34 | { | ||
35 | |||
36 | struct GNUNET_MessageHeader header; | ||
37 | |||
38 | }; | ||
39 | |||
40 | |||
41 | /** | ||
42 | * Message fragment acknowledgement. | ||
43 | */ | ||
44 | struct FragmentAcknowledgement | ||
45 | { | ||
46 | |||
47 | struct GNUNET_MessageHeader header; | ||
48 | |||
49 | }; | ||
50 | |||
51 | |||
52 | #endif | ||
diff --git a/src/fragmentation/fragmentation_new.c b/src/fragmentation/fragmentation_new.c new file mode 100644 index 000000000..a95afc4a4 --- /dev/null +++ b/src/fragmentation/fragmentation_new.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file src/fragmentation/fragmentation_new.c | ||
22 | * @brief library to help fragment messages | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | |||
26 | #include "platform.h" | ||
27 | #include "gnunet_fragmentation_lib.h" | ||
28 | #include "fragmentation.h" | ||
29 | |||
30 | /** | ||
31 | * Fragmentation context. | ||
32 | */ | ||
33 | struct GNUNET_FRAGMENT_Context | ||
34 | { | ||
35 | /** | ||
36 | * Statistics to use. | ||
37 | */ | ||
38 | struct GNUNET_STATISTICS_Handle *stats; | ||
39 | |||
40 | /** | ||
41 | * Tracker for flow control. | ||
42 | */ | ||
43 | struct GNUNET_BANDWIDTH_Tracker *tracker; | ||
44 | |||
45 | /** | ||
46 | * Current expected delay for ACKs. | ||
47 | */ | ||
48 | struct GNUNET_TIME_Relative delay; | ||
49 | |||
50 | /** | ||
51 | * Message to fragment (allocated at the end of this struct). | ||
52 | */ | ||
53 | const struct GNUNET_MessageHeader *msg; | ||
54 | |||
55 | /** | ||
56 | * Function to call for transmissions. | ||
57 | */ | ||
58 | GNUNET_FRAGMENT_MessageProcessor proc; | ||
59 | |||
60 | /** | ||
61 | * Closure for 'proc'. | ||
62 | */ | ||
63 | void *proc_cls; | ||
64 | |||
65 | /** | ||
66 | * Bitfield, set to 1 for each unacknowledged fragment. | ||
67 | */ | ||
68 | uint64_t acks; | ||
69 | |||
70 | /** | ||
71 | * Task performing work for the fragmenter. | ||
72 | */ | ||
73 | GNUNET_SCHEDULER_TaskIdentifier task; | ||
74 | |||
75 | /** | ||
76 | * Target fragment size. | ||
77 | */ | ||
78 | uint16_t mtu; | ||
79 | |||
80 | }; | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Transmit the next fragment to the other peer. | ||
85 | * | ||
86 | * @param cls the 'struct GNUNET_FRAGMENT_Context' | ||
87 | * @param tc scheduler context | ||
88 | */ | ||
89 | static void | ||
90 | transmit_next (void *cls, | ||
91 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
92 | { | ||
93 | struct GNUNET_FRAGMENT_Context *fc = cls; | ||
94 | |||
95 | fc->task = GNUNET_SCHEDULER_NO_TASK; | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Create a fragmentation context for the given message. | ||
101 | * Fragments the message into fragments of size "mtu" or | ||
102 | * less. Calls 'proc' on each un-acknowledged fragment, | ||
103 | * using both the expected 'delay' between messages and | ||
104 | * acknowledgements and the given 'tracker' to guide the | ||
105 | * frequency of calls to 'proc'. | ||
106 | * | ||
107 | * @param stats statistics context | ||
108 | * @param mtu the maximum message size for each fragment | ||
109 | * @param tracker bandwidth tracker to use for flow control (can be NULL) | ||
110 | * @param delay expected delay between fragment transmission | ||
111 | * and ACK based on previous messages | ||
112 | * @param msg the message to fragment | ||
113 | * @param proc function to call for each fragment to transmit | ||
114 | * @param proc_cls closure for proc | ||
115 | * @return the fragmentation context | ||
116 | */ | ||
117 | struct GNUNET_FRAGMENT_Context * | ||
118 | GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | ||
119 | uint16_t mtu, | ||
120 | struct GNUNET_BANDWIDTH_Tracker *tracker, | ||
121 | struct GNUNET_TIME_Relative delay, | ||
122 | const struct GNUNET_MessageHeader *msg, | ||
123 | GNUNET_FRAGMENT_MessageProcessor proc, | ||
124 | void *proc_cls) | ||
125 | { | ||
126 | struct GNUNET_FRAGMENT_Context *fc; | ||
127 | size_t size; | ||
128 | uint64_t bits; | ||
129 | |||
130 | GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); | ||
131 | size = ntohs (msg->size); | ||
132 | GNUNET_assert (size > mtu); | ||
133 | fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); | ||
134 | fc->stats = stats; | ||
135 | fc->mtu = mtu; | ||
136 | fc->tracker = tracker; | ||
137 | fc->delay = delay; | ||
138 | fc->msg = (const struct GNUNET_MessageHeader*)&fc[1]; | ||
139 | fc->proc = proc; | ||
140 | fc->proc_cls = proc_cls; | ||
141 | memcpy (&fc[1], msg, size); | ||
142 | bits = (size + mtu - 1) / (mtu - sizeof (struct FragmentHeader)); | ||
143 | GNUNET_assert (bits <= 64); | ||
144 | if (bits == 64) | ||
145 | fc->acks = UINT64_MAX; /* set all 64 bit */ | ||
146 | else | ||
147 | fc->acks = (1 << bits) - 1; /* set lowest 'bits' bit */ | ||
148 | fc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_BANDWIDTH_tracker_get_delay (tracker, mtu), | ||
149 | &transmit_next, | ||
150 | fc); | ||
151 | return fc; | ||
152 | } | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Process an acknowledgement message we got from the other | ||
157 | * side (to control re-transmits). | ||
158 | * | ||
159 | * @param fc fragmentation context | ||
160 | * @param msg acknowledgement message we received | ||
161 | * @return GNUNET_OK if this ack completes the work of the 'fc' | ||
162 | * (all fragments have been received); | ||
163 | * GNUNET_NO if more messages are pending | ||
164 | * GNUNET_SYSERR if this ack is not valid for this fc | ||
165 | */ | ||
166 | int | ||
167 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | ||
168 | const struct GNUNET_MessageHeader *msg) | ||
169 | { | ||
170 | return GNUNET_SYSERR; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Destroy the given fragmentation context (stop calling 'proc', free | ||
176 | * resources). | ||
177 | * | ||
178 | * @param fc fragmentation context | ||
179 | * @return average delay between transmission and ACK for the | ||
180 | * last message, FOREVER if the message was not fully transmitted | ||
181 | */ | ||
182 | struct GNUNET_TIME_Relative | ||
183 | GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc) | ||
184 | { | ||
185 | struct GNUNET_TIME_Relative ret; | ||
186 | |||
187 | if (fc->task != GNUNET_SCHEDULER_NO_TASK) | ||
188 | GNUNET_SCHEDULER_cancel (fc->task); | ||
189 | ret = fc->delay; | ||
190 | GNUNET_free (fc); | ||
191 | return ret; | ||
192 | } | ||
193 | |||
194 | /* end of fragmentation_new.c */ | ||
195 | |||
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 | */ | ||
45 | struct 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 | */ |
47 | typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, | 55 | typedef 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 | */ | ||
77 | struct GNUNET_FRAGMENT_Context * | ||
78 | GNUNET_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 | */ |
60 | void GNUNET_FRAGMENT_fragment (const struct GNUNET_MessageHeader *msg, | 98 | int 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 | */ | ||
110 | struct GNUNET_TIME_Relative | ||
111 | GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc); | ||
112 | |||
64 | 113 | ||
65 | /** | 114 | /** |
66 | * Defragmentation context. | 115 | * Defragmentation context. |
67 | */ | 116 | */ |
68 | struct GNUNET_FRAGMENT_Context; | 117 | struct 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 | */ |
78 | struct GNUNET_FRAGMENT_Context *GNUNET_FRAGMENT_context_create (struct | 130 | struct GNUNET_DEFRAGMENT_Context * |
79 | GNUNET_STATISTICS_Handle | 131 | GNUNET_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 | */ |
90 | void GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *ctx); | 142 | void |
143 | GNUNET_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 | */ |
100 | void GNUNET_FRAGMENT_process (struct GNUNET_FRAGMENT_Context *ctx, | 152 | void |
101 | const struct GNUNET_PeerIdentity *sender, | 153 | GNUNET_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 */ |