aboutsummaryrefslogtreecommitdiff
path: root/src/ats
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
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')
-rw-r--r--src/ats/ats_api_scheduling.c80
-rw-r--r--src/ats/gnunet-ats-solver-eval.c73
-rw-r--r--src/ats/gnunet-service-ats_addresses.c47
-rw-r--r--src/ats/plugin_ats_proportional.c21
-rw-r--r--src/ats/test_ats_api_common.c68
5 files changed, 195 insertions, 94 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 6bb595391..4cf48d761 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -77,7 +77,7 @@ struct SessionRecord
77 struct Session *session; 77 struct Session *session;
78 78
79 /** 79 /**
80 * Set to GNUNET_YES if the slot is used. 80 * Set to #GNUNET_YES if the slot is used.
81 */ 81 */
82 int slot_used; 82 int slot_used;
83}; 83};
@@ -122,7 +122,7 @@ struct GNUNET_ATS_SchedulingHandle
122 GNUNET_ATS_AddressSuggestionCallback suggest_cb; 122 GNUNET_ATS_AddressSuggestionCallback suggest_cb;
123 123
124 /** 124 /**
125 * Closure for 'suggest_cb'. 125 * Closure for @e suggest_cb.
126 */ 126 */
127 void *suggest_cb_cls; 127 void *suggest_cb_cls;
128 128
@@ -833,34 +833,72 @@ get_addresses (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
833 sh); 833 sh);
834} 834}
835 835
836
836/** 837/**
837 * Convert a GNUNET_ATS_NetworkType to a string 838 * Convert a `enum GNUNET_ATS_Network_Type` to a string
838 * 839 *
839 * @param net the network type 840 * @param net the network type
840 * @return a string or NULL if invalid 841 * @return a string or NULL if invalid
841 */ 842 */
842const char * 843const char *
843GNUNET_ATS_print_network_type (uint32_t net) 844GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net)
844{ 845{
845 char *networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; 846 switch (net)
846 if (net < GNUNET_ATS_NetworkTypeCount) 847 {
847 return networks[net]; 848 case GNUNET_ATS_NET_UNSPECIFIED:
848 return NULL; 849 return "UNSPECIFIED";
850 case GNUNET_ATS_NET_LOOPBACK:
851 return "LOOPBACK";
852 case GNUNET_ATS_NET_LAN:
853 return "LAN";
854 case GNUNET_ATS_NET_WAN:
855 return "WAN";
856 case GNUNET_ATS_NET_WLAN:
857 return "WLAN";
858 case GNUNET_ATS_NET_BT:
859 return "BLUETOOTH";
860 default:
861 return NULL;
862 }
849} 863}
850 864
865
851/** 866/**
852 * Convert a ATS property to a string 867 * Convert a ATS property to a string
853 * 868 *
854 * @param type the atsi type 869 * @param type the property type
855 * @return a string or NULL if invalid 870 * @return a string or NULL if invalid
856 */ 871 */
857const char * 872const char *
858GNUNET_ATS_print_property_type (uint32_t type) 873GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type)
859{ 874{
860 char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings; 875 switch (type)
861 if ((type > 0) && (type < GNUNET_ATS_PropertyCount)) 876 {
862 return props[type]; 877 case GNUNET_ATS_ARRAY_TERMINATOR:
863 return NULL; 878 return "TERMINATOR";
879 case GNUNET_ATS_UTILIZATION_OUT:
880 return "UTILIZATION_UP";
881 case GNUNET_ATS_UTILIZATION_IN:
882 return "UTILIZATION_DOWN";
883 case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT:
884 return "UTILIZATION_PAYLOAD_UP";
885 case GNUNET_ATS_UTILIZATION_PAYLOAD_IN:
886 return "UTILIZATION_PAYLOAD_DOWN";
887 case GNUNET_ATS_NETWORK_TYPE:
888 return "NETWORK_TYPE";
889 case GNUNET_ATS_QUALITY_NET_DELAY:
890 return "DELAY";
891 case GNUNET_ATS_QUALITY_NET_DISTANCE:
892 return "DISTANCE";
893 case GNUNET_ATS_COST_WAN:
894 return "COST_WAN";
895 case GNUNET_ATS_COST_LAN:
896 return "COST_LAN";
897 case GNUNET_ATS_COST_WLAN:
898 return "COST_WLAN";
899 default:
900 return NULL;
901 }
864} 902}
865 903
866 904
@@ -1057,17 +1095,17 @@ GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
1057 do_transmit (sh); 1095 do_transmit (sh);
1058} 1096}
1059 1097
1098
1060/** 1099/**
1061 * We would like to receive address suggestions for a peer. ATS will 1100 * We would like to receive address suggestions for a peer. ATS will
1062 * respond with a call to the continuation immediately containing an address or 1101 * respond with a call to the continuation immediately containing an address or
1063 * no address if none is available. ATS can suggest more addresses until we call 1102 * no address if none is available. ATS can suggest more addresses until we call
1064 * #GNUNET_ATS_suggest_address_cancel. 1103 * #GNUNET_ATS_suggest_address_cancel().
1065 *
1066 * 1104 *
1067 * @param sh handle 1105 * @param sh handle
1068 * @param peer identity of the peer we need an address for 1106 * @param peer identity of the peer we need an address for
1069 * @param cont the continuation to call with the address 1107 * @param cont the continuation to call with the address
1070 * @param cont_cls the cls for the continuation 1108 * @param cont_cls the cls for the @a cont
1071 * @return suggest handle 1109 * @return suggest handle
1072 */ 1110 */
1073struct GNUNET_ATS_SuggestHandle * 1111struct GNUNET_ATS_SuggestHandle *
@@ -1269,9 +1307,9 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
1269 * @param address the address 1307 * @param address the address
1270 * @param session session handle, can be NULL 1308 * @param session session handle, can be NULL
1271 * @param ats performance data for the address 1309 * @param ats performance data for the address
1272 * @param ats_count number of performance records in 'ats' 1310 * @param ats_count number of performance records in @a ats
1273 * @return GNUNET_YES on success, GNUNET_NO if address or session are unknown, 1311 * @return #GNUNET_YES on success, #GNUNET_NO if address or session are unknown,
1274 * GNUNET_SYSERR on hard failure 1312 * #GNUNET_SYSERR on hard failure
1275 */ 1313 */
1276int 1314int
1277GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, 1315GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
@@ -1357,7 +1395,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
1357 * @param sh handle 1395 * @param sh handle
1358 * @param address the address 1396 * @param address the address
1359 * @param session session handle, can be NULL 1397 * @param session session handle, can be NULL
1360 * @param in_use GNUNET_YES if this address is now used, GNUNET_NO 1398 * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO
1361 * if address is not used any more 1399 * if address is not used any more
1362 */ 1400 */
1363void 1401void
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
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index f0af8f1a2..89158936d 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -1746,7 +1746,6 @@ static unsigned int
1746load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, 1746load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
1747 unsigned long long *out_dest, unsigned long long *in_dest, int dest_length) 1747 unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
1748{ 1748{
1749 char *network_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
1750 char * entry_in = NULL; 1749 char * entry_in = NULL;
1751 char * entry_out = NULL; 1750 char * entry_out = NULL;
1752 char * quota_out_str; 1751 char * quota_out_str;
@@ -1758,8 +1757,12 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
1758 { 1757 {
1759 in_dest[c] = 0; 1758 in_dest[c] = 0;
1760 out_dest[c] = 0; 1759 out_dest[c] = 0;
1761 GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); 1760 GNUNET_asprintf (&entry_out,
1762 GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); 1761 "%s_QUOTA_OUT",
1762 GNUNET_ATS_print_network_type (c));
1763 GNUNET_asprintf (&entry_in,
1764 "%s_QUOTA_IN",
1765 GNUNET_ATS_print_network_type (c));
1763 1766
1764 /* quota out */ 1767 /* quota out */
1765 if (GNUNET_OK 1768 if (GNUNET_OK
@@ -1786,23 +1789,27 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
1786 if (GNUNET_NO == res) 1789 if (GNUNET_NO == res)
1787 { 1790 {
1788 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1791 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1789 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 1792 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
1790 network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth); 1793 GNUNET_ATS_print_network_type (c),
1794 quota_out_str,
1795 GNUNET_ATS_DefaultBandwidth);
1791 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 1796 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
1792 } 1797 }
1793 else 1798 else
1794 { 1799 {
1795 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1800 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1796 _("Outbound quota configure for network `%s' is %llu\n"), 1801 _("Outbound quota configure for network `%s' is %llu\n"),
1797 network_str[c], out_dest[c]); 1802 GNUNET_ATS_print_network_type (c),
1803 out_dest[c]);
1798 } 1804 }
1799 GNUNET_free(quota_out_str); 1805 GNUNET_free(quota_out_str);
1800 } 1806 }
1801 else 1807 else
1802 { 1808 {
1803 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1809 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1804 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), 1810 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
1805 network_str[c], GNUNET_ATS_DefaultBandwidth); 1811 GNUNET_ATS_print_network_type (c),
1812 GNUNET_ATS_DefaultBandwidth);
1806 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 1813 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
1807 } 1814 }
1808 1815
@@ -1830,28 +1837,34 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
1830 if (GNUNET_NO == res) 1837 if (GNUNET_NO == res)
1831 { 1838 {
1832 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1839 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1833 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 1840 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
1834 network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth); 1841 GNUNET_ATS_print_network_type (c),
1842 quota_in_str,
1843 GNUNET_ATS_DefaultBandwidth);
1835 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 1844 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
1836 } 1845 }
1837 else 1846 else
1838 { 1847 {
1839 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1848 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1840 _("Inbound quota configured for network `%s' is %llu\n"), 1849 _("Inbound quota configured for network `%s' is %llu\n"),
1841 network_str[c], in_dest[c]); 1850 GNUNET_ATS_print_network_type (c),
1851 in_dest[c]);
1842 } 1852 }
1843 GNUNET_free(quota_in_str); 1853 GNUNET_free(quota_in_str);
1844 } 1854 }
1845 else 1855 else
1846 { 1856 {
1847 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1857 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1848 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), 1858 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
1849 network_str[c], GNUNET_ATS_DefaultBandwidth); 1859 GNUNET_ATS_print_network_type (c),
1860 GNUNET_ATS_DefaultBandwidth);
1850 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 1861 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
1851 } 1862 }
1852 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1863 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1853 "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], 1864 "Loaded quota for network `%s' (in/out): %llu %llu\n",
1854 in_dest[c], out_dest[c]); 1865 GNUNET_ATS_print_network_type (c),
1866 in_dest[c],
1867 out_dest[c]);
1855 GNUNET_free(entry_out); 1868 GNUNET_free(entry_out);
1856 GNUNET_free(entry_in); 1869 GNUNET_free(entry_in);
1857 } 1870 }
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 744602eb8..99cbb1b55 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -27,6 +27,7 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_statistics_service.h" 28#include "gnunet_statistics_service.h"
29#include "gnunet_ats_plugin.h" 29#include "gnunet_ats_plugin.h"
30#include "gnunet_ats_service.h"
30#include "gnunet-service-ats_addresses.h" 31#include "gnunet-service-ats_addresses.h"
31 32
32#define PROP_STABILITY_FACTOR 1.25 33#define PROP_STABILITY_FACTOR 1.25
@@ -317,7 +318,7 @@ struct Network
317 /** 318 /**
318 * Network description 319 * Network description
319 */ 320 */
320 char *desc; 321 const char *desc;
321 322
322 /** 323 /**
323 * Total inbound quota 324 * Total inbound quota
@@ -1293,7 +1294,7 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s,
1293 best_address->active = GNUNET_YES; 1294 best_address->active = GNUNET_YES;
1294 address_increment (s, net, GNUNET_NO, GNUNET_YES); 1295 address_increment (s, net, GNUNET_NO, GNUNET_YES);
1295 LOG (GNUNET_ERROR_TYPE_INFO, "Address %p for peer `%s' is now active\n", 1296 LOG (GNUNET_ERROR_TYPE_INFO, "Address %p for peer `%s' is now active\n",
1296 best_address, GNUNET_i2s (peer)); 1297 best_address, GNUNET_i2s (peer));
1297 /* Distribute bandwidth */ 1298 /* Distribute bandwidth */
1298 distribute_bandwidth_in_network (s, net); 1299 distribute_bandwidth_in_network (s, net);
1299 return best_address; 1300 return best_address;
@@ -1936,7 +1937,6 @@ libgnunet_plugin_ats_proportional_init (void *cls)
1936 struct GNUNET_ATS_PluginEnvironment *env = cls; 1937 struct GNUNET_ATS_PluginEnvironment *env = cls;
1937 struct GAS_PROPORTIONAL_Handle *s; 1938 struct GAS_PROPORTIONAL_Handle *s;
1938 struct Network * cur; 1939 struct Network * cur;
1939 char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
1940 float f_tmp; 1940 float f_tmp;
1941 int c; 1941 int c;
1942 1942
@@ -2022,19 +2022,22 @@ libgnunet_plugin_ats_proportional_init (void *cls)
2022 for (c = 0; c < env->network_count; c++) 2022 for (c = 0; c < env->network_count; c++)
2023 { 2023 {
2024 cur = &s->network_entries[c]; 2024 cur = &s->network_entries[c];
2025 cur->total_addresses = 0;
2026 cur->active_addresses = 0;
2027 cur->type = env->networks[c]; 2025 cur->type = env->networks[c];
2028 cur->total_quota_in = env->in_quota[c]; 2026 cur->total_quota_in = env->in_quota[c];
2029 cur->total_quota_out = env->out_quota[c]; 2027 cur->total_quota_out = env->out_quota[c];
2030 cur->desc = net_str[c]; 2028 cur->desc = GNUNET_ATS_print_network_type (c);
2031 GNUNET_asprintf (&cur->stat_total, 2029 GNUNET_asprintf (&cur->stat_total,
2032 "# ATS addresses %s total", cur->desc); 2030 "# ATS addresses %s total",
2031 cur->desc);
2033 GNUNET_asprintf (&cur->stat_active, 2032 GNUNET_asprintf (&cur->stat_active,
2034 "# ATS active addresses %s total", cur->desc); 2033 "# ATS active addresses %s total",
2034 cur->desc);
2035 LOG (GNUNET_ERROR_TYPE_INFO, 2035 LOG (GNUNET_ERROR_TYPE_INFO,
2036 "Added network %u `%s' (%llu/%llu)\n", 2036 "Added network %u `%s' (%llu/%llu)\n",
2037 c, cur->desc, cur->total_quota_in, cur->total_quota_out); 2037 c,
2038 cur->desc,
2039 cur->total_quota_in,
2040 cur->total_quota_out);
2038 } 2041 }
2039 return s; 2042 return s;
2040} 2043}
diff --git a/src/ats/test_ats_api_common.c b/src/ats/test_ats_api_common.c
index b603d6e6d..569ffbce1 100644
--- a/src/ats/test_ats_api_common.c
+++ b/src/ats/test_ats_api_common.c
@@ -95,7 +95,6 @@ compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is,
95{ 95{
96 unsigned int c_o; 96 unsigned int c_o;
97 unsigned int c_i; 97 unsigned int c_i;
98 char *prop[] = GNUNET_ATS_PropertyStrings;
99 uint32_t type1; 98 uint32_t type1;
100 uint32_t type2; 99 uint32_t type2;
101 uint32_t val1; 100 uint32_t val1;
@@ -110,21 +109,24 @@ compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is,
110 type2 = ntohl(ats_should[c_i].type); 109 type2 = ntohl(ats_should[c_i].type);
111 if (type1 == type2) 110 if (type1 == type2)
112 { 111 {
113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS type `%s'\n", 112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
114 prop[type1]); 113 "ATS type `%s'\n",
114 GNUNET_ATS_print_property_type (type1));
115 val1 = ntohl(ats_is[c_o].value); 115 val1 = ntohl(ats_is[c_o].value);
116 val2 = ntohl(ats_should[c_i].value); 116 val2 = ntohl(ats_should[c_i].value);
117 if (val1 != val2) 117 if (val1 != val2)
118 { 118 {
119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS value `%s' not equal: %u != %u\n", 119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
120 prop[type1], 120 "ATS value `%s' not equal: %u != %u\n",
121 GNUNET_ATS_print_property_type (type1),
121 val1, val2); 122 val1, val2);
122 res = GNUNET_SYSERR; 123 res = GNUNET_SYSERR;
123 } 124 }
124 else 125 else
125 { 126 {
126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS value `%s' equal: %u == %u\n", 127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
127 prop[type1], 128 "ATS value `%s' equal: %u == %u\n",
129 GNUNET_ATS_print_property_type (type1),
128 val1, val2); 130 val1, val2);
129 } 131 }
130 } 132 }
@@ -161,8 +163,12 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
161 { 163 {
162 in_dest[c] = 0; 164 in_dest[c] = 0;
163 out_dest[c] = 0; 165 out_dest[c] = 0;
164 GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); 166 GNUNET_asprintf (&entry_out,
165 GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); 167 "%s_QUOTA_OUT",
168 GNUNET_ATS_print_network_type (c));
169 GNUNET_asprintf (&entry_in,
170 "%s_QUOTA_IN",
171 GNUNET_ATS_print_network_type (c));
166 172
167 /* quota out */ 173 /* quota out */
168 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str)) 174 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
@@ -180,21 +186,28 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
180 186
181 if (GNUNET_NO == res) 187 if (GNUNET_NO == res)
182 { 188 {
183 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 189 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
184 network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth); 190 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
191 GNUNET_ATS_print_network_type (c),
192 quota_out_str,
193 GNUNET_ATS_DefaultBandwidth);
185 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 194 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
186 } 195 }
187 else 196 else
188 { 197 {
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Outbound quota configure for network `%s' is %llu\n"), 198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
190 network_str[c], out_dest[c]); 199 "Outbound quota configure for network `%s' is %llu\n",
200 GNUNET_ATS_print_network_type (c),
201 out_dest[c]);
191 } 202 }
192 GNUNET_free (quota_out_str); 203 GNUNET_free (quota_out_str);
193 } 204 }
194 else 205 else
195 { 206 {
196 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), 207 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
197 network_str[c], GNUNET_ATS_DefaultBandwidth); 208 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
209 GNUNET_ATS_print_network_type (c),
210 GNUNET_ATS_DefaultBandwidth);
198 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 211 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
199 } 212 }
200 213
@@ -214,24 +227,35 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
214 227
215 if (GNUNET_NO == res) 228 if (GNUNET_NO == res)
216 { 229 {
217 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 230 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
218 network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth); 231 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
232 GNUNET_ATS_print_network_type (c),
233 quota_in_str,
234 GNUNET_ATS_DefaultBandwidth);
219 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 235 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
220 } 236 }
221 else 237 else
222 { 238 {
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Inbound quota configured for network `%s' is %llu\n"), 239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
224 network_str[c], in_dest[c]); 240 "Inbound quota configured for network `%s' is %llu\n",
241 GNUNET_ATS_print_network_type (c),
242 in_dest[c]);
225 } 243 }
226 GNUNET_free (quota_in_str); 244 GNUNET_free (quota_in_str);
227 } 245 }
228 else 246 else
229 { 247 {
230 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), 248 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
231 network_str[c], GNUNET_ATS_DefaultBandwidth); 249 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
250 GNUNET_ATS_print_network_type (c),
251 GNUNET_ATS_DefaultBandwidth);
232 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 252 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
233 } 253 }
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]); 254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 "Loaded quota for network `%s' (in/out): %llu %llu\n",
256 GNUNET_ATS_print_network_type (c),
257 in_dest[c],
258 out_dest[c]);
235 GNUNET_free (entry_out); 259 GNUNET_free (entry_out);
236 GNUNET_free (entry_in); 260 GNUNET_free (entry_in);
237 } 261 }