- doxygen
[oweals/gnunet.git] / src / experimentation / gnunet-daemon-experimentation_capabilities.c
index 74220435afd38ec000d08abb1534d05cac246c8d..7d74c2827432976748bdc35aeeb7de6be41e77be 100644 (file)
  * @author Matthias Wachs
  */
 #include "platform.h"
-#include "gnunet_getopt_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_core_service.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet-daemon-experimentation.h"
 
+
+/**
+ * Capability value shared between components
+ */
 uint32_t GSE_node_capabilities;
 
 
-#define GNUNET_EXPERIMENTATION_capabilities_count 11;
+/**
+ * Capabilities defined at the moment
+ */
+#define GNUNET_EXPERIMENTATION_capabilities_count 11
+
 
 /**
  * Capabilities a node has or an experiment requires string
  */
 #define GNUNET_EXPERIMENTATION_capabilities_string {"NONE", "PLUGIN_TCP", "PLUGIN_UDP", "PLUGIN_UNIX", "PLUGIN_HTTP_CLIENT", "PLUGIN_HTTP_SERVER", "PLUGIN_HTTPS_CLIENT", "PLUGIN_HTTPS_SERVER", "PLUGIN_WLAN", "HAVE_IPV6", "BEHIND_NAT"}
 
+
+/**
+ * Print a single capability value
+ *
+ * @param cap capability value
+ * @return the string to print
+ */
 const char *
-GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap)
+GED_capability_to_str (uint32_t cap)
 {
        char * capstr[] = GNUNET_EXPERIMENTATION_capabilities_string;
        unsigned index = 0;
@@ -57,7 +71,7 @@ GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap)
        if (test != cap)
                return "UNDEFINED";
 
-       if (index <= 11)
+       if (index < GNUNET_EXPERIMENTATION_capabilities_count)
                return capstr[index];
        else
         return "UNDEFINED";
@@ -65,14 +79,16 @@ GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap)
 
 }
 
+
 /**
  * Are the capabilities provided?
  *
  * @param have bitstring containing the provided capabilities
- * @param have bitstring containing the desired capabilities
+ * @param desired bitstring containing the desired capabilities\
+ * @return GNUNET_YES or GNUNET_NO
  */
 int
-GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired)
+GED_capabilities_have (uint32_t have, uint32_t desired)
 {
        if (desired == (desired & have))
                return GNUNET_YES;
@@ -83,11 +99,9 @@ GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired)
 
 /**
  * Start the detecting capabilities
- *
- * @param cfg configuration handle
  */
 void
-GNUNET_EXPERIMENTATION_capabilities_start ()
+GED_capabilities_start ()
 {
        char *plugins;
   char *pos;
@@ -97,7 +111,7 @@ GNUNET_EXPERIMENTATION_capabilities_start ()
 
        /* Plugins configured */
 
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (GSE_cfg,
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (GED_cfg,
                        "TRANSPORT", "PLUGINS", &plugins))
   {
          for (pos = strtok (plugins, " "); pos != NULL; pos = strtok (NULL, " "))
@@ -124,12 +138,12 @@ GNUNET_EXPERIMENTATION_capabilities_start ()
 
        /* IPv6 enabled
         * FIXE: just having it not enabled is not really sufficient */
-  if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (GSE_cfg,
+  if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
                        "NAT", "DISABLEV6"))
        GSE_node_capabilities |= HAVE_IPV6;
 
   /* Behind NAT */
-  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (GSE_cfg,
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
                        "NAT", "BEHIND_NAT"))
        GSE_node_capabilities |= BEHIND_NAT;
 
@@ -137,19 +151,20 @@ GNUNET_EXPERIMENTATION_capabilities_start ()
   {
                index = 1;
                index = index << c1;
-               if (GNUNET_YES == GNUNET_EXPERIMENTATION_capabilities_have (GSE_node_capabilities, index))
+               if (GNUNET_YES == GED_capabilities_have (GSE_node_capabilities, index))
                {
-                       GNUNET_log (GNUNET_ERROR_TYPE_INFO, "We have `%s'\n",
-                                       GNUNET_EXPERIMENTATION_capability_to_str(index));
+                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We have `%s'\n",
+                                       GED_capability_to_str(index));
                }
   }
 }
 
+
 /**
  * Stop the detecting capabilities
  */
 void
-GNUNET_EXPERIMENTATION_capabilities_stop ()
+GED_capabilities_stop ()
 {
 
 }