gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r10495 - gnunet/src/fragmentation


From: gnunet
Subject: [GNUnet-SVN] r10495 - gnunet/src/fragmentation
Date: Thu, 4 Mar 2010 23:34:46 +0100

Author: jilu
Date: 2010-03-04 23:34:46 +0100 (Thu, 04 Mar 2010)
New Revision: 10495

Added:
   gnunet/src/fragmentation/test_frag_ji.c
Log:
pending testcase for fragementation

Added: gnunet/src/fragmentation/test_frag_ji.c
===================================================================
--- gnunet/src/fragmentation/test_frag_ji.c                             (rev 0)
+++ gnunet/src/fragmentation/test_frag_ji.c     2010-03-04 22:34:46 UTC (rev 
10495)
@@ -0,0 +1,38 @@
+#include "platform.h"
+#include "gnunet_fragmentation_lib.h"
+
+void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){
+
+       struct GNUNET_MessageHeader * originalMsg = (struct 
GNUNET_MessageHeader *)cls;
+       if(originalMsg->size != msg->size){
+                       fprintf(stderr, "the received message has the different 
size with the sent one!");
+               }
+       if(originalMsg->type != msg->type){
+                       fprintf(stderr, "the received message has the different 
type with the sent one!");
+               }
+       if(memcmp(&originalMsg[1], &msg[1], originalMsg->size - sizeof(struct 
GNUNET_MessageHeader))){
+                       fprintf(stderr, "the received message is not the sent 
one!");
+       }
+
+}
+
+void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){
+       struct GNUNET_FRAGMENT_Context * ctx = (struct GNUNET_FRAGMENT_Context 
* )cls;
+       struct Fragment *frag;
+       struct GNUNET_PeerIdentity sender;
+       GNUNET_FRAGMENT_process(ctx, &sender, msg);
+}
+
+int
+main(int argc, char * argv[]){
+
+       struct GNUNET_FRAGMENT_Context * ctx;
+       struct GNUNET_MessageHeader *msg;
+       ctx = GNUNET_FRAGMENT_context_create(stats, message_proc1, msg);
+       msg->size = sizeof(struct GNUNET_MessageHeader)+2*mtu;
+       msg->type = GNUNET_MESSAGE_TYPE_HELLO;
+       memcpy(&msg[1], 5, 2*mtu);
+       GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, ctx);
+
+       return 0;
+}


Property changes on: gnunet/src/fragmentation/test_frag_ji.c
___________________________________________________________________
Added: svn:mime-type
   + text/plain





reply via email to

[Prev in Thread] Current Thread [Next in Thread]