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 trialuid return the trialuid of the newly inserted trial
39 * @param num_nodes how many nodes are in the trial
40 * @param topology integer representing topology for this trial
41 * @param blacklist_topology integer representing blacklist topology for this trial
42 * @param connect_topology integer representing connect topology for this trial
43 * @param connect_topology_option integer representing connect topology option
44 * @param connect_topology_option_modifier float to modify connect option
45 * @param topology_percentage percentage modifier for certain topologies
46 * @param topology_probability probability modifier for certain topologies
47 * @param puts number of puts to perform
48 * @param gets number of gets to perform
49 * @param concurrent number of concurrent requests
50 * @param settle_time time to wait between creating topology and starting testing
51 * @param num_rounds number of times to repeat the trial
52 * @param malicious_getters number of malicious GET peers in the trial
53 * @param malicious_putters number of malicious PUT peers in the trial
54 * @param malicious_droppers number of malicious DROP peers in the trial
55 * @param message string to put into DB for this trial
57 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
60 add_trial (unsigned long long *trialuid, int num_nodes, int topology,
61 int blacklist_topology, int connect_topology,
62 int connect_topology_option, float connect_topology_option_modifier,
63 float topology_percentage, float topology_probability,
64 int puts, int gets, int concurrent, int settle_time,
65 int num_rounds, int malicious_getters, int malicious_putters,
66 int malicious_droppers, char *message)
73 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
74 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
76 * @param dhtkeyuid return value
77 * @param dhtkey hashcode of key to insert
79 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
82 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
90 * Inserts the specified node into the dhttests.nodes table
92 * @param nodeuid the inserted node uid
93 * @param node the node to insert
95 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
98 add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
105 * Update dhttests.trials table with current server time as end time
107 * @param trialuid trial to update
108 * @param totalMessagesDropped stats value for messages dropped
109 * @param totalBytesDropped stats value for total bytes dropped
110 * @param unknownPeers stats value for unknown peers
112 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
115 update_trials (unsigned long long trialuid,
116 unsigned long long totalMessagesDropped,
117 unsigned long long totalBytesDropped,
118 unsigned long long unknownPeers)
125 * Update dhttests.trials table with total connections information
127 * @param trialuid the trialuid to update
128 * @param totalConnections the number of connections
130 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
133 add_connections (unsigned long long trialuid, unsigned int totalConnections)
139 * Inserts the specified query into the dhttests.queries table
141 * @param sqlqueruid inserted query uid
142 * @param queryid dht query id
143 * @param type type of the query
144 * @param hops number of hops query traveled
145 * @param succeeded whether or not query was successful
146 * @param node the node the query hit
147 * @param key the key of the query
149 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
152 add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
153 unsigned int type, unsigned int hops, int succeeded,
154 const struct GNUNET_PeerIdentity * node, const GNUNET_HashCode * key)
161 * Inserts the specified route information into the dhttests.routes table
163 * @param sqlqueruid inserted query uid
164 * @param queryid dht query id
165 * @param type type of the query
166 * @param hops number of hops query traveled
167 * @param succeeded whether or not query was successful
168 * @param node the node the query hit
169 * @param key the key of the query
170 * @param from_node the node that sent the message to node
171 * @param to_node next node to forward message to
173 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
176 add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
177 unsigned int type, unsigned int hops,
178 int succeeded, const struct GNUNET_PeerIdentity * node,
179 const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity * from_node,
180 const struct GNUNET_PeerIdentity * to_node)
188 * Records the current topology (number of connections, time, trial)
190 * @param num_connections how many connections are in the topology
192 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
195 add_topology (int num_connections)
201 * Records a connection between two peers in the current topology
203 * @param first one side of the connection
204 * @param second other side of the connection
206 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
209 add_extended_topology (struct GNUNET_PeerIdentity *first, struct GNUNET_PeerIdentity *second)
215 * Update dhttests.topology table with total connections information
217 * @param totalConnections the number of connections
219 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
222 update_topology (unsigned int connections)
229 * Provides the dhtlog api
231 * @param c the configuration to use to connect to a server
233 * @return the handle to the server, or NULL on error
236 libgnunet_plugin_dhtlog_dummy_init (void * cls)
238 struct GNUNET_DHTLOG_Plugin *plugin = cls;
240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DUMMY DHT Logger: initializing.\n");
242 GNUNET_assert(plugin->dhtlog_api == NULL);
243 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
244 plugin->dhtlog_api->insert_trial = &add_trial;
245 plugin->dhtlog_api->insert_query = &add_query;
246 plugin->dhtlog_api->update_trial = &update_trials;
247 plugin->dhtlog_api->insert_route = &add_route;
248 plugin->dhtlog_api->insert_node = &add_node;
249 plugin->dhtlog_api->insert_dhtkey = &add_dhtkey;
250 plugin->dhtlog_api->update_connections = &add_connections;
251 plugin->dhtlog_api->insert_topology = &add_topology;
252 plugin->dhtlog_api->update_topology = &update_topology;
253 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
258 * Shutdown the plugin.
261 libgnunet_plugin_dhtlog_dummy_done (void * cls)
264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
265 "DUMMY DHT Logger: shutdown\n");
270 /* end of plugin_dhtlog_dummy.c */