*/
int public_key_valid;
+ /**
+ * Performance data for the peer.
+ */
+ struct GNUNET_TRANSPORT_ATS_Information *ats;
+
+ /**
+ * Identity of the neighbour.
+ */
+ struct GNUNET_PeerIdentity peer;
+
};
/**
struct ConnectInfoMessage * cim;
struct TransportClient *cpos;
uint32_t ats_count;
- uint16_t size;
+ size_t size;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
ats_count = 2;
size = sizeof (struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
+ if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break(0);
+ }
cim = GNUNET_malloc (size);
cim->header.size = htons (size);
GNUNET_NO);
/* transmit message to all clients */
uint32_t ats_count = 2;
- uint16_t size = sizeof (struct InboundMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) + msize;
+ size_t size = sizeof (struct InboundMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) + msize;
+ if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ GNUNET_break(0);
im = GNUNET_malloc (size);
im->header.size = htons (size);
{
const struct StartMessage *start;
struct TransportClient *c;
- struct ConnectInfoMessage cim;
+ struct ConnectInfoMessage * cim;
struct NeighbourList *n;
+ uint32_t ats_count;
+ size_t size;
start = (const struct StartMessage*) message;
#if DEBUG_TRANSPORT
clients = c;
c->client = client;
if (our_hello != NULL)
- {
+ {
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending our own `%s' to new client\n", "HELLO");
(const struct GNUNET_MessageHeader *) our_hello,
GNUNET_NO);
/* tell new client about all existing connections */
- cim.header.size = htons (sizeof (struct ConnectInfoMessage));
- cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
- cim.ats_count = htonl(0);
- cim.ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
- cim.ats.value = htonl (0);
+ ats_count = 2;
+ size = sizeof (struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
+ if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break(0);
+ }
+ cim = GNUNET_malloc (size);
+
+ cim->header.size = htons (size);
+ cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
+ cim->ats_count = htonl(ats_count);
+ (&(cim->ats))[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+ (&(cim->ats))[2].value = htonl (0);
n = neighbours;
while (n != NULL)
- {
- if (GNUNET_YES == n->received_pong)
- {
- cim.id = n->id;
- transmit_to_client (c, &cim.header, GNUNET_NO);
- }
+ {
+ if (GNUNET_YES == n->received_pong)
+ {
+ (&(cim->ats))[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+ (&(cim->ats))[0].value = htonl (n->distance);
+ (&(cim->ats))[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+ (&(cim->ats))[1].value = htonl ((uint32_t) n->latency.rel_value);
+ cim->id = n->id;
+ transmit_to_client (c, &cim->header, GNUNET_NO);
+ }
n = n->next;
- }
- }
+ }
+ }
GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_free(cim);
}
GNUNET_break (0);
break;
}
+
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Receiving `%s' message for `%4s'.\n",
/* FIXME */
if (h->nc_cb != NULL)
h->nc_cb (h->cls, &n->id,
- NULL,0);
+ &cim->ats,ats_count);
/* FIXEND */
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
ats_count = ntohl(im->ats_count);
//imm = (const struct GNUNET_MessageHeader *) &im[1];
imm = (const struct GNUNET_MessageHeader *) &((&(im->ats))[ats_count+1]);
+
if (ntohs (imm->size) + sizeof (struct InboundMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) != size)
{
GNUNET_break (0);
}
/* FIXME: */
if (h->rec != NULL)
- h->rec (h->cls, &im->peer, imm,
- NULL, 0);
+ h->rec (h->cls, &im->peer, imm,
+ &im->ats, ats_count);
/* ENDFIX */
break;
default: