missing definition
[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 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 malicious_get_frequency how often malicious gets are sent
56    * @param malicious_put_frequency how often malicious puts are sent
57    * @param stop_closest stop forwarding PUTs if closest node found
58    * @param stop_found stop forwarding GETs if data found
59    * @param strict_kademlia test used kademlia routing algorithm
60    * @param gets_succeeded how many gets did the test driver report success on
61    * @param message string to put into DB for this trial
62    *
63    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
64    */
65 int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
66                unsigned int blacklist_topology, unsigned int connect_topology,
67                unsigned int connect_topology_option, float connect_topology_option_modifier,
68                float topology_percentage, float topology_probability,
69                unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
70                unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
71                unsigned int malicious_droppers, unsigned int malicious_get_frequency,
72                unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
73                unsigned int strict_kademlia, unsigned int gets_succeeded,
74                char *message)
75 {
76   *trialuid = 42;
77   return GNUNET_OK;
78 }
79
80 /*
81  * Inserts the specified dhtkey into the dhttests.dhtkeys table,
82  * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
83  *
84  * @param dhtkeyuid return value
85  * @param dhtkey hashcode of key to insert
86  *
87  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
88  */
89 int
90 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
91 {
92   *dhtkeyuid = 1171;
93   return GNUNET_OK;
94 }
95
96
97 /*
98  * Inserts the specified node into the dhttests.nodes table
99  *
100  * @param nodeuid the inserted node uid
101  * @param node the node to insert
102  *
103  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
104  */
105 int
106 add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
107 {
108   *nodeuid = 1337;
109   return GNUNET_OK;
110 }
111
112 /*
113  * Update dhttests.trials table with current server time as end time
114  *
115  * @param trialuid trial to update
116  * @param gets_succeeded how many gets did the testcase report as successful
117  *
118  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
119  */
120 int
121 update_trials (unsigned long long trialuid,
122                unsigned int gets_succeeded)
123 {
124   return GNUNET_OK;
125 }
126
127
128 /*
129  * Inserts the specified stats into the dhttests.generic_stats table
130  *
131  * @param peer the peer inserting the statistic
132  * @param name the name of the statistic
133  * @param section the section of the statistic
134  * @param value the value of the statistic
135  *
136  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
137  */
138 int
139 add_generic_stat (const struct GNUNET_PeerIdentity *peer,
140                   const char *name,
141                   const char *section, uint64_t value)
142 {
143   return GNUNET_OK;
144 }
145
146 /*
147  * Update dhttests.trials table with total connections information
148  *
149  * @param trialuid the trialuid to update
150  * @param totalConnections the number of connections
151  *
152  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
153  */
154 int
155 add_connections (unsigned long long trialuid, unsigned int totalConnections)
156 {
157   return GNUNET_OK;
158 }
159
160 /*
161  * Inserts the specified query into the dhttests.queries table
162  *
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  *
171  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
172  */
173 int
174 add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
175            unsigned int type, unsigned int hops, int succeeded,
176            const struct GNUNET_PeerIdentity * node, const GNUNET_HashCode * key)
177 {
178   *sqlqueryuid = 17;
179   return GNUNET_OK;
180 }
181
182 /*
183  * Inserts the specified route information into the dhttests.routes table
184  *
185  * @param sqlqueruid inserted query uid
186  * @param queryid dht query id
187  * @param type type of the query
188  * @param hops number of hops query traveled
189  * @param succeeded whether or not query was successful
190  * @param node the node the query hit
191  * @param key the key of the query
192  * @param from_node the node that sent the message to node
193  * @param to_node next node to forward message to
194  *
195  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
196  */
197 int
198 add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
199            unsigned int type, unsigned int hops,
200            int succeeded, const struct GNUNET_PeerIdentity * node,
201            const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity * from_node,
202            const struct GNUNET_PeerIdentity * to_node)
203 {
204   *sqlqueryuid = 18;
205   return GNUNET_OK;
206 }
207
208
209 /*
210  * Records the current topology (number of connections, time, trial)
211  *
212  * @param num_connections how many connections are in the topology
213  *
214  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
215  */
216 int
217 add_topology (int num_connections)
218 {
219   return GNUNET_OK;
220 }
221
222 /*
223  * Records a connection between two peers in the current topology
224  *
225  * @param first one side of the connection
226  * @param second other side of the connection
227  *
228  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
229  */
230 int
231 add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second)
232 {
233   return GNUNET_OK;
234 }
235
236 /*
237  * Update dhttests.topology table with total connections information
238  *
239  * @param totalConnections the number of connections
240  *
241  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
242  */
243 int
244 update_topology (unsigned int connections)
245 {
246   return GNUNET_OK;
247 }
248
249
250 /*
251  * Provides the dhtlog api
252  *
253  * @param c the configuration to use to connect to a server
254  *
255  * @return the handle to the server, or NULL on error
256  */
257 void *
258 libgnunet_plugin_dhtlog_dummy_init (void * cls)
259 {
260   struct GNUNET_DHTLOG_Plugin *plugin = cls;
261 #if DEBUG_DHTLOG
262   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DUMMY DHT Logger: initializing.\n");
263 #endif
264   GNUNET_assert(plugin->dhtlog_api == NULL);
265   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
266   plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
267   plugin->dhtlog_api->insert_trial = &add_trial;
268   plugin->dhtlog_api->insert_query = &add_query;
269   plugin->dhtlog_api->update_trial = &update_trials;
270   plugin->dhtlog_api->insert_route = &add_route;
271   plugin->dhtlog_api->insert_node = &add_node;
272   plugin->dhtlog_api->insert_dhtkey = &add_dhtkey;
273   plugin->dhtlog_api->update_connections = &add_connections;
274   plugin->dhtlog_api->insert_topology = &add_topology;
275   plugin->dhtlog_api->update_topology = &update_topology;
276   plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
277   return NULL;
278 }
279
280 /**
281  * Shutdown the plugin.
282  */
283 void *
284 libgnunet_plugin_dhtlog_dummy_done (void * cls)
285 {
286 #if DEBUG_DHTLOG
287   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
288               "DUMMY DHT Logger: shutdown\n");
289 #endif
290   return NULL;
291 }
292
293 /* end of plugin_dhtlog_dummy.c */