fix: ats data
authorMatthias Wachs <wachs@net.in.tum.de>
Tue, 13 Sep 2011 08:48:47 +0000 (08:48 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Tue, 13 Sep 2011 08:48:47 +0000 (08:48 +0000)
src/transport/gnunet-service-transport-new.c
src/transport/plugin_transport_tcp.c

index 4b1becacd052d7514b4b96eb45cd3809dc2a1433..d1ef887fd11d61128473ef6fb4dcef80f82fb5cc 100644 (file)
@@ -165,7 +165,6 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
   struct GNUNET_TIME_Relative ret;
   uint16_t type;
 
-
   ret = GNUNET_TIME_UNIT_ZERO;
   if (NULL != message)
   {
@@ -202,8 +201,8 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
       (void) GST_blacklist_test_allowed (peer, NULL, &try_connect_if_allowed,
                                          NULL);
       /* TODO: if 'session != NULL', and timestamp more recent than the
-        previous one, maybe notify ATS that this is now the preferred
-       * way to communicate with this peer (other peer switched transport) */
+       * previous one, maybe notify ATS that this is now the preferred
+       * way to communicate with this peer (other peer switched transport) */
       break;
     case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
       /* TODO: do some validation to prevent an attacker from sending
@@ -242,6 +241,9 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
       break;
     }
   }
+
+  GNUNET_assert ((ats_count > 0) && (ats != NULL));
+
   GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (),        /* valid at least until right now... */
                              plugin_name, session, sender_address,
                              sender_address_len, ats, ats_count);
index 452f55e1a88635d4b949bdfbe8c8527e748b9271..af253f9645e21241cb741f341444489b3da9cdde 100644 (file)
@@ -1661,11 +1661,15 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct Session *session = cls;
   struct GNUNET_TIME_Relative delay;
+  struct GNUNET_TRANSPORT_ATS_Information ats;
+
+  ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+  ats.value = htonl (0);
 
   session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK;
   delay =
       session->plugin->env->receive (session->plugin->env->cls,
-                                     &session->target, NULL, NULL, 0, session,
+                                     &session->target, NULL, &ats, 1, session,
                                      NULL, 0);
   if (delay.rel_value == 0)
     GNUNET_SERVER_receive_done (session->client, GNUNET_OK);