diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-11 09:51:47 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-11 09:51:47 +0000 |
commit | 913b6faffd0ff1711db0675e69382ba9edec4ae0 (patch) | |
tree | 805b113d02dd530f4671bca07815c38dbb76d825 /src | |
parent | 763db022115084a225f62f8795a897c1512b8709 (diff) | |
download | gnunet-913b6faffd0ff1711db0675e69382ba9edec4ae0.tar.gz gnunet-913b6faffd0ff1711db0675e69382ba9edec4ae0.zip |
commit for mantis: 0002729
quota load: support "unlimited", fancy strings and integer values (set by gnunet setup)
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 55eee1af3..6650c7b01 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -965,36 +965,45 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long * | |||
965 | char * quota_out_str; | 965 | char * quota_out_str; |
966 | char * quota_in_str; | 966 | char * quota_in_str; |
967 | int c; | 967 | int c; |
968 | int res; | ||
968 | 969 | ||
969 | for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) | 970 | for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) |
970 | { | 971 | { |
971 | in_dest[c] = 0; | 972 | in_dest[c] = 0; |
972 | out_dest[c] = 0; | 973 | out_dest[c] = 0; |
973 | |||
974 | GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); | 974 | GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]); |
975 | GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); | 975 | GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]); |
976 | 976 | ||
977 | |||
978 | /* quota out */ | 977 | /* quota out */ |
979 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) | 978 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) |
980 | { | 979 | { |
980 | res = GNUNET_NO; | ||
981 | if (0 == strcmp(quota_out_str, BIG_M_STRING)) | 981 | if (0 == strcmp(quota_out_str, BIG_M_STRING)) |
982 | { | 982 | { |
983 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Outbound quota configure for network `%s' is unlimited (%llu)\n"), | ||
984 | network_str[c], GNUNET_ATS_MaxBandwidth); | ||
985 | out_dest[c] = GNUNET_ATS_MaxBandwidth; | 983 | out_dest[c] = GNUNET_ATS_MaxBandwidth; |
984 | res = GNUNET_YES; | ||
985 | } | ||
986 | if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c]))) | ||
987 | res = GNUNET_YES; | ||
988 | if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_out, &out_dest[c]))) | ||
989 | res = GNUNET_YES; | ||
990 | |||
991 | if (GNUNET_NO == res) | ||
992 | { | ||
993 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), | ||
994 | network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth); | ||
995 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; | ||
986 | } | 996 | } |
987 | else if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c])) | 997 | else |
988 | { | 998 | { |
989 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not convert quota configure for network `%s': `%s', assigning default bandwidth %llu\n"), | 999 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Outbound quota configure for network `%s' is %llu\n"), |
990 | network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth); | 1000 | network_str[c], out_dest[c]); |
991 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; | ||
992 | } | 1001 | } |
993 | GNUNET_free (quota_out_str); | 1002 | GNUNET_free (quota_out_str); |
994 | } | 1003 | } |
995 | else | 1004 | else |
996 | { | 1005 | { |
997 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), | 1006 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), |
998 | network_str[c], GNUNET_ATS_DefaultBandwidth); | 1007 | network_str[c], GNUNET_ATS_DefaultBandwidth); |
999 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; | 1008 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; |
1000 | } | 1009 | } |
@@ -1002,26 +1011,35 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long * | |||
1002 | /* quota in */ | 1011 | /* quota in */ |
1003 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str)) | 1012 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str)) |
1004 | { | 1013 | { |
1014 | res = GNUNET_NO; | ||
1005 | if (0 == strcmp(quota_in_str, BIG_M_STRING)) | 1015 | if (0 == strcmp(quota_in_str, BIG_M_STRING)) |
1006 | { | 1016 | { |
1007 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Inbound quota configure for network `%s' is unlimited (%llu)\n"), | ||
1008 | network_str[c], GNUNET_ATS_MaxBandwidth); | ||
1009 | in_dest[c] = GNUNET_ATS_MaxBandwidth; | 1017 | in_dest[c] = GNUNET_ATS_MaxBandwidth; |
1018 | res = GNUNET_YES; | ||
1010 | } | 1019 | } |
1020 | if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c]))) | ||
1021 | res = GNUNET_YES; | ||
1022 | if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_in, &in_dest[c]))) | ||
1023 | res = GNUNET_YES; | ||
1011 | 1024 | ||
1012 | else if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c])) | 1025 | if (GNUNET_NO == res) |
1026 | { | ||
1027 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), | ||
1028 | network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth); | ||
1029 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; | ||
1030 | } | ||
1031 | else | ||
1013 | { | 1032 | { |
1014 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not convert quota configure for network `%s': `%s', assigning default bandwidth %llu\n"), | 1033 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Inbound quota configured for network `%s' is %llu\n"), |
1015 | network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth); | 1034 | network_str[c], in_dest[c]); |
1016 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; | ||
1017 | } | 1035 | } |
1018 | GNUNET_free (quota_in_str); | 1036 | GNUNET_free (quota_in_str); |
1019 | } | 1037 | } |
1020 | else | 1038 | else |
1021 | { | 1039 | { |
1022 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No inbound quota configure for network `%s', assigning default bandwidth %llu\n"), | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), |
1023 | network_str[c], GNUNET_ATS_DefaultBandwidth); | 1041 | network_str[c], GNUNET_ATS_DefaultBandwidth); |
1024 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; | 1042 | out_dest[c] = GNUNET_ATS_DefaultBandwidth; |
1025 | } | 1043 | } |
1026 | 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]); | 1044 | 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]); |
1027 | GNUNET_free (entry_out); | 1045 | GNUNET_free (entry_out); |