new components
[oweals/gnunet.git] / src / experimentation / gnunet-daemon-experimentation.h
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.h
23  * @brief experimentation daemon
24  * @author Christian Grothoff
25  * @author Matthias Wachs
26  */
27 #include "platform.h"
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
33
34 /**
35  * Timeout between request and expected response
36  */
37 #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
38
39
40 /**
41  * Statistics handle shared between components
42  */
43 extern struct GNUNET_STATISTICS_Handle *GSE_stats;
44
45
46 /**
47  * Configuration handle shared between components
48  */
49 extern struct GNUNET_CONFIGURATION_Handle *GSE_cfg;
50
51
52 /**
53  * Capability value shared between components
54  */
55 extern uint32_t GSE_node_capabilities;
56
57
58 /**
59  * Capabilities a node has or an experiment requires
60  */
61 enum GNUNET_EXPERIMENTATION_capabilities
62 {
63         NONE = 0,
64         PLUGIN_TCP = 1,
65         PLUGIN_UDP = 2,
66         PLUGIN_UNIX = 4,
67         PLUGIN_HTTP_CLIENT = 8,
68         PLUGIN_HTTP_SERVER = 16,
69         PLUGIN_HTTPS_CLIENT = 32,
70         PLUGIN_HTTPS_SERVER = 64,
71         PLUGIN_WLAN = 128,
72         HAVE_IPV6 = 256,
73         BEHIND_NAT = 512
74 };
75
76
77 /**
78  * A experimentation node
79  */
80 struct Node
81 {
82         /**
83          * Peer id
84          */
85         struct GNUNET_PeerIdentity id;
86
87         /**
88          * Task for response timeout
89          */
90         GNUNET_SCHEDULER_TaskIdentifier timeout_task;
91
92         /**
93          * Core transmission handle
94          */
95         struct GNUNET_CORE_TransmitHandle *cth;
96
97         uint32_t capabilities;
98 };
99
100 /**
101  * Experimentation request message
102  * Used to detect experimentation capability
103  */
104 struct Experimentation_Request
105 {
106         struct GNUNET_MessageHeader msg;
107
108         uint32_t capabilities;
109 };
110
111 /**
112  * Experimentation response message
113  * Sent if peer is running the daemon
114  */
115 struct Experimentation_Response
116 {
117         struct GNUNET_MessageHeader msg;
118
119         uint32_t capabilities;
120 };
121
122
123 /**
124  * Start the nodes management
125  */
126 void
127 GNUNET_EXPERIMENTATION_nodes_start ();
128
129
130 /**
131  * Stop the nodes management
132  */
133 void
134 GNUNET_EXPERIMENTATION_nodes_stop ();
135
136
137 /**
138  * Print a single capability value
139  *
140  * @param cap capability value
141  * @return the string to print
142  */
143 const char *
144 GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap);
145
146
147 /**
148  * Are the capabilities provided?
149  *
150  * @param have bitstring containing the provided capabilities
151  * @param desired bitstring containing the desired capabilities\
152  * @return GNUNET_YES or GNUNET_NO
153  */
154 int
155 GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired);
156
157
158 /**
159  * Start the detecting capabilities
160  */
161 void
162 GNUNET_EXPERIMENTATION_capabilities_start ();
163
164
165 /**
166  * Stop the detecting capabilities
167  */
168 void
169 GNUNET_EXPERIMENTATION_capabilities_stop ();
170
171
172 /**
173  * Start experiments management
174  *
175  * @return GNUNET_YES or GNUNET_NO
176  */
177 int
178 GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID);
179
180
181 /**
182  * Start experiments management
183  *
184  * @return GNUNET_OK on success, GNUNET_SYSERR on error
185  */
186 int
187 GNUNET_EXPERIMENTATION_experiments_start ();
188
189
190 /**
191  * Stop experiments management
192  */
193 void
194 GNUNET_EXPERIMENTATION_experiments_stop ();
195
196
197 /**
198  * Start the storage component
199  */
200 void
201 GNUNET_EXPERIMENTATION_storage_start ();
202
203
204
205 /**
206  * Stop the storage component
207  */
208 void
209 GNUNET_EXPERIMENTATION_storage_stop ();
210
211
212 /* end of gnunet-daemon-experimentation.h */