1 #include "platform.h"
\r
2 #include "gnunet_fragmentation_lib.h"
\r
4 void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){
\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
10 if(originalMsg->type != msg->type){
\r
11 fprintf(stderr, "the received message has the different type with the sent one!");
\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
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
27 main(int argc, char * argv[]){
\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