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