aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2010-03-04 22:34:46 +0000
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2010-03-04 22:34:46 +0000
commitecf49b51f5b34145ea39e08d271aaeec65f02835 (patch)
treef4be0c0e3dae617c566fbbd77fe26480d543173c
parent93e050bbf5e9b307a88af9e2df4115239bc9dedb (diff)
downloadgnunet-ecf49b51f5b34145ea39e08d271aaeec65f02835.tar.gz
gnunet-ecf49b51f5b34145ea39e08d271aaeec65f02835.zip
pending testcase for fragementation
-rw-r--r--src/fragmentation/test_frag_ji.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/fragmentation/test_frag_ji.c b/src/fragmentation/test_frag_ji.c
new file mode 100644
index 000000000..8cba654ad
--- /dev/null
+++ b/src/fragmentation/test_frag_ji.c
@@ -0,0 +1,38 @@
1#include "platform.h"
2#include "gnunet_fragmentation_lib.h"
3
4void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){
5
6 struct GNUNET_MessageHeader * originalMsg = (struct GNUNET_MessageHeader *)cls;
7 if(originalMsg->size != msg->size){
8 fprintf(stderr, "the received message has the different size with the sent one!");
9 }
10 if(originalMsg->type != msg->type){
11 fprintf(stderr, "the received message has the different type with the sent one!");
12 }
13 if(memcmp(&originalMsg[1], &msg[1], originalMsg->size - sizeof(struct GNUNET_MessageHeader))){
14 fprintf(stderr, "the received message is not the sent one!");
15 }
16
17}
18
19void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){
20 struct GNUNET_FRAGMENT_Context * ctx = (struct GNUNET_FRAGMENT_Context * )cls;
21 struct Fragment *frag;
22 struct GNUNET_PeerIdentity sender;
23 GNUNET_FRAGMENT_process(ctx, &sender, msg);
24}
25
26int
27main(int argc, char * argv[]){
28
29 struct GNUNET_FRAGMENT_Context * ctx;
30 struct GNUNET_MessageHeader *msg;
31 ctx = GNUNET_FRAGMENT_context_create(stats, message_proc1, msg);
32 msg->size = sizeof(struct GNUNET_MessageHeader)+2*mtu;
33 msg->type = GNUNET_MESSAGE_TYPE_HELLO;
34 memcpy(&msg[1], 5, 2*mtu);
35 GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, ctx);
36
37 return 0;
38}