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