-simplify logic
[oweals/gnunet.git] / src / transport / gnunet-service-transport_validation.c
index 8f563de025c739f475007cbd5275f369ab457d89..ee8cd93089bde54864470c6b1175d66cbe31feab 100644 (file)
@@ -505,11 +505,17 @@ timeout_hello_validation (void *cls,
  *
  * @param cls our `struct ValidationEntry`
  * @param pid identity of the other peer
- * @param result #GNUNET_OK if the connection is allowed, #GNUNET_NO if not
+ * @param address_null address associated with the request, always NULL
+ * @param session_null session associated with the request, always NULL
+ * @param result #GNUNET_OK if the connection is allowed,
+ *               #GNUNET_NO if not,
+ *               #GNUNET_SYSERR if operation was aborted
  */
 static void
 transmit_ping_if_allowed (void *cls,
                           const struct GNUNET_PeerIdentity *pid,
+                         const struct GNUNET_HELLO_Address *address_null,
+                         struct Session *session_null,
                           int result)
 {
   struct ValidationEntry *ve = cls;
@@ -524,7 +530,7 @@ transmit_ping_if_allowed (void *cls,
   struct Session *session;
 
   ve->bc = NULL;
-  if (GNUNET_NO == result)
+  if (GNUNET_OK != result)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Blacklist denies sending PING to `%s' `%s' `%s'\n",
@@ -578,6 +584,7 @@ transmit_ping_if_allowed (void *cls,
             ve->address->address,
            ve->address->address_length);
     papi = GST_plugins_find (ve->address->transport_name);
+    GNUNET_assert (NULL != papi);
     session = papi->get_session (papi->cls,
                                  ve->address);
     if (NULL == session)
@@ -742,7 +749,10 @@ revalidate_address (void *cls,
                             GNUNET_NO);
   bc = GST_blacklist_test_allowed (&ve->address->peer,
                                   ve->address->transport_name,
-                                   &transmit_ping_if_allowed, ve);
+                                   &transmit_ping_if_allowed,
+                                  ve,
+                                  NULL,
+                                  NULL);
   if (NULL != bc)
     ve->bc = bc;                /* only set 'bc' if 'transmit_ping_if_allowed' was not already
                                  * called... */
@@ -1514,9 +1524,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
   /* build HELLO to store in PEERINFO */
   ve->copied = GNUNET_NO;
   hello = GNUNET_HELLO_create (&ve->address->peer.public_key,
-                               &add_valid_peer_address, ve,
+                               &add_valid_peer_address, 
+                              ve,
                                GNUNET_NO);
-  GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL);
+  GNUNET_PEERINFO_add_peer (GST_peerinfo, 
+                           hello,
+                           NULL,
+                           NULL);
   GNUNET_free (hello);
   return GNUNET_OK;
 }
@@ -1555,26 +1569,10 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
     /* got our own HELLO, how boring */
     return GNUNET_OK;
   }
-  if (GNUNET_NO ==
-      GNUNET_CONTAINER_multipeermap_contains (validation_map,
-                                              &pid))
-  {
-    /* Add peer identity without addresses to peerinfo service */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Adding HELLO without addresses for peer `%s'\n",
-                GNUNET_i2s (&pid));
-    h = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, friend);
-    GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
-
-    GNUNET_free (h);
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Validation received HELLO message for peer `%s' with size %u, checking for new addresses\n",
-                GNUNET_i2s (&pid),
-                ntohs (hello->size));
-  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Validation received HELLO message for peer `%s' with size %u, checking for new addresses\n",
+             GNUNET_i2s (&pid),
+             ntohs (hello->size));
   GNUNET_assert (NULL ==
                  GNUNET_HELLO_iterate_addresses (hm,
                                                 GNUNET_NO,