stub
[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    * Insert the result of a query into the database
76    *
77    * @param sqlqueryuid return value for the sql uid for this query
78    * @param queryid gnunet internal query id (doesn't exist)
79    * @param type the type of query (DHTLOG_GET, DHTLOG_PUT, DHTLOG_RESULT)
80    * @param hops the hops the query has traveled
81    * @param succeeded is successful or not (GNUNET_YES or GNUNET_NO)
82    * @param GNUNET_PeerIdentity of the node the query is at now
83    * @param key the GNUNET_HashCode of this query
84    *
85    */
86   int (*insert_query) (unsigned long long *sqlqueryuid,
87                        unsigned long long queryid, DHTLOG_MESSAGE_TYPES type,
88                        unsigned int hops,
89                        int succeeded,
90                        const struct GNUNET_PeerIdentity * node,
91                        const GNUNET_HashCode * key);
92
93   /*
94    * Inserts the trial information into the database
95    */
96   int (*insert_trial) (unsigned long long *trialuid, int num_nodes, int topology,
97                        int blacklist_topology, int connect_topology,
98                        int connect_topology_option, float connect_topology_option_modifier,
99                        float topology_percentage, float topology_probability,
100                        int puts, int gets, int concurrent, int settle_time,
101                        int num_rounds, int malicious_getters, int malicious_putters,
102                        int malicious_droppers,
103                        char *message);
104
105   /*
106    * Update the trial information with the ending time and dropped message stats
107    */
108   int (*update_trial) (unsigned long long trialuid,
109                        unsigned long long totalMessagesDropped,
110                        unsigned long long totalBytesDropped,
111                        unsigned long long unknownPeers);
112
113   /*
114    * Update the trial information with the total connections
115    */
116   int (*update_connections) (unsigned long long trialuid,
117                              unsigned int totalConnections);
118
119   /*
120    * Insert the query information from a single hop into the database
121    *
122    * @param sqlqueryuid return value for the sql uid for this query
123    * @param queryid gnunet internal query id (doesn't exist)
124    * @param type the type of query (DHTLOG_GET, DHTLOG_PUT, DHTLOG_RESULT)
125    * @param hops the hops the query has traveled
126    * @param succeeded query is successful or not (GNUNET_YES or GNUNET_NO)
127    * @param node GNUNET_PeerIdentity of the node the query is at now
128    * @param key the GNUNET_HashCode of this query
129    * @param from_node GNUNET_PeerIdentity of the node the query was
130    *        received from (NULL if origin)
131    * @param to_node GNUNET_PeerIdentity of the node this node will forward
132    *        to (NULL if none)
133    *
134    */
135   int (*insert_route) (unsigned long long *sqlqueryuid,
136                        unsigned long long queryid,
137                        unsigned int type,
138                        unsigned int hops,
139                        int succeeded,
140                        const struct GNUNET_PeerIdentity * node,
141                        const GNUNET_HashCode * key,
142                        const struct GNUNET_PeerIdentity * from_node,
143                        const struct GNUNET_PeerIdentity * to_node);
144
145   /*
146    * Inserts the specified node into the dhttests.nodes table
147    */
148   int (*insert_node) (unsigned long long *nodeuid,
149                       struct GNUNET_PeerIdentity * node);
150
151   /*
152    * Inserts a dhtkey into the database
153    */
154   int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
155                         const GNUNET_HashCode * dhtkey);
156
157 };
158
159 struct GNUNET_DHTLOG_Plugin
160 {
161   const struct GNUNET_CONFIGURATION_Handle *cfg;
162
163   struct GNUNET_DHTLOG_Handle *dhtlog_api;
164 };
165
166 /**
167  * Connect to mysql server using the DHT log plugin.
168  *
169  * @param c a configuration to use
170  */
171 struct GNUNET_DHTLOG_Handle *
172 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
173
174 /**
175  * Shutdown the module.
176  */
177 void
178 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
179
180
181 #if 0                           /* keep Emacsens' auto-indent happy */
182 {
183 #endif
184 #ifdef __cplusplus
185 }
186 #endif
187
188 /* end of dhtlog.h */
189 #endif