aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-ats-solver-eval.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
commitc76f29f898f6b1a73f33ce6d2578e06ce8e0a24e (patch)
tree4d9fbf87fa9d65b8b966b51739af96205943be8f /src/ats/gnunet-ats-solver-eval.c
parentf6323d915af7494ecfeba39407d1c30dc06dc238 (diff)
downloadgnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.tar.gz
gnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.zip
use ATS functions to convert quality network type to string, instead of using string API
Diffstat (limited to 'src/ats/gnunet-ats-solver-eval.c')
-rw-r--r--src/ats/gnunet-ats-solver-eval.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 0fa83d741..58fe03e25 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -1706,17 +1706,19 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
1706 return GNUNET_OK; 1706 return GNUNET_OK;
1707} 1707}
1708 1708
1709
1709static enum GNUNET_ATS_Property 1710static enum GNUNET_ATS_Property
1710parse_property_string (const char * str) 1711parse_property_string (const char *str)
1711{ 1712{
1712 int c = 0; 1713 enum GNUNET_ATS_Property c;
1713 char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
1714 1714
1715 for (c = 0; c < GNUNET_ATS_PropertyCount; c++) 1715 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1716 if (0 == strcmp(str, props[c])) 1716 if (0 == strcmp(str,
1717 GNUNET_ATS_print_property_type (c)))
1717 return c; 1718 return c;
1718 return 0; 1719 return 0;
1719}; 1720}
1721
1720 1722
1721static int 1723static int
1722load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, 1724load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
@@ -2770,7 +2772,6 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2770 unsigned long long *in_dest, 2772 unsigned long long *in_dest,
2771 int dest_length) 2773 int dest_length)
2772{ 2774{
2773 char *network_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
2774 char * entry_in = NULL; 2775 char * entry_in = NULL;
2775 char * entry_out = NULL; 2776 char * entry_out = NULL;
2776 char * quota_out_str; 2777 char * quota_out_str;
@@ -2782,8 +2783,12 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2782 { 2783 {
2783 in_dest[c] = 0; 2784 in_dest[c] = 0;
2784 out_dest[c] = 0; 2785 out_dest[c] = 0;
2785 GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); 2786 GNUNET_asprintf (&entry_out,
2786 GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); 2787 "%s_QUOTA_OUT",
2788 GNUNET_ATS_print_network_type (c));
2789 GNUNET_asprintf (&entry_in,
2790 "%s_QUOTA_IN",
2791 GNUNET_ATS_print_network_type (c));
2787 2792
2788 /* quota out */ 2793 /* quota out */
2789 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str)) 2794 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
@@ -2801,21 +2806,28 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2801 2806
2802 if (GNUNET_NO == res) 2807 if (GNUNET_NO == res)
2803 { 2808 {
2804 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 2809 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2805 network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth); 2810 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2811 GNUNET_ATS_print_network_type (c),
2812 quota_out_str,
2813 GNUNET_ATS_DefaultBandwidth);
2806 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2814 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2807 } 2815 }
2808 else 2816 else
2809 { 2817 {
2810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Outbound quota configure for network `%s' is %llu\n"), 2818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2811 network_str[c], out_dest[c]); 2819 "Outbound quota configure for network `%s' is %llu\n",
2820 GNUNET_ATS_print_network_type (c),
2821 out_dest[c]);
2812 } 2822 }
2813 GNUNET_free (quota_out_str); 2823 GNUNET_free (quota_out_str);
2814 } 2824 }
2815 else 2825 else
2816 { 2826 {
2817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), 2827 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2818 network_str[c], GNUNET_ATS_DefaultBandwidth); 2828 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2829 GNUNET_ATS_print_network_type (c),
2830 GNUNET_ATS_DefaultBandwidth);
2819 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2831 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2820 } 2832 }
2821 2833
@@ -2835,30 +2847,42 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2835 2847
2836 if (GNUNET_NO == res) 2848 if (GNUNET_NO == res)
2837 { 2849 {
2838 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 2850 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2839 network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth); 2851 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2852 GNUNET_ATS_print_network_type (c),
2853 quota_in_str,
2854 GNUNET_ATS_DefaultBandwidth);
2840 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 2855 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
2841 } 2856 }
2842 else 2857 else
2843 { 2858 {
2844 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Inbound quota configured for network `%s' is %llu\n"), 2859 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2845 network_str[c], in_dest[c]); 2860 "Inbound quota configured for network `%s' is %llu\n",
2861 GNUNET_ATS_print_network_type (c),
2862 in_dest[c]);
2846 } 2863 }
2847 GNUNET_free (quota_in_str); 2864 GNUNET_free (quota_in_str);
2848 } 2865 }
2849 else 2866 else
2850 { 2867 {
2851 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), 2868 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2852 network_str[c], GNUNET_ATS_DefaultBandwidth); 2869 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
2870 GNUNET_ATS_print_network_type (c),
2871 GNUNET_ATS_DefaultBandwidth);
2853 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2872 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2854 } 2873 }
2855 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]); 2874 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2875 "Loaded quota for network `%s' (in/out): %llu %llu\n",
2876 GNUNET_ATS_print_network_type (c),
2877 in_dest[c],
2878 out_dest[c]);
2856 GNUNET_free (entry_out); 2879 GNUNET_free (entry_out);
2857 GNUNET_free (entry_in); 2880 GNUNET_free (entry_in);
2858 } 2881 }
2859 return GNUNET_ATS_NetworkTypeCount; 2882 return GNUNET_ATS_NetworkTypeCount;
2860} 2883}
2861 2884
2885
2862/** 2886/**
2863 * Information callback for the solver 2887 * Information callback for the solver
2864 * 2888 *
@@ -2869,9 +2893,9 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2869 */ 2893 */
2870static void 2894static void
2871solver_info_cb (void *cls, 2895solver_info_cb (void *cls,
2872 enum GAS_Solver_Operation op, 2896 enum GAS_Solver_Operation op,
2873 enum GAS_Solver_Status stat, 2897 enum GAS_Solver_Status stat,
2874 enum GAS_Solver_Additional_Information add) 2898 enum GAS_Solver_Additional_Information add)
2875{ 2899{
2876 char *add_info; 2900 char *add_info;
2877 switch (add) { 2901 switch (add) {
@@ -3433,4 +3457,3 @@ main (int argc, char *argv[])
3433 return res; 3457 return res;
3434} 3458}
3435/* end of file ats-testing-experiment.c*/ 3459/* end of file ats-testing-experiment.c*/
3436