-GArik: fix typo
[oweals/gnunet.git] / src / dv / gnunet-service-dv.c
index 4b68f69b170f3cb5dbf8002e9cf663a6091b1c4b..50aac09cde13c96f73133aa6dc77867d62d467e7 100644 (file)
@@ -662,8 +662,7 @@ static unsigned long long max_table_size;
  * respective neighbor.
  */
 static int
-find_destination (void *cls,
-                  struct GNUNET_CONTAINER_HeapNode *node,
+find_destination (void *cls, struct GNUNET_CONTAINER_HeapNode *node,
                   void *element, GNUNET_CONTAINER_HeapCostType cost)
 {
   struct FindDestinationContext *fdc = cls;
@@ -752,21 +751,20 @@ transmit_to_plugin (void *cls, size_t size, void *buf)
   while ((NULL != (reply = plugin_pending_head)) &&
          (size >= off + (msize = ntohs (reply->msg->size))))
   {
-    GNUNET_CONTAINER_DLL_remove (plugin_pending_head,
-                                 plugin_pending_tail, reply);
+    GNUNET_CONTAINER_DLL_remove (plugin_pending_head, plugin_pending_tail,
+                                 reply);
     memcpy (&cbuf[off], reply->msg, msize);
     GNUNET_free (reply);
     off += msize;
   }
 
   if (plugin_pending_head != NULL)
-    plugin_transmit_handle = GNUNET_SERVER_notify_transmit_ready (client_handle,
-                                                                  ntohs
-                                                                  (plugin_pending_head->msg->
-                                                                   size),
-                                                                  GNUNET_TIME_UNIT_FOREVER_REL,
-                                                                  &transmit_to_plugin,
-                                                                  NULL);
+    plugin_transmit_handle =
+        GNUNET_SERVER_notify_transmit_ready (client_handle,
+                                             ntohs (plugin_pending_head->msg->
+                                                    size),
+                                             GNUNET_TIME_UNIT_FOREVER_REL,
+                                             &transmit_to_plugin, NULL);
 
   return off;
 }
@@ -783,8 +781,7 @@ transmit_to_plugin (void *cls, size_t size, void *buf)
  */
 void
 send_to_plugin (const struct GNUNET_PeerIdentity *sender,
-                const struct GNUNET_MessageHeader *message,
-                size_t message_size,
+                const struct GNUNET_MessageHeader *message, size_t message_size,
                 struct GNUNET_PeerIdentity *distant_neighbor, size_t cost)
 {
   struct GNUNET_DV_MessageReceived *received_msg;
@@ -861,7 +858,8 @@ send_to_plugin (const struct GNUNET_PeerIdentity *sender,
 }
 
 /* Declare here so retry_core_send is aware of it */
-size_t core_transmit_notify (void *cls, size_t size, void *buf);
+size_t
+core_transmit_notify (void *cls, size_t size, void *buf);
 
 /**
  *  Try to send another message from our core sending list
@@ -877,14 +875,13 @@ try_core_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     return;                     /* Message send already in progress */
 
   if ((pending != NULL) && (coreAPI != NULL))
-    core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI,
-                                                              GNUNET_YES,
-                                                              pending->importance,
-                                                              pending->timeout,
-                                                              &pending->recipient,
-                                                              pending->msg_size,
-                                                              &core_transmit_notify,
-                                                              NULL);
+    core_transmit_handle =
+        GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+                                           pending->importance,
+                                           pending->timeout,
+                                           &pending->recipient,
+                                           pending->msg_size,
+                                           &core_transmit_notify, NULL);
 }
 
 
@@ -1019,8 +1016,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
   if (0 == (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity))))
   {
     sender_id = 0;
-    source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
-                                                &sender->hashPubKey);
+    source =
+        GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
+                                           &sender->hashPubKey);
     if (source != NULL)
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "%s: send_message_via found %s, myself in extended peer list???\n",
@@ -1028,8 +1026,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
   }
   else
   {
-    source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
-                                                &sender->hashPubKey);
+    source =
+        GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
+                                           &sender->hashPubKey);
     if (source == NULL)
     {
       /* sender unknown to us, drop! */
@@ -1067,8 +1066,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
               "DV", &shortname, GNUNET_i2s (recipient), msg_size);
 #endif
 
-  GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
-                                     core_pending_tail,
+  GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail,
                                      core_pending_tail, pending_message);
 
   GNUNET_SCHEDULER_add_now (try_core_send, NULL);
@@ -1117,10 +1115,9 @@ static int
 send_message (const struct GNUNET_PeerIdentity *recipient,
               const struct GNUNET_PeerIdentity *sender,
               const struct DistantNeighbor *specific_neighbor,
-              const struct GNUNET_MessageHeader *message,
-              size_t message_size,
-              unsigned int importance,
-              unsigned int uid, struct GNUNET_TIME_Relative timeout)
+              const struct GNUNET_MessageHeader *message, size_t message_size,
+              unsigned int importance, unsigned int uid,
+              struct GNUNET_TIME_Relative timeout)
 {
   p2p_dv_MESSAGE_Data *toSend;
   unsigned int msg_size;
@@ -1160,12 +1157,13 @@ send_message (const struct GNUNET_PeerIdentity *recipient,
   }
   recipient_id = target->referrer_id;
 
-  source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
-                                              &sender->hashPubKey);
+  source =
+      GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
+                                         &sender->hashPubKey);
   if (source == NULL)
   {
-    if (0 != (memcmp (&my_identity,
-                      sender, sizeof (struct GNUNET_PeerIdentity))))
+    if (0 !=
+        (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity))))
     {
       /* sender unknown to us, drop! */
       return GNUNET_SYSERR;
@@ -1229,8 +1227,7 @@ send_message (const struct GNUNET_PeerIdentity *recipient,
                 "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n",
                 my_short_id);
   }
-  GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
-                                     core_pending_tail,
+  GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail,
                                      core_pending_tail, pending_message);
 #if DEBUG_DV
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1292,8 +1289,7 @@ checkPeerID (void *cls, const GNUNET_HashCode * key, void *value)
  * @param message the actual message
  */
 void
-tokenized_message_handler (void *cls,
-                           void *client,
+tokenized_message_handler (void *cls, void *client,
                            const struct GNUNET_MessageHeader *message)
 {
   struct TokenizedMessageContext *ctx = client;
@@ -1335,13 +1331,9 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   if (msg_ctx != NULL)
   {
-    send_message (&msg_ctx->dest,
-                  &msg_ctx->sender,
-                  NULL,
-                  msg_ctx->message,
-                  msg_ctx->message_size,
-                  default_dv_priority,
-                  msg_ctx->uid, GNUNET_TIME_relative_get_forever ());
+    send_message (&msg_ctx->dest, &msg_ctx->sender, NULL, msg_ctx->message,
+                  msg_ctx->message_size, default_dv_priority, msg_ctx->uid,
+                  GNUNET_TIME_relative_get_forever ());
     GNUNET_free (msg_ctx->message);
     GNUNET_free (msg_ctx);
   }
@@ -1352,44 +1344,42 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Get distance information from 'atsi'.
  *
  * @param atsi performance data
+ * @param atsi_count number of entries in atsi
  * @return connected transport distance
  */
 static uint32_t
-get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
+                   unsigned int atsi_count)
 {
-  while ((ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
-         (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE))
-    atsi++;
-  if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
-  {
-    GNUNET_break (0);
-    /* FIXME: we do not have distance data? Assume direct neighbor. */
-    return DIRECT_NEIGHBOR_COST;
-  }
-  return ntohl (atsi->value);
+  unsigned int i;
+
+  for (i = 0; i < atsi_count; i++)
+    if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
+      return ntohl (atsi->value);
+  /* FIXME: we do not have distance data? Assume direct neighbor. */
+  return DIRECT_NEIGHBOR_COST;
 }
 
 /**
  * Find latency information in 'atsi'.
  *
  * @param atsi performance data
+ * @param atsi_count number of entries in atsi
  * @return connection latency
  */
 static struct GNUNET_TIME_Relative
-get_atsi_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+get_atsi_latency (const struct GNUNET_ATS_Information *atsi,
+                  unsigned int atsi_count)
 {
-  while ((ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
-         (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY))
-    atsi++;
-  if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
-  {
-    GNUNET_break (0);
-    /* how can we not have latency data? */
-    return GNUNET_TIME_UNIT_SECONDS;
-  }
-  /* FIXME: Multiply by GNUNET_TIME_UNIT_MILLISECONDS (1) to get as a GNUNET_TIME_Relative */
-  return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                        ntohl (atsi->value));
+  unsigned int i;
+
+  for (i = 0; i < atsi_count; i++)
+    if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY)
+      return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+                                            ntohl (atsi->value));
+  GNUNET_break (0);
+  /* how can we not have latency data? */
+  return GNUNET_TIME_UNIT_SECONDS;
 }
 
 /**
@@ -1402,12 +1392,13 @@ get_atsi_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
  * @param peer peer which sent the message (immediate sender)
  * @param message the message
  * @param atsi transport ATS information (latency, distance, etc.)
+ * @param atsi_count number of entries in atsi
  */
 static int
-handle_dv_data_message (void *cls,
-                        const struct GNUNET_PeerIdentity *peer,
+handle_dv_data_message (void *cls, const struct GNUNET_PeerIdentity *peer,
                         const struct GNUNET_MessageHeader *message,
-                        const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+                        const struct GNUNET_ATS_Information *atsi,
+                        unsigned int atsi_count)
 {
   const p2p_dv_MESSAGE_Data *incoming = (const p2p_dv_MESSAGE_Data *) message;
   const struct GNUNET_MessageHeader *packed_message;
@@ -1460,8 +1451,8 @@ handle_dv_data_message (void *cls,
   }
 
   /* Iterate over ATS_Information to get distance and latency */
-  latency = get_atsi_latency (atsi);
-  distance = get_atsi_distance (atsi);
+  latency = get_atsi_latency (atsi, atsi_count);
+  distance = get_atsi_distance (atsi, atsi_count);
   dn = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
   if (dn == NULL)
     return GNUNET_OK;
@@ -1478,8 +1469,9 @@ handle_dv_data_message (void *cls,
   }
   else
   {
-    pos = GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
-                                             &peer->hashPubKey);
+    pos =
+        GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
+                                           &peer->hashPubKey);
   }
 #else
   pos = dn->referee_head;
@@ -1497,7 +1489,7 @@ handle_dv_data_message (void *cls,
     pos = dn->referee_head;
     while ((NULL != pos) && (pos->referrer_id != sid))
     {
-      sender_id = strdup (GNUNET_i2s (&pos->identity));
+      sender_id = GNUNET_strdup (GNUNET_i2s (&pos->identity));
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I know sender %u %s\n",
                   pos->referrer_id, sender_id);
       GNUNET_free (sender_id);
@@ -1547,11 +1539,9 @@ handle_dv_data_message (void *cls,
     tkm_ctx.peer = peer;
     tkm_ctx.distant = pos;
     tkm_ctx.uid = ntohl (incoming->uid);
-    if (GNUNET_OK != GNUNET_SERVER_mst_receive (coreMST,
-                                                &tkm_ctx,
-                                                cbuf,
-                                                packed_message_size,
-                                                GNUNET_NO, GNUNET_NO))
+    if (GNUNET_OK !=
+        GNUNET_SERVER_mst_receive (coreMST, &tkm_ctx, cbuf, packed_message_size,
+                                   GNUNET_NO, GNUNET_NO))
     {
       GNUNET_break_op (0);
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1634,14 +1624,11 @@ handle_dv_data_message (void *cls,
   else
 #endif
   {
-    ret = send_message (destination,
-                        original_sender,
-                        NULL,
-                        packed_message,
-                        packed_message_size,
-                        default_dv_priority,
-                        ntohl (incoming->uid),
-                        GNUNET_TIME_relative_get_forever ());
+    ret =
+        send_message (destination, original_sender, NULL, packed_message,
+                      packed_message_size, default_dv_priority,
+                      ntohl (incoming->uid),
+                      GNUNET_TIME_relative_get_forever ());
   }
   if (ret != GNUNET_SYSERR)
     return GNUNET_OK;
@@ -1756,17 +1743,17 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       (about->hidden == GNUNET_NO) &&
 #endif
       (to != NULL) &&
-      (0 != memcmp (&about->identity,
-                    &to->identity, sizeof (struct GNUNET_PeerIdentity))) &&
-      (about->pkey != NULL))
+      (0 !=
+       memcmp (&about->identity, &to->identity,
+               sizeof (struct GNUNET_PeerIdentity))) && (about->pkey != NULL))
   {
 #if DEBUG_DV_GOSSIP_SEND
     encPeerAbout = GNUNET_strdup (GNUNET_i2s (&about->identity));
     encPeerTo = GNUNET_strdup (GNUNET_i2s (&to->identity));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "%s: Sending info about peer %s id %u to directly connected peer %s\n",
-                GNUNET_i2s (&my_identity),
-                encPeerAbout, about->our_id, encPeerTo);
+                GNUNET_i2s (&my_identity), encPeerAbout, about->our_id,
+                encPeerTo);
     GNUNET_free (encPeerAbout);
     GNUNET_free (encPeerTo);
 #endif
@@ -1791,8 +1778,7 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     memcpy (&message->neighbor, &about->identity,
             sizeof (struct GNUNET_PeerIdentity));
 
-    GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
-                                       core_pending_tail,
+    GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail,
                                        core_pending_tail, pending_message);
 
     GNUNET_SCHEDULER_add_now (try_core_send, NULL);
@@ -1834,14 +1820,13 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @param message the actual message
  */
 static void
-handle_start (void *cls,
-              struct GNUNET_SERVER_Client *client,
+handle_start (void *cls, struct GNUNET_SERVER_Client *client,
               const struct GNUNET_MessageHeader *message)
 {
 
 #if DEBUG_DV
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' request from client\n", "START");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n",
+              "START");
 #endif
 
   client_handle = client;
@@ -1886,8 +1871,7 @@ send_iterator (void *cls, const GNUNET_HashCode * key, void *abs_value)
  * @param message the actual message
  */
 void
-handle_dv_send_message (void *cls,
-                        struct GNUNET_SERVER_Client *client,
+handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client,
                         const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_DV_SendMessage *send_msg;
@@ -2088,19 +2072,17 @@ handle_dv_send_message (void *cls,
 }
 
 /** Forward declarations **/
-static int handle_dv_gossip_message (void *cls,
-                                     const struct GNUNET_PeerIdentity *peer,
-                                     const struct GNUNET_MessageHeader *message,
-                                     const struct
-                                     GNUNET_TRANSPORT_ATS_Information *atsi);
-
-static int handle_dv_disconnect_message (void *cls,
-                                         const struct GNUNET_PeerIdentity *peer,
-                                         const struct GNUNET_MessageHeader
-                                         *message,
-                                         const struct
-                                         GNUNET_TRANSPORT_ATS_Information
-                                         *atsi);
+static int
+handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer,
+                          const struct GNUNET_MessageHeader *message,
+                          const struct GNUNET_ATS_Information *atsi,
+                          unsigned int atsi_count);
+
+static int
+handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer,
+                              const struct GNUNET_MessageHeader *message,
+                              const struct GNUNET_ATS_Information *atsi,
+                              unsigned int atsi_count);
 /** End forward declarations **/
 
 
@@ -2139,8 +2121,8 @@ distant_neighbor_free (struct DistantNeighbor *referee)
   referrer = referee->referrer;
   if (referrer != NULL)
   {
-    GNUNET_CONTAINER_DLL_remove (referrer->referee_head,
-                                 referrer->referee_tail, referee);
+    GNUNET_CONTAINER_DLL_remove (referrer->referee_head, referrer->referee_tail,
+                                 referee);
   }
   GNUNET_CONTAINER_heap_remove_node (referee->max_loc);
   GNUNET_CONTAINER_heap_remove_node (referee->min_loc);
@@ -2191,8 +2173,8 @@ direct_neighbor_free (struct DirectNeighbor *direct)
  * @return GNUNET_YES to continue iteration, GNUNET_NO to stop
  */
 static int
-schedule_disconnect_messages (void *cls,
-                              const GNUNET_HashCode * key, void *value)
+schedule_disconnect_messages (void *cls, const GNUNET_HashCode * key,
+                              void *value)
 {
   struct DisconnectContext *disconnect_context = cls;
   struct DirectNeighbor *disconnected = disconnect_context->direct;
@@ -2219,8 +2201,7 @@ schedule_disconnect_messages (void *cls,
   disconnect_message->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISCONNECT);
   disconnect_message->peer_id = htonl (disconnect_context->distant->our_id);
 
-  GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
-                                     core_pending_tail,
+  GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail,
                                      core_pending_tail, pending_message);
 
   GNUNET_SCHEDULER_add_now (try_core_send, NULL);
@@ -2305,10 +2286,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * To be called on core init/fail.
  */
 void
-core_init (void *cls,
-           struct GNUNET_CORE_Handle *server,
-           const struct GNUNET_PeerIdentity *identity,
-           const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
+core_init (void *cls, struct GNUNET_CORE_Handle *server,
+           const struct GNUNET_PeerIdentity *identity)
 {
 
   if (server == NULL)
@@ -2404,8 +2383,8 @@ update_matching_neighbors (void *cls, const GNUNET_HashCode * key, void *value)
  * @return GNUNET_YES to continue iteration, GNUNET_NO otherwise
  */
 static int
-add_distant_all_direct_neighbors (void *cls,
-                                  const GNUNET_HashCode * key, void *value)
+add_distant_all_direct_neighbors (void *cls, const GNUNET_HashCode * key,
+                                  void *value)
 {
   struct DirectNeighbor *direct = (struct DirectNeighbor *) value;
   struct DistantNeighbor *distant = (struct DistantNeighbor *) cls;
@@ -2473,6 +2452,7 @@ static size_t
 generate_hello_address (void *cls, size_t max, void *buf)
 {
   struct HelloContext *hello_context = cls;
+  struct GNUNET_HELLO_Address hello_address;
   char *addr_buffer;
   size_t offset;
   size_t size;
@@ -2494,11 +2474,14 @@ generate_hello_address (void *cls, size_t max, void *buf)
   /* Copy the direct peer identity to buffer */
   memcpy (&addr_buffer[offset], hello_context->direct_peer,
           sizeof (struct GNUNET_PeerIdentity));
+  memset (&hello_address.peer, 0, sizeof (struct GNUNET_PeerIdentity));
+  hello_address.address = addr_buffer;
+  hello_address.transport_name = "dv";
+  hello_address.address_length = size;
   ret =
-      GNUNET_HELLO_add_address ("dv",
+      GNUNET_HELLO_add_address (&hello_address,
                                 GNUNET_TIME_relative_to_absolute
-                                (GNUNET_TIME_UNIT_HOURS), addr_buffer, size,
-                                buf, max);
+                                (GNUNET_TIME_UNIT_HOURS), buf, max);
 
   hello_context->addresses_to_add--;
 
@@ -2541,13 +2524,13 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
 #if DEBUG_DV_PEER_NUMBERS
   char *encAbout;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "%s Received sender id (%u)!\n", "DV SERVICE", referrer_peer_id);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s Received sender id (%u)!\n",
+              "DV SERVICE", referrer_peer_id);
 #endif
 
   now = GNUNET_TIME_absolute_get ();
-  neighbor = GNUNET_CONTAINER_multihashmap_get (extended_neighbors,
-                                                &peer->hashPubKey);
+  neighbor =
+      GNUNET_CONTAINER_multihashmap_get (extended_neighbors, &peer->hashPubKey);
   neighbor_update = GNUNET_malloc (sizeof (struct NeighborUpdateInfo));
   neighbor_update->neighbor = neighbor;
   neighbor_update->cost = cost;
@@ -2576,11 +2559,9 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
 
   /* Either we do not know this peer, or we already do but via a different immediate peer */
   if ((neighbor == NULL) ||
-      (GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors,
-                                                   &peer->hashPubKey,
-                                                   &update_matching_neighbors,
-                                                   neighbor_update) !=
-       GNUNET_SYSERR))
+      (GNUNET_CONTAINER_multihashmap_get_multiple
+       (extended_neighbors, &peer->hashPubKey, &update_matching_neighbors,
+        neighbor_update) != GNUNET_SYSERR))
   {
 #if AT_MOST_ONE
     if ((neighbor != NULL) && (cost < neighbor->cost))  /* New cost is less than old, remove old */
@@ -2630,12 +2611,12 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
     }
 
     neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor));
-    GNUNET_CONTAINER_DLL_insert (referrer->referee_head,
-                                 referrer->referee_tail, neighbor);
-    neighbor->max_loc = GNUNET_CONTAINER_heap_insert (neighbor_max_heap,
-                                                      neighbor, cost);
-    neighbor->min_loc = GNUNET_CONTAINER_heap_insert (neighbor_min_heap,
-                                                      neighbor, cost);
+    GNUNET_CONTAINER_DLL_insert (referrer->referee_head, referrer->referee_tail,
+                                 neighbor);
+    neighbor->max_loc =
+        GNUNET_CONTAINER_heap_insert (neighbor_max_heap, neighbor, cost);
+    neighbor->min_loc =
+        GNUNET_CONTAINER_heap_insert (neighbor_min_heap, neighbor, cost);
     neighbor->referrer = referrer;
     memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity));
     if (pkey != NULL)           /* pkey will be null on direct neighbor addition */
@@ -2673,21 +2654,17 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
                       "%s: learned about peer %llu from which we have a previous unknown message, processing!\n",
                       my_short_id, referrer_peer_id);
 #endif
-          struct GNUNET_TRANSPORT_ATS_Information atsi[3];
+          struct GNUNET_ATS_Information atsi[2];
 
-          atsi[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+          atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
           atsi[0].value = htonl (referrer->pending_messages[i].distance);
-          atsi[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
+          atsi[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
           atsi[1].value =
               htonl ((uint32_t) referrer->pending_messages[i].
                      latency.rel_value);
-          atsi[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
-          atsi[2].value = htonl (0);
-          handle_dv_data_message (NULL,
-                                  &referrer->pending_messages[i].sender,
-                                  referrer->pending_messages[i].message,
-                                  (const struct GNUNET_TRANSPORT_ATS_Information
-                                   *) &atsi);
+          handle_dv_data_message (NULL, &referrer->pending_messages[i].sender,
+                                  referrer->pending_messages[i].message, atsi,
+                                  2);
           GNUNET_free (referrer->pending_messages[i].message);
           referrer->pending_messages[i].sender_id = 0;
         }
@@ -2733,9 +2710,8 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
 #endif
   }
 #if DEBUG_DV
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "%s: Size of extended_neighbors is %d\n", "dv",
-              GNUNET_CONTAINER_multihashmap_size (extended_neighbors));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Size of extended_neighbors is %d\n",
+              "dv", GNUNET_CONTAINER_multihashmap_size (extended_neighbors));
 #endif
 
   GNUNET_free (neighbor_update);
@@ -2754,13 +2730,13 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
  * @param peer peer which sent the message (immediate sender)
  * @param message the message
  * @param atsi performance data
+ * @param atsi_count number of entries in atsi
  */
 static int
-handle_dv_disconnect_message (void *cls,
-                              const struct GNUNET_PeerIdentity *peer,
+handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer,
                               const struct GNUNET_MessageHeader *message,
-                              const struct GNUNET_TRANSPORT_ATS_Information
-                              *atsi)
+                              const struct GNUNET_ATS_Information *atsi,
+                              unsigned int atsi_count)
 {
   struct DirectNeighbor *referrer;
   struct DistantNeighbor *distant;
@@ -2772,8 +2748,8 @@ handle_dv_disconnect_message (void *cls,
     return GNUNET_SYSERR;       /* invalid message */
   }
 
-  referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors,
-                                                &peer->hashPubKey);
+  referrer =
+      GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
   if (referrer == NULL)
     return GNUNET_OK;
 
@@ -2804,12 +2780,13 @@ handle_dv_disconnect_message (void *cls,
  * @param peer peer which sent the message (immediate sender)
  * @param message the message
  * @param atsi performance data
+ * @param atsi_count number of entries in atsi
  */
 static int
-handle_dv_gossip_message (void *cls,
-                          const struct GNUNET_PeerIdentity *peer,
+handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer,
                           const struct GNUNET_MessageHeader *message,
-                          const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+                          const struct GNUNET_ATS_Information *atsi,
+                          unsigned int atsi_count)
 {
   struct DirectNeighbor *referrer;
   p2p_dv_MESSAGE_NeighborInfo *enc_message =
@@ -2834,14 +2811,14 @@ handle_dv_gossip_message (void *cls,
   GNUNET_free (encPeerFrom);
 #endif
 
-  referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors,
-                                                &peer->hashPubKey);
+  referrer =
+      GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
   if (referrer == NULL)
     return GNUNET_OK;
 
   addUpdateNeighbor (&enc_message->neighbor, &enc_message->pkey,
-                     ntohl (enc_message->neighbor_id),
-                     referrer, ntohl (enc_message->cost) + 1);
+                     ntohl (enc_message->neighbor_id), referrer,
+                     ntohl (enc_message->cost) + 1);
 
   return GNUNET_OK;
 }
@@ -2897,8 +2874,8 @@ add_all_extended_peers (void *cls, const GNUNET_HashCode * key, void *value)
  *         GNUNET_NO if not.
  */
 static int
-gossip_all_to_all_iterator (void *cls,
-                            const GNUNET_HashCode * key, void *abs_value)
+gossip_all_to_all_iterator (void *cls, const GNUNET_HashCode * key,
+                            void *abs_value)
 {
   struct DirectNeighbor *direct = abs_value;
 
@@ -3007,8 +2984,7 @@ add_all_direct_neighbors (void *cls, const GNUNET_HashCode * key, void *value)
  * @param err_msg NULL if successful, otherwise contains error message
  */
 static void
-process_peerinfo (void *cls,
-                  const struct GNUNET_PeerIdentity *peer,
+process_peerinfo (void *cls, const struct GNUNET_PeerIdentity *peer,
                   const struct GNUNET_HELLO_Message *hello, const char *err_msg)
 {
   struct PeerIteratorContext *peerinfo_iterator = cls;
@@ -3034,13 +3010,12 @@ process_peerinfo (void *cls,
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Failed to get peerinfo information for this peer, retrying!\n");
 #endif
-      peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle,
-                                                       &peerinfo_iterator->neighbor->
-                                                       identity,
-                                                       GNUNET_TIME_relative_multiply
-                                                       (GNUNET_TIME_UNIT_SECONDS,
-                                                        3), &process_peerinfo,
-                                                       peerinfo_iterator);
+      peerinfo_iterator->ic =
+          GNUNET_PEERINFO_iterate (peerinfo_handle,
+                                   &peerinfo_iterator->neighbor->identity,
+                                   GNUNET_TIME_relative_multiply
+                                   (GNUNET_TIME_UNIT_SECONDS, 3),
+                                   &process_peerinfo, peerinfo_iterator);
     }
     else
     {
@@ -3109,11 +3084,12 @@ process_peerinfo (void *cls,
  * @param cls closure
  * @param peer peer identity this notification is about
  * @param atsi performance data
+ * @param atsi_count number of entries in atsi
  */
 static void
-handle_core_connect (void *cls,
-                     const struct GNUNET_PeerIdentity *peer,
-                     const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
+                     const struct GNUNET_ATS_Information *atsi,
+                     unsigned int atsi_count)
 {
   struct DirectNeighbor *neighbor;
   struct DistantNeighbor *about;
@@ -3126,7 +3102,7 @@ handle_core_connect (void *cls,
   if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
 
-  distance = get_atsi_distance (atsi);
+  distance = get_atsi_distance (atsi, atsi_count);
   if ((distance == DIRECT_NEIGHBOR_COST) &&
       (GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey)
        == NULL))
@@ -3146,12 +3122,11 @@ handle_core_connect (void *cls,
     about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST);
     peerinfo_iterator->distant = about;
     peerinfo_iterator->neighbor = neighbor;
-    peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle,
-                                                     peer,
-                                                     GNUNET_TIME_relative_multiply
-                                                     (GNUNET_TIME_UNIT_SECONDS,
-                                                      3), &process_peerinfo,
-                                                     peerinfo_iterator);
+    peerinfo_iterator->ic =
+        GNUNET_PEERINFO_iterate (peerinfo_handle, peer,
+                                 GNUNET_TIME_relative_multiply
+                                 (GNUNET_TIME_UNIT_SECONDS, 3),
+                                 &process_peerinfo, peerinfo_iterator);
 
     if ((about != NULL) && (about->pkey == NULL))
     {
@@ -3257,9 +3232,9 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
   }
 
   GNUNET_assert (neighbor->referee_tail == NULL);
-  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors,
-                                                         &peer->hashPubKey,
-                                                         neighbor))
+  if (GNUNET_NO ==
+      GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, &peer->hashPubKey,
+                                            neighbor))
   {
     GNUNET_break (0);
   }
@@ -3278,8 +3253,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
  * @param c configuration to use
  */
 static void
-run (void *cls,
-     struct GNUNET_SERVER_Handle *server,
+run (void *cls, struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   unsigned long long max_hosts;
@@ -3321,12 +3295,9 @@ run (void *cls,
 
   GNUNET_SERVER_add_handlers (server, plugin_handlers);
   coreAPI = GNUNET_CORE_connect (cfg, 1, NULL,  /* FIXME: anything we want to pass around? */
-                                 &core_init,
-                                 &handle_core_connect,
-                                 &handle_core_disconnect,
-                                 NULL,
-                                 NULL,
-                                 GNUNET_NO, NULL, GNUNET_NO, core_handlers);
+                                 &core_init, &handle_core_connect,
+                                 &handle_core_disconnect, NULL, GNUNET_NO, NULL,
+                                 GNUNET_NO, core_handlers);
 
   if (coreAPI == NULL)
     return;
@@ -3342,8 +3313,9 @@ run (void *cls,
   }
 
   /* Scheduled the task to clean up when shutdown is called */
-  cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                               &shutdown_task, NULL);
+  cleanup_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                                    &shutdown_task, NULL);
 }
 
 
@@ -3358,8 +3330,6 @@ int
 main (int argc, char *const *argv)
 {
   return (GNUNET_OK ==
-          GNUNET_SERVICE_run (argc,
-                              argv,
-                              "dv",
-                              GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
+          GNUNET_SERVICE_run (argc, argv, "dv", GNUNET_SERVICE_OPTION_NONE,
+                              &run, NULL)) ? 0 : 1;
 }