fixing mantis 2098:
[oweals/gnunet.git] / src / ats / gnunet-service-ats_scheduling.c
index 4af44e29bd4567598f6f09470c2c075168ea8414..f5e286a643e96c62797c7dcb65170966553a4dcf 100644 (file)
@@ -141,6 +141,12 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity
   addrp = (char *) &atsp[atsi_count];
   memcpy (addrp, plugin_addr, plugin_addr_len);
   strcpy (&addrp[plugin_addr_len], plugin_name);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "ATS sends quota for peer `%s': (in/out) %u/%u\n",
+              GNUNET_i2s (peer), ntohl (bandwidth_in.value__),
+              ntohl (bandwidth_out.value__));
+
   GNUNET_SERVER_notification_context_unicast (nc, my_client, &msg->header,
                                               GNUNET_YES);
 }
@@ -170,6 +176,31 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
 }
 
 
+/**
+ * Handle 'request address' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_request_address_cancel (void *cls,
+                                   struct GNUNET_SERVER_Client *client,
+                                   const struct GNUNET_MessageHeader *message)
+{
+  const struct RequestAddressMessage *msg =
+      (const struct RequestAddressMessage *) message;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+              "REQUEST_ADDRESS_CANCEL");
+  GNUNET_break (0 == ntohl (msg->reserved));
+
+  /* TODO */
+
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
 /**
  * Handle 'address update' messages from clients.
  *
@@ -246,9 +277,8 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
   uint16_t plugin_name_length;
 
   uint16_t size;
+  uint16_t in_use;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
-              "ADDRESS_IN_USE");
   size = ntohs (message->size);
   if (size < sizeof (struct AddressUseMessage))
   {
@@ -276,16 +306,10 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
     return;
   }
 
+  in_use = ntohs (m->in_use);
+  GAS_addresses_in_use (&m->peer, plugin_name, address, address_length,
+                        ntohl (m->session_id), in_use);
 
-/*
-  GAS_addresses_update (&m->peer,
-                        plugin_name,
-                        address,
-                        address_length,
-                        ntohl (m->session_id),
-                        atsi,
-                        ats_count);
-*/
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -334,7 +358,7 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  if ((plugin_name_length != 0) &&
+  if ((plugin_name_length == 0) ||
       (plugin_name[plugin_name_length - 1] != '\0'))
   {
     GNUNET_break (0);