added fix
[oweals/gnunet.git] / src / transport / gnunet-service-transport.c
index c1bb7bec6f79833b3477329f702252d74a0cc9ad..293e9c63790d4a55adbb19c1d22a3c97f6691508 100644 (file)
 #include "gnunet_protocols.h"
 #include "gnunet_service_lib.h"
 #include "gnunet_signatures.h"
-#include "plugin_transport.h"
+#include "gnunet_transport_plugin.h"
 #include "transport.h"
 
-#define DEBUG_BLACKLIST GNUNET_NO
+#define DEBUG_BLACKLIST GNUNET_YES
 
-#define DEBUG_PING_PONG GNUNET_NO
+#define DEBUG_PING_PONG GNUNET_YES
 
 #define DEBUG_TRANSPORT_HELLO GNUNET_YES
 
@@ -562,6 +562,16 @@ struct NeighbourList
    */
   int public_key_valid;
 
+  /**
+   * Performance data for the peer.
+   */
+  struct GNUNET_TRANSPORT_ATS_Information *ats;
+
+  /**
+   * Identity of the neighbour.
+   */
+  struct GNUNET_PeerIdentity peer;
+
 };
 
 /**
@@ -842,11 +852,6 @@ static struct GNUNET_PeerIdentity my_identity;
  */
 static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
 
-/**
- * Our scheduler.
- */
-struct GNUNET_SCHEDULER_Handle *sched;
-
 /**
  * Our configuration.
  */
@@ -1401,7 +1406,7 @@ transmit_send_ok (struct TransportClient *client,
  *
  * @param cls closure, identifies the entry on the
  *            message queue that was transmitted and the
- *            client responsible for queueing the message
+ *            client responsible for queuing the message
  * @param target the peer receiving the message
  * @param result GNUNET_OK on success, if the transmission
  *           failed, we should not tell the client to transmit
@@ -1554,7 +1559,7 @@ find_ready_address(struct NeighbourList *neighbour)
                       best_address->addr,
                       best_address->addrlen)
                  : "<inbound>",
-                  best_address->latency.abs_value);
+                  best_address->latency.rel_value);
 #endif
     }
   else
@@ -1656,10 +1661,8 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
                                1,
                                GNUNET_NO);
       if (neighbour->retry_task != GNUNET_SCHEDULER_NO_TASK)
-       GNUNET_SCHEDULER_cancel (sched,
-                                neighbour->retry_task);
-      neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                           timeout,
+       GNUNET_SCHEDULER_cancel (neighbour->retry_task);
+      neighbour->retry_task = GNUNET_SCHEDULER_add_delayed (timeout,
                                                            &retry_transmission_task,
                                                            neighbour);
 #if DEBUG_TRANSPORT
@@ -1667,7 +1670,7 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
                  "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n",
                  mq->message_buf_size,
                  GNUNET_i2s (&mq->neighbour_id),
-                 timeout.abs_value);
+                 timeout.rel_value);
 #endif
       /* FIXME: might want to trigger peerinfo lookup here
         (unless that's already pending...) */
@@ -1912,7 +1915,8 @@ expire_address_task (void *cls,
  *        expired
  */
 static void
-update_addresses (struct TransportPlugin *plugin, int fresh)
+update_addresses (struct TransportPlugin *plugin, 
+                 int fresh)
 {
   static struct GNUNET_TIME_Absolute last_update;
   struct GNUNET_TIME_Relative min_remaining;
@@ -1924,7 +1928,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
   int expired;
 
   if (plugin->address_update_task != GNUNET_SCHEDULER_NO_TASK)
-    GNUNET_SCHEDULER_cancel (plugin->env.sched, plugin->address_update_task);
+    GNUNET_SCHEDULER_cancel (plugin->address_update_task);
   plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK;
   now = GNUNET_TIME_absolute_get ();
   min_remaining = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1962,8 +1966,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
                                            GNUNET_TIME_relative_divide (HELLO_ADDRESS_EXPIRATION,
                                                                         2));
   plugin->address_update_task
-    = GNUNET_SCHEDULER_add_delayed (plugin->env.sched,
-                                   min_remaining,
+    = GNUNET_SCHEDULER_add_delayed (min_remaining,
                                    &expire_address_task, plugin);
 }
 
@@ -2126,8 +2129,7 @@ plugin_env_session_end  (void *cls,
     prev->next = pos->next;
   if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task)
     {
-      GNUNET_SCHEDULER_cancel (sched,
-                              pos->revalidate_task);
+      GNUNET_SCHEDULER_cancel (pos->revalidate_task);
       pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
     }
   GNUNET_free (pos);
@@ -2190,9 +2192,9 @@ plugin_env_notify_address (void *cls,
   while (al != NULL)
     {
       if ((addrlen == al->addrlen) && (0 == memcmp (addr, &al[1], addrlen)))
-        {
-          if (al->expires.abs_value < abex.abs_value)
-            al->expires = abex;
+        {            
+         al->expires = abex;
+         update_addresses (p, GNUNET_NO);
           return;
         }
       al = al->next;
@@ -2214,10 +2216,12 @@ plugin_env_notify_address (void *cls,
 static void
 notify_clients_connect (const struct GNUNET_PeerIdentity *peer,
                         struct GNUNET_TIME_Relative latency,
-                       uint32_t distance)
+                        uint32_t distance)
 {
-  struct ConnectInfoMessage cim;
+  struct ConnectInfoMessage cim;
   struct TransportClient *cpos;
+  uint32_t ats_count;
+  size_t size;
 
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2228,17 +2232,32 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer,
                            gettext_noop ("# peers connected"),
                            1,
                            GNUNET_NO);
-  cim.header.size = htons (sizeof (struct ConnectInfoMessage));
-  cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
-  cim.distance = htonl (distance);
-  cim.latency = GNUNET_TIME_relative_hton (latency);
-  memcpy (&cim.id, peer, sizeof (struct GNUNET_PeerIdentity));
+
+  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(2);
+  (&(cim->ats))[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  (&(cim->ats))[0].value = htonl (distance);
+  (&(cim->ats))[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+  (&(cim->ats))[1].value = htonl ((uint32_t) latency.rel_value);
+  (&(cim->ats))[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+  (&(cim->ats))[2].value = htonl (0);
+  memcpy (&cim->id, peer, sizeof (struct GNUNET_PeerIdentity));
   cpos = clients;
   while (cpos != NULL)
     {
-      transmit_to_client (cpos, &cim.header, GNUNET_NO);
+      transmit_to_client (cpos, &(cim->header), GNUNET_NO);
       cpos = cpos->next;
     }
+  GNUNET_free (cim);
 }
 
 
@@ -2518,7 +2537,7 @@ abort_validation (void *cls,
   struct ValidationEntry *va = value;
 
   if (GNUNET_SCHEDULER_NO_TASK != va->timeout_task)
-    GNUNET_SCHEDULER_cancel (sched, va->timeout_task);
+    GNUNET_SCHEDULER_cancel (va->timeout_task);
   GNUNET_free (va->transport_name);
   if (va->chvc != NULL)
     {
@@ -2776,8 +2795,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
     }
   n->latency = GNUNET_TIME_UNIT_FOREVER_REL;
   n->distance = -1;
-  n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                  GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+  n->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
                                                   &neighbour_timeout_task, n);
   if (do_hello)
     {
@@ -2954,8 +2972,7 @@ transmit_blacklist_message (void *cls,
   if (size == 0)
     {
       GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK);
-      bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                          &do_blacklist_check,
+      bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                           bc);
       return 0;
     }
@@ -3047,8 +3064,7 @@ setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer,
   bc->cont = cont;
   bc->cont_cls = cont_cls;
   bc->bl_pos = bl_head;
-  bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                      &do_blacklist_check,
+  bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                       bc);
 }
 
@@ -3120,8 +3136,7 @@ handle_blacklist_init (void *cls,
       bc->bl_pos = bl;
       if (n == neighbours) /* all would wait for the same client, no need to
                              create more than just the first task right now */
-       bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                            &do_blacklist_check,
+       bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                             bc);
       n = n->next;
     }
@@ -3164,8 +3179,7 @@ handle_blacklist_reply (void *cls,
   else
     {
       bc->bl_pos = bc->bl_pos->next;
-      bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                          &do_blacklist_check,
+      bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                           bc);
     }
   /* check if any other bc's are waiting for this blacklister */
@@ -3174,8 +3188,7 @@ handle_blacklist_reply (void *cls,
     {
       if ( (bc->bl_pos == bl) &&
           (GNUNET_SCHEDULER_NO_TASK == bc->task) )
-       bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                            &do_blacklist_check,
+       bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                             bc);
       bc = bc->next;
     }
@@ -3258,8 +3271,7 @@ send_periodic_ping (void *cls,
         &neighbour->publicKey,
         sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
 
-  va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                   HELLO_VERIFICATION_TIMEOUT,
+  va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
                                                    &timeout_hello_validation,
                                                    va);
   GNUNET_CONTAINER_multihashmap_put (validation_map,
@@ -3384,8 +3396,7 @@ schedule_next_ping (struct ForeignAddressList *fal)
                                    GNUNET_TIME_UNIT_SECONDS);
   /* randomize a bit (to avoid doing all at the same time) */
   delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
-  fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched,
-                                                     delay,
+  fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(delay,
                                                      &send_periodic_ping,
                                                      fal);
 }
@@ -3402,7 +3413,7 @@ schedule_next_ping (struct ForeignAddressList *fal)
  */
 static void
 handle_payload_message (const struct GNUNET_MessageHeader *message,
-                       struct NeighbourList *n)
+                                               struct NeighbourList *n)
 {
   struct InboundMessage *im;
   struct TransportClient *cpos;
@@ -3458,13 +3469,25 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
                            msize,
                            GNUNET_NO);
   /* transmit message to all clients */
-  im = GNUNET_malloc (sizeof (struct InboundMessage) + msize);
-  im->header.size = htons (sizeof (struct InboundMessage) + msize);
+  uint32_t ats_count = 2;
+  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);
   im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
-  im->latency = GNUNET_TIME_relative_hton (n->latency);
   im->peer = n->id;
-  im->distance = ntohl(n->distance);
-  memcpy (&im[1], message, msize);
+  im->ats_count = htonl(ats_count);
+  /* Setting ATS data */
+  (&(im->ats))[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  (&(im->ats))[0].value = htonl (n->distance);
+  (&(im->ats))[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+  (&(im->ats))[1].value = htonl ((uint32_t) n->latency.rel_value);
+  (&(im->ats))[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+  (&(im->ats))[ats_count].value = htonl (0);
+
+  memcpy (&((&(im->ats))[ats_count+1]), message, msize);
   cpos = clients;
   while (cpos != NULL)
     {
@@ -3691,8 +3714,7 @@ check_pending_validation (void *cls,
        }
       if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
        {
-         GNUNET_SCHEDULER_cancel (sched,
-                                  n->retry_task);
+         GNUNET_SCHEDULER_cancel (n->retry_task);
          n->retry_task = GNUNET_SCHEDULER_NO_TASK;
          try_transmission_to_peer (n);
        }
@@ -3981,8 +4003,7 @@ run_validation (void *cls,
   va->addrlen = addrlen;
   GNUNET_HELLO_get_key (chvc->hello,
                        &va->publicKey);
-  va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                  HELLO_VERIFICATION_TIMEOUT,
+  va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
                                                   &timeout_hello_validation,
                                                   va);
   GNUNET_CONTAINER_multihashmap_put (validation_map,
@@ -4146,8 +4167,7 @@ process_hello (struct TransportPlugin *plugin,
                            GNUNET_NO);
 
   /* first, check if load is too high */
-  if (GNUNET_SCHEDULER_get_load (sched,
-                                GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD)
+  if (GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_BACKGROUND) > MAX_HELLO_LOAD)
     {
       GNUNET_STATISTICS_update (stats,
                                gettext_noop ("# HELLOs ignored due to high load"),
@@ -4351,8 +4371,7 @@ disconnect_neighbour (struct NeighbourList *n, int check)
                                      GNUNET_NO);
          if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task)
            {
-             GNUNET_SCHEDULER_cancel (sched,
-                                      peer_pos->revalidate_task);
+             GNUNET_SCHEDULER_cancel (peer_pos->revalidate_task);
              peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
            }
           GNUNET_free(peer_pos);
@@ -4381,12 +4400,12 @@ disconnect_neighbour (struct NeighbourList *n, int check)
     }
   if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK)
     {
-      GNUNET_SCHEDULER_cancel (sched, n->timeout_task);
+      GNUNET_SCHEDULER_cancel (n->timeout_task);
       n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
     }
   if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
     {
-      GNUNET_SCHEDULER_cancel (sched, n->retry_task);
+      GNUNET_SCHEDULER_cancel (n->retry_task);
       n->retry_task = GNUNET_SCHEDULER_NO_TASK;
     }
   if (n->piter != NULL)
@@ -4684,9 +4703,10 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
 static struct GNUNET_TIME_Relative
 plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
                     const struct GNUNET_MessageHeader *message,
-                    uint32_t distance,
-                   struct Session *session,
-                   const char *sender_address,
+                    const struct GNUNET_TRANSPORT_ATS_Information *ats,
+                    uint32_t ats_count,
+                    struct Session *session,
+                    const char *sender_address,
                     uint16_t sender_address_len)
 {
   struct TransportPlugin *plugin = cls;
@@ -4697,6 +4717,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
   struct GNUNET_TIME_Relative ret;
   if (is_blacklisted (peer, plugin))
     return GNUNET_TIME_UNIT_FOREVER_REL;
+  uint32_t distance;
+  int c;
 
   n = find_neighbour (peer);
   if (n == NULL)
@@ -4706,6 +4728,15 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
     service_context = service_context->next;
   GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL));
   peer_address = NULL;
+  distance = 1;
+  for (c=0; c<ats_count; c++)
+  {
+         if (ntohl(ats[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE)
+         {
+                 distance = ntohl(ats[c].value);
+         }
+  }
+
   if (message != NULL)
     {
       if ( (session != NULL) ||
@@ -4736,11 +4767,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
       n->peer_timeout =
        GNUNET_TIME_relative_to_absolute
        (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
-      GNUNET_SCHEDULER_cancel (sched,
-                              n->timeout_task);
+      GNUNET_SCHEDULER_cancel (n->timeout_task);
       n->timeout_task =
-       GNUNET_SCHEDULER_add_delayed (sched,
-                                     GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+       GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
                                      &neighbour_timeout_task, n);
       if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
        {
@@ -4816,8 +4845,10 @@ handle_start (void *cls,
 {
   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
@@ -4852,7 +4883,7 @@ handle_start (void *cls,
   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");
@@ -4861,22 +4892,36 @@ handle_start (void *cls,
                           (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);
+      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;
-             cim.latency = GNUNET_TIME_relative_hton (n->latency);
-             cim.distance = htonl (n->distance);
-             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);
 }
 
 
@@ -5191,7 +5236,6 @@ static void
 create_environment (struct TransportPlugin *plug)
 {
   plug->env.cfg = cfg;
-  plug->env.sched = sched;
   plug->env.my_identity = &my_identity;
   plug->env.our_hello = &our_hello;
   plug->env.cls = plug;
@@ -5276,8 +5320,7 @@ client_disconnect_notification (void *cls,
                      bc->th = NULL;            
                    }
                  if (bc->task == GNUNET_SCHEDULER_NO_TASK)
-                   bc->task = GNUNET_SCHEDULER_add_now (sched,
-                                                        &do_blacklist_check,
+                   bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
                                                         bc);
                  break;
                }
@@ -5359,8 +5402,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       plugins = plug->next;
       if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK)
        {
-         GNUNET_SCHEDULER_cancel (plug->env.sched,
-                                  plug->address_update_task);
+         GNUNET_SCHEDULER_cancel (plug->address_update_task);
          plug->address_update_task = GNUNET_SCHEDULER_NO_TASK;
        }
       GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
@@ -5423,13 +5465,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Initiate transport service.
  *
  * @param cls closure
- * @param s scheduler to use
  * @param server the initialized server
  * @param c configuration to use
  */
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *s,
      struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
@@ -5459,9 +5499,8 @@ run (void *cls,
   unsigned long long tneigh;
   char *keyfile;
 
-  sched = s;
   cfg = c;
-  stats = GNUNET_STATISTICS_create (sched, "transport", cfg);
+  stats = GNUNET_STATISTICS_create ("transport", cfg);
   validation_map = GNUNET_CONTAINER_multihashmap_create (64);
   /* parse configuration */
   if ((GNUNET_OK !=
@@ -5477,7 +5516,7 @@ run (void *cls,
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _
                   ("Transport service is lacking key configuration settings.  Exiting.\n"));
-      GNUNET_SCHEDULER_shutdown (s);
+      GNUNET_SCHEDULER_shutdown ();
       if (stats != NULL)
        {
          GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5488,12 +5527,12 @@ run (void *cls,
       return;
     }
   max_connect_per_transport = (uint32_t) tneigh;
-  peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
+  peerinfo = GNUNET_PEERINFO_connect (cfg);
   if (peerinfo == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                  _("Could not access PEERINFO service.  Exiting.\n")); 
-      GNUNET_SCHEDULER_shutdown (s);
+      GNUNET_SCHEDULER_shutdown ();
       if (stats != NULL)
        {
          GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5511,7 +5550,7 @@ run (void *cls,
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _
                   ("Transport service could not access hostkey.  Exiting.\n"));
-      GNUNET_SCHEDULER_shutdown (s);
+      GNUNET_SCHEDULER_shutdown ();
       if (stats != NULL)
        {
          GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -5544,8 +5583,7 @@ run (void *cls,
         }
       GNUNET_free (plugs);
     }
-  GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_TIME_UNIT_FOREVER_REL,
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                 &shutdown_task, NULL);
   if (no_transports)
     refresh_hello ();