backup errno
[oweals/gnunet.git] / src / dht / plugin_dhtlog_dummy.c
1 /*
2      This file is part of GNUnet.
3      (C) 2006 - 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 2, 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 src/dht/plugin_dhtlog_dummy.c
23  * @brief Dummy logging plugin to test logging calls
24  * @author Nathan Evans
25  *
26  * Database: NONE
27  */
28
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "dhtlog.h"
32
33 #define DEBUG_DHTLOG GNUNET_NO
34
35   /*
36    * Inserts the specified trial into the dhttests.trials table
37    *
38    * @param trialuid return the trialuid of the newly inserted trial
39    * @param other_identifier identifier for the trial from another source
40    *        (for joining later)
41    * @param num_nodes how many nodes are in the trial
42    * @param topology integer representing topology for this trial
43    * @param blacklist_topology integer representing blacklist topology for this trial
44    * @param connect_topology integer representing connect topology for this trial
45    * @param connect_topology_option integer representing connect topology option
46    * @param connect_topology_option_modifier float to modify connect option
47    * @param topology_percentage percentage modifier for certain topologies
48    * @param topology_probability probability modifier for certain topologies
49    * @param puts number of puts to perform
50    * @param gets number of gets to perform
51    * @param concurrent number of concurrent requests
52    * @param settle_time time to wait between creating topology and starting testing
53    * @param num_rounds number of times to repeat the trial
54    * @param malicious_getters number of malicious GET peers in the trial
55    * @param malicious_putters number of malicious PUT peers in the trial
56    * @param malicious_droppers number of malicious DROP peers in the trial
57    * @param malicious_get_frequency how often malicious gets are sent
58    * @param malicious_put_frequency how often malicious puts are sent
59    * @param stop_closest stop forwarding PUTs if closest node found
60    * @param stop_found stop forwarding GETs if data found
61    * @param strict_kademlia test used kademlia routing algorithm
62    * @param gets_succeeded how many gets did the test driver report success on
63    * @param message string to put into DB for this trial
64    *
65    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
66    */
67 int add_trial (unsigned long long *trialuid, unsigned int other_identifier, unsigned int num_nodes, unsigned int topology,
68                unsigned int blacklist_topology, unsigned int connect_topology,
69                unsigned int connect_topology_option, float connect_topology_option_modifier,
70                float topology_percentage, float topology_probability,
71                unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
72                unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
73                unsigned int malicious_droppers, unsigned int malicious_get_frequency,
74                unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
75                unsigned int strict_kademlia, unsigned int gets_succeeded,
76                char *message)
77 {
78   *trialuid = 42;
79   return GNUNET_OK;
80 }
81
82 /*
83  * Inserts the specified dhtkey into the dhttests.dhtkeys table,
84  * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
85  *
86  * @param dhtkeyuid return value
87  * @param dhtkey hashcode of key to insert
88  *
89  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
90  */
91 int
92 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
93 {
94   *dhtkeyuid = 1171;
95   return GNUNET_OK;
96 }
97
98
99 /*
100  * Inserts the specified node into the dhttests.nodes table
101  *
102  * @param nodeuid the inserted node uid
103  * @param node the node to insert
104  *
105  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
106  */
107 int
108 add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
109 {
110   *nodeuid = 1337;
111   return GNUNET_OK;
112 }
113
114 /*
115  * Update dhttests.trials table with current server time as end time
116  *
117  * @param trialuid trial to update
118  * @param gets_succeeded how many gets did the testcase report as successful
119  *
120  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
121  */
122 int
123 update_trials (unsigned long long trialuid,
124                unsigned int gets_succeeded)
125 {
126   return GNUNET_OK;
127 }
128
129
130 /*
131  * Inserts the specified stats into the dhttests.generic_stats table
132  *
133  * @param peer the peer inserting the statistic
134  * @param name the name of the statistic
135  * @param section the section of the statistic
136  * @param value the value of the statistic
137  *
138  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
139  */
140 int
141 add_generic_stat (const struct GNUNET_PeerIdentity *peer,
142                   const char *name,
143                   const char *section, uint64_t value)
144 {
145   return GNUNET_OK;
146 }
147
148 /*
149  * Update dhttests.trials table with total connections information
150  *
151  * @param trialuid the trialuid to update
152  * @param totalConnections the number of connections
153  *
154  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
155  */
156 int
157 add_connections (unsigned long long trialuid, unsigned int totalConnections)
158 {
159   return GNUNET_OK;
160 }
161
162 /*
163  * Inserts the specified query into the dhttests.queries table
164  *
165  * @param sqlqueruid inserted query uid
166  * @param queryid dht query id
167  * @param type type of the query
168  * @param hops number of hops query traveled
169  * @param succeeded whether or not query was successful
170  * @param node the node the query hit
171  * @param key the key of the query
172  *
173  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
174  */
175 int
176 add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
177            unsigned int type, unsigned int hops, int succeeded,
178            const struct GNUNET_PeerIdentity * node, const GNUNET_HashCode * key)
179 {
180   *sqlqueryuid = 17;
181   return GNUNET_OK;
182 }
183
184 /*
185  * Inserts the specified route information into the dhttests.routes table
186  *
187  * @param sqlqueruid inserted query uid
188  * @param queryid dht query id
189  * @param type type of the query
190  * @param hops number of hops query traveled
191  * @param succeeded whether or not query was successful
192  * @param node the node the query hit
193  * @param key the key of the query
194  * @param from_node the node that sent the message to node
195  * @param to_node next node to forward message to
196  *
197  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
198  */
199 int
200 add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
201            unsigned int type, unsigned int hops,
202            int succeeded, const struct GNUNET_PeerIdentity * node,
203            const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity * from_node,
204            const struct GNUNET_PeerIdentity * to_node)
205 {
206   *sqlqueryuid = 18;
207   return GNUNET_OK;
208 }
209
210
211 /*
212  * Records the current topology (number of connections, time, trial)
213  *
214  * @param num_connections how many connections are in the topology
215  *
216  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
217  */
218 int
219 add_topology (int num_connections)
220 {
221   return GNUNET_OK;
222 }
223
224 /*
225  * Records a connection between two peers in the current topology
226  *
227  * @param first one side of the connection
228  * @param second other side of the connection
229  *
230  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
231  */
232 int
233 add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second)
234 {
235   return GNUNET_OK;
236 }
237
238 /*
239  * Update dhttests.topology table with total connections information
240  *
241  * @param totalConnections the number of connections
242  *
243  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
244  */
245 int
246 update_topology (unsigned int connections)
247 {
248   return GNUNET_OK;
249 }
250
251 /*
252  * Update dhttests.nodes table setting the identified
253  * node as a malicious dropper.
254  *
255  * @param peer the peer that was set to be malicious
256  *
257  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
258  */
259 int
260 set_malicious (struct GNUNET_PeerIdentity *peer)
261 {
262   return GNUNET_OK;
263 }
264
265 /*
266  * Inserts the specified stats into the dhttests.node_statistics table
267  *
268  * @param peer the peer inserting the statistic
269  * @param route_requests route requests seen
270  * @param route_forwards route requests forwarded
271  * @param result_requests route result requests seen
272  * @param client_requests client requests initiated
273  * @param result_forwards route results forwarded
274  * @param gets get requests handled
275  * @param puts put requests handle
276  * @param data_inserts data inserted at this node
277  * @param find_peer_requests find peer requests seen
278  * @param find_peers_started find peer requests initiated at this node
279  * @param gets_started get requests initiated at this node
280  * @param puts_started put requests initiated at this node
281  * @param find_peer_responses_received find peer responses received locally
282  * @param get_responses_received get responses received locally
283  * @param find_peer_responses_sent find peer responses sent from this node
284  * @param get_responses_sent get responses sent from this node
285  *
286  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
287  */
288 int insert_stat
289    (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
290     unsigned int route_forwards, unsigned int result_requests,
291     unsigned int client_requests, unsigned int result_forwards,
292     unsigned int gets, unsigned int puts,
293     unsigned int data_inserts, unsigned int find_peer_requests,
294     unsigned int find_peers_started, unsigned int gets_started,
295     unsigned int puts_started, unsigned int find_peer_responses_received,
296     unsigned int get_responses_received, unsigned int find_peer_responses_sent,
297     unsigned int get_responses_sent)
298 {
299   return GNUNET_OK;
300 }
301
302 /*
303  * Provides the dhtlog api
304  *
305  * @param c the configuration to use to connect to a server
306  *
307  * @return the handle to the server, or NULL on error
308  */
309 void *
310 libgnunet_plugin_dhtlog_dummy_init (void * cls)
311 {
312   struct GNUNET_DHTLOG_Plugin *plugin = cls;
313 #if DEBUG_DHTLOG
314   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DUMMY DHT Logger: initializing.\n");
315 #endif
316   GNUNET_assert(plugin->dhtlog_api == NULL);
317   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
318   plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
319   plugin->dhtlog_api->insert_stat = &insert_stat;
320   plugin->dhtlog_api->insert_trial = &add_trial;
321   plugin->dhtlog_api->insert_query = &add_query;
322   plugin->dhtlog_api->update_trial = &update_trials;
323   plugin->dhtlog_api->set_malicious = &set_malicious;
324   plugin->dhtlog_api->insert_route = &add_route;
325   plugin->dhtlog_api->insert_node = &add_node;
326   plugin->dhtlog_api->insert_dhtkey = &add_dhtkey;
327   plugin->dhtlog_api->update_connections = &add_connections;
328   plugin->dhtlog_api->insert_topology = &add_topology;
329   plugin->dhtlog_api->update_topology = &update_topology;
330   plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
331   return NULL;
332 }
333
334 /**
335  * Shutdown the plugin.
336  */
337 void *
338 libgnunet_plugin_dhtlog_dummy_done (void * cls)
339 {
340 #if DEBUG_DHTLOG
341   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
342               "DUMMY DHT Logger: shutdown\n");
343 #endif
344   return NULL;
345 }
346
347 /* end of plugin_dhtlog_dummy.c */