- cleanup
[oweals/gnunet.git] / src / ats / ats_api_performance.c
index ca489e4a67417c401f18613b6c8db5865d8085f0..c98e1c243e898cc76aba6a5b2071ee7589400495 100644 (file)
@@ -167,7 +167,7 @@ struct GNUNET_ATS_PerformanceHandle
 /**
  * Re-establish the connection to the ATS service.
  *
- * @param sh handle to use to re-connect.
+ * @param ph handle to use to re-connect.
  */
 static void
 reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
@@ -193,7 +193,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Transmit messages from the message queue to the service
  * (if there are any, and if we are not already trying).
  *
- * @param sh handle to use
+ * @param ph handle to use
  */
 static void
 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
@@ -269,9 +269,10 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
 {
   const struct PeerInformationMessage *pi;
   const struct GNUNET_ATS_Information *atsi;
-  const char *address;
+  const char *plugin_address;
   const char *plugin_name;
-  uint16_t address_length;
+  struct GNUNET_HELLO_Address address;
+  uint16_t plugin_address_length;
   uint16_t plugin_name_length;
   uint32_t ats_count;
 
@@ -287,12 +288,12 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
   }
   pi = (const struct PeerInformationMessage *) msg;
   ats_count = ntohl (pi->ats_count);
-  address_length = ntohs (pi->address_length);
+  plugin_address_length = ntohs (pi->address_length);
   plugin_name_length = ntohs (pi->plugin_name_length);
   atsi = (const struct GNUNET_ATS_Information *) &pi[1];
-  address = (const char *) &atsi[ats_count];
-  plugin_name = &address[address_length];
-  if ((address_length + plugin_name_length +
+  plugin_address = (const char *) &atsi[ats_count];
+  plugin_name = &plugin_address[plugin_address_length];
+  if ((plugin_address_length + plugin_name_length +
        ats_count * sizeof (struct GNUNET_ATS_Information) +
        sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
       (ats_count >
@@ -302,8 +303,12 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  ph->infocb (ph->infocb_cls, &pi->peer, plugin_name, address, address_length,
-              pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count);
+  address.peer = pi->peer;
+  address.address = plugin_address;
+  address.address_length = plugin_address_length;
+  address.transport_name = plugin_name;
+  ph->infocb (ph->infocb_cls, &address, pi->bandwidth_out, pi->bandwidth_in,
+              atsi, ats_count);
   return GNUNET_OK;
 }
 
@@ -385,13 +390,12 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
   default:
     GNUNET_break (0);
     goto reconnect;
-    return;
   }
   GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
                          GNUNET_TIME_UNIT_FOREVER_REL);
   return;
 reconnect:
-  GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
+  GNUNET_CLIENT_disconnect (ph->client);
   ph->client = NULL;
   ph->task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
@@ -489,7 +493,7 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
   }
   if (NULL != ph->client)
   {
-    GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
+    GNUNET_CLIENT_disconnect (ph->client);
     ph->client = NULL;
   }
   GNUNET_free (ph);