REST: nothing triggers rest
[oweals/gnunet.git] / src / ats / gnunet-service-ats_preferences.c
index 64779bbca4a3336d6c4afd37584a0132b5fd1694..26929ea7c7fdfc1ba2a71bd4e8371b4361b26423 100644 (file)
@@ -2,20 +2,20 @@
      This file is part of GNUnet.
      Copyright (C) 2011-2015 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 /**
  * @file ats/gnunet-service-ats_preferences.c
@@ -132,7 +132,7 @@ struct PreferenceClient
   /**
    * Client handle
    */
-  struct GNUNET_SERVER_Client *client;
+  struct GNUNET_SERVICE_Client *client;
 
   /**
    * Mapping peer identities to `struct PreferencePeer` entry
@@ -553,7 +553,7 @@ update_iterator (void *cls,
  * @param score_abs the normalized score
  */
 static void
-update_preference (struct GNUNET_SERVER_Client *client,
+update_preference (struct GNUNET_SERVICE_Client *client,
                    const struct GNUNET_PeerIdentity *peer,
                    enum GNUNET_ATS_PreferenceKind kind,
                    float score_abs)
@@ -646,41 +646,17 @@ update_preference (struct GNUNET_SERVER_Client *client,
 /**
  * Handle 'preference change' messages from clients.
  *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
+ * @param client the client that sent the request
+ * @param msg the request message
  */
 void
-GAS_handle_preference_change (void *cls,
-                              struct GNUNET_SERVER_Client *client,
-                              const struct GNUNET_MessageHeader *message)
+GAS_handle_preference_change (struct GNUNET_SERVICE_Client *client,
+                             const struct ChangePreferenceMessage *msg)
 {
-  const struct ChangePreferenceMessage *msg;
   const struct PreferenceInformation *pi;
-  uint16_t msize;
   uint32_t nump;
-  uint32_t i;
 
-  msize = ntohs (message->size);
-  if (msize < sizeof (struct ChangePreferenceMessage))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
-    return;
-  }
-  msg = (const struct ChangePreferenceMessage *) message;
   nump = ntohl (msg->num_preferences);
-  if ( (msize !=
-        sizeof (struct ChangePreferenceMessage) +
-        nump * sizeof (struct PreferenceInformation)) ||
-       (UINT16_MAX / sizeof (struct PreferenceInformation) < nump) )
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
-    return;
-  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received PREFERENCE_CHANGE message for peer `%s'\n",
               GNUNET_i2s (&msg->peer));
@@ -690,14 +666,12 @@ GAS_handle_preference_change (void *cls,
                             GNUNET_NO);
   pi = (const struct PreferenceInformation *) &msg[1];
   GAS_plugin_solver_lock ();
-  for (i = 0; i < nump; i++)
+  for (uint32_t i = 0; i < nump; i++)
     update_preference (client,
                        &msg->peer,
                        (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
                        pi[i].preference_value);
   GAS_plugin_solver_unlock ();
-  GNUNET_SERVER_receive_done (client,
-                              GNUNET_OK);
 }
 
 
@@ -782,7 +756,7 @@ GAS_preference_get_by_peer (void *cls,
  * @param client the client
  */
 void
-GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client)
+GAS_preference_client_disconnect (struct GNUNET_SERVICE_Client *client)
 {
   struct PreferenceClient *c_cur;