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