socklen_t addrlen)
{
struct ATS_Network *cur = is->net_head;
- enum GNUNET_ATS_NetworkType type = GNUNET_ATS_NET_UNSPECIFIED;
+ enum GNUNET_ATS_Network_Type type = GNUNET_ATS_NET_UNSPECIFIED;
switch (addr->sa_family)
{
{
struct SolverHandle *sh;
char * solver_str;
- int c;
switch (type) {
case GNUNET_ATS_SOLVER_PROPORTIONAL:
sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
sh->env.info_cb = &solver_info_cb;
sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
- int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
- for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
- sh->env.networks[c] = networks[c];
-
/* start normalization */
GAS_normalization_start ();
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GAS_addresses_done ();
+ GAS_connectivity_done ();
GAS_plugins_done ();
GAS_normalization_stop ();
GAS_scheduling_done ();
- GAS_connectivity_done ();
GAS_performance_done ();
GAS_preference_done ();
GAS_reservations_done ();
GNUNET_free(mode_str);
}
- load_quotas (cfg, quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount);
+ load_quotas (cfg,
+ quotas_out,
+ quotas_in,
+ GNUNET_ATS_NetworkTypeCount);
env.cls = NULL;
env.info_cb = &solver_info_cb;
env.bandwidth_changed_cb = &bandwidth_changed_cb;
env.cfg = cfg;
env.stats = GSA_stats;
env.addresses = GSA_addresses;
-
env.network_count = GNUNET_ATS_NetworkTypeCount;
- int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
- env.networks[c] = networks[c];
env.out_quota[c] = quotas_out[c];
env.in_quota[c] = quotas_in[c];
}
ph.env.network_count = GNUNET_ATS_NetworkTypeCount;
ph.env.info_cb = &solver_info_cb;
- int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
- ph.env.networks[c] = networks[c];
ph.env.out_quota[c] = quotas_out[c];
ph.env.in_quota[c] = quotas_in[c];
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loading network quotas: `%s' %llu %llu \n",
- GNUNET_ATS_print_network_type(ph.env.networks[c]),
- ph.env.out_quota[c],
- ph.env.in_quota[c]);
+ GNUNET_ATS_print_network_type (c),
+ ph.env.out_quota[c],
+ ph.env.in_quota[c]);
}
GAS_normalization_start ();
static struct GNUNET_ATS_SolverFunctions sf;
struct GNUNET_ATS_PluginEnvironment *env = cls;
struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle);
-
float f_tmp;
unsigned long long tmp;
unsigned int b_min;
unsigned int n_min;
int c;
- int c2;
- int found;
char *outputformat;
struct GNUNET_TIME_Relative max_duration;
n_min = MLP_DEFAULT_MIN_CONNECTIONS;
/* Init network quotas */
- int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
- found = GNUNET_NO;
- for (c2 = 0; c2 < env->network_count; c2++)
- {
- if (quotas[c] == env->networks[c2])
- {
- mlp->pv.quota_index[c] = env->networks[c2];
- mlp->pv.quota_out[c] = env->out_quota[c2];
- mlp->pv.quota_in[c] = env->in_quota[c2];
-
- found = GNUNET_YES;
- LOG (GNUNET_ERROR_TYPE_INFO,
- "Quota for network `%s' (in/out) %llu/%llu\n",
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_out[c],
- mlp->pv.quota_in[c]);
- break;
-
- }
- }
-
- /* Check if defined quota could make problem unsolvable */
- if ((n_min * b_min) > mlp->pv.quota_out[c])
- {
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_out[c],
- (n_min * b_min));
- mlp->pv.quota_out[c] = (n_min * b_min);
- }
- if ((n_min * b_min) > mlp->pv.quota_in[c])
- {
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_in[c],
- (n_min * b_min));
- mlp->pv.quota_in[c] = (n_min * b_min);
- }
-
- /* Check if bandwidth is too big to make problem solvable */
- if (mlp->pv.BIG_M < mlp->pv.quota_out[c])
- {
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_out[c],
- mlp->pv.BIG_M);
- mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
- }
- if (mlp->pv.BIG_M < mlp->pv.quota_in[c])
- {
- LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_in[c],
- mlp->pv.BIG_M);
- mlp->pv.quota_in[c] = mlp->pv.BIG_M ;
- }
+ mlp->pv.quota_index[c] = c;
+ mlp->pv.quota_out[c] = env->out_quota[c];
+ mlp->pv.quota_in[c] = env->in_quota[c];
- if (GNUNET_NO == found)
- {
- mlp->pv.quota_in[c] = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- mlp->pv.quota_out[c] = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"),
- GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
- mlp->pv.quota_in[c],
- mlp->pv.quota_out[c]);
- }
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Quota for network `%s' (in/out) %llu/%llu\n",
+ GNUNET_ATS_print_network_type (c),
+ mlp->pv.quota_out[c],
+ mlp->pv.quota_in[c]);
+ /* Check if defined quota could make problem unsolvable */
+ if ((n_min * b_min) > mlp->pv.quota_out[c])
+ {
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_out[c],
+ (n_min * b_min));
+ mlp->pv.quota_out[c] = (n_min * b_min);
+ }
+ if ((n_min * b_min) > mlp->pv.quota_in[c])
+ {
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_in[c],
+ (n_min * b_min));
+ mlp->pv.quota_in[c] = (n_min * b_min);
+ }
+ /* Check if bandwidth is too big to make problem solvable */
+ if (mlp->pv.BIG_M < mlp->pv.quota_out[c])
+ {
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_out[c],
+ mlp->pv.BIG_M);
+ mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
+ }
+ if (mlp->pv.BIG_M < mlp->pv.quota_in[c])
+ {
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_in[c],
+ mlp->pv.BIG_M);
+ mlp->pv.quota_in[c] = mlp->pv.BIG_M ;
+ }
}
mlp->env = env;
sf.cls = mlp;
/**
* ATS network type
*/
- unsigned int type;
+ enum GNUNET_ATS_Network_Type type;
/**
* Network description
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];
}
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;
}
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);
for (c = 0; c < env->network_count; c++)
{
cur = &solver->network_entries[c];
- cur->type = env->networks[c];
+ cur->type = c;
cur->bw_in_available = env->in_quota[c];
cur->bw_out_available = env->out_quota[c];
LOG(GNUNET_ERROR_TYPE_DEBUG, "init() Quotas for %s network: IN %llu - OUT %llu\n", GNUNET_ATS_print_network_type(cur->type), cur->bw_in_available/1024, cur->bw_out_available/1024);
GAS_solver_information_callback info_cb;
/**
- * Available networks
+ * Number of networks available, size of the @e out_quota
+ * and @e in_quota arrays.
*/
- int networks[GNUNET_ATS_NetworkTypeCount];
-
- /**
- * Number of networks available
- */
- int network_count;
+ unsigned int network_count;
/**
* Array of configured outbound quotas
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
-/**
- * Number of network types supported by ATS
- */
-#define GNUNET_ATS_NetworkTypeCount 6
-
-
/**
* Types of networks (with separate quotas) we support.
*/
* Bluetooth LAN
*/
GNUNET_ATS_NET_BT = 5
-};
-
/**
- * ATS network types as array initializer
+ * Number of network types supported by ATS
*/
-#define GNUNET_ATS_NetworkType { GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN, GNUNET_ATS_NET_BT }
+#define GNUNET_ATS_NetworkTypeCount 6
+};
/**