changes to transport_api
authorMatthias Wachs <wachs@net.in.tum.de>
Tue, 30 Nov 2010 12:19:48 +0000 (12:19 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Tue, 30 Nov 2010 12:19:48 +0000 (12:19 +0000)
src/transport/gnunet-service-transport.c
src/transport/transport.h
src/transport/transport_api.c

index c7fb59458197a16afedc39e2888c8b004bd33009..990b504776fa85507c82626c66f5269a4e80ed6f 100644 (file)
@@ -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;
        }
index 747986439c211a7c0f0393e4b4743bc63288868b..8f22abd183a4a09990952b26adaf1d73d0cbea95 100644 (file)
@@ -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
index 05e12e1f33dcf60fbe0b8abbbe0316e2ca41b8b8..30294de927e8702a62f0aae36b0ac88435a4328a 100644 (file)
@@ -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,