[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1380 - GNUnet/src/applications/fragmentation
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1380 - GNUnet/src/applications/fragmentation |
Date: |
Sun, 10 Jul 2005 16:34:48 -0700 (PDT) |
Author: grothoff
Date: 2005-07-10 16:34:45 -0700 (Sun, 10 Jul 2005)
New Revision: 1380
Modified:
GNUnet/src/applications/fragmentation/fragmentation.c
Log:
fragfix
Modified: GNUnet/src/applications/fragmentation/fragmentation.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentation.c 2005-07-10
23:25:35 UTC (rev 1379)
+++ GNUnet/src/applications/fragmentation/fragmentation.c 2005-07-10
23:34:45 UTC (rev 1380)
@@ -431,11 +431,6 @@
unsigned short len;
/** when did we intend to transmit? */
cron_t transmissionTime;
- /** callback to call to create the message part */
- BuildMessageCallback callback;
- /** argument to callback, call FREENONNULL(closure) if we
- can not transmit this MessagePart. */
- void * closure;
} FragmentBMC;
/**
@@ -455,25 +450,15 @@
FragmentBMC * ctx,
unsigned short len) {
static int idGen = 0;
- char * tmp;
- int ret;
FRAGMENT_Message * frag;
unsigned int pos;
int id;
unsigned short mlen;
if (len < ctx->mtu) {
- ctx->callback(NULL, ctx->closure, 0);
FREE(ctx);
return SYSERR;
}
- tmp = MALLOC(ctx->len);
- ret = ctx->callback(tmp, ctx->closure, ctx->len);
- if (ret == SYSERR) {
- FREE(tmp);
- FREE(ctx);
- return SYSERR;
- }
if (stats != NULL)
stats->change(stat_fragmented, 1);
id = (idGen++) + randomi(512);
@@ -485,7 +470,7 @@
frag->off = htons(0);
frag->len = htons(ctx->len);
memcpy(&((FRAGMENT_Message_GENERIC*)frag)->data[0],
- tmp,
+ &ctx[1],
len - sizeof(FRAGMENT_Message));
/* create remaining fragments, add to queue! */
@@ -502,7 +487,7 @@
frag->off = htons(pos);
frag->len = htons(ctx->len);
memcpy(&((FRAGMENT_Message_GENERIC*)frag)->data[0],
- &tmp[pos],
+ &ctx[1],
mlen - sizeof(FRAGMENT_Message));
coreAPI->unicast(&ctx->sender,
&frag->header,
@@ -512,7 +497,6 @@
}
GNUNET_ASSERT(pos == ctx->len);
FREE(frag);
- FREE(tmp);
FREE(ctx);
return OK;
}
@@ -535,13 +519,17 @@
GNUNET_ASSERT(len > mtu);
GNUNET_ASSERT(mtu > sizeof(FRAGMENT_Message));
- fbmc = MALLOC(sizeof(FragmentBMC));
+ fbmc = MALLOC(sizeof(FragmentBMC) + len);
fbmc->mtu = mtu;
fbmc->sender = *peer;
- fbmc->transmissionTime = targetTime;
- fbmc->callback = bmc;
- fbmc->closure = bmcClosure;
+ fbmc->transmissionTime = targetTime;
fbmc->len = len;
+ if (SYSERR == bmc(&fbmc[1],
+ bmcClosure,
+ len)) {
+ FREE(fbmc);
+ return;
+ }
xlen = mtu - sizeof(FRAGMENT_Message);
coreAPI->unicastCallback(peer,
(BuildMessageCallback) &fragmentBMC,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1380 - GNUnet/src/applications/fragmentation,
grothoff <=