gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34912 - in gnunet/src: ats ats-tool include transport


From: gnunet
Subject: [GNUnet-SVN] r34912 - in gnunet/src: ats ats-tool include transport
Date: Sat, 17 Jan 2015 22:31:48 +0100

Author: grothoff
Date: 2015-01-17 22:31:48 +0100 (Sat, 17 Jan 2015)
New Revision: 34912

Modified:
   gnunet/src/ats-tool/gnunet-ats.c
   gnunet/src/ats/ats_api_scheduling.c
   gnunet/src/ats/gnunet-ats-solver-eval.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/plugin_ats_proportional.c
   gnunet/src/ats/test_ats_api_common.c
   gnunet/src/include/gnunet_ats_service.h
   gnunet/src/transport/test_quota_compliance.c
Log:
use ATS functions to convert quality network type to string, instead of using 
string API

Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2015-01-17 16:24:45 UTC (rev 34911)
+++ gnunet/src/ats/ats_api_scheduling.c 2015-01-17 21:31:48 UTC (rev 34912)
@@ -77,7 +77,7 @@
   struct Session *session;
 
   /**
-   * Set to GNUNET_YES if the slot is used.
+   * Set to #GNUNET_YES if the slot is used.
    */
   int slot_used;
 };
@@ -122,7 +122,7 @@
   GNUNET_ATS_AddressSuggestionCallback suggest_cb;
 
   /**
-   * Closure for 'suggest_cb'.
+   * Closure for @e suggest_cb.
    */
   void *suggest_cb_cls;
 
@@ -833,34 +833,72 @@
                                                      sh);
 }
 
+
 /**
- * Convert a GNUNET_ATS_NetworkType to a string
+ * Convert a `enum GNUNET_ATS_Network_Type` to a string
  *
  * @param net the network type
  * @return a string or NULL if invalid
  */
 const char *
-GNUNET_ATS_print_network_type (uint32_t net)
+GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net)
 {
-  char *networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
-  if (net < GNUNET_ATS_NetworkTypeCount)
-    return networks[net];
-  return NULL;
+  switch (net)
+    {
+    case GNUNET_ATS_NET_UNSPECIFIED:
+      return "UNSPECIFIED";
+    case GNUNET_ATS_NET_LOOPBACK:
+      return "LOOPBACK";
+    case GNUNET_ATS_NET_LAN:
+      return "LAN";
+    case GNUNET_ATS_NET_WAN:
+      return "WAN";
+    case GNUNET_ATS_NET_WLAN:
+      return "WLAN";
+    case GNUNET_ATS_NET_BT:
+      return "BLUETOOTH";
+    default:
+      return NULL;
+    }
 }
 
+
 /**
  * Convert a ATS property to a string
  *
- * @param type the atsi type
+ * @param type the property type
  * @return a string or NULL if invalid
  */
 const char *
-GNUNET_ATS_print_property_type (uint32_t type)
+GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type)
 {
-       char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
-       if ((type > 0) && (type < GNUNET_ATS_PropertyCount))
-               return props[type];
-       return NULL;
+  switch (type)
+  {
+  case GNUNET_ATS_ARRAY_TERMINATOR:
+    return "TERMINATOR";
+  case GNUNET_ATS_UTILIZATION_OUT:
+    return "UTILIZATION_UP";
+  case GNUNET_ATS_UTILIZATION_IN:
+    return "UTILIZATION_DOWN";
+  case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT:
+    return "UTILIZATION_PAYLOAD_UP";
+  case GNUNET_ATS_UTILIZATION_PAYLOAD_IN:
+    return "UTILIZATION_PAYLOAD_DOWN";
+  case GNUNET_ATS_NETWORK_TYPE:
+    return "NETWORK_TYPE";
+  case GNUNET_ATS_QUALITY_NET_DELAY:
+    return "DELAY";
+  case GNUNET_ATS_QUALITY_NET_DISTANCE:
+    return "DISTANCE";
+  case GNUNET_ATS_COST_WAN:
+    return "COST_WAN";
+  case GNUNET_ATS_COST_LAN:
+    return "COST_LAN";
+  case GNUNET_ATS_COST_WLAN:
+    return "COST_WLAN";
+  default:
+    return NULL;
+  }
 }
 
 
@@ -1057,17 +1095,17 @@
   do_transmit (sh);
 }
 
+
 /**
  * We would like to receive address suggestions for a peer. ATS will
  * respond with a call to the continuation immediately containing an address or
  * no address if none is available. ATS can suggest more addresses until we 
call
- * #GNUNET_ATS_suggest_address_cancel.
+ * #GNUNET_ATS_suggest_address_cancel().
  *
- *
  * @param sh handle
  * @param peer identity of the peer we need an address for
  * @param cont the continuation to call with the address
- * @param cont_cls the cls for the continuation
+ * @param cont_cls the cls for the @a cont
  * @return suggest handle
  */
 struct GNUNET_ATS_SuggestHandle *
@@ -1269,9 +1307,9 @@
  * @param address the address
  * @param session session handle, can be NULL
  * @param ats performance data for the address
- * @param ats_count number of performance records in 'ats'
- * @return GNUNET_YES on success, GNUNET_NO if address or session are unknown,
- * GNUNET_SYSERR on hard failure
+ * @param ats_count number of performance records in @a ats
+ * @return #GNUNET_YES on success, #GNUNET_NO if address or session are 
unknown,
+ * #GNUNET_SYSERR on hard failure
  */
 int
 GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
@@ -1357,7 +1395,7 @@
  * @param sh handle
  * @param address the address
  * @param session session handle, can be NULL
- * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
+ * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO
  * if address is not used any more
  */
 void

Modified: gnunet/src/ats/gnunet-ats-solver-eval.c
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.c     2015-01-17 16:24:45 UTC (rev 
34911)
+++ gnunet/src/ats/gnunet-ats-solver-eval.c     2015-01-17 21:31:48 UTC (rev 
34912)
@@ -1706,18 +1706,20 @@
   return GNUNET_OK;
 }
 
+
 static enum GNUNET_ATS_Property
-parse_property_string (const char * str)
+parse_property_string (const char *str)
 {
-  int c = 0;
-  char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
+  enum GNUNET_ATS_Property c;
 
   for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
-    if (0 == strcmp(str, props[c]))
+    if (0 == strcmp(str,
+                    GNUNET_ATS_print_property_type (c)))
       return c;
   return 0;
-};
+}
 
+
 static int
 load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
     struct Episode *e,
@@ -2770,7 +2772,6 @@
                                                  unsigned long long *in_dest,
                                                  int dest_length)
 {
-  char *network_str[GNUNET_ATS_NetworkTypeCount] = 
GNUNET_ATS_NetworkTypeString;
   char * entry_in = NULL;
   char * entry_out = NULL;
   char * quota_out_str;
@@ -2782,8 +2783,12 @@
   {
     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]);
+    GNUNET_asprintf (&entry_out,
+                     "%s_QUOTA_OUT",
+                     GNUNET_ATS_print_network_type (c));
+    GNUNET_asprintf (&entry_in,
+                     "%s_QUOTA_IN",
+                     GNUNET_ATS_print_network_type (c));
 
     /* quota out */
     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
entry_out, &quota_out_str))
@@ -2801,21 +2806,28 @@
 
       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);
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _("Could not load quota for network `%s':  `%s', 
assigning default bandwidth %llu\n"),
+                      GNUNET_ATS_print_network_type (c),
+                      quota_out_str,
+                      GNUNET_ATS_DefaultBandwidth);
           out_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Outbound quota configure for 
network `%s' is %llu\n"),
-              network_str[c], out_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Outbound quota configure for network `%s' is %llu\n",
+                      GNUNET_ATS_print_network_type (c),
+                      out_dest[c]);
       }
       GNUNET_free (quota_out_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured 
for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configured for network `%s', assigning 
default bandwidth %llu\n"),
+                  GNUNET_ATS_print_network_type (c),
+                  GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
 
@@ -2835,30 +2847,42 @@
 
       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);
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _("Could not load quota for network `%s':  `%s', 
assigning default bandwidth %llu\n"),
+                      GNUNET_ATS_print_network_type (c),
+                      quota_in_str,
+                      GNUNET_ATS_DefaultBandwidth);
           in_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Inbound quota configured for 
network `%s' is %llu\n"),
-              network_str[c], in_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Inbound quota configured for network `%s' is %llu\n",
+                      GNUNET_ATS_print_network_type (c),
+                      in_dest[c]);
       }
       GNUNET_free (quota_in_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure 
for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configure for network `%s', assigning 
default bandwidth %llu\n"),
+                  GNUNET_ATS_print_network_type (c),
+                  GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
-    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]);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Loaded quota for network `%s' (in/out): %llu %llu\n",
+                GNUNET_ATS_print_network_type (c),
+                in_dest[c],
+                out_dest[c]);
     GNUNET_free (entry_out);
     GNUNET_free (entry_in);
   }
   return GNUNET_ATS_NetworkTypeCount;
 }
 
+
 /**
  * Information callback for the solver
  *
@@ -2869,9 +2893,9 @@
  */
 static void
 solver_info_cb (void *cls,
-    enum GAS_Solver_Operation op,
-    enum GAS_Solver_Status stat,
-    enum GAS_Solver_Additional_Information add)
+                enum GAS_Solver_Operation op,
+                enum GAS_Solver_Status stat,
+                enum GAS_Solver_Additional_Information add)
 {
   char *add_info;
   switch (add) {
@@ -3433,4 +3457,3 @@
   return res;
 }
 /* end of file ats-testing-experiment.c*/
-

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-17 16:24:45 UTC 
(rev 34911)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-17 21:31:48 UTC 
(rev 34912)
@@ -1746,7 +1746,6 @@
 load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
     unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
 {
-  char *network_str[GNUNET_ATS_NetworkTypeCount] = 
GNUNET_ATS_NetworkTypeString;
   char * entry_in = NULL;
   char * entry_out = NULL;
   char * quota_out_str;
@@ -1758,8 +1757,12 @@
   {
     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]);
+    GNUNET_asprintf (&entry_out,
+                     "%s_QUOTA_OUT",
+                     GNUNET_ATS_print_network_type (c));
+    GNUNET_asprintf (&entry_in,
+                     "%s_QUOTA_IN",
+                     GNUNET_ATS_print_network_type (c));
 
     /* quota out */
     if (GNUNET_OK
@@ -1786,23 +1789,27 @@
       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);
+                   _("Could not load quota for network `%s':  `%s', assigning 
default bandwidth %llu\n"),
+                   GNUNET_ATS_print_network_type (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]);
+                   _("Outbound quota configure for network `%s' is %llu\n"),
+                   GNUNET_ATS_print_network_type (c),
+                   out_dest[c]);
       }
       GNUNET_free(quota_out_str);
     }
     else
     {
       GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-          _("No outbound quota configured for network `%s', assigning default 
bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+                 _("No outbound quota configured for network `%s', assigning 
default bandwidth %llu\n"),
+                 GNUNET_ATS_print_network_type (c),
+                 GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
 
@@ -1830,28 +1837,34 @@
       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);
+                   _("Could not load quota for network `%s':  `%s', assigning 
default bandwidth %llu\n"),
+                   GNUNET_ATS_print_network_type (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]);
+                   _("Inbound quota configured for network `%s' is %llu\n"),
+                   GNUNET_ATS_print_network_type (c),
+                   in_dest[c]);
       }
       GNUNET_free(quota_in_str);
     }
     else
     {
       GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-          _("No outbound quota configure for network `%s', assigning default 
bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+                 _("No outbound quota configure for network `%s', assigning 
default bandwidth %llu\n"),
+                 GNUNET_ATS_print_network_type (c),
+                 GNUNET_ATS_DefaultBandwidth);
       in_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]);
+               "Loaded quota for network `%s' (in/out): %llu %llu\n",
+               GNUNET_ATS_print_network_type (c),
+               in_dest[c],
+               out_dest[c]);
     GNUNET_free(entry_out);
     GNUNET_free(entry_in);
   }

Modified: gnunet/src/ats/plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/plugin_ats_proportional.c    2015-01-17 16:24:45 UTC (rev 
34911)
+++ gnunet/src/ats/plugin_ats_proportional.c    2015-01-17 21:31:48 UTC (rev 
34912)
@@ -27,6 +27,7 @@
 #include "platform.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_ats_plugin.h"
+#include "gnunet_ats_service.h"
 #include "gnunet-service-ats_addresses.h"
 
 #define PROP_STABILITY_FACTOR 1.25
@@ -317,7 +318,7 @@
   /**
    * Network description
    */
-  char *desc;
+  const char *desc;
 
   /**
    * Total inbound quota
@@ -1293,7 +1294,7 @@
   best_address->active = GNUNET_YES;
   address_increment (s, net, GNUNET_NO, GNUNET_YES);
   LOG (GNUNET_ERROR_TYPE_INFO, "Address %p for peer `%s' is now active\n",
-      best_address, GNUNET_i2s (peer));        
+      best_address, GNUNET_i2s (peer));
   /* Distribute bandwidth */
   distribute_bandwidth_in_network (s, net);
   return best_address;
@@ -1936,7 +1937,6 @@
   struct GNUNET_ATS_PluginEnvironment *env = cls;
   struct GAS_PROPORTIONAL_Handle *s;
   struct Network * cur;
-  char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
   float f_tmp;
   int c;
 
@@ -2022,19 +2022,22 @@
   for (c = 0; c < env->network_count; c++)
   {
     cur = &s->network_entries[c];
-    cur->total_addresses = 0;
-    cur->active_addresses = 0;
     cur->type = env->networks[c];
     cur->total_quota_in = env->in_quota[c];
     cur->total_quota_out = env->out_quota[c];
-    cur->desc = net_str[c];
+    cur->desc = GNUNET_ATS_print_network_type (c);
     GNUNET_asprintf (&cur->stat_total,
-        "# ATS addresses %s total", cur->desc);
+                     "# ATS addresses %s total",
+                     cur->desc);
     GNUNET_asprintf (&cur->stat_active,
-        "# ATS active addresses %s total", cur->desc);
+                     "# ATS active addresses %s total",
+                     cur->desc);
     LOG (GNUNET_ERROR_TYPE_INFO,
          "Added network %u `%s' (%llu/%llu)\n",
-        c, cur->desc, cur->total_quota_in, cur->total_quota_out);
+         c,
+         cur->desc,
+         cur->total_quota_in,
+         cur->total_quota_out);
   }
   return s;
 }

Modified: gnunet/src/ats/test_ats_api_common.c
===================================================================
--- gnunet/src/ats/test_ats_api_common.c        2015-01-17 16:24:45 UTC (rev 
34911)
+++ gnunet/src/ats/test_ats_api_common.c        2015-01-17 21:31:48 UTC (rev 
34912)
@@ -95,7 +95,6 @@
 {
   unsigned int c_o;
   unsigned int c_i;
-  char *prop[] = GNUNET_ATS_PropertyStrings;
   uint32_t type1;
   uint32_t type2;
   uint32_t val1;
@@ -110,21 +109,24 @@
         type2 = ntohl(ats_should[c_i].type);
         if (type1 == type2)
         {
-            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS type `%s'\n",
-                        prop[type1]);
+            GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                        "ATS type `%s'\n",
+                        GNUNET_ATS_print_property_type (type1));
             val1 = ntohl(ats_is[c_o].value);
             val2 = ntohl(ats_should[c_i].value);
             if (val1 != val2)
             {
-                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS value `%s' not 
equal: %u != %u\n",
-                            prop[type1],
+                GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                            "ATS value `%s' not equal: %u != %u\n",
+                            GNUNET_ATS_print_property_type (type1),
                             val1, val2);
                 res = GNUNET_SYSERR;
             }
             else
             {
-              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS value `%s' equal: %u 
== %u\n",
-                          prop[type1],
+              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                          "ATS value `%s' equal: %u == %u\n",
+                          GNUNET_ATS_print_property_type (type1),
                           val1, val2);
             }
         }
@@ -161,8 +163,12 @@
   {
     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]);
+    GNUNET_asprintf (&entry_out,
+                     "%s_QUOTA_OUT",
+                     GNUNET_ATS_print_network_type (c));
+    GNUNET_asprintf (&entry_in,
+                     "%s_QUOTA_IN",
+                     GNUNET_ATS_print_network_type (c));
 
     /* quota out */
     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
entry_out, &quota_out_str))
@@ -180,21 +186,28 @@
 
       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);
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    _("Could not load quota for network `%s':  `%s', assigning 
default bandwidth %llu\n"),
+                    GNUNET_ATS_print_network_type (c),
+                    quota_out_str,
+                    GNUNET_ATS_DefaultBandwidth);
           out_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Outbound quota configure for 
network `%s' is %llu\n"),
-              network_str[c], out_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Outbound quota configure for network `%s' is %llu\n",
+                      GNUNET_ATS_print_network_type (c),
+                      out_dest[c]);
       }
       GNUNET_free (quota_out_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured 
for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configured for network `%s', assigning 
default bandwidth %llu\n"),
+                  GNUNET_ATS_print_network_type (c),
+                  GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
 
@@ -214,24 +227,35 @@
 
       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);
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _("Could not load quota for network `%s':  `%s', 
assigning default bandwidth %llu\n"),
+                      GNUNET_ATS_print_network_type (c),
+                      quota_in_str,
+                      GNUNET_ATS_DefaultBandwidth);
           in_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Inbound quota configured for 
network `%s' is %llu\n"),
-              network_str[c], in_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Inbound quota configured for network `%s' is %llu\n",
+                      GNUNET_ATS_print_network_type (c),
+                      in_dest[c]);
       }
       GNUNET_free (quota_in_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure 
for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configure for network `%s', assigning 
default bandwidth %llu\n"),
+                  GNUNET_ATS_print_network_type (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_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Loaded quota for network `%s' (in/out): %llu %llu\n",
+                GNUNET_ATS_print_network_type (c),
+                in_dest[c],
+                out_dest[c]);
     GNUNET_free (entry_out);
     GNUNET_free (entry_in);
   }

Modified: gnunet/src/ats-tool/gnunet-ats.c
===================================================================
--- gnunet/src/ats-tool/gnunet-ats.c    2015-01-17 16:24:45 UTC (rev 34911)
+++ gnunet/src/ats-tool/gnunet-ats.c    2015-01-17 21:31:48 UTC (rev 34912)
@@ -327,7 +327,6 @@
   struct PendingResolutions *pr = cls;
   char *ats_str;
   char *ats_tmp;
-  char *ats_prop_arr[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
   char *ats_prop_value;
   unsigned int c;
   uint32_t ats_type;
@@ -416,7 +415,7 @@
       GNUNET_asprintf (&ats_str,
                        "%s%s=%s, ",
                        ats_tmp,
-                       ats_prop_arr[ats_type],
+                       GNUNET_ATS_print_property_type (ats_type),
                        ats_prop_value);
       GNUNET_free(ats_tmp);
     }
@@ -675,7 +674,6 @@
 static unsigned int
 print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  char *network_str[GNUNET_ATS_NetworkTypeCount] = 
GNUNET_ATS_NetworkTypeString;
   char * entry_in = NULL;
   char * entry_out = NULL;
   char * quota_out_str;
@@ -689,10 +687,10 @@
 
     GNUNET_asprintf (&entry_out,
                      "%s_QUOTA_OUT",
-                     network_str[c]);
+                     GNUNET_ATS_print_network_type (c));
     GNUNET_asprintf (&entry_in,
                      "%s_QUOTA_IN",
-                     network_str[c]);
+                     GNUNET_ATS_print_network_type (c));
 
     /* quota out */
     if (GNUNET_OK ==
@@ -714,7 +712,7 @@
     {
       FPRINTF (stderr,
                "Outbound quota for network `%11s' not configured!\n",
-               network_str[c]);
+               GNUNET_ATS_print_network_type (c));
       GNUNET_asprintf (&quota_out_str, "-");
     }
     GNUNET_free(entry_out);
@@ -737,14 +735,14 @@
     {
       FPRINTF (stderr,
                "Inbound quota for network `%11s' not configured!\n",
-               network_str[c]);
+               GNUNET_ATS_print_network_type (c));
       GNUNET_asprintf (&quota_in_str, "-");
     }
     GNUNET_free(entry_in);
 
     FPRINTF (stderr,
              _("Quota for network `%11s' (in/out): %10s / %10s\n"),
-             network_str[c],
+             GNUNET_ATS_print_network_type (c),
              quota_in_str,
              quota_out_str);
     GNUNET_free(quota_out_str);

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2015-01-17 16:24:45 UTC (rev 
34911)
+++ gnunet/src/include/gnunet_ats_service.h     2015-01-17 21:31:48 UTC (rev 
34912)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- (C) 2010,2011 Christian Grothoff (and other contributing authors)
+ (C) 2010-2015 Christian Grothoff (and other contributing authors)
 
  GNUnet is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
@@ -38,30 +38,53 @@
 /**
  * ATS network types as array initializer
  */
-#define GNUNET_ATS_NetworkType {GNUNET_ATS_NET_UNSPECIFIED, 
GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, 
GNUNET_ATS_NET_WLAN, GNUNET_ATS_NET_BT}
+#define GNUNET_ATS_NetworkType { GNUNET_ATS_NET_UNSPECIFIED, 
GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, 
GNUNET_ATS_NET_WLAN, GNUNET_ATS_NET_BT }
 
+
 /**
- * ATS network types as string array initializer
+ * Types of networks (with separate quotas) we support.
  */
-#define GNUNET_ATS_NetworkTypeString {"UNSPECIFIED", "LOOPBACK", "LAN", "WAN", 
"WLAN", "BLUETOOTH"}
-
 enum GNUNET_ATS_Network_Type
 {
+  /**
+   * Category of last resort.
+   */
   GNUNET_ATS_NET_UNSPECIFIED = 0,
+
+  /**
+   * Loopback (same host).
+   */
   GNUNET_ATS_NET_LOOPBACK = 1,
+
+  /**
+   * Local area network.
+   */
   GNUNET_ATS_NET_LAN = 2,
+
+  /**
+   * Wide area network (i.e. Internet)
+   */
   GNUNET_ATS_NET_WAN = 3,
+
+  /**
+   * Wireless LAN (i.e. 802.11abgn)
+   */
   GNUNET_ATS_NET_WLAN = 4,
+
+  /**
+   * Bluetooth LAN
+   */
   GNUNET_ATS_NET_BT = 5
 };
 
+
 /**
  * Default bandwidth assigned to a network : 64 KB/s
  */
 #define GNUNET_ATS_DefaultBandwidth 65536
 
 /**
- * Undefined value for a GNUNET_ATS_Property
+ * Undefined value for an `enum GNUNET_ATS_Property`
  */
 #define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX
 
@@ -85,10 +108,6 @@
  */
 #define GNUNET_ATS_PropertyCount 11
 
-/**
- * ATS properties types as string array initializer
- */
-#define GNUNET_ATS_PropertyStrings {"TERMINATOR", "UTILIZATION_UP", 
"UTILIZATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", 
"NETWORK_TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN"}
 
 /**
  * Enum defining all known property types for ATS Enum values are used
@@ -98,7 +117,7 @@
  * Cost are always stored in uint32_t, so all units used to define costs
  * have to be normalized to fit in uint32_t [0 .. UINT32_MAX-1]
  *
- * UINT32_MAX is reserved for uninitialized values GNUNET_ATS_VALUE_UNDEFINED
+ * UINT32_MAX is reserved for uninitialized values #GNUNET_ATS_VALUE_UNDEFINED
  */
 enum GNUNET_ATS_Property
 {
@@ -125,7 +144,6 @@
    */
   GNUNET_ATS_UTILIZATION_IN,
 
-
   /**
    * Actual traffic on this connection from this peer to the other peer.
    * Only payload from layers > transport
@@ -231,248 +249,10 @@
    * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
    */
   GNUNET_ATS_COST_WLAN
-/* Cost related values */
-/* =================== */
-/**
- * Volume based cost in financial units to transmit data
- *
- * Note: This value is not bound to a specific currency or unit and only
- * used locally.
- * "cent" just refers the smallest amount of money in the respective
- * currency.
- *
- * Unit: [cent/MB]
- *
- * Interpretation: less is better
- *
- * Examples:
- * LAN:  0 [cent/MB]
- * 2G : 10 [cent/MB]
- */
-// GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
-/**
- * Time based cost in financial units to transmit data
- *
- * Note: This value is not bound to a specific currency or unit and only
- * used locally.
- * "cent" just refers the smallest amount of money in the respective
- * currency.
- *
- * Unit: [cent/h]
- *
- * Interpretation: less is better
- *
- * Examples:
- * LAN   :  0 [cent/h]
- * Dialup: 10 [cent/h]
- */
-// GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
-/**
- * Computational costs
- *
- * Effort of preparing data to be sent with this transport
- * Includes encoding, encryption and conversion of data
- * Partial values can be summed up: c_sum = c_enc + c_enc + c_conv
- * Resulting values depend on local system properties, e.g. CPU
- *
- * Unit: [ms/GB]
- *
- * Interpretation: less is better
- *
- * Examples:
- *
- * HTTPS with AES CBC-256:     7,382
- * HTTPS with AES CBC-128:     5,279
- * HTTPS with RC4-1024:        2,652
- */
-// GNUNET_ATS_COST_COMPUTATIONAL = 3,
-/**
- * Energy consumption
- *
- * Energy consumption using this transport when sending with a certain
- * power at a certain bitrate. This is only an approximation based on:
- * Energy consumption E = P / D
- *
- * with:
- * Power P in Watt (J/s)
- * Datarate D in MBit/s
- *
- * Conversion between power P and dBm used by WLAN in radiotap's dBm TX power:
- *
- * Lp(dbm) = 10 log10 (P/ 1mW)
- *
- * => P = 1 mW  * 10^(Lp(dbm)/10)
- *
- * Unit: [mJ/MB]
- *
- * Interpretation: less is better
- *
- * Examples:
- *
- * LAN:       0
- * WLAN:      89 (600 mW @ 802.11g /w 54 MBit/s)
- * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
- */
-// GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
-/**
- * Connect cost
- * How many bytes are transmitted to initiate a new connection using
- * this transport?
- *
- * Unit: [bytes]
- *
- * Interpretation: less is better
- *
- * Examples:
- *
- * UDP (No connection)      :
- *     0 bytes
- * TCP (TCP 3-Way handshake):
- *   220 bytes Ethernet,  172 bytes TCP/IP,  122 bytes TCP
- * HTTP (TCP + Header)      :
- *   477 bytes Ethernet,  429 bytes TCP/IP,  374 bytes TCP,  278 bytes HTTP
- * HTTPS  HTTP+TLS Handshake:
- *  2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
- *
- * */
-// GNUNET_ATS_COST_CONNECT = 5,
-/**
- * Bandwidth cost
- *
- * How many bandwidth is available to consume?
- * Used to calculate which impact sending data with this transport has
- *
- * Unit: [kB/s]
- *
- * Interpretation: more is better
- *
- * Examples:
- * LAN:     12,800  (100 MBit/s)
- * WLAN:    6,912   (54 MBit/s)
- * Dial-up: 8       (64 Kbit/s)
- *
- */
-// GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
-/**
- *  Network overhead
- *
- * How many bytes are sent over the wire when 1 kilobyte (1024 bytes)
- * of application data is transmitted?
- * A factor used with connect cost, bandwidth cost and energy cost
- * to describe the overhead produced by the transport protocol
- *
- * Unit: [bytes/kb]
- *
- * Interpretation: less is better
- *
- * Examples:
- *
- * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
- * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
- * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
- * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
- */
-// GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
-/* Quality related values */
-/* ====================== */
-/* Physical layer quality properties */
-/**
- * Signal strength on physical layer
- *
- * Unit: [dBm]
- */
-// GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
-/**
- * Collision rate on physical layer
- *
- * Unit: [B/s]
- */
-// GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
-/**
- * Error rate on physical layer
- *
- * Unit: [B/s]
- */
-// GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
-/**
- * Jitter
- * Time variations of the delay
- * 1st derivative of a delay function
- *
- * Unit: [ms]
- */
-// GNUNET_ATS_QUALITY_NET_JITTER = 1029,
-/**
- * Error rate on network layer
- *
- * Unit: [B/s]
- *
- * Examples:
- *
- * LAN       :    0
- * WLAN      :  400
- * Bluetooth :  100
- * Note: This numbers are just assumptions as an example, not
- * measured or somehow determined
- */
-// GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
-/**
- * Drop rate on network layer
- * Bytes actively dismissed by a network component during transmission
- * Reasons for dropped data can be full queues, congestion, quota violations...
- *
- * Unit: [B/s]
- *
- * Examples:
- *
- * LAN       :    0
- * WLAN      :  400
- * Bluetooth :  100
- * Note: This numbers are just assumptions as an example, not
- * measured or somehow determined
- */
-// GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
-/**
- * Loss rate on network layer
- * Bytes lost during transmission
- * Reasons can be collisions, ...
- *
- * Unit: [B/s]
- *
- * Examples:
- *
- * LAN       :    0
- * WLAN      :   40
- * Bluetooth :   10
- * Note: This numbers are just assumptions as an example, not measured
- * or somehow determined
- */
-// GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
-/**
- * Throughput on network layer
- *
- * Unit: [kB/s]
- *
- * Examples:
- *
- * LAN   : 3400
- * WLAN  : 1200
- * Dialup:       4
- *
- */
-// GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
-/* Availability related values */
-/* =========================== */
-/**
- * Is a peer reachable?
- */
-// GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
-/**
- * Is there a connection established to a peer using this transport
- */
-// GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
+
 };
 
+
 /**
  * Number of ATS quality properties
  */
@@ -481,7 +261,7 @@
 /**
  * ATS quality properties as array initializer
  */
-#define GNUNET_ATS_QualityProperties {GNUNET_ATS_QUALITY_NET_DELAY, 
GNUNET_ATS_QUALITY_NET_DISTANCE}
+#define GNUNET_ATS_QualityProperties { GNUNET_ATS_QUALITY_NET_DELAY, 
GNUNET_ATS_QUALITY_NET_DISTANCE }
 
 /**
  * ATS quality properties as string array initializer
@@ -559,7 +339,8 @@
 typedef void
 (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
     const struct GNUNET_PeerIdentity *peer,
-    const struct GNUNET_HELLO_Address *address, struct Session *session,
+    const struct GNUNET_HELLO_Address *address,
+    struct Session *session,
     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
     const struct GNUNET_ATS_Information *ats, uint32_t ats_count);
@@ -589,7 +370,7 @@
 
 /**
  * We would like to reset the address suggestion block time for this
- * peer
+ * peer.
  *
  * @param sh handle
  * @param peer identity of the peer we want to reset
@@ -630,25 +411,26 @@
 /**
  * Convert a ATS property to a string
  *
- * @param type the atsi type
+ * @param type the property type
  * @return a string or NULL if invalid
  */
 const char *
-GNUNET_ATS_print_property_type (uint32_t type);
+GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type);
 
 
 /**
- * Convert a GNUNET_ATS_NetworkType to a string
+ * Convert a `enum GNUNET_ATS_Network_Type` to a string
  *
  * @param net the network type
  * @return a string or NULL if invalid
  */
 const char *
-GNUNET_ATS_print_network_type (uint32_t net);
+GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net);
 
 
 /**
  * Returns where the address is located: LAN or WAN or ...
+ *
  * @param sh the `struct GNUNET_ATS_SchedulingHandle` handle
  * @param addr address
  * @param addrlen address length
@@ -656,12 +438,12 @@
  */
 struct GNUNET_ATS_Information
 GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh,
-                             const struct sockaddr * addr,
+                             const struct sockaddr *addr,
                              socklen_t addrlen);
 
 
 /**
- * Test if a address and a session is known to ATS
+ * Test if a address and a session is known to ATS.
  *
  * @param sh the scheduling handle
  * @param address the address

Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2015-01-17 16:24:45 UTC 
(rev 34911)
+++ gnunet/src/transport/test_quota_compliance.c        2015-01-17 21:31:48 UTC 
(rev 34912)
@@ -415,7 +415,6 @@
 generate_config (char *cfg_file, unsigned long long quota_in,
                  unsigned long long quota_out)
 {
-  char *networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
   char *in_name;
   char *out_name;
   char *fname = NULL;
@@ -430,12 +429,16 @@
 
   for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
   {
-      GNUNET_asprintf (&in_name, "%s_QUOTA_IN", networks[c]);
-      GNUNET_asprintf (&out_name, "%s_QUOTA_OUT", networks[c]);
-      GNUNET_CONFIGURATION_set_value_number (cfg, "ats", in_name, quota_in);
-      GNUNET_CONFIGURATION_set_value_number (cfg, "ats", out_name, quota_out);
-      GNUNET_free (in_name);
-      GNUNET_free (out_name);
+    GNUNET_asprintf (&in_name,
+                     "%s_QUOTA_IN",
+                     GNUNET_ATS_print_network_type (c));
+    GNUNET_asprintf (&out_name,
+                     "%s_QUOTA_OUT",
+                     GNUNET_ATS_print_network_type (c));
+    GNUNET_CONFIGURATION_set_value_number (cfg, "ats", in_name, quota_in);
+    GNUNET_CONFIGURATION_set_value_number (cfg, "ats", out_name, quota_out);
+    GNUNET_free (in_name);
+    GNUNET_free (out_name);
   }
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname));
   GNUNET_CONFIGURATION_destroy (cfg);




reply via email to

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