gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25752 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r25752 - gnunet/src/ats
Date: Fri, 11 Jan 2013 10:51:47 +0100

Author: wachs
Date: 2013-01-11 10:51:47 +0100 (Fri, 11 Jan 2013)
New Revision: 25752

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses.c
Log:
commit for mantis: 0002729
quota load: support "unlimited", fancy strings and integer values (set by 
gnunet setup)


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-01-11 09:22:17 UTC 
(rev 25751)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-01-11 09:51:47 UTC 
(rev 25752)
@@ -965,36 +965,45 @@
   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, &quota_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;
       }
-      else if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes 
(quota_out_str, &out_dest[c]))
+      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 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_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
+      {
+          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;
     }
@@ -1002,26 +1011,35 @@
     /* quota in */
     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
entry_in, &quota_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 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_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_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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]