struct GNUNET_TIME_Relative ret;
int do_forward;
struct InboundMessage *im;
- size_t size = sizeof (struct InboundMessage) + ntohs (message->size);
+ size_t size = sizeof (struct InboundMessage) + ntohs (message->size) + sizeof (struct GNUNET_ATS_Information) * ats_count;
char buf[size];
- memset (&buf, 0, size);
+ struct GNUNET_ATS_Information *ap;
ret = GNUNET_TIME_UNIT_ZERO;
do_forward = GNUNET_SYSERR;
im = (struct InboundMessage*) buf;
im->header.size = htons (size);
im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
- im->ats_count = htonl (0);
- memcpy (&(im->peer), peer, sizeof (struct GNUNET_PeerIdentity));
- memcpy (&im[1], message, ntohs (message->size));
+ im->ats_count = htonl (ats_count);
+ im->peer = *peer;
+ ap = (struct GNUNET_ATS_Information*) &im[1];
+ memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
+ memcpy (&ap[ats_count], message, ntohs (message->size));
switch (do_forward)
{
size_t len = sizeof (struct ConnectInfoMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information);
char buf[len];
- memset (&buf, 0, len);
struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
+ struct GNUNET_ATS_Information *ap;
connect_msg->header.size = htons (sizeof (buf));
connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
connect_msg->ats_count = htonl (ats_count);
connect_msg->id = *peer;
- memcpy (&connect_msg->ats, &connect_msg->ats,
+ ap = (struct GNUNET_ATS_Information *) &connect_msg[1];
+ memcpy (ap, ats,
ats_count * sizeof (struct GNUNET_ATS_Information));
GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
}
{
struct TransportClient *tc = cls;
struct ConnectInfoMessage *cim;
- size_t size;
+ struct GNUNET_ATS_Information *ap;
+ size_t size =
+ sizeof (struct ConnectInfoMessage) +
+ ats_count * sizeof (struct GNUNET_ATS_Information);
+ char buf[size];
- size =
- sizeof (struct ConnectInfoMessage) +
- ats_count * sizeof (struct GNUNET_ATS_Information);
GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- cim = GNUNET_malloc (size);
+ cim = (struct ConnectInfoMessage*) buf;
cim->header.size = htons (size);
cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
cim->ats_count = htonl (ats_count);
cim->id = *peer;
- memcpy (&cim->ats, ats,
+ ap = (struct GNUNET_ATS_Information *) &cim[1];
+ memcpy (ap, ats,
ats_count * sizeof (struct GNUNET_ATS_Information));
unicast (tc, &cim->header, GNUNET_NO);
- GNUNET_free (cim);
}
* Identity of the new neighbour.
*/
struct GNUNET_PeerIdentity id;
-
- /**
- * First of the ATS information blocks (we must have at least
- * one due to the 0-termination requirement).
- */
- struct GNUNET_ATS_Information ats;
};
*/
struct GNUNET_PeerIdentity peer;
- /**
- * First of the ATS information blocks (we must have at least
- * one due to the 0-termination requirement).
- */
- struct GNUNET_ATS_Information ats;
};
const struct GNUNET_MessageHeader *imm;
const struct SendOkMessage *okm;
const struct QuotaSetMessage *qm;
+ const struct GNUNET_ATS_Information *ats;
struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
struct Neighbour *n;
GNUNET_break (0);
break;
}
+ ats = (const struct GNUNET_ATS_Information*) &cim[1];
#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
"CONNECT", GNUNET_i2s (&cim->id));
}
n = neighbour_add (h, &cim->id);
if (h->nc_cb != NULL)
- h->nc_cb (h->cls, &n->id, &cim->ats, ats_count);
+ h->nc_cb (h->cls, &n->id, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
if (size != sizeof (struct DisconnectInfoMessage))
}
im = (const struct InboundMessage *) msg;
ats_count = ntohl (im->ats_count);
- imm = (const struct GNUNET_MessageHeader *) &((&(im->ats))[ats_count + 1]);
-
+ ats = (const struct GNUNET_ATS_Information*) &im[1];
+ imm = (const struct GNUNET_MessageHeader *) &ats[ats_count];
if (ntohs (imm->size) + sizeof (struct InboundMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) != size)
{
break;
}
if (h->rec != NULL)
- h->rec (h->cls, &im->peer, imm, &im->ats, ats_count);
+ h->rec (h->cls, &im->peer, imm, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA:
#if DEBUG_TRANSPORT_API