From 1f11396323462186aa2795983d97d7bc168301fb Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 30 Nov 2010 12:19:48 +0000 Subject: [PATCH] changes to transport_api --- src/transport/gnunet-service-transport.c | 15 +++++++++++---- src/transport/transport.h | 15 +++++++++++++-- src/transport/transport_api.c | 7 +++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index c7fb59458..990b50477 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -3448,9 +3448,9 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, 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)); @@ -3680,8 +3680,14 @@ check_pending_validation (void *cls, 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); } } @@ -4771,6 +4777,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, handle_pong (plugin, message, peer, sender_address, sender_address_len); break; default: + /* FIXME */ handle_payload_message (message, n, NULL, 0); break; } diff --git a/src/transport/transport.h b/src/transport/transport.h index 747986439..8f22abd18 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -85,6 +85,12 @@ struct ConnectInfoMessage */ 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) */ @@ -100,6 +106,11 @@ struct ConnectInfoMessage */ 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; }; @@ -198,7 +209,7 @@ struct InboundMessage /** * Latency estimate. */ - struct GNUNET_TIME_RelativeNBO latency; + //struct GNUNET_TIME_RelativeNBO latency; /** * Which peer sent the message? @@ -208,7 +219,7 @@ struct InboundMessage /** * Distance metric. */ - uint32_t distance; + //uint32_t distance; /** * First of the ATS information blocks (we must have at least diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 05e12e1f3..30294de92 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -1591,9 +1591,12 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) 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)) @@ -1685,8 +1688,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) 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, -- 2.25.1