char * quota_out_str;
char * quota_in_str;
int c;
+ int res;
for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++)
{
in_dest[c] = 0;
out_dest[c] = 0;
-
GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]);
GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]);
-
/* quota out */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str))
{
+ res = GNUNET_NO;
if (0 == strcmp(quota_out_str, BIG_M_STRING))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Outbound quota configure for network `%s' is unlimited (%llu)\n"),
- network_str[c], GNUNET_ATS_MaxBandwidth);
out_dest[c] = GNUNET_ATS_MaxBandwidth;
+ res = GNUNET_YES;
+ }
+ if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c])))
+ res = GNUNET_YES;
+ if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_out, &out_dest[c])))
+ res = GNUNET_YES;
+
+ if (GNUNET_NO == res)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
+ network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth);
+ out_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
- else if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c]))
+ else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not convert quota configure for network `%s': `%s', assigning default bandwidth %llu\n"),
- network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth);
- out_dest[c] = GNUNET_ATS_DefaultBandwidth;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Outbound quota configure for network `%s' is %llu\n"),
+ network_str[c], out_dest[c]);
}
GNUNET_free (quota_out_str);
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
network_str[c], GNUNET_ATS_DefaultBandwidth);
out_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
/* quota in */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str))
{
+ res = GNUNET_NO;
if (0 == strcmp(quota_in_str, BIG_M_STRING))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Inbound quota configure for network `%s' is unlimited (%llu)\n"),
- network_str[c], GNUNET_ATS_MaxBandwidth);
in_dest[c] = GNUNET_ATS_MaxBandwidth;
+ res = GNUNET_YES;
}
+ if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c])))
+ res = GNUNET_YES;
+ if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_in, &in_dest[c])))
+ res = GNUNET_YES;
- else if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c]))
+ if (GNUNET_NO == res)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
+ network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth);
+ in_dest[c] = GNUNET_ATS_DefaultBandwidth;
+ }
+ else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not convert quota configure for network `%s': `%s', assigning default bandwidth %llu\n"),
- network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth);
- in_dest[c] = GNUNET_ATS_DefaultBandwidth;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Inbound quota configured for network `%s' is %llu\n"),
+ network_str[c], in_dest[c]);
}
GNUNET_free (quota_in_str);
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No inbound quota configure for network `%s', assigning default bandwidth %llu\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
network_str[c], GNUNET_ATS_DefaultBandwidth);
- in_dest[c] = GNUNET_ATS_DefaultBandwidth;
+ out_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
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]);
GNUNET_free (entry_out);