2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file experimentation/gnunet-daemon-experimentation_capabilities.c
23 * @brief experimentation daemon: capabilities management
24 * @author Christian Grothoff
25 * @author Matthias Wachs
28 #include "gnunet_getopt_lib.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_statistics_service.h"
32 #include "gnunet-daemon-experimentation.h"
36 * Capability value shared between components
38 uint32_t GSE_node_capabilities;
42 * Capabilities defined at the moment
44 #define GNUNET_EXPERIMENTATION_capabilities_count 11;
48 * Capabilities a node has or an experiment requires string
50 #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"}
54 * Print a single capability value
56 * @param cap capability value
57 * @return the string to print
60 GED_capability_to_str (uint32_t cap)
62 char * capstr[] = GNUNET_EXPERIMENTATION_capabilities_string;
69 index = (log(cap) / log (2)) + 1;
71 test = 1 << (index - 1);
85 * Are the capabilities provided?
87 * @param have bitstring containing the provided capabilities
88 * @param desired bitstring containing the desired capabilities\
89 * @return GNUNET_YES or GNUNET_NO
92 GED_capabilities_have (uint32_t have, uint32_t desired)
94 if (desired == (desired & have))
102 * Start the detecting capabilities
105 GED_capabilities_start ()
111 GSE_node_capabilities = NONE;
113 /* Plugins configured */
115 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (GED_cfg,
116 "TRANSPORT", "PLUGINS", &plugins))
118 for (pos = strtok (plugins, " "); pos != NULL; pos = strtok (NULL, " "))
120 if (0 == strcmp (pos, "tcp"))
121 GSE_node_capabilities |= PLUGIN_TCP;
122 else if (0 == strcmp (pos, "udp"))
123 GSE_node_capabilities |= PLUGIN_UDP;
124 else if (0 == strcmp (pos, "unix"))
125 GSE_node_capabilities |= PLUGIN_UNIX;
126 else if (0 == strcmp (pos, "http_client"))
127 GSE_node_capabilities |= PLUGIN_HTTP_CLIENT;
128 else if (0 == strcmp (pos, "http_server"))
129 GSE_node_capabilities |= PLUGIN_HTTP_SERVER;
130 else if (0 == strcmp (pos, "https_client"))
131 GSE_node_capabilities |= PLUGIN_HTTP_CLIENT;
132 else if (0 == strcmp (pos, "https_server"))
133 GSE_node_capabilities |= PLUGIN_HTTPS_SERVER;
134 else if (0 == strcmp (pos, "wlan"))
135 GSE_node_capabilities |= PLUGIN_WLAN;
137 GNUNET_free (plugins);
141 * FIXE: just having it not enabled is not really sufficient */
142 if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
144 GSE_node_capabilities |= HAVE_IPV6;
147 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
148 "NAT", "BEHIND_NAT"))
149 GSE_node_capabilities |= BEHIND_NAT;
151 for (c1 = 0 ; c1 < 32; c1++)
155 if (GNUNET_YES == GED_capabilities_have (GSE_node_capabilities, index))
157 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "We have `%s'\n",
158 GED_capability_to_str(index));
165 * Stop the detecting capabilities
168 GED_capabilities_stop ()
173 /* end of gnunet-daemon-experimentation_capabilities.c */