aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-24 16:15:02 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-24 16:15:02 +0000
commit0f4bee916929a41fd6cc516cd6276685d283d706 (patch)
tree351ee64a09deccd3bcfb994d9d84550ff2789e45 /src/transport/gnunet-service-transport.c
parent227d261c1ff256be9dea7bf98e5e07f7875dcde0 (diff)
downloadgnunet-0f4bee916929a41fd6cc516cd6276685d283d706.tar.gz
gnunet-0f4bee916929a41fd6cc516cd6276685d283d706.zip
improving r17722
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 6a56f6830..a45e49fc5 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -154,9 +154,9 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
154 struct GNUNET_TIME_Relative ret; 154 struct GNUNET_TIME_Relative ret;
155 int do_forward; 155 int do_forward;
156 struct InboundMessage *im; 156 struct InboundMessage *im;
157 size_t size = sizeof (struct InboundMessage) + ntohs (message->size); 157 size_t size = sizeof (struct InboundMessage) + ntohs (message->size) + sizeof (struct GNUNET_ATS_Information) * ats_count;
158 char buf[size]; 158 char buf[size];
159 memset (&buf, 0, size); 159 struct GNUNET_ATS_Information *ap;
160 160
161 ret = GNUNET_TIME_UNIT_ZERO; 161 ret = GNUNET_TIME_UNIT_ZERO;
162 do_forward = GNUNET_SYSERR; 162 do_forward = GNUNET_SYSERR;
@@ -169,9 +169,11 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
169 im = (struct InboundMessage*) buf; 169 im = (struct InboundMessage*) buf;
170 im->header.size = htons (size); 170 im->header.size = htons (size);
171 im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); 171 im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
172 im->ats_count = htonl (0); 172 im->ats_count = htonl (ats_count);
173 memcpy (&(im->peer), peer, sizeof (struct GNUNET_PeerIdentity)); 173 im->peer = *peer;
174 memcpy (&im[1], message, ntohs (message->size)); 174 ap = (struct GNUNET_ATS_Information*) &im[1];
175 memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
176 memcpy (&ap[ats_count], message, ntohs (message->size));
175 177
176 switch (do_forward) 178 switch (do_forward)
177 { 179 {
@@ -454,14 +456,15 @@ neighbours_connect_notification (void *cls,
454 size_t len = sizeof (struct ConnectInfoMessage) + 456 size_t len = sizeof (struct ConnectInfoMessage) +
455 ats_count * sizeof (struct GNUNET_ATS_Information); 457 ats_count * sizeof (struct GNUNET_ATS_Information);
456 char buf[len]; 458 char buf[len];
457 memset (&buf, 0, len);
458 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; 459 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
460 struct GNUNET_ATS_Information *ap;
459 461
460 connect_msg->header.size = htons (sizeof (buf)); 462 connect_msg->header.size = htons (sizeof (buf));
461 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 463 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
462 connect_msg->ats_count = htonl (ats_count); 464 connect_msg->ats_count = htonl (ats_count);
463 connect_msg->id = *peer; 465 connect_msg->id = *peer;
464 memcpy (&connect_msg->ats, &connect_msg->ats, 466 ap = (struct GNUNET_ATS_Information *) &connect_msg[1];
467 memcpy (ap, ats,
465 ats_count * sizeof (struct GNUNET_ATS_Information)); 468 ats_count * sizeof (struct GNUNET_ATS_Information));
466 GST_clients_broadcast (&connect_msg->header, GNUNET_NO); 469 GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
467} 470}