aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-11 18:57:49 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-11 18:57:49 +0000
commitc4c451a78270f0e1ef90dd64b14b179d09b24801 (patch)
tree1889934a36371b489a8229211fea9df4fad4bbed /src/fragmentation
parent958c94402f15a0104f05c688ee8bf5ce25c3a228 (diff)
downloadgnunet-c4c451a78270f0e1ef90dd64b14b179d09b24801.tar.gz
gnunet-c4c451a78270f0e1ef90dd64b14b179d09b24801.zip
dce
Diffstat (limited to 'src/fragmentation')
-rw-r--r--src/fragmentation/test_frag_ji.c60
-rw-r--r--src/fragmentation/test_fragmentation_enhanced.c89
2 files changed, 0 insertions, 149 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
5struct combine{
6 struct GNUNET_FRAGMENT_Context* ctx;
7 struct GNUNET_PeerIdentity* sender;
8};
9
10void 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
30void 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
37int
38main(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}
diff --git a/src/fragmentation/test_fragmentation_enhanced.c b/src/fragmentation/test_fragmentation_enhanced.c
deleted file mode 100644
index 2636b1827..000000000
--- a/src/fragmentation/test_fragmentation_enhanced.c
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file fragmentation/test_fragmentation_enhanced.c
23 * @brief testcase for the fragmentation.c
24 * @author Ji Lu
25 */
26
27#include "platform.h"
28#include "gnunet_protocols.h"
29#include "gnunet_fragmentation_lib.h"
30
31struct combine{
32 struct GNUNET_FRAGMENT_Context* ctx;
33 struct GNUNET_PeerIdentity* sender;
34};
35
36void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){
37
38 fprintf(stderr, "enter into message_proc1\n");
39
40 struct GNUNET_MessageHeader * originalMsg = (struct GNUNET_MessageHeader *)cls;
41
42 if(ntohs(originalMsg->size) != ntohs(msg->size)){
43 fprintf(stderr, "the received message has the different size with the sent one!\n");
44 }
45 if(ntohs(originalMsg->type) != ntohs(msg->type)){
46 fprintf(stderr, "the received message has the different type with the sent one!\n");
47 }
48 if(memcmp(msg, originalMsg, originalMsg->size)){
49 fprintf(stderr, "the received message is not the sent one!\n");
50 }
51 else{
52 fprintf(stdout, "You got the right message!\n");
53 }
54
55}
56
57void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){
58
59 printf("enter into message_proc2\n");
60
61 struct combine * com2 = (struct combine* )cls;
62 GNUNET_FRAGMENT_process(com2->ctx, com2->sender, msg);
63
64}
65
66int
67main(int argc, char * argv[]){
68
69 uint32_t mtu = 512;
70 struct GNUNET_FRAGMENT_Context * ctx;
71 struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *)GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)+2*mtu);
72 ctx = GNUNET_FRAGMENT_context_create(NULL, message_proc1, msg);
73 msg->size = htons(sizeof(struct GNUNET_MessageHeader)+4*mtu);
74 msg->type = htons(GNUNET_MESSAGE_TYPE_HELLO);
75 struct GNUNET_PeerIdentity *sender;
76 sender = (struct GNUNET_PeerIdentity *)GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
77
78 memset(sender, 9, sizeof(struct GNUNET_PeerIdentity));
79
80 memset(&msg[1], 5, 2*mtu);
81
82 struct combine *com;
83 com = (struct combine *)GNUNET_malloc(sizeof(struct combine));
84 com->ctx = ctx;
85 com->sender = sender;
86 GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, com);
87 GNUNET_free(msg);
88 return 0;
89}