tolerate additional IPv4 address now available for gnunet.org
[oweals/gnunet.git] / src / ats-tests / ats-testing.c
index 8ed135d4984f5a457756cd065ccda3e689480617..d8b9e5ef564a9154853513cfb9f03273bcf9d8ff 100644 (file)
@@ -1,21 +1,21 @@
 /*
  This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ Copyright (C) 2010-2013, 2016, 2017 GNUnet e.V.
 
- GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
 
  GNUnet is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- General Public License for more details.
Affero General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING.  If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
  */
 /**
  * @file ats-tests/ats-testing.c
@@ -88,23 +88,13 @@ do_shutdown (void *cls)
 
     for (c_op = 0; c_op < p->num_partners; c_op++)
     {
-      if (NULL != p->partners[c_op].cth)
-      {
-        GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
-        p->partners[c_op].cth = NULL;
-      }
-      if (NULL != p->partners[c_op].tth)
-      {
-        GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
-        p->partners[c_op].tth = NULL;
-      }
       if ( (NULL != p->core_connect_ops) &&
            (NULL != p->core_connect_ops[c_op].connect_op) )
       {
-        GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-            _("Failed to connect peer 0 and %u\n"), c_op);
-        GNUNET_TESTBED_operation_done (
-            p->core_connect_ops[c_op].connect_op);
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                   "Failed to connect peer 0 and %u\n",
+                   c_op);
+        GNUNET_TESTBED_operation_done (p->core_connect_ops[c_op].connect_op);
         p->core_connect_ops[c_op].connect_op = NULL;
       }
     }
@@ -133,20 +123,6 @@ do_shutdown (void *cls)
       GNUNET_TESTBED_operation_done (p->peer_id_op);
       p->peer_id_op = NULL;
     }
-
-    for (c_op = 0; c_op < p->num_partners; c_op++)
-    {
-      if (NULL != p->partners[c_op].cth)
-      {
-        GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
-        p->partners[c_op].cth = NULL;
-      }
-      if (NULL != p->partners[c_op].tth)
-      {
-        GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
-        p->partners[c_op].tth = NULL;
-      }
-    }
     if (NULL != p->ats_perf_op)
     {
       GNUNET_TESTBED_operation_done (p->ats_perf_op);
@@ -175,9 +151,8 @@ find_partner (struct BenchmarkPeer *me,
   for (c_m = 0; c_m < me->num_partners; c_m++)
   {
     /* Find a partner with other as destination */
-    if (0 == memcmp (peer,
-                    &me->partners[c_m].dest->id,
-                    sizeof (struct GNUNET_PeerIdentity)))
+    if (0 == GNUNET_memcmp (peer,
+                    &me->partners[c_m].dest->id))
     {
       return &me->partners[c_m];
     }
@@ -194,17 +169,15 @@ find_peer (const struct GNUNET_PeerIdentity * peer)
 
   for (c_p = 0; c_p < top->num_masters; c_p++)
   {
-    if (0 == memcmp (&top->mps[c_p].id,
-                    peer,
-                    sizeof(struct GNUNET_PeerIdentity)))
+    if (0 == GNUNET_memcmp (&top->mps[c_p].id,
+                    peer))
       return &top->mps[c_p];
   }
 
   for (c_p = 0; c_p < top->num_slaves; c_p++)
   {
-    if (0 == memcmp (&top->sps[c_p].id,
-                    peer,
-                    sizeof(struct GNUNET_PeerIdentity)))
+    if (0 == GNUNET_memcmp (&top->sps[c_p].id,
+                    peer))
       return &top->sps[c_p];
   }
   return NULL ;
@@ -216,13 +189,17 @@ find_peer (const struct GNUNET_PeerIdentity * peer)
  *
  * @param cls closure
  * @param peer peer identity this notification is about
+ * @param mq queue to use to send messages to @a peer
+ * @return the `struct BenchmarkPartner` of @a peer
  */
-static void
+static void *
 comm_connect_cb (void *cls,
-                const struct GNUNET_PeerIdentity *peer)
+                const struct GNUNET_PeerIdentity *peer,
+                struct GNUNET_MQ_Handle *mq)
 {
   struct BenchmarkPeer *me = cls;
   struct BenchmarkPeer *remote;
+  struct BenchmarkPartner *p;
   char *id;
   int c;
   int completed;
@@ -233,28 +210,32 @@ comm_connect_cb (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                "Unknown peer connected: `%s'\n",
                GNUNET_i2s (peer));
-    GNUNET_break(0);
-    return;
+    GNUNET_break (0);
+    return NULL;
   }
 
   id = GNUNET_strdup (GNUNET_i2s (&me->id));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "%s [%u] `%s' connected to %s [%u] %s\n",
-             (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
-             (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
+             (me->master == GNUNET_YES) ? "Master": "Slave",
+             me->no,
+             id,
+             (remote->master == GNUNET_YES) ? "Master": "Slave",
+             remote->no,
              GNUNET_i2s (peer));
 
   me->core_connections++;
-  if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
-      && (GNUNET_NO == top->state.connected_CORE))
+  if ((GNUNET_YES == me->master) &&
+      (GNUNET_NO == remote->master) &&
+      (GNUNET_NO == top->state.connected_CORE))
   {
     me->core_slave_connections++;
 
     if (me->core_slave_connections == top->num_slaves)
     {
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-                 "Master [%u] connected all slaves\n",
-                 me->no);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                 "Master [%u] connected all slaves\n",
+                 me->no);
     }
     completed = GNUNET_YES;
     for (c = 0; c < top->num_masters; c++)
@@ -269,22 +250,35 @@ comm_connect_cb (void *cls,
       top->state.connected_CORE = GNUNET_YES;
       /* Notify about setup done */
       if (NULL != top->done_cb)
-        top->done_cb (top->done_cb_cls, top->mps, top->sps);
+        top->done_cb (top->done_cb_cls,
+                     top->mps,
+                     top->sps);
     }
   }
-  GNUNET_free(id);
+  GNUNET_free (id);
+  p = find_partner (me,
+                   peer);
+  if (NULL != p)
+    p->mq = mq;
+  return p;
 }
 
 
+/**
+ * @param cls this peer
+ * @param peer id of disconnecting peer
+ * @param internal_cls the `struct BenchmarkPartner` of @a peer
+ */
 static void
 comm_disconnect_cb (void *cls,
-                   const struct GNUNET_PeerIdentity *peer)
+                   const struct GNUNET_PeerIdentity *peer,
+                   void *internal_cls)
 {
   struct BenchmarkPeer *me = cls;
-  struct BenchmarkPartner *p;
+  struct BenchmarkPartner *p = internal_cls;
   char *id;
 
-  if (NULL == (p = find_partner (me, peer)))
+  if (NULL == p)
     return;
 
   id = GNUNET_strdup (GNUNET_i2s (&me->id));
@@ -292,147 +286,122 @@ comm_disconnect_cb (void *cls,
              "%s disconnected from %s\n",
              id,
              GNUNET_i2s (peer));
-  GNUNET_assert(me->core_connections > 0);
+  GNUNET_assert (me->core_connections > 0);
   me->core_connections--;
 
   if ( (GNUNET_YES == top->state.benchmarking) &&
        ( (GNUNET_YES == me->master) ||
         (GNUNET_YES == p->dest->master) ) )
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-              "%s disconnected from %s while benchmarking\n",
-              id,
-              GNUNET_i2s (peer));
-    if (NULL != p->tth)
-    {
-      GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
-      p->tth = NULL;
-    }
-    if (NULL != p->cth)
-    {
-      GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
-      p->cth = NULL;
-    }
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "%s disconnected from %s while benchmarking\n",
+               id,
+               GNUNET_i2s (peer));
   }
   GNUNET_free(id);
 }
 
 
-static void *
-core_connect_adapter (void *cls,
-                     const struct GNUNET_CONFIGURATION_Handle *cfg)
+static void
+handle_pong (void *cls,
+            const struct TestMessage *message)
 {
-  struct BenchmarkPeer *me = cls;
+  struct BenchmarkPartner *p = cls;
 
-  me->ch = GNUNET_CORE_connect (cfg,
-                               me,
-                               NULL,
-                               &comm_connect_cb,
-                               &comm_disconnect_cb,
-                               NULL,
-                               GNUNET_NO,
-                               NULL,
-                               GNUNET_NO,
-                               top->handlers);
-  if (NULL == me->ch)
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               "Failed to create core connection \n");
-  return me->ch;
+  GNUNET_ATS_TEST_traffic_handle_pong (p);
 }
 
 
 static void
-core_disconnect_adapter (void *cls, void *op_result)
+handle_ping (void *cls,
+            const struct TestMessage *message)
 {
-  struct BenchmarkPeer *me = cls;
+  struct BenchmarkPartner *p = cls;
 
-  GNUNET_CORE_disconnect (me->ch);
-  me->ch = NULL;
+  GNUNET_ATS_TEST_traffic_handle_ping (p);
 }
 
 
-static int
-comm_handle_pong (void *cls,
-                 const struct GNUNET_PeerIdentity *other,
-                 const struct GNUNET_MessageHeader *message)
+static void *
+transport_connect_adapter (void *cls,
+                           const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct BenchmarkPeer *me = cls;
-  struct BenchmarkPartner *p = NULL;
-
-  if (NULL == (p = find_partner (me, other)))
-  {
-    GNUNET_break(0);
-    return GNUNET_SYSERR;
-  }
-
-  GNUNET_ATS_TEST_traffic_handle_pong (p);
-
-  return GNUNET_OK;
+  struct GNUNET_MQ_MessageHandler handlers[] = {
+    GNUNET_MQ_hd_fixed_size (ping,
+                             TEST_MESSAGE_TYPE_PING,
+                             struct TestMessage,
+                             me),
+    GNUNET_MQ_hd_fixed_size (pong,
+                             TEST_MESSAGE_TYPE_PONG,
+                             struct TestMessage,
+                             me),
+    GNUNET_MQ_handler_end ()
+  };
+
+  me->th = GNUNET_TRANSPORT_core_connect (cfg,
+                                         &me->id,
+                                         handlers,
+                                         me,
+                                         &comm_connect_cb,
+                                         &comm_disconnect_cb,
+                                         NULL);
+  if (NULL == me->th)
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "Failed to create transport connection \n");
+  return me->th;
 }
 
 
-static int
-comm_handle_ping (void *cls,
-                 const struct GNUNET_PeerIdentity *other,
-                 const struct GNUNET_MessageHeader *message)
+static void
+transport_disconnect_adapter (void *cls,
+                             void *op_result)
 {
   struct BenchmarkPeer *me = cls;
-  struct BenchmarkPartner *p = NULL;
-
-  if (NULL == (p = find_partner(me, other)))
-  {
-    GNUNET_break(0);
-    return GNUNET_SYSERR;
-  }
-  GNUNET_ATS_TEST_traffic_handle_ping (p);
-  return GNUNET_OK;
-}
-
 
-static void
-test_recv_cb (void *cls,
-             const struct GNUNET_PeerIdentity *peer,
-             const struct GNUNET_MessageHeader *message)
-{
-  if ( (TEST_MESSAGE_SIZE != ntohs (message->size)) ||
-       ( (TEST_MESSAGE_TYPE_PING != ntohs (message->type)) &&
-        (TEST_MESSAGE_TYPE_PONG != ntohs (message->type)) ) )
-  {
-    return;
-  }
-  if (TEST_MESSAGE_TYPE_PING == ntohs (message->type))
-    comm_handle_ping (cls, peer, message);
-  if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type))
-    comm_handle_pong (cls, peer, message);
+  GNUNET_TRANSPORT_core_disconnect (me->th);
+  me->th = NULL;
 }
 
 
 static void *
-transport_connect_adapter (void *cls,
-                           const struct GNUNET_CONFIGURATION_Handle *cfg)
+core_connect_adapter (void *cls,
+                     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct BenchmarkPeer *me = cls;
+  struct GNUNET_MQ_MessageHandler handlers[] = {
+    GNUNET_MQ_hd_fixed_size (ping,
+                             TEST_MESSAGE_TYPE_PING,
+                             struct TestMessage,
+                             me),
+    GNUNET_MQ_hd_fixed_size (pong,
+                             TEST_MESSAGE_TYPE_PONG,
+                             struct TestMessage,
+                             me),
+    GNUNET_MQ_handler_end ()
+  };
 
-  me->th = GNUNET_TRANSPORT_connect (cfg,
-                                    &me->id,
-                                    me,
-                                    &test_recv_cb,
-                                    &comm_connect_cb,
-                                    &comm_disconnect_cb);
-  if (NULL == me->th)
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-              "Failed to create transport connection \n");
-  return me->th;
+  me->ch = GNUNET_CORE_connect (cfg,
+                               me,
+                               NULL,
+                               &comm_connect_cb,
+                               &comm_disconnect_cb,
+                               handlers);
+  if (NULL == me->ch)
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "Failed to create core connection \n");
+  return me->ch;
 }
 
 
 static void
-transport_disconnect_adapter (void *cls, void *op_result)
+core_disconnect_adapter (void *cls,
+                        void *op_result)
 {
   struct BenchmarkPeer *me = cls;
 
-  GNUNET_TRANSPORT_disconnect (me->th);
-  me->th = NULL;
+  GNUNET_CORE_disconnect (me->ch);
+  me->ch = NULL;
 }
 
 
@@ -484,8 +453,8 @@ do_connect_peers (void *cls)
       (top->state.connected_COMM_service == GNUNET_NO))
     return;
 
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
-
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "Connecting peers on CORE level\n");
   for (c_m = 0; c_m < top->num_masters; c_m++)
   {
     p = &top->mps[c_m];
@@ -494,18 +463,24 @@ do_connect_peers (void *cls)
 
     for (c_s = 0; c_s < top->num_slaves; c_s++)
     {
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-          _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Connecting master [%u] with slave [%u]\n",
+                 p->no,
+                 top->sps[c_s].no);
       p->core_connect_ops[c_s].master = p;
       p->core_connect_ops[c_s].slave = &top->sps[c_s];
-      p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
-          NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
-          top->sps[c_s].peer, p->peer);
+      p->core_connect_ops[c_s].connect_op
+       = GNUNET_TESTBED_overlay_connect (NULL,
+                                         &connect_completion_callback,
+                                         &p->core_connect_ops[c_s],
+                                         top->sps[c_s].peer,
+                                         p->peer);
       if (NULL == p->core_connect_ops[c_s].connect_op)
-      {
-        GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-            _("Could not connect master [%u] and slave [%u]\n"), p->no,
-            top->sps[c_s].no);
+       {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                   "Could not connect master [%u] and slave [%u]\n",
+                   p->no,
+                   top->sps[c_s].no);
         GNUNET_break(0);
         GNUNET_SCHEDULER_shutdown ();
         return;
@@ -535,10 +510,12 @@ comm_connect_completion_cb (void *cls,
 
   if (comm_done == top->num_slaves + top->num_masters)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
-        (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+               "Connected to all %s services\n",
+               (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
     top->state.connected_COMM_service = GNUNET_YES;
-    GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
+    GNUNET_SCHEDULER_add_now (&do_connect_peers,
+                             NULL);
   }
 }
 
@@ -548,33 +525,58 @@ do_comm_connect (void *cls)
 {
   int c_s;
   int c_m;
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
-      (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "Connecting to all %s services\n",
+             (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
   for (c_m = 0; c_m < top->num_masters; c_m++)
   {
     if (GNUNET_YES == top->test_core)
-      top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
-        "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
-        &core_disconnect_adapter, &top->mps[c_m]);
+      top->mps[c_m].comm_op
+       = GNUNET_TESTBED_service_connect (NULL,
+                                         top->mps[c_m].peer,
+                                         "core",
+                                         &comm_connect_completion_cb,
+                                         NULL,
+                                         &core_connect_adapter,
+                                         &core_disconnect_adapter,
+                                         &top->mps[c_m]);
     else
     {
-      top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
-        "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
-        &transport_disconnect_adapter, &top->mps[c_m]);
+      top->mps[c_m].comm_op
+       = GNUNET_TESTBED_service_connect (NULL,
+                                         top->mps[c_m].peer,
+                                         "transport",
+                                         &comm_connect_completion_cb,
+                                         NULL,
+                                         &transport_connect_adapter,
+                                         &transport_disconnect_adapter,
+                                         &top->mps[c_m]);
     }
   }
 
   for (c_s = 0; c_s < top->num_slaves; c_s++)
   {
     if (GNUNET_YES == top->test_core)
-      top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
-        "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
-        &core_disconnect_adapter, &top->sps[c_s]);
+      top->sps[c_s].comm_op
+       = GNUNET_TESTBED_service_connect (NULL,
+                                         top->sps[c_s].peer,
+                                         "core",
+                                         &comm_connect_completion_cb,
+                                         NULL,
+                                         &core_connect_adapter,
+                                         &core_disconnect_adapter,
+                                         &top->sps[c_s]);
     else
     {
-      top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
-        "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
-        &transport_disconnect_adapter, &top->sps[c_s]);
+      top->sps[c_s].comm_op
+       = GNUNET_TESTBED_service_connect (NULL,
+                                         top->sps[c_s].peer,
+                                         "transport",
+                                         &comm_connect_completion_cb,
+                                         NULL,
+                                         &transport_connect_adapter,
+                                         &transport_disconnect_adapter,
+                                         &top->sps[c_s]);
     }
   }
 }
@@ -595,12 +597,14 @@ ats_performance_info_cb (void *cls,
 
   if (NULL == address)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service disconnected!\n",
-        me->no);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "Peer %u: ATS Service disconnected!\n",
+               me->no);
     return;
   }
 
-  p = find_partner (me, &address->peer);
+  p = find_partner (me,
+                   &address->peer);
   if (NULL == p)
   {
     /* This is not one of my partners
@@ -657,7 +661,8 @@ ats_perf_connect_adapter (void *cls,
 
 
 static void
-ats_perf_disconnect_adapter (void *cls, void *op_result)
+ats_perf_disconnect_adapter (void *cls,
+                            void *op_result)
 {
   struct BenchmarkPeer *me = cls;
 
@@ -743,9 +748,11 @@ peerinformation_cb (void *cb_cls,
   GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
 
   p->id = *pinfo->result.id;
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
-      (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
-      GNUNET_i2s (&p->id));
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "%s [%u] has peer id `%s'\n",
+             (p->master == GNUNET_YES) ? "Master" : "Slave",
+             p->no,
+             GNUNET_i2s (&p->id));
 
   GNUNET_TESTBED_operation_done (op);
   p->peer_id_op = NULL;
@@ -753,12 +760,14 @@ peerinformation_cb (void *cb_cls,
 
   if (done == top->num_slaves + top->num_masters)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-        "Retrieved all peer ID, connect to ATS\n");
-    GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+               "Retrieved all peer ID, connect to ATS\n");
+    GNUNET_SCHEDULER_add_now (&do_connect_ats,
+                             NULL);
   }
 }
 
+
 /**
  * Signature of a main function for a testcase.
  *
@@ -772,7 +781,8 @@ peerinformation_cb (void *cb_cls,
  *          failed
  */
 static void
-main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
+main_run (void *cls,
+         struct GNUNET_TESTBED_RunHandle *h,
           unsigned int num_peers,
           struct GNUNET_TESTBED_Peer **peers_,
           unsigned int links_succeeded,
@@ -781,9 +791,9 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
   int c_m;
   int c_s;
 
-  GNUNET_assert(NULL == cls);
-  GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
-  GNUNET_assert(NULL != peers_);
+  GNUNET_assert (NULL == cls);
+  GNUNET_assert (top->num_masters + top->num_slaves == num_peers);
+  GNUNET_assert (NULL != peers_);
 
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
                                  top);
@@ -812,8 +822,11 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
       top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
     }
     /* Get configuration */
-    top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
-        GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
+    top->mps[c_m].peer_id_op
+      = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
+                                            GNUNET_TESTBED_PIT_IDENTITY,
+                                            &peerinformation_cb,
+                                            &top->mps[c_m]);
   }
 
   /* Setup slave peers */
@@ -824,7 +837,8 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
     top->sps[c_s].no = c_s + top->num_masters;
     top->sps[c_s].master = GNUNET_NO;
     top->sps[c_s].partners =
-        GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
+      GNUNET_new_array (top->num_masters,
+                       struct BenchmarkPartner);
     top->sps[c_s].num_partners = top->num_masters;
     /* Initialize partners */
     for (c_m = 0; c_m < top->num_masters; c_m++)
@@ -835,16 +849,20 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
       /* Initialize properties */
       top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
       top->sps[c_s].partners[c_m].props.distance = 0;
-      top->sps[c_s].partners[c_m].props.scope = GNUNET_ATS_NET_UNSPECIFIED;
+      top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED;
       top->sps[c_s].partners[c_m].props.utilization_in = 0;
       top->sps[c_s].partners[c_m].props.utilization_out = 0;
     }
     /* Get configuration */
-    top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
-        GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
+    top->sps[c_s].peer_id_op
+      = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
+                                            GNUNET_TESTBED_PIT_IDENTITY,
+                                            &peerinformation_cb,
+                                            &top->sps[c_s]);
   }
 }
 
+
 /**
  * Controller event callback
  *
@@ -878,7 +896,8 @@ GNUNET_ATS_TEST_get_peer (int src)
 
 
 struct BenchmarkPartner *
-GNUNET_ATS_TEST_get_partner (int src, int dest)
+GNUNET_ATS_TEST_get_partner (int src,
+                            int dest)
 {
   if (src > top->num_masters)
     return NULL;
@@ -909,20 +928,13 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
                                  void *done_cb_cls,
                                  GNUNET_ATS_AddressInformationCallback log_request_cb)
 {
-  static struct GNUNET_CORE_MessageHandler handlers[] = {
-      {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
-      {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
-      { NULL, 0, 0 } };
-
   top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
   top->num_masters = num_masters;
   top->num_slaves = num_slaves;
-  top->handlers = handlers;
   top->done_cb = done_cb;
   top->done_cb_cls = done_cb_cls;
   top->test_core = test_core;
   top->ats_perf_cb = log_request_cb;
-
   top->mps = GNUNET_new_array (num_masters,
                               struct BenchmarkPeer);
   top->sps = GNUNET_new_array (num_slaves,
@@ -933,8 +945,8 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
   event_mask = 0;
   event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
   event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
-  (void) GNUNET_TESTBED_test_run (name, cfg_file,
-
+  (void) GNUNET_TESTBED_test_run (name,
+                                 cfg_file,
                                   num_slaves + num_masters,
                                   event_mask,
                                   &controller_event_cb, NULL,
@@ -954,7 +966,4 @@ GNUNET_ATS_TEST_shutdown_topology (void)
 }
 
 
-
-
-
 /* end of file ats-testing.c */