changing type
[oweals/gnunet.git] / src / transport / gnunet-service-transport_clients.c
index 939f57b10c072ae2ff7041bdede3dee3a6e34b3d..294af9ba91cd1282ce38d3f9a24a6892f137a621 100644 (file)
@@ -339,6 +339,12 @@ unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg,
   struct ClientMessageQueueEntry *q;
   uint16_t msize;
 
+  if (msg == NULL)
+  {
+    GNUNET_break (0);
+    return;
+  }
+
   if ((tc->message_count >= MAX_PENDING) && (GNUNET_YES == may_drop))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -425,13 +431,17 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
  * @param address the address
+ * @param bandwidth_in inbound bandwidth in NBO
+ * @param bandwidth_out outbound bandwidth in NBO
  */
 static void
 notify_client_about_neighbour (void *cls,
                                const struct GNUNET_PeerIdentity *peer,
                                const struct GNUNET_ATS_Information *ats,
                                uint32_t ats_count,
-                               const struct GNUNET_HELLO_Address *address)
+                               const struct GNUNET_HELLO_Address *address,
+                               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   struct TransportClient *tc = cls;
   struct ConnectInfoMessage *cim;
@@ -439,7 +449,7 @@ notify_client_about_neighbour (void *cls,
   size_t size =
       sizeof (struct ConnectInfoMessage) +
       ats_count * sizeof (struct GNUNET_ATS_Information);
-  char buf[size];
+  char buf[size] GNUNET_ALIGN;
 
   GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
   cim = (struct ConnectInfoMessage *) buf;
@@ -447,6 +457,8 @@ notify_client_about_neighbour (void *cls,
   cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
   cim->ats_count = htonl (ats_count);
   cim->id = *peer;
+  cim->quota_in = bandwidth_in;
+  cim->quota_out = bandwidth_out;
   ap = (struct GNUNET_ATS_Information *) &cim[1];
   memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
   unicast (tc, &cim->header, GNUNET_NO);
@@ -610,10 +622,7 @@ clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client,
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  GNUNET_STATISTICS_update (GST_stats,
-                            gettext_noop
-                            ("# bytes payload received for other peers"), msize,
-                            GNUNET_NO);
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received `%s' request from client with target `%4s' and first message of type %u and total size %u\n",
               "SEND", GNUNET_i2s (&obm->peer), ntohs (obmm->type), msize);
@@ -760,7 +769,7 @@ clients_handle_address_to_string (void *cls,
   rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
   numeric = ntohs (alum->numeric_only);
   tc = GNUNET_SERVER_transmit_context_create (client);
-  papi = GST_plugins_find (plugin_name);
+  papi = GST_plugins_printer_find (plugin_name);
   if (NULL == papi)
   {
     GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
@@ -769,10 +778,6 @@ clients_handle_address_to_string (void *cls,
     return;
   }
   GNUNET_SERVER_disable_receive_done_warning (client);
-  if ((NULL == address) || (0 == address_len))
-  {
-    GNUNET_break_op (0);
-  }
   papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
                                 numeric, rtimeout, &transmit_address_to_client,
                                 tc);
@@ -833,11 +838,15 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
  * @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
  */
 static void
 output_address (void *cls, const struct GNUNET_PeerIdentity *peer,
                 const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
-                const struct GNUNET_HELLO_Address *address)
+                const struct GNUNET_HELLO_Address *address,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   struct GNUNET_SERVER_TransmitContext *tc = cls;
   struct AddressIterateResponseMessage *msg;
@@ -901,7 +910,9 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
     /* just return one neighbour */
     address = GST_neighbour_get_current_address (&msg->peer);
     if (address != NULL)
-      output_address (tc, &msg->peer, NULL, 0, address);
+      output_address (tc, &msg->peer, NULL, 0, address,
+                      GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+                      GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT);
   }
   if (GNUNET_YES != ntohl (msg->one_shot))
     setup_monitoring_client (client, &msg->peer);