- fix error messages
[oweals/gnunet.git] / src / transport / transport_api_monitoring.c
index bfbe1d0a1128ab8796a22aca880b147e4992ea7c..b753ce73a6b228e14c1f48344363d16ee452a146 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file transport/transport_api_montoring.c
+ * @file transport/transport_api_monitoring.c
  * @brief montoring api for transport peer status and validation entries
  *
  * This api provides the ability to query the transport service about
@@ -151,24 +151,24 @@ GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state)
 {
   switch (state)
   {
-  case S_NOT_CONNECTED:
-  case S_INIT_ATS:
-  case S_INIT_BLACKLIST:
-  case S_CONNECT_SENT:
-  case S_CONNECT_RECV_BLACKLIST_INBOUND:
-  case S_CONNECT_RECV_ATS:
-  case S_CONNECT_RECV_BLACKLIST:
-  case S_CONNECT_RECV_ACK:
+  case GNUNET_TRANSPORT_NOT_CONNECTED:
+  case GNUNET_TRANSPORT_INIT_ATS:
+  case GNUNET_TRANSPORT_INIT_BLACKLIST:
+  case GNUNET_TRANSPORT_CONNECT_SENT:
+  case GNUNET_TRANSPORT_CONNECT_RECV_BLACKLIST_INBOUND:
+  case GNUNET_TRANSPORT_CONNECT_RECV_ATS:
+  case GNUNET_TRANSPORT_CONNECT_RECV_BLACKLIST:
+  case GNUNET_TRANSPORT_CONNECT_RECV_ACK:
     return GNUNET_NO;
-  case S_CONNECTED:
-  case S_RECONNECT_ATS:
-  case S_RECONNECT_BLACKLIST:
-  case S_RECONNECT_SENT:
-  case S_CONNECTED_SWITCHING_BLACKLIST:
-  case S_CONNECTED_SWITCHING_CONNECT_SENT:
+  case GNUNET_TRANSPORT_CONNECTED:
+  case GNUNET_TRANSPORT_RECONNECT_ATS:
+  case GNUNET_TRANSPORT_RECONNECT_BLACKLIST:
+  case GNUNET_TRANSPORT_RECONNECT_SENT:
+  case GNUNET_TRANSPORT_CONNECTED_SWITCHING_BLACKLIST:
+  case GNUNET_TRANSPORT_CONNECTED_SWITCHING_CONNECT_SENT:
     return GNUNET_YES;
-  case S_DISCONNECT:
-  case S_DISCONNECT_FINISHED:
+  case GNUNET_TRANSPORT_DISCONNECT:
+  case GNUNET_TRANSPORT_DISCONNECT_FINISHED:
     return GNUNET_NO;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -191,37 +191,37 @@ GNUNET_TRANSPORT_p2s (enum GNUNET_TRANSPORT_PeerState state)
 {
   switch (state)
   {
-  case S_NOT_CONNECTED:
+  case GNUNET_TRANSPORT_NOT_CONNECTED:
     return "S_NOT_CONNECTED";
-  case S_INIT_ATS:
+  case GNUNET_TRANSPORT_INIT_ATS:
     return "S_INIT_ATS";
-  case S_INIT_BLACKLIST:
+  case GNUNET_TRANSPORT_INIT_BLACKLIST:
     return "S_INIT_BLACKLIST";
-  case S_CONNECT_SENT:
+  case GNUNET_TRANSPORT_CONNECT_SENT:
     return "S_CONNECT_SENT";
-  case S_CONNECT_RECV_BLACKLIST_INBOUND:
+  case GNUNET_TRANSPORT_CONNECT_RECV_BLACKLIST_INBOUND:
     return "S_CONNECT_RECV_BLACKLIST_INBOUND";
-  case S_CONNECT_RECV_ATS:
+  case GNUNET_TRANSPORT_CONNECT_RECV_ATS:
     return "S_CONNECT_RECV_ATS";
-  case S_CONNECT_RECV_BLACKLIST:
+  case GNUNET_TRANSPORT_CONNECT_RECV_BLACKLIST:
     return "S_CONNECT_RECV_BLACKLIST";
-  case S_CONNECT_RECV_ACK:
+  case GNUNET_TRANSPORT_CONNECT_RECV_ACK:
     return "S_CONNECT_RECV_ACK";
-  case S_CONNECTED:
+  case GNUNET_TRANSPORT_CONNECTED:
     return "S_CONNECTED";
-  case S_RECONNECT_ATS:
+  case GNUNET_TRANSPORT_RECONNECT_ATS:
     return "S_RECONNECT_ATS";
-  case S_RECONNECT_BLACKLIST:
+  case GNUNET_TRANSPORT_RECONNECT_BLACKLIST:
     return "S_RECONNECT_BLACKLIST";
-  case S_RECONNECT_SENT:
+  case GNUNET_TRANSPORT_RECONNECT_SENT:
     return "S_RECONNECT_SENT";
-  case S_CONNECTED_SWITCHING_BLACKLIST:
+  case GNUNET_TRANSPORT_CONNECTED_SWITCHING_BLACKLIST:
     return "S_CONNECTED_SWITCHING_BLACKLIST";
-  case S_CONNECTED_SWITCHING_CONNECT_SENT:
+  case GNUNET_TRANSPORT_CONNECTED_SWITCHING_CONNECT_SENT:
     return "S_CONNECTED_SWITCHING_CONNECT_SENT";
-  case S_DISCONNECT:
+  case GNUNET_TRANSPORT_DISCONNECT:
     return "S_DISCONNECT";
-  case S_DISCONNECT_FINISHED:
+  case GNUNET_TRANSPORT_DISCONNECT_FINISHED:
     return "S_DISCONNECT_FINISHED";
   default:
     GNUNET_break (0);
@@ -328,7 +328,7 @@ peer_response_processor (void *cls,
     if (pal_ctx->one_shot)
     {
       pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
-          S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+          GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
       GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
     }
     else
@@ -346,7 +346,7 @@ peer_response_processor (void *cls,
     if (pal_ctx->one_shot)
     {
       pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
-          S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+          GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
       GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
     }
     else
@@ -364,7 +364,7 @@ peer_response_processor (void *cls,
     if (pal_ctx->one_shot)
     {
       pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
-          S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+          GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
       GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
     }
     else
@@ -384,7 +384,7 @@ peer_response_processor (void *cls,
     if (pal_ctx->one_shot)
     {
       pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
-          S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+          GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
       GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
     }
     else
@@ -397,7 +397,7 @@ peer_response_processor (void *cls,
   if (alen == 0 && tlen == 0)
   {
     pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL,
-        S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+        GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
   }
   else
   {
@@ -410,7 +410,7 @@ peer_response_processor (void *cls,
       if (pal_ctx->one_shot)   
       {
        pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
-           S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
+           GNUNET_TRANSPORT_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
        GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
       }
       else
@@ -445,21 +445,24 @@ peer_response_processor (void *cls,
  * time with 'NULL' for the address and the peer.  After this, the operation must no
  * longer be explicitly canceled.
  *
+ * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
+ * the peer_callback!
+ *
  * @param cfg configuration to use
  * @param peer peer identity to look up the addresses of, CHANGE: allow NULL for all (connected) peers
  * @param one_shot GNUNET_YES to return the current state and then end (with NULL+NULL),
  *                 GNUNET_NO to monitor the set of addresses used (continuously, must be explicitly canceled)
  * @param timeout how long is the lookup allowed to take at most (irrelevant if one_shot is set to GNUNET_NO)
- * @param peer_address_callback function to call with the results
- * @param peer_address_callback_cls closure for peer_address_callback
+ * @param peer_callback function to call with the results
+ * @param peer_callback_cls closure for peer_address_callback
  */
 struct GNUNET_TRANSPORT_PeerMonitoringContext *
 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
     const struct GNUNET_PeerIdentity *peer,
     int one_shot,
     struct GNUNET_TIME_Relative timeout,
-    GNUNET_TRANSPORT_PeerIterateCallback peer_address_callback,
-    void *peer_address_callback_cls)
+    GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
+    void *peer_callback_cls)
 {
   struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx;
   struct GNUNET_CLIENT_Connection *client;
@@ -470,8 +473,8 @@ GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
   if (GNUNET_YES != one_shot)
     timeout = GNUNET_TIME_UNIT_FOREVER_REL;
   pal_ctx = GNUNET_new (struct GNUNET_TRANSPORT_PeerMonitoringContext);
-  pal_ctx->cb = peer_address_callback;
-  pal_ctx->cb_cls = peer_address_callback_cls;
+  pal_ctx->cb = peer_callback;
+  pal_ctx->cb_cls = peer_callback_cls;
   pal_ctx->cfg = cfg;
   pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
   if (NULL != peer)
@@ -485,30 +488,30 @@ GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
 
 
 /**
- * Cancel request for address conversion.
+ * Cancel request to monitor peers
  *
- * @param alc handle for the request to cancel
+ * @param pic handle for the request to cancel
  */
 void
-GNUNET_TRANSPORT_monitor_peers_cancel (
-    struct GNUNET_TRANSPORT_PeerMonitoringContext *alc)
+GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic)
 {
-  if (NULL != alc->client)
+  if (NULL != pic->client)
   {
-    GNUNET_CLIENT_disconnect (alc->client);
-    alc->client = NULL;
+    GNUNET_CLIENT_disconnect (pic->client);
+    pic->client = NULL;
   }
-  if (GNUNET_SCHEDULER_NO_TASK != alc->reconnect_task)
+  if (GNUNET_SCHEDULER_NO_TASK != pic->reconnect_task)
   {
-    GNUNET_SCHEDULER_cancel (alc->reconnect_task);
-    alc->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+    GNUNET_SCHEDULER_cancel (pic->reconnect_task);
+    pic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  GNUNET_free (alc);
+  GNUNET_free (pic);
 }
 
 
 /**
- * Return information about a peer's or all current pending validation operations
+ * Return information about pending address validation operations for a specific
+ * or all peers
  *
  * @param cfg configuration to use
  * @param peer a specific peer identity to obtain validation entries for,
@@ -516,8 +519,8 @@ GNUNET_TRANSPORT_monitor_peers_cancel (
  * @param one_shot GNUNET_YES to return all entries and then end (with NULL+NULL),
  *                 GNUNET_NO to monitor validation entries continuously
  * @param timeout how long is the lookup allowed to take at most
- * @param peer_address_callback function to call with the results
- * @param peer_address_callback_cls closure for peer_address_callback
+ * @param validation_callback function to call with the results
+ * @param validation_callback_cls closure for peer_address_callback
  */
 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
 GNUNET_TRANSPORT_monitor_validation_entries (const struct
@@ -545,4 +548,4 @@ GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_Vali
 }
 
 
-/* end of transport_api_montoring.c */
+/* end of transport_api_monitoring.c */