pending testcase for fragementation
[oweals/gnunet.git] / src / fragmentation / test_frag_ji.c
1 #include "platform.h"\r
2 #include "gnunet_fragmentation_lib.h"\r
3 \r
4 void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){\r
5 \r
6         struct GNUNET_MessageHeader * originalMsg = (struct GNUNET_MessageHeader *)cls;\r
7         if(originalMsg->size != msg->size){\r
8                         fprintf(stderr, "the received message has the different size with the sent one!");\r
9                 }\r
10         if(originalMsg->type != msg->type){\r
11                         fprintf(stderr, "the received message has the different type with the sent one!");\r
12                 }\r
13         if(memcmp(&originalMsg[1], &msg[1], originalMsg->size - sizeof(struct GNUNET_MessageHeader))){\r
14                         fprintf(stderr, "the received message is not the sent one!");\r
15         }\r
16 \r
17 }\r
18 \r
19 void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){\r
20         struct GNUNET_FRAGMENT_Context * ctx = (struct GNUNET_FRAGMENT_Context * )cls;\r
21         struct Fragment *frag;\r
22         struct GNUNET_PeerIdentity sender;\r
23         GNUNET_FRAGMENT_process(ctx, &sender, msg);\r
24 }\r
25 \r
26 int\r
27 main(int argc, char * argv[]){\r
28 \r
29         struct GNUNET_FRAGMENT_Context * ctx;\r
30         struct GNUNET_MessageHeader *msg;\r
31         ctx = GNUNET_FRAGMENT_context_create(stats, message_proc1, msg);\r
32         msg->size = sizeof(struct GNUNET_MessageHeader)+2*mtu;\r
33         msg->type = GNUNET_MESSAGE_TYPE_HELLO;\r
34         memcpy(&msg[1], 5, 2*mtu);\r
35         GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, ctx);\r
36 \r
37         return 0;\r
38 }\r