[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35119 - in gnunet/src: ats include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35119 - in gnunet/src: ats include |
Date: |
Fri, 6 Feb 2015 10:28:57 +0100 |
Author: grothoff
Date: 2015-02-06 10:28:57 +0100 (Fri, 06 Feb 2015)
New Revision: 35119
Modified:
gnunet/src/ats/ats_api_scanner.c
gnunet/src/ats/gnunet-ats-solver-eval.c
gnunet/src/ats/gnunet-service-ats.c
gnunet/src/ats/gnunet-service-ats_plugins.c
gnunet/src/ats/perf_ats_solver.c
gnunet/src/ats/plugin_ats_mlp.c
gnunet/src/ats/plugin_ats_proportional.c
gnunet/src/ats/plugin_ats_ril.c
gnunet/src/include/gnunet_ats_plugin.h
gnunet/src/include/gnunet_ats_service.h
Log:
get rid of stupid network[i]=i array
Modified: gnunet/src/ats/ats_api_scanner.c
===================================================================
--- gnunet/src/ats/ats_api_scanner.c 2015-02-06 09:00:14 UTC (rev 35118)
+++ gnunet/src/ats/ats_api_scanner.c 2015-02-06 09:28:57 UTC (rev 35119)
@@ -331,7 +331,7 @@
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)
{
Modified: gnunet/src/ats/gnunet-ats-solver-eval.c
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.c 2015-02-06 09:00:14 UTC (rev
35118)
+++ gnunet/src/ats/gnunet-ats-solver-eval.c 2015-02-06 09:28:57 UTC (rev
35119)
@@ -3057,7 +3057,6 @@
{
struct SolverHandle *sh;
char * solver_str;
- int c;
switch (type) {
case GNUNET_ATS_SOLVER_PROPORTIONAL:
@@ -3091,11 +3090,7 @@
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 ();
Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2015-02-06 09:00:14 UTC (rev 35118)
+++ gnunet/src/ats/gnunet-service-ats.c 2015-02-06 09:28:57 UTC (rev 35119)
@@ -126,10 +126,10 @@
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 ();
Modified: gnunet/src/ats/gnunet-service-ats_plugins.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-06 09:00:14 UTC (rev
35118)
+++ gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-06 09:28:57 UTC (rev
35119)
@@ -452,7 +452,10 @@
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;
@@ -461,12 +464,9 @@
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];
}
Modified: gnunet/src/ats/perf_ats_solver.c
===================================================================
--- gnunet/src/ats/perf_ats_solver.c 2015-02-06 09:00:14 UTC (rev 35118)
+++ gnunet/src/ats/perf_ats_solver.c 2015-02-06 09:28:57 UTC (rev 35119)
@@ -1307,16 +1307,14 @@
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 ();
Modified: gnunet/src/ats/plugin_ats_mlp.c
===================================================================
--- gnunet/src/ats/plugin_ats_mlp.c 2015-02-06 09:00:14 UTC (rev 35118)
+++ gnunet/src/ats/plugin_ats_mlp.c 2015-02-06 09:28:57 UTC (rev 35119)
@@ -2420,14 +2420,11 @@
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;
@@ -2740,77 +2737,55 @@
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];
+ mlp->pv.quota_index[c] = c;
+ mlp->pv.quota_out[c] = env->out_quota[c];
+ mlp->pv.quota_in[c] = env->in_quota[c];
- 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 ;
- }
-
- 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;
Modified: gnunet/src/ats/plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/plugin_ats_proportional.c 2015-02-06 09:00:14 UTC (rev
35118)
+++ gnunet/src/ats/plugin_ats_proportional.c 2015-02-06 09:28:57 UTC (rev
35119)
@@ -282,7 +282,7 @@
/**
* ATS network type
*/
- unsigned int type;
+ enum GNUNET_ATS_Network_Type type;
/**
* Network description
@@ -875,11 +875,12 @@
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;
}
@@ -892,15 +893,15 @@
* @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];
}
@@ -1672,24 +1673,23 @@
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;
}
@@ -1807,7 +1807,7 @@
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);
Modified: gnunet/src/ats/plugin_ats_ril.c
===================================================================
--- gnunet/src/ats/plugin_ats_ril.c 2015-02-06 09:00:14 UTC (rev 35118)
+++ gnunet/src/ats/plugin_ats_ril.c 2015-02-06 09:28:57 UTC (rev 35119)
@@ -2799,7 +2799,7 @@
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);
Modified: gnunet/src/include/gnunet_ats_plugin.h
===================================================================
--- gnunet/src/include/gnunet_ats_plugin.h 2015-02-06 09:00:14 UTC (rev
35118)
+++ gnunet/src/include/gnunet_ats_plugin.h 2015-02-06 09:28:57 UTC (rev
35119)
@@ -464,16 +464,12 @@
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];
+ unsigned int network_count;
/**
- * Number of networks available
- */
- int network_count;
-
- /**
* Array of configured outbound quotas
* Order according to networks in network array
*/
Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h 2015-02-06 09:00:14 UTC (rev
35118)
+++ gnunet/src/include/gnunet_ats_service.h 2015-02-06 09:28:57 UTC (rev
35119)
@@ -31,12 +31,6 @@
#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.
*/
enum GNUNET_ATS_Network_Type
@@ -70,14 +64,13 @@
* 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
+};
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35119 - in gnunet/src: ats include,
gnunet <=