removed debug out
[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 message string to put into DB for this trial
115    *
116    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
117    */
118   int (*insert_trial) (unsigned long long *trialuid, int num_nodes, int topology,
119                        int blacklist_topology, int connect_topology,
120                        int connect_topology_option, float connect_topology_option_modifier,
121                        float topology_percentage, float topology_probability,
122                        int puts, int gets, int concurrent, int settle_time,
123                        int num_rounds, int malicious_getters, int malicious_putters,
124                        int malicious_droppers,
125                        char *message);
126
127   /*
128    * Update dhttests.trials table with current server time as end time
129    *
130    * @param trialuid trial to update
131    * @param totalMessagesDropped stats value for messages dropped
132    * @param totalBytesDropped stats value for total bytes dropped
133    * @param unknownPeers stats value for unknown peers
134    *
135    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
136    */
137   int (*update_trial) (unsigned long long trialuid,
138                        unsigned long long totalMessagesDropped,
139                        unsigned long long totalBytesDropped,
140                        unsigned long long unknownPeers);
141
142   /*
143    * Records the current topology (number of connections, time, trial)
144    *
145    * @param num_connections how many connections are in the topology
146    *
147    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
148    */
149   int (*insert_topology) (int num_connections);
150
151   /*
152    * Records a connection between two peers in the current topology
153    *
154    * @param first one side of the connection
155    * @param second other side of the connection
156    *
157    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
158    */
159   int (*insert_extended_topology) (struct GNUNET_PeerIdentity *first, struct GNUNET_PeerIdentity *second);
160
161   /*
162    * Update dhttests.trials table with total connections information
163    *
164    * @param trialuid the trialuid to update
165    * @param totalConnections the number of connections
166    *
167    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
168    */
169   int (*update_connections) (unsigned long long trialuid,
170                              unsigned int totalConnections);
171
172   /*
173    * Update dhttests.trials table with total connections information
174    *
175    * @param connections the number of connections
176    *
177    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
178    */
179   int (*update_topology) (unsigned int connections);
180
181   /*
182    * Inserts the specified route information into the dhttests.routes table
183    *
184    * @param sqlqueruid inserted query uid
185    * @param queryid dht query id
186    * @param type type of the query
187    * @param hops number of hops query traveled
188    * @param succeeded whether or not query was successful
189    * @param node the node the query hit
190    * @param key the key of the query
191    * @param from_node the node that sent the message to node
192    * @param to_node next node to forward message to
193    *
194    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
195    */
196   int (*insert_route) (unsigned long long *sqlqueryuid,
197                        unsigned long long queryid,
198                        unsigned int type,
199                        unsigned int hops,
200                        int succeeded,
201                        const struct GNUNET_PeerIdentity * node,
202                        const GNUNET_HashCode * key,
203                        const struct GNUNET_PeerIdentity * from_node,
204                        const struct GNUNET_PeerIdentity * to_node);
205
206   /*
207    * Inserts the specified node into the dhttests.nodes table
208    *
209    * @param nodeuid the inserted node uid
210    * @param node the node to insert
211    *
212    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
213    */
214   int (*insert_node) (unsigned long long *nodeuid,
215                       struct GNUNET_PeerIdentity * node);
216
217   /*
218    * Inserts the specified dhtkey into the dhttests.dhtkeys table,
219    * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
220    *
221    * @param dhtkeyuid return value
222    * @param dhtkey hashcode of key to insert
223    *
224    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
225    */
226   int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
227                         const GNUNET_HashCode * dhtkey);
228
229 };
230
231 struct GNUNET_DHTLOG_Plugin
232 {
233   const struct GNUNET_CONFIGURATION_Handle *cfg;
234
235   struct GNUNET_DHTLOG_Handle *dhtlog_api;
236 };
237
238 /**
239  * Connect to mysql server using the DHT log plugin.
240  *
241  * @param c a configuration to use
242  */
243 struct GNUNET_DHTLOG_Handle *
244 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
245
246 /**
247  * Shutdown the module.
248  */
249 void
250 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
251
252
253 #if 0                           /* keep Emacsens' auto-indent happy */
254 {
255 #endif
256 #ifdef __cplusplus
257 }
258 #endif
259
260 /* end of dhtlog.h */
261 #endif