diff options
Diffstat (limited to 'src/fragmentation/test_frag_ji.c')
-rw-r--r-- | src/fragmentation/test_frag_ji.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/fragmentation/test_frag_ji.c b/src/fragmentation/test_frag_ji.c deleted file mode 100644 index 4779abddd..000000000 --- a/src/fragmentation/test_frag_ji.c +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | #include "platform.h" | ||
2 | #include "gnunet_protocols.h" | ||
3 | #include "gnunet_fragmentation_lib.h" | ||
4 | |||
5 | struct combine{ | ||
6 | struct GNUNET_FRAGMENT_Context* ctx; | ||
7 | struct GNUNET_PeerIdentity* sender; | ||
8 | }; | ||
9 | |||
10 | void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){ | ||
11 | fprintf(stderr, "enter into message_proc1\n"); | ||
12 | |||
13 | struct GNUNET_MessageHeader * originalMsg = (struct GNUNET_MessageHeader *)cls; | ||
14 | |||
15 | if(ntohs(originalMsg->size) != ntohs(msg->size)){ | ||
16 | fprintf(stderr, "the received message has the different size with the sent one!\n"); | ||
17 | } | ||
18 | if(ntohs(originalMsg->type) != ntohs(msg->type)){ | ||
19 | fprintf(stderr, "the received message has the different type with the sent one!\n"); | ||
20 | } | ||
21 | if(memcmp(msg, originalMsg, originalMsg->size)){ | ||
22 | fprintf(stderr, "the received message is not the sent one!\n"); | ||
23 | } | ||
24 | else{ | ||
25 | fprintf(stdout, "You got the right message!\n"); | ||
26 | } | ||
27 | |||
28 | } | ||
29 | |||
30 | void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){ | ||
31 | printf("enter into message_proc2\n"); | ||
32 | struct combine * com2 = (struct combine* )cls; | ||
33 | GNUNET_FRAGMENT_process(com2->ctx, com2->sender, msg); | ||
34 | |||
35 | } | ||
36 | |||
37 | int | ||
38 | main(int argc, char * argv[]){ | ||
39 | |||
40 | uint32_t mtu = 512; | ||
41 | struct GNUNET_FRAGMENT_Context * ctx; | ||
42 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *)GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)+2*mtu); | ||
43 | ctx = GNUNET_FRAGMENT_context_create(NULL, message_proc1, msg); | ||
44 | msg->size = htons(sizeof(struct GNUNET_MessageHeader)+4*mtu); | ||
45 | msg->type = htons(GNUNET_MESSAGE_TYPE_HELLO); | ||
46 | struct GNUNET_PeerIdentity *sender; | ||
47 | sender = (struct GNUNET_PeerIdentity *)GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); | ||
48 | |||
49 | memset(sender, 9, sizeof(struct GNUNET_PeerIdentity)); | ||
50 | |||
51 | memset(&msg[1], 5, 2*mtu); | ||
52 | |||
53 | struct combine *com; | ||
54 | com = (struct combine *)GNUNET_malloc(sizeof(struct combine)); | ||
55 | com->ctx = ctx; | ||
56 | com->sender = sender; | ||
57 | GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, com); | ||
58 | GNUNET_free(msg); | ||
59 | return 0; | ||
60 | } | ||