im = GNUNET_malloc (sizeof (struct InboundMessage) + ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize);
im->header.size = htons (sizeof (struct InboundMessage) + ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize);
im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
- im->latency = GNUNET_TIME_relative_hton (n->latency);
+ //im->latency = GNUNET_TIME_relative_hton (n->latency);
+ //im->distance = ntohl(n->distance);
im->peer = n->id;
- im->distance = ntohl(n->distance);
im->ats_count = htonl(ats_count);
/* insert ATS elements */
memcpy (&(im->ats), ats, ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information));
if (NULL != (prem = n->pre_connect_message_buffer))
{
n->pre_connect_message_buffer = NULL;
- /* FIXME: */
- handle_payload_message (prem, n, NULL, 0);
+ struct GNUNET_TRANSPORT_ATS_Information * ats = GNUNET_malloc(2 * sizeof(struct GNUNET_TRANSPORT_ATS_Information));
+ ats[0].type = htonl(GNUNET_TRANSPORT_LATENCY_LSB);
+ ats[0].value = htonl(n->latency.rel_value);
+ ats[1].type = htonl(GNUNET_TRANSPORT_DISTANCE);
+ ats[1].value = htonl(n->distance);
+ handle_payload_message (prem, n, ats, 2);
+ fprintf(stderr,"ATS!");
+ GNUNET_free (ats);
GNUNET_free (prem);
}
}
handle_pong (plugin, message, peer, sender_address, sender_address_len);
break;
default:
+ /* FIXME */
handle_payload_message (message, n, NULL, 0);
break;
}
*/
struct GNUNET_MessageHeader header;
+ /**
+ * Number of ATS key-value pairs that follow this struct
+ * (excluding the 0-terminator).
+ */
+ uint32_t ats_count GNUNET_PACKED;
+
/**
* Transport distance metric (i.e. hops for DV)
*/
*/
struct GNUNET_PeerIdentity id;
+ /**
+ * First of the ATS information blocks (we must have at least
+ * one due to the 0-termination requirement).
+ */
+ struct GNUNET_TRANSPORT_ATS_Information ats;
};
/**
* Latency estimate.
*/
- struct GNUNET_TIME_RelativeNBO latency;
+ //struct GNUNET_TIME_RelativeNBO latency;
/**
* Which peer sent the message?
/**
* Distance metric.
*/
- uint32_t distance;
+ //uint32_t distance;
/**
* First of the ATS information blocks (we must have at least
GNUNET_break (n->is_connected == GNUNET_NO);
n->is_connected = GNUNET_YES;
if (h->nc_cb != NULL)
+ h->nc_cb (h->cls, &n->id, &(cim->ats), cim->ats_count);
+/*
h->nc_cb (h->cls, &n->id,
GNUNET_TIME_relative_ntoh (cim->latency),
ntohl (cim->distance));
+*/
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
if (size != sizeof (struct DisconnectInfoMessage))
break;
}
if (h->rec != NULL)
- h->rec (h->cls, &im->peer, imm,
- GNUNET_TIME_relative_ntoh (im->latency), ntohl(im->distance));
+ h->rec (h->cls, &im->peer, imm, &im->ats, im->ats_count);
+ //h->rec (h->cls, &im->peer, imm, GNUNET_TIME_relative_ntoh (im->latency), ntohl(im->distance));
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,