2 This file is part of GNUnet.
3 Copyright (C) 2011-2015 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats/gnunet-service-ats_feedback.c
22 * @brief ats service, handling of feedback
23 * @author Matthias Wachs
24 * @author Christian Grothoff
27 #include "gnunet-service-ats_plugins.h"
28 #include "gnunet-service-ats_feedback.h"
33 * Change the preference for a peer
35 * @param application the client sending this request
36 * @param peer the peer id
37 * @param scope the time interval for this feedback: [now - scope .. now]
38 * @param kind the preference kind to change
39 * @param score_abs the new preference score
42 preference_feedback (struct GNUNET_SERVER_Client *application,
43 const struct GNUNET_PeerIdentity *peer,
44 const struct GNUNET_TIME_Relative scope,
45 enum GNUNET_ATS_PreferenceKind kind,
48 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
49 "Received PREFERENCE FEEDBACK for peer `%s'\n",
51 GAS_plugin_preference_feedback (application,
60 * Handle 'preference feedback' messages from clients.
62 * @param cls unused, NULL
63 * @param client client that sent the request
64 * @param message the request message
67 GAS_handle_preference_feedback (void *cls,
68 struct GNUNET_SERVER_Client *client,
69 const struct GNUNET_MessageHeader *message)
71 const struct FeedbackPreferenceMessage *msg;
72 const struct PreferenceInformation *pi;
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
78 "Received PREFERENCE_FEEDBACK message\n");
79 msize = ntohs (message->size);
80 if (msize < sizeof (struct FeedbackPreferenceMessage))
83 GNUNET_SERVER_receive_done (client,
87 msg = (const struct FeedbackPreferenceMessage *) message;
88 nump = ntohl (msg->num_feedback);
90 sizeof (struct FeedbackPreferenceMessage) +
91 nump * sizeof (struct PreferenceInformation))
94 GNUNET_SERVER_receive_done (client,
99 GNUNET_CONTAINER_multipeermap_contains (GSA_addresses,
102 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
103 "Received PREFERENCE FEEDBACK for unknown peer `%s'\n",
104 GNUNET_i2s (&msg->peer));
108 GNUNET_STATISTICS_update (GSA_stats,
109 "# preference feedbacks requests processed",
112 pi = (const struct PreferenceInformation *) &msg[1];
113 for (i = 0; i < nump; i++)
114 preference_feedback (client,
116 GNUNET_TIME_relative_ntoh(msg->scope),
117 (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
118 pi[i].preference_value);
119 GNUNET_SERVER_receive_done (client,
123 /* end of gnunet-service-ats_feedback.c */