X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffragmentation%2Ftest_frag_ji.c;h=4779abdddbea5358ff35a58a68193fac45aad769;hb=087ad145760e874bf10252f96b5ce7fc1bd7a49f;hp=059994f2b44957f045586cddd413140fabbc5687;hpb=40ff2323130e2cbe383f9b00fdb5ddfef995d347;p=oweals%2Fgnunet.git diff --git a/src/fragmentation/test_frag_ji.c b/src/fragmentation/test_frag_ji.c index 059994f2b..4779abddd 100644 --- a/src/fragmentation/test_frag_ji.c +++ b/src/fragmentation/test_frag_ji.c @@ -18,9 +18,12 @@ void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){ if(ntohs(originalMsg->type) != ntohs(msg->type)){ fprintf(stderr, "the received message has the different type with the sent one!\n"); } - if(memcmp(msg+960, originalMsg+960, 68)){ + if(memcmp(msg, originalMsg, originalMsg->size)){ fprintf(stderr, "the received message is not the sent one!\n"); } + else{ + fprintf(stdout, "You got the right message!\n"); + } } @@ -28,25 +31,27 @@ void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){ printf("enter into message_proc2\n"); struct combine * com2 = (struct combine* )cls; GNUNET_FRAGMENT_process(com2->ctx, com2->sender, msg); + } int main(int argc, char * argv[]){ - uint16_t mtu = 512; + uint32_t mtu = 512; struct GNUNET_FRAGMENT_Context * ctx; - struct GNUNET_MessageHeader *msg = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)+2*mtu); + struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *)GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)+2*mtu); ctx = GNUNET_FRAGMENT_context_create(NULL, message_proc1, msg); - msg->size = htons(sizeof(struct GNUNET_MessageHeader)+2*mtu); + msg->size = htons(sizeof(struct GNUNET_MessageHeader)+4*mtu); msg->type = htons(GNUNET_MESSAGE_TYPE_HELLO); struct GNUNET_PeerIdentity *sender; - sender = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); + sender = (struct GNUNET_PeerIdentity *)GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); memset(sender, 9, sizeof(struct GNUNET_PeerIdentity)); memset(&msg[1], 5, 2*mtu); + struct combine *com; - com = GNUNET_malloc(sizeof(struct combine)); + com = (struct combine *)GNUNET_malloc(sizeof(struct combine)); com->ctx = ctx; com->sender = sender; GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, com);