aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/fragmentation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/fragmentation/fragmentation.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fragmentation/fragmentation.c')
-rw-r--r--src/fragmentation/fragmentation.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index d3483fc8d..cea33b652 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -176,16 +176,15 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
176 fh->fragment_id = htonl (fc->fragment_id); 176 fh->fragment_id = htonl (fc->fragment_id);
177 fh->total_size = fc->msg->size; /* already in big-endian */ 177 fh->total_size = fc->msg->size; /* already in big-endian */
178 fh->offset = htons ((fc->mtu - sizeof (struct FragmentHeader)) * bit); 178 fh->offset = htons ((fc->mtu - sizeof (struct FragmentHeader)) * bit);
179 memcpy (&fh[1], 179 memcpy (&fh[1], &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))],
180 &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))],
181 fsize - sizeof (struct FragmentHeader)); 180 fsize - sizeof (struct FragmentHeader));
182 if (NULL != fc->tracker) 181 if (NULL != fc->tracker)
183 GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); 182 GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize);
184 GNUNET_STATISTICS_update (fc->stats, 183 GNUNET_STATISTICS_update (fc->stats, _("# fragments transmitted"), 1,
185 _("# fragments transmitted"), 1, GNUNET_NO); 184 GNUNET_NO);
186 if (0 != fc->last_round.abs_value) 185 if (0 != fc->last_round.abs_value)
187 GNUNET_STATISTICS_update (fc->stats, 186 GNUNET_STATISTICS_update (fc->stats, _("# fragments retransmitted"), 1,
188 _("# fragments retransmitted"), 1, GNUNET_NO); 187 GNUNET_NO);
189 188
190 /* select next message to calculate delay */ 189 /* select next message to calculate delay */
191 bit = fc->next_transmission; 190 bit = fc->next_transmission;
@@ -201,8 +200,9 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
201 if (wrap) 200 if (wrap)
202 { 201 {
203 /* full round transmitted wait 2x delay for ACK before going again */ 202 /* full round transmitted wait 2x delay for ACK before going again */
204 delay = GNUNET_TIME_relative_max (GNUNET_TIME_relative_multiply (delay, 2), 203 delay =
205 fc->delay); 204 GNUNET_TIME_relative_max (GNUNET_TIME_relative_multiply (delay, 2),
205 fc->delay);
206 /* never use zero, need some time for ACK always */ 206 /* never use zero, need some time for ACK always */
207 delay = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, delay); 207 delay = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, delay);
208 fc->last_round = GNUNET_TIME_absolute_get (); 208 fc->last_round = GNUNET_TIME_absolute_get ();
@@ -248,8 +248,7 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
248 GNUNET_STATISTICS_update (stats, _("# messages fragmented"), 1, GNUNET_NO); 248 GNUNET_STATISTICS_update (stats, _("# messages fragmented"), 1, GNUNET_NO);
249 GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); 249 GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader));
250 size = ntohs (msg->size); 250 size = ntohs (msg->size);
251 GNUNET_STATISTICS_update (stats, 251 GNUNET_STATISTICS_update (stats, _("# total size of fragmented messages"),
252 _("# total size of fragmented messages"),
253 size, GNUNET_NO); 252 size, GNUNET_NO);
254 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); 253 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
255 fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); 254 fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size);
@@ -260,8 +259,8 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
260 fc->msg = (const struct GNUNET_MessageHeader *) &fc[1]; 259 fc->msg = (const struct GNUNET_MessageHeader *) &fc[1];
261 fc->proc = proc; 260 fc->proc = proc;
262 fc->proc_cls = proc_cls; 261 fc->proc_cls = proc_cls;
263 fc->fragment_id = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 262 fc->fragment_id =
264 UINT32_MAX); 263 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
265 memcpy (&fc[1], msg, size); 264 memcpy (&fc[1], msg, size);
266 bits = 265 bits =
267 (size + mtu - sizeof (struct FragmentHeader) - 1) / (mtu - 266 (size + mtu - sizeof (struct FragmentHeader) - 1) / (mtu -
@@ -333,14 +332,14 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
333 fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4; 332 fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4;
334 } 333 }
335 GNUNET_STATISTICS_update (fc->stats, 334 GNUNET_STATISTICS_update (fc->stats,
336 _("# fragment acknowledgements received"), 335 _("# fragment acknowledgements received"), 1,
337 1, GNUNET_NO); 336 GNUNET_NO);
338 if (abits != (fc->acks & abits)) 337 if (abits != (fc->acks & abits))
339 { 338 {
340 /* ID collission or message reordering, count! This should be rare! */ 339 /* ID collission or message reordering, count! This should be rare! */
341 GNUNET_STATISTICS_update (fc->stats, 340 GNUNET_STATISTICS_update (fc->stats,
342 _("# bits removed from fragmentation ACKs"), 341 _("# bits removed from fragmentation ACKs"), 1,
343 1, GNUNET_NO); 342 GNUNET_NO);
344 } 343 }
345 fc->acks = abits & fc->acks_mask; 344 fc->acks = abits & fc->acks_mask;
346 if (0 != fc->acks) 345 if (0 != fc->acks)
@@ -363,8 +362,8 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
363 362
364 /* all done */ 363 /* all done */
365 GNUNET_STATISTICS_update (fc->stats, 364 GNUNET_STATISTICS_update (fc->stats,
366 _("# fragmentation transmissions completed"), 365 _("# fragmentation transmissions completed"), 1,
367 1, GNUNET_NO); 366 GNUNET_NO);
368 if (fc->task != GNUNET_SCHEDULER_NO_TASK) 367 if (fc->task != GNUNET_SCHEDULER_NO_TASK)
369 { 368 {
370 GNUNET_SCHEDULER_cancel (fc->task); 369 GNUNET_SCHEDULER_cancel (fc->task);