From: Christian Grothoff Date: Mon, 17 Oct 2011 07:12:24 +0000 (+0000) Subject: parse preference change messages X-Git-Tag: initial-import-from-subversion-38251~16492 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4b5e8dcb8d6f0d29fffb823e600c73be404d9b39;p=oweals%2Fgnunet.git parse preference change messages --- diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 5eb6a4e6e..9c504b26c 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -279,6 +279,17 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) } +// FIXME: this function should likely end up in the LP-subsystem and +// not with 'addresses' in the future... +void +GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer, + enum GNUNET_ATS_PreferenceKind kind, + float score) +{ + // do nothing for now... +} + + /** * Initialize address subsystem. * @@ -321,7 +332,6 @@ free_address_it (void *cls, } - /** * Shutdown address subsystem. */ diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index 849e9b31a..fdb3df678 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h @@ -29,6 +29,8 @@ #include "gnunet_util_lib.h" #include "gnunet_transport_service.h" // FIXME... +#include "gnunet_ats_service.h" +#include "ats.h" /** * Initialize address subsystem. @@ -73,6 +75,14 @@ void GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer); +// FIXME: this function should likely end up in the LP-subsystem and +// not with 'addresses' in the future... +void +GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer, + enum GNUNET_ATS_PreferenceKind kind, + float score); + + /* FIXME: add performance request API */ #endif diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 8a1ad611c..3a4acc641 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c @@ -25,6 +25,7 @@ * @author Christian Grothoff */ #include "platform.h" +#include "gnunet-service-ats_addresses.h" #include "gnunet-service-ats_performance.h" #include "gnunet-service-ats_reservations.h" #include "ats.h" @@ -242,9 +243,31 @@ void GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { - // const struct ChangePreferenceMessage * msg = (const struct ChangePreferenceMessage *) message; + const struct ChangePreferenceMessage * msg; + const struct PreferenceInformation *pi; + uint16_t msize; + uint32_t nump; + uint32_t i; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE"); - // FIXME: implement later (we can safely ignore these for now) + msize = ntohs (message->size); + if (msize < sizeof (struct ChangePreferenceMessage)) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + } + msg = (const struct ChangePreferenceMessage *) message; + nump = ntohl (msg->num_preferences); + if (msize != sizeof (struct ChangePreferenceMessage) * nump * sizeof (struct PreferenceInformation)) + { + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + } + pi = (const struct PreferenceInformation *) &msg[1]; + for (i=0;ipeer, + (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind), + pi[i].preference_value); GNUNET_SERVER_receive_done (client, GNUNET_OK); }