aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/fragmentation.c
diff options
context:
space:
mode:
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2010-04-01 15:16:00 +0000
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2010-04-01 15:16:00 +0000
commit36bfd342bf5703f0f482e0ea0c6adf0682f3d014 (patch)
tree7154c685d65979674fe1b242e86026f694f1dc9b /src/fragmentation/fragmentation.c
parentebb09b65cddeee11ea8a6e3a95eb328bc0f7711c (diff)
downloadgnunet-36bfd342bf5703f0f482e0ea0c6adf0682f3d014.tar.gz
gnunet-36bfd342bf5703f0f482e0ea0c6adf0682f3d014.zip
final version from ji lu
Diffstat (limited to 'src/fragmentation/fragmentation.c')
-rw-r--r--src/fragmentation/fragmentation.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index c3739a3e9..c06715b99 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -28,7 +28,7 @@
28 * fragmented packet at any given point in time (prevents 28 * fragmented packet at any given point in time (prevents
29 * DoS attacks). Fragmented messages that have not been 29 * DoS attacks). Fragmented messages that have not been
30 * completed after a certain amount of time are discarded. 30 * completed after a certain amount of time are discarded.
31 * @author Christian Grothoff 31 * @author Ji Lu
32 */ 32 */
33 33
34#include "platform.h" 34#include "platform.h"
@@ -115,13 +115,13 @@ GNUNET_FRAGMENT_fragment (const struct GNUNET_MessageHeader *msg,
115 { 115 {
116 struct Fragment *frag; 116 struct Fragment *frag;
117 if(actualNum != num){ 117 if(actualNum != num){
118 if(i!=actualNum-1){ 118 if(i!=actualNum-1){
119 frag = (struct Fragment *)GNUNET_malloc(mtu); 119 frag = (struct Fragment *)GNUNET_malloc(mtu);
120 } 120 }
121 else{ 121 else{
122 frag = (struct Fragment *)GNUNET_malloc(lastSize+size); 122 frag = (struct Fragment *)GNUNET_malloc(lastSize+size);
123 } 123 }
124 } 124 }
125 else{ 125 else{
126 frag = (struct Fragment *)GNUNET_malloc(mtu); 126 frag = (struct Fragment *)GNUNET_malloc(mtu);
127 } 127 }
@@ -131,20 +131,20 @@ GNUNET_FRAGMENT_fragment (const struct GNUNET_MessageHeader *msg,
131 frag->mtu = htons(mtu); 131 frag->mtu = htons(mtu);
132 frag->totalNum = htons(actualNum); 132 frag->totalNum = htons(actualNum);
133 frag->totalSize = msg->size; 133 frag->totalSize = msg->size;
134 char *m = (char *)msg; 134 char *tmpMsg = (char *)msg;
135 if(actualNum != num){ 135 if(actualNum != num){
136 if(i!=actualNum-1){ 136 if(i!=actualNum-1){
137 frag->header.size = frag->mtu; 137 frag->header.size = htons(mtu);
138 memcpy(&frag[1], m + (mtu-size)*i, mtu - size); 138 memcpy(&frag[1], tmpMsg + (mtu-size)*i, mtu - size);
139 } 139 }
140 else{ 140 else{
141 frag->header.size = htons(lastSize+size); 141 frag->header.size = htons(lastSize+size);
142 memcpy(&frag[1], m + (mtu-size)*i, lastSize); 142 memcpy(&frag[1], tmpMsg + (mtu-size)*i, lastSize);
143 } 143 }
144 } 144 }
145 else{ 145 else{
146 frag->header.size = frag->mtu; 146 frag->header.size = htons(mtu);
147 memcpy(&frag[1], m + (mtu-size)*i, mtu - size); 147 memcpy(&frag[1], tmpMsg + (mtu-size)*i, mtu - size);
148 } 148 }
149 proc(proc_cls, &frag->header); 149 proc(proc_cls, &frag->header);
150 GNUNET_free(frag); 150 GNUNET_free(frag);