nitpicks
[oweals/gnunet.git] / src / dht / dhtlog.h
1 /*
2      This file is part of GNUnet
3      (C) 2006 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/dhtlog.h
23  *
24  * @brief dhtlog is a service that implements logging of dht operations
25  * for testing
26  * @author Nathan Evans
27  */
28
29 #ifndef GNUNET_DHTLOG_SERVICE_H
30 #define GNUNET_DHTLOG_SERVICE_H
31
32 #include "gnunet_util_lib.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #if 0                           /* keep Emacsens' auto-indent happy */
38 }
39 #endif
40 #endif
41
42 typedef enum
43 {
44   /**
45    * Type for a DHT GET message
46    */
47   DHTLOG_GET = 1,
48
49   /**
50    * Type for a DHT PUT message
51    */
52   DHTLOG_PUT = 2,
53
54   /**
55    * Type for a DHT FIND PEER message
56    */
57   DHTLOG_FIND_PEER = 3,
58
59   /**
60    * Type for a DHT RESULT message
61    */
62   DHTLOG_RESULT = 4,
63
64   /**
65    * Generic DHT ROUTE message
66    */
67   DHTLOG_ROUTE = 5,
68
69 } DHTLOG_MESSAGE_TYPES;
70
71 struct GNUNET_DHTLOG_Handle
72 {
73
74   /*
75    * Inserts the specified query into the dhttests.queries table
76    *
77    * @param sqlqueruid inserted query uid
78    * @param queryid dht query id
79    * @param type type of the query
80    * @param hops number of hops query traveled
81    * @param succeeded whether or not query was successful
82    * @param node the node the query hit
83    * @param key the key of the query
84    *
85    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
86    */
87   int (*insert_query) (unsigned long long *sqlqueryuid,
88                        unsigned long long queryid, DHTLOG_MESSAGE_TYPES type,
89                        unsigned int hops,
90                        int succeeded,
91                        const struct GNUNET_PeerIdentity * node,
92                        const GNUNET_HashCode * key);
93
94   /*
95    * Inserts the specified trial into the dhttests.trials table
96    *
97    * @param trialuid return the trialuid of the newly inserted trial
98    * @param num_nodes how many nodes are in the trial
99    * @param topology integer representing topology for this trial
100    * @param blacklist_topology integer representing blacklist topology for this trial
101    * @param connect_topology integer representing connect topology for this trial
102    * @param connect_topology_option integer representing connect topology option
103    * @param connect_topology_option_modifier float to modify connect option
104    * @param topology_percentage percentage modifier for certain topologies
105    * @param topology_probability probability modifier for certain topologies
106    * @param puts number of puts to perform
107    * @param gets number of gets to perform
108    * @param concurrent number of concurrent requests
109    * @param settle_time time to wait between creating topology and starting testing
110    * @param num_rounds number of times to repeat the trial
111    * @param malicious_getters number of malicious GET peers in the trial
112    * @param malicious_putters number of malicious PUT peers in the trial
113    * @param malicious_droppers number of malicious DROP peers in the trial
114    * @param malicious_get_frequency how often malicious gets are sent
115    * @param malicious_put_frequency how often malicious puts are sent
116    * @param stop_closest stop forwarding PUTs if closest node found
117    * @param stop_found stop forwarding GETs if data found
118    * @param strict_kademlia test used kademlia routing algorithm
119    * @param gets_succeeded how many gets did the test driver report success on
120    * @param message string to put into DB for this trial
121    *
122    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
123    */
124   int (*insert_trial) (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
125                        unsigned int blacklist_topology, unsigned int connect_topology,
126                        unsigned int connect_topology_option, float connect_topology_option_modifier,
127                        float topology_percentage, float topology_probability,
128                        unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
129                        unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
130                        unsigned int malicious_droppers, unsigned int malicious_get_frequency,
131                        unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
132                        unsigned int strict_kademlia, unsigned int gets_succeeded,
133                        char *message);
134
135   /*
136    * Inserts the specified stats into the dhttests.node_statistics table
137    *
138    * @param peer the peer inserting the statistic
139    * @param route_requests route requests seen
140    * @param route_forwards route requests forwarded
141    * @param result_requests route result requests seen
142    * @param client_requests client requests initiated
143    * @param result_forwards route results forwarded
144    * @param gets get requests handled
145    * @param puts put requests handle
146    * @param data_inserts data inserted at this node
147    * @param find_peer_requests find peer requests seen
148    * @param find_peers_started find peer requests initiated at this node
149    * @param gets_started get requests initiated at this node
150    * @param puts_started put requests initiated at this node
151    * @param find_peer_responses_received find peer responses received locally
152    * @param get_responses_received get responses received locally
153    * @param find_peer_responses_sent find peer responses sent from this node
154    * @param get_responses_sent get responses sent from this node
155    *
156    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
157    */
158   int (*insert_stat)
159      (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
160       unsigned int route_forwards, unsigned int result_requests,
161       unsigned int client_requests, unsigned int result_forwards,
162       unsigned int gets, unsigned int puts,
163       unsigned int data_inserts, unsigned int find_peer_requests,
164       unsigned int find_peers_started, unsigned int gets_started,
165       unsigned int puts_started, unsigned int find_peer_responses_received,
166       unsigned int get_responses_received, unsigned int find_peer_responses_sent,
167       unsigned int get_responses_sent);
168
169   /*
170    * Update dhttests.trials table with current server time as end time
171    *
172    * @param trialuid trial to update
173    * @param gets_succeeded how many gets did the trial report successful
174    *
175    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
176    */
177   int (*update_trial) (unsigned long long trialuid,
178                        unsigned int gets_succeeded);
179
180   /*
181    * Update dhttests.nodes table setting the identified
182    * node as a malicious dropper.
183    *
184    * @param peer the peer that was set to be malicious
185    *
186    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
187    */
188   int (*set_malicious) (struct GNUNET_PeerIdentity *peer);
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 (*insert_topology) (int num_connections);
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 (*insert_extended_topology) (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second);
208
209   /*
210    * Inserts the specified stats into the dhttests.generic_stats table
211    *
212    * @param peer the peer inserting the statistic
213    * @param name the name of the statistic
214    * @param section the section of the statistic
215    * @param value the value of the statistic
216    *
217    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
218    */
219   int
220   (*add_generic_stat) (const struct GNUNET_PeerIdentity *peer,
221                        const char *name,
222                        const char *section, uint64_t value);
223
224   /*
225    * Update dhttests.trials table with total connections information
226    *
227    * @param trialuid the trialuid to update
228    * @param totalConnections the number of connections
229    *
230    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
231    */
232   int (*update_connections) (unsigned long long trialuid,
233                              unsigned int totalConnections);
234
235   /*
236    * Update dhttests.trials table with total connections information
237    *
238    * @param connections the number of connections
239    *
240    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
241    */
242   int (*update_topology) (unsigned int connections);
243
244   /*
245    * Inserts the specified route information into the dhttests.routes table
246    *
247    * @param sqlqueruid inserted query uid
248    * @param queryid dht query id
249    * @param type type of the query
250    * @param hops number of hops query traveled
251    * @param succeeded whether or not query was successful
252    * @param node the node the query hit
253    * @param key the key of the query
254    * @param from_node the node that sent the message to node
255    * @param to_node next node to forward message to
256    *
257    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
258    */
259   int (*insert_route) (unsigned long long *sqlqueryuid,
260                        unsigned long long queryid,
261                        unsigned int type,
262                        unsigned int hops,
263                        int succeeded,
264                        const struct GNUNET_PeerIdentity * node,
265                        const GNUNET_HashCode * key,
266                        const struct GNUNET_PeerIdentity * from_node,
267                        const struct GNUNET_PeerIdentity * to_node);
268
269   /*
270    * Inserts the specified node into the dhttests.nodes table
271    *
272    * @param nodeuid the inserted node uid
273    * @param node the node to insert
274    *
275    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
276    */
277   int (*insert_node) (unsigned long long *nodeuid,
278                       struct GNUNET_PeerIdentity * node);
279
280   /*
281    * Inserts the specified dhtkey into the dhttests.dhtkeys table,
282    * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
283    *
284    * @param dhtkeyuid return value
285    * @param dhtkey hashcode of key to insert
286    *
287    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
288    */
289   int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
290                         const GNUNET_HashCode * dhtkey);
291
292 };
293
294 struct GNUNET_DHTLOG_Plugin
295 {
296   const struct GNUNET_CONFIGURATION_Handle *cfg;
297
298   struct GNUNET_DHTLOG_Handle *dhtlog_api;
299 };
300
301 /**
302  * Connect to mysql server using the DHT log plugin.
303  *
304  * @param c a configuration to use
305  */
306 struct GNUNET_DHTLOG_Handle *
307 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
308
309 /**
310  * Shutdown the module.
311  */
312 void
313 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
314
315
316 #if 0                           /* keep Emacsens' auto-indent happy */
317 {
318 #endif
319 #ifdef __cplusplus
320 }
321 #endif
322
323 /* end of dhtlog.h */
324 #endif