indentation
[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 trial_info struct containing the data to insert about this trial
39  *
40  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
41  */
42 int
43 add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
44 {
45   return GNUNET_OK;
46 }
47
48 /*
49  * Inserts the specified round into the dhttests.rounds table
50  *
51  * @param round_type the type of round that is being started
52  * @param round_count counter for the round (if applicable)
53  *
54  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
55  */
56 int
57 add_round (unsigned int round_type, unsigned int round_count)
58 {
59   return GNUNET_OK;
60 }
61
62 /*
63  * Inserts the specified round results into the
64  * dhttests.processed_round_details table
65  *
66  * @param round_type the type of round that is being started
67  * @param round_count counter for the round (if applicable)
68  * @param num_messages the total number of messages initiated
69  * @param num_messages_succeeded the number of messages that succeeded
70  *
71  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
72  */
73 int
74 add_round_details (unsigned int round_type, unsigned int round_count,
75                    unsigned int num_messages,
76                    unsigned int num_messages_succeded)
77 {
78   return GNUNET_OK;
79 }
80
81 /*
82  * Inserts the specified dhtkey into the dhttests.dhtkeys table,
83  * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
84  *
85  * @param dhtkeyuid return value
86  * @param dhtkey hashcode of key to insert
87  *
88  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
89  */
90 int
91 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
92 {
93   *dhtkeyuid = 1171;
94   return GNUNET_OK;
95 }
96
97
98 /*
99  * Inserts the specified node into the dhttests.nodes table
100  *
101  * @param nodeuid the inserted node uid
102  * @param node the node to insert
103  *
104  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
105  */
106 int
107 add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity *node)
108 {
109   *nodeuid = 1337;
110   return GNUNET_OK;
111 }
112
113 /*
114  * Update dhttests.trials table with current server time as end time
115  *
116  * @param gets_succeeded how many gets did the testcase report as successful
117  *
118  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
119  */
120 int
121 update_trials (unsigned int gets_succeeded)
122 {
123   return GNUNET_OK;
124 }
125
126
127 /*
128  * Inserts the specified stats into the dhttests.generic_stats table
129  *
130  * @param peer the peer inserting the statistic
131  * @param name the name of the statistic
132  * @param section the section of the statistic
133  * @param value the value of the statistic
134  *
135  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
136  */
137 int
138 add_generic_stat (const struct GNUNET_PeerIdentity *peer,
139                   const char *name, const char *section, uint64_t value)
140 {
141   return GNUNET_OK;
142 }
143
144 /*
145  * Update dhttests.trials table with total connections information
146  *
147  * @param totalConnections the number of connections
148  *
149  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
150  */
151 int
152 add_connections (unsigned int totalConnections)
153 {
154   return GNUNET_OK;
155 }
156
157 /*
158  * Inserts the specified query into the dhttests.queries table
159  *
160  * @param sqlqueruid inserted query uid
161  * @param queryid dht query id
162  * @param type type of the query
163  * @param hops number of hops query traveled
164  * @param succeeded whether or not query was successful
165  * @param node the node the query hit
166  * @param key the key of the query
167  *
168  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
169  */
170 int
171 add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
172            unsigned int type, unsigned int hops, int succeeded,
173            const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key)
174 {
175   *sqlqueryuid = 17;
176   return GNUNET_OK;
177 }
178
179 /*
180  * Inserts the specified route information into the dhttests.routes table
181  *
182  * @param sqlqueruid inserted query uid
183  * @param queryid dht query id
184  * @param type type of the query
185  * @param hops number of hops query traveled
186  * @param succeeded whether or not query was successful
187  * @param node the node the query hit
188  * @param key the key of the query
189  * @param from_node the node that sent the message to node
190  * @param to_node next node to forward message to
191  *
192  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
193  */
194 int
195 add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
196            unsigned int type, unsigned int hops,
197            int succeeded, const struct GNUNET_PeerIdentity *node,
198            const GNUNET_HashCode * key,
199            const struct GNUNET_PeerIdentity *from_node,
200            const struct GNUNET_PeerIdentity *to_node)
201 {
202   *sqlqueryuid = 18;
203   return GNUNET_OK;
204 }
205
206
207 /*
208  * Records the current topology (number of connections, time, trial)
209  *
210  * @param num_connections how many connections are in the topology
211  *
212  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
213  */
214 int
215 add_topology (int num_connections)
216 {
217   return GNUNET_OK;
218 }
219
220 /*
221  * Records a connection between two peers in the current topology
222  *
223  * @param first one side of the connection
224  * @param second other side of the connection
225  *
226  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
227  */
228 int
229 add_extended_topology (const struct GNUNET_PeerIdentity *first,
230                        const struct GNUNET_PeerIdentity *second)
231 {
232   return GNUNET_OK;
233 }
234
235 /*
236  * Update dhttests.topology table with total connections information
237  *
238  * @param totalConnections the number of connections
239  *
240  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
241  */
242 int
243 update_topology (unsigned int connections)
244 {
245   return GNUNET_OK;
246 }
247
248 /*
249  * Update dhttests.nodes table setting the identified
250  * node as a malicious dropper.
251  *
252  * @param peer the peer that was set to be malicious
253  *
254  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
255  */
256 int
257 set_malicious (struct GNUNET_PeerIdentity *peer)
258 {
259   return GNUNET_OK;
260 }
261
262 /*
263  * Inserts the specified stats into the dhttests.node_statistics table
264  *
265  * @param peer the peer inserting the statistic
266  * @param route_requests route requests seen
267  * @param route_forwards route requests forwarded
268  * @param result_requests route result requests seen
269  * @param client_requests client requests initiated
270  * @param result_forwards route results forwarded
271  * @param gets get requests handled
272  * @param puts put requests handle
273  * @param data_inserts data inserted at this node
274  * @param find_peer_requests find peer requests seen
275  * @param find_peers_started find peer requests initiated at this node
276  * @param gets_started get requests initiated at this node
277  * @param puts_started put requests initiated at this node
278  * @param find_peer_responses_received find peer responses received locally
279  * @param get_responses_received get responses received locally
280  * @param find_peer_responses_sent find peer responses sent from this node
281  * @param get_responses_sent get responses sent from this node
282  *
283  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
284  */
285 int insert_stat
286     (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
287      unsigned int route_forwards, unsigned int result_requests,
288      unsigned int client_requests, unsigned int result_forwards,
289      unsigned int gets, unsigned int puts,
290      unsigned int data_inserts, unsigned int find_peer_requests,
291      unsigned int find_peers_started, unsigned int gets_started,
292      unsigned int puts_started, unsigned int find_peer_responses_received,
293      unsigned int get_responses_received, unsigned int find_peer_responses_sent,
294      unsigned int get_responses_sent)
295 {
296   return GNUNET_OK;
297 }
298
299 /*
300  * Provides the dhtlog api
301  *
302  * @param c the configuration to use to connect to a server
303  *
304  * @return the handle to the server, or NULL on error
305  */
306 void *
307 libgnunet_plugin_dhtlog_dummy_init (void *cls)
308 {
309   struct GNUNET_DHTLOG_Plugin *plugin = cls;
310
311 #if DEBUG_DHTLOG
312   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DUMMY DHT Logger: initializing.\n");
313 #endif
314   GNUNET_assert (plugin->dhtlog_api == NULL);
315   plugin->dhtlog_api = GNUNET_malloc (sizeof (struct GNUNET_DHTLOG_Handle));
316   plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
317   plugin->dhtlog_api->insert_round = &add_round;
318   plugin->dhtlog_api->insert_round_details = &add_round_details;
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 plugin;
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, "DUMMY DHT Logger: shutdown\n");
342 #endif
343   return NULL;
344 }
345
346 /* end of plugin_dhtlog_dummy.c */