/* This file is part of GNUnet. (C) 2011 Christian Grothoff (and other contributing authors) 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 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. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @file ats/gnunet-service-ats_addresses_simplistic.h * @brief ats simplistic ressource assignment * @author Matthias Wachs * @author Christian Grothoff */ #include "platform.h" #include "gnunet_statistics_service.h" #include "gnunet-service-ats_addresses.h" #define BIG_M_STRING "unlimited" /** * Init the simplistic problem solving component * * Quotas: * network[i] contains the network type as type GNUNET_ATS_NetworkType[i] * out_quota[i] contains outbound quota for network type i * in_quota[i] contains inbound quota for network type i * * Example * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN} * network[2] == GNUNET_ATS_NET_LAN * out_quota[2] == 65353 * in_quota[2] == 65353 * * @param cfg configuration handle * @param stats the GNUNET_STATISTICS handle * @param network array of GNUNET_ATS_NetworkType with length dest_length * @param out_quota array of outbound quotas * @param in_quota array of outbound quota * @param dest_length array length for quota arrays * @param bw_changed_cb callback for changed bandwidth amounts * @param bw_changed_cb_cls cls for callback * @return handle for the solver on success, NULL on fail */ void * GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_STATISTICS_Handle *stats, int *network, unsigned long long *out_quota, unsigned long long *in_quota, int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, void *bw_changed_cb_cls); /** * Shutdown the simplistic problem solving component * * @param solver the respective handle to shutdown */ void GAS_simplistic_done (void * solver); /** * Add a single address to the solve * * @param solver the solver Handle * @param addresses the address hashmap containing all addresses * @param address the address to add */ void GAS_simplistic_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address); /** * Updates a single address in the solve * * @param solver the solver Handle * @param addresses the address hashmap containing all addresses * @param address the update address * @param session the new session (if changed otherwise current) * @param in_use the new address in use state (if changed otherwise current) * @param atsi the latest ATS information * @param atsi_count the atsi count */ void GAS_simplistic_address_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap *addresses, struct ATS_Address *address, uint32_t session, int in_use, const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count); /** * Remove an address from the solver * * @param solver the solver handle * @param addresses the address hashmap containing all addresses * @param address the address to remove * @param session_only delete only session not whole address */ void GAS_simplistic_address_delete (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address, int session_only); /** * Get the prefered address for a specific peer * * @param solver the solver handle * @param addresses the address hashmap containing all addresses * @param peer the identity of the peer */ const struct ATS_Address * GAS_simplistic_get_preferred_address (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, const struct GNUNET_PeerIdentity *peer); /** * Changes the preferences for a peer in the problem * * @param solver the solver handle * @param peer the peer to change the preference for * @param kind the kind to change the preference * @param score the score */ void GAS_simplistic_address_change_preference (void *solver, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score); /* end of gnunet-service-ats_addresses_simplistic.h */