aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_mlp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-06 09:28:57 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-06 09:28:57 +0000
commit66d788dbe9224b7d3e51ad60d2a29a167b2e348d (patch)
treedd1737e137f070c01ef42800c4fe625f526d0214 /src/ats/plugin_ats_mlp.c
parent170d5baeece2def099112c6a25287a95d2b28899 (diff)
downloadgnunet-66d788dbe9224b7d3e51ad60d2a29a167b2e348d.tar.gz
gnunet-66d788dbe9224b7d3e51ad60d2a29a167b2e348d.zip
get rid of stupid network[i]=i array
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r--src/ats/plugin_ats_mlp.c117
1 files changed, 46 insertions, 71 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 11f74a37f..23fbf5063 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -2420,14 +2420,11 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2420 static struct GNUNET_ATS_SolverFunctions sf; 2420 static struct GNUNET_ATS_SolverFunctions sf;
2421 struct GNUNET_ATS_PluginEnvironment *env = cls; 2421 struct GNUNET_ATS_PluginEnvironment *env = cls;
2422 struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle); 2422 struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle);
2423
2424 float f_tmp; 2423 float f_tmp;
2425 unsigned long long tmp; 2424 unsigned long long tmp;
2426 unsigned int b_min; 2425 unsigned int b_min;
2427 unsigned int n_min; 2426 unsigned int n_min;
2428 int c; 2427 int c;
2429 int c2;
2430 int found;
2431 char *outputformat; 2428 char *outputformat;
2432 2429
2433 struct GNUNET_TIME_Relative max_duration; 2430 struct GNUNET_TIME_Relative max_duration;
@@ -2740,77 +2737,55 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2740 n_min = MLP_DEFAULT_MIN_CONNECTIONS; 2737 n_min = MLP_DEFAULT_MIN_CONNECTIONS;
2741 2738
2742 /* Init network quotas */ 2739 /* Init network quotas */
2743 int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
2744 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 2740 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
2745 { 2741 {
2746 found = GNUNET_NO; 2742 mlp->pv.quota_index[c] = c;
2747 for (c2 = 0; c2 < env->network_count; c2++) 2743 mlp->pv.quota_out[c] = env->out_quota[c];
2748 { 2744 mlp->pv.quota_in[c] = env->in_quota[c];
2749 if (quotas[c] == env->networks[c2])
2750 {
2751 mlp->pv.quota_index[c] = env->networks[c2];
2752 mlp->pv.quota_out[c] = env->out_quota[c2];
2753 mlp->pv.quota_in[c] = env->in_quota[c2];
2754
2755 found = GNUNET_YES;
2756 LOG (GNUNET_ERROR_TYPE_INFO,
2757 "Quota for network `%s' (in/out) %llu/%llu\n",
2758 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2759 mlp->pv.quota_out[c],
2760 mlp->pv.quota_in[c]);
2761 break;
2762
2763 }
2764 }
2765
2766 /* Check if defined quota could make problem unsolvable */
2767 if ((n_min * b_min) > mlp->pv.quota_out[c])
2768 {
2769 LOG (GNUNET_ERROR_TYPE_INFO,
2770 _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2771 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2772 mlp->pv.quota_out[c],
2773 (n_min * b_min));
2774 mlp->pv.quota_out[c] = (n_min * b_min);
2775 }
2776 if ((n_min * b_min) > mlp->pv.quota_in[c])
2777 {
2778 LOG (GNUNET_ERROR_TYPE_INFO,
2779 _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2780 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2781 mlp->pv.quota_in[c],
2782 (n_min * b_min));
2783 mlp->pv.quota_in[c] = (n_min * b_min);
2784 }
2785
2786 /* Check if bandwidth is too big to make problem solvable */
2787 if (mlp->pv.BIG_M < mlp->pv.quota_out[c])
2788 {
2789 LOG (GNUNET_ERROR_TYPE_INFO,
2790 _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
2791 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2792 mlp->pv.quota_out[c],
2793 mlp->pv.BIG_M);
2794 mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
2795 }
2796 if (mlp->pv.BIG_M < mlp->pv.quota_in[c])
2797 {
2798 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
2799 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2800 mlp->pv.quota_in[c],
2801 mlp->pv.BIG_M);
2802 mlp->pv.quota_in[c] = mlp->pv.BIG_M ;
2803 }
2804 2745
2805 if (GNUNET_NO == found) 2746 LOG (GNUNET_ERROR_TYPE_INFO,
2806 { 2747 "Quota for network `%s' (in/out) %llu/%llu\n",
2807 mlp->pv.quota_in[c] = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 2748 GNUNET_ATS_print_network_type (c),
2808 mlp->pv.quota_out[c] = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 2749 mlp->pv.quota_out[c],
2809 LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"), 2750 mlp->pv.quota_in[c]);
2810 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2751 /* Check if defined quota could make problem unsolvable */
2811 mlp->pv.quota_in[c], 2752 if ((n_min * b_min) > mlp->pv.quota_out[c])
2812 mlp->pv.quota_out[c]); 2753 {
2813 } 2754 LOG (GNUNET_ERROR_TYPE_INFO,
2755 _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2756 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2757 mlp->pv.quota_out[c],
2758 (n_min * b_min));
2759 mlp->pv.quota_out[c] = (n_min * b_min);
2760 }
2761 if ((n_min * b_min) > mlp->pv.quota_in[c])
2762 {
2763 LOG (GNUNET_ERROR_TYPE_INFO,
2764 _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2765 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2766 mlp->pv.quota_in[c],
2767 (n_min * b_min));
2768 mlp->pv.quota_in[c] = (n_min * b_min);
2769 }
2770 /* Check if bandwidth is too big to make problem solvable */
2771 if (mlp->pv.BIG_M < mlp->pv.quota_out[c])
2772 {
2773 LOG (GNUNET_ERROR_TYPE_INFO,
2774 _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
2775 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2776 mlp->pv.quota_out[c],
2777 mlp->pv.BIG_M);
2778 mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
2779 }
2780 if (mlp->pv.BIG_M < mlp->pv.quota_in[c])
2781 {
2782 LOG (GNUNET_ERROR_TYPE_INFO,
2783 _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
2784 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2785 mlp->pv.quota_in[c],
2786 mlp->pv.BIG_M);
2787 mlp->pv.quota_in[c] = mlp->pv.BIG_M ;
2788 }
2814 } 2789 }
2815 mlp->env = env; 2790 mlp->env = env;
2816 sf.cls = mlp; 2791 sf.cls = mlp;