remove output
[oweals/gnunet.git] / src / transport / gnunet-service-transport_neighbours.c
index d372f5c4330f8ba7a4c34acacc34d15f634f1943..8f53b93beb3772d6e89f3f353afc0e40f4e6669a 100644 (file)
@@ -329,7 +329,7 @@ struct SessionDisconnectMessage
   /**
    * Public key of the sender.
    */
-  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
+  struct GNUNET_CRYPTO_EccPublicKey public_key;
 
   /**
    * Signature of the peer that sends us the disconnect.  Only
@@ -1195,7 +1195,7 @@ send_disconnect (struct NeighbourMapEntry *n)
   disconnect_msg.reserved = htonl (0);
   disconnect_msg.purpose.size =
       htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
-             sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) +
+             sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
              sizeof (struct GNUNET_TIME_AbsoluteNBO));
   disconnect_msg.purpose.purpose =
       htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
@@ -1543,7 +1543,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour)
   else
     latency = n->latency.rel_value;
   ats.value = htonl (latency);
-  GST_update_ats_metrics (&n->id,
+  GST_ats_update_metrics (&n->id,
                                                                                          n->primary_address.address,
                                                                                        n->primary_address.session,
                                                                                        &ats, 1);
@@ -1925,9 +1925,6 @@ handle_test_blacklist_cont (void *cls,
 {
   struct BlackListCheckContext *bcc = cls;
   struct NeighbourMapEntry *n;
-  struct GNUNET_TRANSPORT_PluginFunctions *papi;
-       struct GNUNET_ATS_Information ats;
-       int net;
 
   bcc->bc = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1991,32 +1988,8 @@ handle_test_blacklist_cont (void *cls,
     break; 
   case S_CONNECT_RECV_BLACKLIST_INBOUND:
     if (GNUNET_OK == result)
-    {
-      /* valid new address, let ATS know! */
-      GNUNET_assert (bcc->na.address->transport_name != NULL);
-      if (NULL == (papi = GST_plugins_find (bcc->na.address->transport_name)))
-      {
-        /* we don't have the plugin for this address */
-       GNUNET_break (0);
-      }
-      else
-      {
-       if (NULL != papi->get_network)
-       {
-               net = papi->get_network (NULL, bcc->na.session);
-               ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-               ats.value = htonl(net);
-//                     GNUNET_break (0);
-//                     fprintf (stderr, "NET: %u\n", ntohl(net));
-               GNUNET_ATS_address_add (GST_ats,
-                                                                                                                               bcc->na.address,
-                                                                                                                               bcc->na.session,
-                                                                                                                               &ats, 1);
-       }
-       else
-               GNUNET_break (0);
-      }
-    }
+       GST_ats_add_address (bcc->na.address, bcc->na.session);
+
     n->state = S_CONNECT_RECV_ATS;
     n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
     GNUNET_ATS_reset_backoff (GST_ats, peer);
@@ -2777,9 +2750,6 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
   const struct SessionConnectMessage *scm;
   struct GNUNET_TIME_Absolute ts;
   struct NeighbourMapEntry *n;
-  struct GNUNET_TRANSPORT_PluginFunctions *papi;
-       struct GNUNET_ATS_Information ats;
-       int net;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received CONNECT_ACK message from peer `%s'\n",
@@ -2827,29 +2797,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
                        n->primary_address.bandwidth_in,
                        n->primary_address.bandwidth_out);
     /* Tell ATS that the outbound session we created to send CONNECT was successfull */
-    GNUNET_assert (n->primary_address.address->transport_name != NULL);
-    if (NULL == (papi = GST_plugins_find (n->primary_address.address->transport_name)))
-    {
-      /* we don't have the plugin for this address */
-       GNUNET_break (0);
-    }
-    else
-    {
-       if (NULL != papi->get_network)
-       {
-               net = papi->get_network (NULL, n->primary_address.session);
-               ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-               ats.value = htonl(net);
-//             GNUNET_break (0);
-//             fprintf (stderr, "NET: %u\n", ntohl(net));
-        GNUNET_ATS_address_add (GST_ats,
-                                n->primary_address.address,
-                                n->primary_address.session,
-                                &ats, 1);
-       }
-       else
-               GNUNET_break (0);
-    }
+    GST_ats_add_address (n->primary_address.address, n->primary_address.session);
     set_address (&n->primary_address,
                 n->primary_address.address,
                 n->primary_address.session,
@@ -2895,30 +2843,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
     n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
 
-    GNUNET_assert (n->alternative_address.address->transport_name != NULL);
-    if (NULL == (papi = GST_plugins_find (n->alternative_address.address->transport_name)))
-    {
-      /* we don't have the plugin for this address */
-       GNUNET_break (0);
-    }
-    else
-    {
-       if (NULL != papi->get_network)
-       {
-               net = papi->get_network (NULL, n->alternative_address.session);
-               ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-               ats.value = htonl(net);
-//             GNUNET_break (0);
-//             fprintf (stderr, "NET: %u\n", ntohl(net));
-        GNUNET_ATS_address_add (GST_ats,
-                                n->alternative_address.address,
-                                n->alternative_address.session,
-                                &ats, 1);
-       }
-       else
-               GNUNET_break (0);
-    }
-
+    GST_ats_add_address (n->alternative_address.address, n->alternative_address.session);
     set_address (&n->primary_address,
                 n->alternative_address.address,
                 n->alternative_address.session,
@@ -3126,31 +3051,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                      n->primary_address.bandwidth_in,
                      n->primary_address.bandwidth_out);
 
-  GNUNET_assert (n->primary_address.address->transport_name != NULL);
-  struct GNUNET_TRANSPORT_PluginFunctions *papi;
-  if (NULL == (papi = GST_plugins_find (n->primary_address.address->transport_name)))
-  {
-    /* we don't have the plugin for this address */
-       GNUNET_break (0);
-  }
-  else
-  {
-       if (NULL != papi->get_network)
-       {
-               int net = papi->get_network (NULL, n->primary_address.session);
-               struct GNUNET_ATS_Information ats;
-               ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-               ats.value = htonl(net);
-//             GNUNET_break (0);
-//             fprintf (stderr, "NET: %u\n", ntohl(net));
-      GNUNET_ATS_address_add (GST_ats,
-                              n->primary_address.address,
-                              n->primary_address.session,
-                              &ats, 1);
-       }
-       else
-               GNUNET_break (0);
-  }
+  GST_ats_add_address (n->primary_address.address, n->primary_address.session);
   set_address (&n->primary_address,
               n->primary_address.address,
               n->primary_address.session,
@@ -3250,7 +3151,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
     return;
   }
   GNUNET_CRYPTO_hash (&sdm->public_key,
-                      sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded),
+                      sizeof (struct GNUNET_CRYPTO_EccPublicKey),
                       &hc);
   if (0 != memcmp (peer, &hc, sizeof (struct GNUNET_PeerIdentity)))
   {
@@ -3259,9 +3160,13 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
   }
   if (ntohl (sdm->purpose.size) !=
       sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
-      sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) +
+      sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
       sizeof (struct GNUNET_TIME_AbsoluteNBO))
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "%s message from peer `%s' has invalid size \n",
+                "DISCONNECT",
+                GNUNET_i2s (peer));
     GNUNET_break_op (0);
     return;
   }
@@ -3270,6 +3175,10 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
       (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, &sdm->purpose,
        &sdm->signature, &sdm->public_key))
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "%s message from peer `%s' cannot be verified \n",
+                "DISCONNECT",
+                GNUNET_i2s (peer));
     GNUNET_break_op (0);
     return;
   }