/*
This file is part of GNUnet.
- Copyright (C) 2011-2015 Christian Grothoff (and other contributing authors)
+ 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 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.
+ 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/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* @file ats/plugin_ats_proportional.c
*/
#include "platform.h"
#include "gnunet_statistics_service.h"
-#include "gnunet_ats_plugin.h"
#include "gnunet_ats_service.h"
+#include "gnunet_ats_plugin.h"
#include "gnunet-service-ats_addresses.h"
#define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__)
/**
* ATS network type
*/
- enum GNUNET_ATS_Network_Type type;
+ enum GNUNET_NetworkType type;
/**
* Number of active addresses for this network
unsigned int na;
uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- GNUNET_assert (net->active_addresses + extra >= 0);
+ GNUNET_assert (((int)net->active_addresses) + extra >= 0);
na = net->active_addresses + extra;
if (0 == na)
return GNUNET_YES;
continue;
peer_relative_prefs = s->env->get_preferences (s->env->cls,
&aw->addr->peer);
- sum_relative_peer_prefences += peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
+ sum_relative_peer_prefences
+ += peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
count_addresses++;
}
if (count_addresses != net->active_addresses)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Redistributing bandwidth in network %s with %u active and %u total addresses\n",
- GNUNET_ATS_print_network_type(n->type),
+ GNUNET_NT_to_string(n->type),
n->active_addresses,
n->total_addresses);
s->env->info_cb (s->env->cls,
};
-/**
- * Find index of a ATS property type in the quality properties array.
- *
- * @param type ATS property type
- * @return index in the quality array, #GNUNET_SYSERR if the type
- * was not a quality property
- */
-static int
-find_quality_property_index (enum GNUNET_ATS_Property type)
-{
- enum GNUNET_ATS_Property existing_types[] = GNUNET_ATS_QualityProperties;
- unsigned int c;
-
- for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
- if (existing_types[c] == type)
- return c;
- GNUNET_break (0);
- return GNUNET_SYSERR;
-}
-
-
/**
* Find a "good" address to use for a peer by iterating over the
* addresses for this peer. If we already have an existing address,
double best_distance;
double cur_delay;
double cur_distance;
- int index;
unsigned int con;
int bw_available;
int need;
}
/* Now compare ATS information */
- index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
- cur_distance = current->atsin[index].norm;
- best_distance = ctx->best->atsin[index].norm;
- index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- cur_delay = current->atsin[index].norm;
- best_delay = ctx->best->atsin[index].norm;
+ cur_distance = current->norm_distance.norm;
+ best_distance = ctx->best->norm_distance.norm;
+ cur_delay = current->norm_delay.norm;
+ best_delay = ctx->best->norm_delay.norm;
/* user shorter distance */
if (cur_distance < best_distance)
aw_min = NULL;
for (aw = asi_best->network->head; NULL != aw; aw = aw->next)
{
- if (con_min >
- (a_con = s->env->get_connectivity (s->env->cls,
- &aw->addr->peer)))
+ if ( (con_min >
+ (a_con = s->env->get_connectivity (s->env->cls,
+ &aw->addr->peer))) &&
+ (GNUNET_YES == aw->addr->active) )
{
aw_min = aw;
con_min = a_con;
}
update_active_address (s,
aw_min->addr,
- &aw->addr->peer);
+ &aw_min->addr->peer);
}
distribute_bandwidth_in_network (s,
asi_best->network);
*/
static void
GAS_proportional_feedback (void *solver,
- struct GNUNET_SERVER_Client *application,
+ struct GNUNET_SERVICE_Client *application,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TIME_Relative scope,
enum GNUNET_ATS_PreferenceKind kind,
*
* @param solver solver handle
* @param address the address
- * @param type the ATSI type
- * @param abs_value the absolute value of the property
- * @param rel_value the normalized value
*/
static void
GAS_proportional_address_property_changed (void *solver,
- struct ATS_Address *address,
- enum GNUNET_ATS_Property type,
- uint32_t abs_value,
- double rel_value)
+ struct ATS_Address *address)
{
struct GAS_PROPORTIONAL_Handle *s = solver;
struct AddressWrapper *asi = address->solver_information;
static void
GAS_proportional_address_add (void *solver,
struct ATS_Address *address,
- enum GNUNET_ATS_Network_Type network)
+ uint32_t network)
{
struct GAS_PROPORTIONAL_Handle *s = solver;
struct Network *net;
cur->type = c;
cur->total_quota_in = env->in_quota[c];
cur->total_quota_out = env->out_quota[c];
- cur->desc = GNUNET_ATS_print_network_type (c);
+ cur->desc = GNUNET_NT_to_string (c);
GNUNET_asprintf (&cur->stat_total,
"# ATS addresses %s total",
cur->desc);