aboutsummaryrefslogtreecommitdiff
path: root/src/experimentation/gnunet-daemon-experimentation_capabilities.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/experimentation/gnunet-daemon-experimentation_capabilities.c')
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_capabilities.c172
1 files changed, 0 insertions, 172 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation_capabilities.c b/src/experimentation/gnunet-daemon-experimentation_capabilities.c
deleted file mode 100644
index 7d74c2827..000000000
--- a/src/experimentation/gnunet-daemon-experimentation_capabilities.c
+++ /dev/null
@@ -1,172 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19*/
20
21/**
22 * @file experimentation/gnunet-daemon-experimentation_capabilities.c
23 * @brief experimentation daemon: capabilities management
24 * @author Christian Grothoff
25 * @author Matthias Wachs
26 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_core_service.h"
30#include "gnunet_statistics_service.h"
31#include "gnunet-daemon-experimentation.h"
32
33
34/**
35 * Capability value shared between components
36 */
37uint32_t GSE_node_capabilities;
38
39
40/**
41 * Capabilities defined at the moment
42 */
43#define GNUNET_EXPERIMENTATION_capabilities_count 11
44
45
46/**
47 * Capabilities a node has or an experiment requires string
48 */
49#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"}
50
51
52/**
53 * Print a single capability value
54 *
55 * @param cap capability value
56 * @return the string to print
57 */
58const char *
59GED_capability_to_str (uint32_t cap)
60{
61 char * capstr[] = GNUNET_EXPERIMENTATION_capabilities_string;
62 unsigned index = 0;
63 uint32_t test = 0;
64
65 if (0 == cap)
66 return capstr[0];
67
68 index = (log(cap) / log (2)) + 1;
69
70 test = 1 << (index - 1);
71 if (test != cap)
72 return "UNDEFINED";
73
74 if (index < GNUNET_EXPERIMENTATION_capabilities_count)
75 return capstr[index];
76 else
77 return "UNDEFINED";
78
79
80}
81
82
83/**
84 * Are the capabilities provided?
85 *
86 * @param have bitstring containing the provided capabilities
87 * @param desired bitstring containing the desired capabilities\
88 * @return GNUNET_YES or GNUNET_NO
89 */
90int
91GED_capabilities_have (uint32_t have, uint32_t desired)
92{
93 if (desired == (desired & have))
94 return GNUNET_YES;
95 else
96 return GNUNET_NO;
97}
98
99
100/**
101 * Start the detecting capabilities
102 */
103void
104GED_capabilities_start ()
105{
106 char *plugins;
107 char *pos;
108 unsigned int c1;
109 uint32_t index;
110 GSE_node_capabilities = NONE;
111
112 /* Plugins configured */
113
114 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (GED_cfg,
115 "TRANSPORT", "PLUGINS", &plugins))
116 {
117 for (pos = strtok (plugins, " "); pos != NULL; pos = strtok (NULL, " "))
118 {
119 if (0 == strcmp (pos, "tcp"))
120 GSE_node_capabilities |= PLUGIN_TCP;
121 else if (0 == strcmp (pos, "udp"))
122 GSE_node_capabilities |= PLUGIN_UDP;
123 else if (0 == strcmp (pos, "unix"))
124 GSE_node_capabilities |= PLUGIN_UNIX;
125 else if (0 == strcmp (pos, "http_client"))
126 GSE_node_capabilities |= PLUGIN_HTTP_CLIENT;
127 else if (0 == strcmp (pos, "http_server"))
128 GSE_node_capabilities |= PLUGIN_HTTP_SERVER;
129 else if (0 == strcmp (pos, "https_client"))
130 GSE_node_capabilities |= PLUGIN_HTTP_CLIENT;
131 else if (0 == strcmp (pos, "https_server"))
132 GSE_node_capabilities |= PLUGIN_HTTPS_SERVER;
133 else if (0 == strcmp (pos, "wlan"))
134 GSE_node_capabilities |= PLUGIN_WLAN;
135 }
136 GNUNET_free (plugins);
137 }
138
139 /* IPv6 enabled
140 * FIXE: just having it not enabled is not really sufficient */
141 if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
142 "NAT", "DISABLEV6"))
143 GSE_node_capabilities |= HAVE_IPV6;
144
145 /* Behind NAT */
146 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (GED_cfg,
147 "NAT", "BEHIND_NAT"))
148 GSE_node_capabilities |= BEHIND_NAT;
149
150 for (c1 = 0 ; c1 < 32; c1++)
151 {
152 index = 1;
153 index = index << c1;
154 if (GNUNET_YES == GED_capabilities_have (GSE_node_capabilities, index))
155 {
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We have `%s'\n",
157 GED_capability_to_str(index));
158 }
159 }
160}
161
162
163/**
164 * Stop the detecting capabilities
165 */
166void
167GED_capabilities_stop ()
168{
169
170}
171
172/* end of gnunet-daemon-experimentation_capabilities.c */