2 This file is part of GNUnet
3 (C) 2006 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/dhtlog.h
24 * @brief dhtlog is a service that implements logging of dht operations
26 * @author Nathan Evans
29 #ifndef GNUNET_DHTLOG_SERVICE_H
30 #define GNUNET_DHTLOG_SERVICE_H
32 #include "gnunet_util_lib.h"
37 #if 0 /* keep Emacsens' auto-indent happy */
45 * Type for a DHT GET message
50 * Type for a DHT PUT message
55 * Type for a DHT FIND PEER message
60 * Type for a DHT RESULT message
65 * Generic DHT ROUTE message
69 } DHTLOG_MESSAGE_TYPES;
71 struct GNUNET_DHTLOG_Handle
75 * Inserts the specified query into the dhttests.queries table
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
85 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
87 int (*insert_query) (unsigned long long *sqlqueryuid,
88 unsigned long long queryid, DHTLOG_MESSAGE_TYPES type,
91 const struct GNUNET_PeerIdentity * node,
92 const GNUNET_HashCode * key);
95 * Inserts the specified trial into the dhttests.trials table
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
122 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
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,
136 * Inserts the specified stats into the dhttests.node_statistics table
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
156 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
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);
170 * Update dhttests.trials table with current server time as end time
172 * @param trialuid trial to update
173 * @param gets_succeeded how many gets did the trial report successful
175 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
177 int (*update_trial) (unsigned long long trialuid,
178 unsigned int gets_succeeded);
181 * Update dhttests.nodes table setting the identified
182 * node as a malicious dropper.
184 * @param peer the peer that was set to be malicious
186 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
188 int (*set_malicious) (struct GNUNET_PeerIdentity *peer);
191 * Records the current topology (number of connections, time, trial)
193 * @param num_connections how many connections are in the topology
195 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
197 int (*insert_topology) (int num_connections);
200 * Records a connection between two peers in the current topology
202 * @param first one side of the connection
203 * @param second other side of the connection
205 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
207 int (*insert_extended_topology) (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second);
210 * Inserts the specified stats into the dhttests.generic_stats table
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
217 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
220 (*add_generic_stat) (const struct GNUNET_PeerIdentity *peer,
222 const char *section, uint64_t value);
225 * Update dhttests.trials table with total connections information
227 * @param trialuid the trialuid to update
228 * @param totalConnections the number of connections
230 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
232 int (*update_connections) (unsigned long long trialuid,
233 unsigned int totalConnections);
236 * Update dhttests.trials table with total connections information
238 * @param connections the number of connections
240 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
242 int (*update_topology) (unsigned int connections);
245 * Inserts the specified route information into the dhttests.routes table
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
257 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
259 int (*insert_route) (unsigned long long *sqlqueryuid,
260 unsigned long long queryid,
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);
270 * Inserts the specified node into the dhttests.nodes table
272 * @param nodeuid the inserted node uid
273 * @param node the node to insert
275 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
277 int (*insert_node) (unsigned long long *nodeuid,
278 struct GNUNET_PeerIdentity * node);
281 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
282 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
284 * @param dhtkeyuid return value
285 * @param dhtkey hashcode of key to insert
287 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
289 int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
290 const GNUNET_HashCode * dhtkey);
294 struct GNUNET_DHTLOG_Plugin
296 const struct GNUNET_CONFIGURATION_Handle *cfg;
298 struct GNUNET_DHTLOG_Handle *dhtlog_api;
302 * Connect to mysql server using the DHT log plugin.
304 * @param c a configuration to use
306 struct GNUNET_DHTLOG_Handle *
307 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
310 * Shutdown the module.
313 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
316 #if 0 /* keep Emacsens' auto-indent happy */
323 /* end of dhtlog.h */