/*
This file is part of GNUnet.
- (C) 2011-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2011-2014 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
/**
* ATS network type
*/
- unsigned int type;
+ enum GNUNET_ATS_Network_Type type;
/**
* Network description
struct AddressSolverInformation *asi;
struct GNUNET_TIME_Relative active_time;
struct GNUNET_TIME_Relative min_active_time;
- const double *norm_prop_cur;
- const double *norm_prop_best;
double best_delay;
double best_distance;
double cur_delay;
}
/* Now compare ATS information */
- norm_prop_cur = ctx->s->env->get_property (ctx->s->env->cls,
- current);
index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
- cur_distance = norm_prop_cur[index];
+ cur_distance = current->atsin[index].norm;
+ best_distance = ctx->best->atsin[index].norm;
index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- cur_delay = norm_prop_cur[index];
-
- norm_prop_best = ctx->s->env->get_property (ctx->s->env->cls,
- ctx->best);
- index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
- best_distance = norm_prop_best[index];
- index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- best_delay = norm_prop_best[index];
+ cur_delay = current->atsin[index].norm;
+ best_delay = ctx->best->atsin[index].norm;
/* user shorter distance */
if (cur_distance < best_distance)
const struct GNUNET_CONTAINER_MultiPeerMap * addresses,
const struct GNUNET_PeerIdentity *peer)
{
- static struct ATS_Address * dest = NULL;
+ static struct ATS_Address *dest;
dest = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (addresses, peer,
- &get_active_address_it, &dest);
+ &get_active_address_it,
+ &dest);
return dest;
}
* @return the network struct
*/
static struct Network *
-get_network (struct GAS_PROPORTIONAL_Handle *s, uint32_t type)
+get_network (struct GAS_PROPORTIONAL_Handle *s,
+ enum GNUNET_ATS_Network_Type type)
{
- int c;
- for (c = 0; c < s->network_count; c++)
+ if (type >= s->env->network_count)
{
- if (s->network_entries[c].type == type)
- return &s->network_entries[c];
+ GNUNET_break (0);
+ return NULL;
}
- return NULL ;
+ return &s->network_entries[type];
}
GNUNET_ATS_print_network_type(n->type),
n->active_addresses, n->total_addresses);
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_START,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_SINGLE);
/* Distribute */
distribute_bandwidth(s, n);
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_STOP,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_SINGLE);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_SINGLE);
/* Do propagation */
propagate_bandwidth (s, n);
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_SINGLE);
}
else
{
int i;
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_START,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_ALL);
for (i = 0; i < s->network_count; i++)
{
/* Distribute */
distribute_bandwidth(s, &s->network_entries[i]);
}
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_STOP,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_ALL);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_ALL);
for (i = 0; i < s->network_count; i++)
{
/* Do propagation */
propagate_bandwidth(s, &s->network_entries[i]);
}
- if (NULL != s->env->info_cb)
- s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
- GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+ s->env->info_cb (s->env->cls,
+ GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
+ GAS_STAT_SUCCESS,
+ GAS_INFO_PROP_ALL);
}
}
static void
GAS_proportional_address_property_changed (void *solver,
struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
uint32_t abs_value,
double rel_value)
{
static void
GAS_proportional_address_add (void *solver,
struct ATS_Address *address,
- uint32_t network)
+ enum GNUNET_ATS_Network_Type network)
{
struct GAS_PROPORTIONAL_Handle *s = solver;
- struct Network *net = NULL;
- struct AddressWrapper *aw = NULL;
+ struct Network *net;
+ struct AddressWrapper *aw;
struct AddressSolverInformation *asi;
- GNUNET_assert(NULL != s);
net = get_network (s, network);
if (NULL == net)
{
- GNUNET_break(0);
-
- LOG(GNUNET_ERROR_TYPE_ERROR,
- "Unknown network %u `%s' for new address %p for peer `%s'\n",
- network, GNUNET_ATS_print_network_type(network),
- address, GNUNET_i2s(&address->peer));
-
+ GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Unknown network %u `%s' for new address %p for peer `%s'\n",
+ network,
+ GNUNET_ATS_print_network_type (network),
+ address,
+ GNUNET_i2s (&address->peer));
return;
}
GNUNET_assert (NULL != env->cfg);
GNUNET_assert (NULL != env->bandwidth_changed_cb);
GNUNET_assert (NULL != env->get_preferences);
- GNUNET_assert (NULL != env->get_property);
s = GNUNET_new (struct GAS_PROPORTIONAL_Handle);
s->env = env;
for (c = 0; c < env->network_count; c++)
{
cur = &s->network_entries[c];
- cur->type = env->networks[c];
+ 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);