fixing unchecked return values
[oweals/gnunet.git] / src / transport / gnunet-service-transport_clients.c
index aefe581c7d488776c7f829131db27391afaf0fed..d9a750e2911e10f42bb0aab9838b32b662dc9637 100644 (file)
@@ -262,6 +262,7 @@ setup_client (struct GNUNET_SERVER_Client *client)
  * Find the handle to the monitoring client associated with the given
  * client handle
  *
+ * @param head the head of the client queue to look in
  * @param client server's client handle to look up
  * @return handle to the monitoring client
  */
@@ -765,11 +766,16 @@ try_connect_if_allowed (void *cls,
 {
   if (GNUNET_OK != result)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Blacklist refuses connection attempt to peer `%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                _("Blacklist refuses connection attempt to peer `%s'\n"),
                 GNUNET_i2s (peer));
     return;                     /* not allowed */
   }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              _("Blacklist allows connection attempt to peer `%s'\n"),
+              GNUNET_i2s (peer));
+
   GST_neighbours_try_connect (peer);
 }
 
@@ -788,27 +794,59 @@ clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client,
   const struct TransportRequestConnectMessage *trcm =
       (const struct TransportRequestConnectMessage *) message;
 
-  GNUNET_STATISTICS_update (GST_stats,
-                            gettext_noop
-                            ("# REQUEST CONNECT messages received"), 1,
-                            GNUNET_NO);
+  if (GNUNET_YES == ntohl (trcm->connect))
+  {
+    GNUNET_STATISTICS_update (GST_stats,
+                              gettext_noop
+                              ("# REQUEST CONNECT messages received"), 1,
+                              GNUNET_NO);
 
-  if (0 == memcmp (&trcm->peer, &GST_my_identity,
-               sizeof (struct GNUNET_PeerIdentity)))
+    if (0 == memcmp (&trcm->peer, &GST_my_identity,
+                  sizeof (struct GNUNET_PeerIdentity)))
+    {
+      GNUNET_break_op (0);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Received a request connect message myself `%s'\n",
+                  GNUNET_i2s (&trcm->peer));
+    }
+    else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  _("Received a request connect message for peer `%s'\n"),
+                  GNUNET_i2s (&trcm->peer));
+
+      (void) GST_blacklist_test_allowed (&trcm->peer, NULL, &try_connect_if_allowed,
+                                       NULL);
+    }
+  }
+  else if (GNUNET_NO == ntohl (trcm->connect))
   {
-    GNUNET_break_op (0);
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Received a request connect message myself `%s'\n",
-                GNUNET_i2s (&trcm->peer));
+    GNUNET_STATISTICS_update (GST_stats,
+                              gettext_noop
+                              ("# REQUEST DISCONNECT messages received"), 1,
+                              GNUNET_NO);
+
+    if (0 == memcmp (&trcm->peer, &GST_my_identity,
+                  sizeof (struct GNUNET_PeerIdentity)))
+    {
+      GNUNET_break_op (0);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Received a request disconnect message myself `%s'\n",
+                  GNUNET_i2s (&trcm->peer));
+    }
+    else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  _("Received a request disconnect message for peer `%s'\n"),
+                  GNUNET_i2s (&trcm->peer));
+      (void) GST_neighbours_force_disconnect (&trcm->peer);
+    }
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Received a request connect message for peer `%s'\n",
-                GNUNET_i2s (&trcm->peer));
-
-    (void) GST_blacklist_test_allowed (&trcm->peer, NULL, &try_connect_if_allowed,
-                                     NULL);
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
   }
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
@@ -1006,15 +1044,15 @@ struct IterationContext
 };
 
 /**
- * Output information of neighbours to the given client.
+ * Output information of validation entries to the given client.
  *
- * @param cls the 'struct PeerIterationContext'
+ * @param cls the 'struct IterationContext'
  * @param peer identity of the neighbour
  * @param address the address
- * @param state current state this peer is in
- * @param state_timeout timeout for the current state of the peer
- * @param bandwidth_in inbound quota in NBO
- * @param bandwidth_out outbound quota in NBO
+ * @param last_validation point in time when last validation was performed
+ * @param valid_until point in time how long address is valid
+ * @param next_validation point in time when next validation will be performed
+ * @param state state of validation notification
  */
 static void
 send_validation_information (void *cls,
@@ -1378,12 +1416,14 @@ GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer,
 }
 
 /**
- * Broadcast the new active address to all clients monitoring the peer.
+ * Broadcast the new validation changes to all clients monitoring the peer.
  *
  * @param peer peer this update is about (never NULL)
  * @param address address, NULL on disconnect
- * @param state the current state of the peer
- * @param state_timeout the time out for the state
+ * @param last_validation point in time when last validation was performed
+ * @param valid_until point in time how long address is valid
+ * @param next_validation point in time when next validation will be performed
+ * @param state state of validation notification
  */
 void
 GST_clients_broadcast_validation_notification (