2 This file is part of GNUnet.
3 (C) 2006 - 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file src/dht/plugin_dhtlog_dummy.c
23 * @brief Dummy logging plugin to test logging calls
24 * @author Nathan Evans
30 #include "gnunet_util_lib.h"
33 #define DEBUG_DHTLOG GNUNET_NO
36 * Inserts the specified trial into the dhttests.trials table
38 * @param trial_info struct containing the data to insert about this trial
40 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
42 int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
48 * Inserts the specified round into the dhttests.rounds table
50 * @param round_type the type of round that is being started
51 * @param round_count counter for the round (if applicable)
53 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
55 int add_round (unsigned int round_type, unsigned int round_count)
61 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
62 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
64 * @param dhtkeyuid return value
65 * @param dhtkey hashcode of key to insert
67 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
70 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
78 * Inserts the specified node into the dhttests.nodes table
80 * @param nodeuid the inserted node uid
81 * @param node the node to insert
83 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
86 add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
93 * Update dhttests.trials table with current server time as end time
95 * @param gets_succeeded how many gets did the testcase report as successful
97 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
100 update_trials (unsigned int gets_succeeded)
107 * Inserts the specified stats into the dhttests.generic_stats table
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
114 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
117 add_generic_stat (const struct GNUNET_PeerIdentity *peer,
119 const char *section, uint64_t value)
125 * Update dhttests.trials table with total connections information
127 * @param totalConnections the number of connections
129 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
132 add_connections (unsigned int totalConnections)
138 * Inserts the specified query into the dhttests.queries table
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
148 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
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)
160 * Inserts the specified route information into the dhttests.routes table
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
172 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
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)
187 * Records the current topology (number of connections, time, trial)
189 * @param num_connections how many connections are in the topology
191 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
194 add_topology (int num_connections)
200 * Records a connection between two peers in the current topology
202 * @param first one side of the connection
203 * @param second other side of the connection
205 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
208 add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second)
214 * Update dhttests.topology table with total connections information
216 * @param totalConnections the number of connections
218 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
221 update_topology (unsigned int connections)
227 * Update dhttests.nodes table setting the identified
228 * node as a malicious dropper.
230 * @param peer the peer that was set to be malicious
232 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
235 set_malicious (struct GNUNET_PeerIdentity *peer)
241 * Inserts the specified stats into the dhttests.node_statistics table
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
261 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
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)
278 * Provides the dhtlog api
280 * @param c the configuration to use to connect to a server
282 * @return the handle to the server, or NULL on error
285 libgnunet_plugin_dhtlog_dummy_init (void * cls)
287 struct GNUNET_DHTLOG_Plugin *plugin = cls;
289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DUMMY DHT Logger: initializing.\n");
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;
311 * Shutdown the plugin.
314 libgnunet_plugin_dhtlog_dummy_done (void * cls)
317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
318 "DUMMY DHT Logger: shutdown\n");
323 /* end of plugin_dhtlog_dummy.c */