aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/test_frag_ji.c
blob: 8cba654ada6ee7b1f1c90c7c744f7dc00dec51f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}