aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_topo.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/dht/test_dht_topo.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
downloadgnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz
gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip
uncrustify as demanded.
Diffstat (limited to 'src/dht/test_dht_topo.c')
-rw-r--r--src/dht/test_dht_topo.c495
1 files changed, 246 insertions, 249 deletions
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c
index a0d80e52c..32d99152d 100644
--- a/src/dht/test_dht_topo.c
+++ b/src/dht/test_dht_topo.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file dht/test_dht_topo.c 21 * @file dht/test_dht_topo.c
22 * @author Christian Grothoff 22 * @author Christian Grothoff
@@ -32,19 +32,18 @@
32/** 32/**
33 * How long until we give up on fetching the data? 33 * How long until we give up on fetching the data?
34 */ 34 */
35#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 35#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120)
36 36
37/** 37/**
38 * How frequently do we execute the PUTs? 38 * How frequently do we execute the PUTs?
39 */ 39 */
40#define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 40#define PUT_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
41 41
42 42
43/** 43/**
44 * Information we keep for each GET operation. 44 * Information we keep for each GET operation.
45 */ 45 */
46struct GetOperation 46struct GetOperation {
47{
48 /** 47 /**
49 * DLL. 48 * DLL.
50 */ 49 */
@@ -59,7 +58,6 @@ struct GetOperation
59 * Handle for the operation. 58 * Handle for the operation.
60 */ 59 */
61 struct GNUNET_DHT_GetHandle *get; 60 struct GNUNET_DHT_GetHandle *get;
62
63}; 61};
64 62
65 63
@@ -107,80 +105,79 @@ static unsigned int NUM_PEERS;
107/** 105/**
108 * Statistics we print out. 106 * Statistics we print out.
109 */ 107 */
110static struct 108static struct {
111{
112 const char *subsystem; 109 const char *subsystem;
113 const char *name; 110 const char *name;
114 unsigned long long total; 111 unsigned long long total;
115} stats[] = { 112} stats[] = {
116 {"core", "# bytes decrypted", 0}, 113 { "core", "# bytes decrypted", 0 },
117 {"core", "# bytes encrypted", 0}, 114 { "core", "# bytes encrypted", 0 },
118 {"core", "# type maps received", 0}, 115 { "core", "# type maps received", 0 },
119 {"core", "# session keys confirmed via PONG", 0}, 116 { "core", "# session keys confirmed via PONG", 0 },
120 {"core", "# peers connected", 0}, 117 { "core", "# peers connected", 0 },
121 {"core", "# key exchanges initiated", 0}, 118 { "core", "# key exchanges initiated", 0 },
122 {"core", "# send requests dropped (disconnected)", 0}, 119 { "core", "# send requests dropped (disconnected)", 0 },
123 {"core", "# transmissions delayed due to corking", 0}, 120 { "core", "# transmissions delayed due to corking", 0 },
124 {"core", "# messages discarded (expired prior to transmission)", 0}, 121 { "core", "# messages discarded (expired prior to transmission)", 0 },
125 {"core", "# messages discarded (disconnected)", 0}, 122 { "core", "# messages discarded (disconnected)", 0 },
126 {"core", "# discarded CORE_SEND requests", 0}, 123 { "core", "# discarded CORE_SEND requests", 0 },
127 {"core", "# discarded lower priority CORE_SEND requests", 0}, 124 { "core", "# discarded lower priority CORE_SEND requests", 0 },
128 {"transport", "# bytes received via TCP", 0}, 125 { "transport", "# bytes received via TCP", 0 },
129 {"transport", "# bytes transmitted via TCP", 0}, 126 { "transport", "# bytes transmitted via TCP", 0 },
130 {"dht", "# PUT messages queued for transmission", 0}, 127 { "dht", "# PUT messages queued for transmission", 0 },
131 {"dht", "# P2P PUT requests received", 0}, 128 { "dht", "# P2P PUT requests received", 0 },
132 {"dht", "# GET messages queued for transmission", 0}, 129 { "dht", "# GET messages queued for transmission", 0 },
133 {"dht", "# P2P GET requests received", 0}, 130 { "dht", "# P2P GET requests received", 0 },
134 {"dht", "# RESULT messages queued for transmission", 0}, 131 { "dht", "# RESULT messages queued for transmission", 0 },
135 {"dht", "# P2P RESULTS received", 0}, 132 { "dht", "# P2P RESULTS received", 0 },
136 {"dht", "# Queued messages discarded (peer disconnected)", 0}, 133 { "dht", "# Queued messages discarded (peer disconnected)", 0 },
137 {"dht", "# Peers excluded from routing due to Bloomfilter", 0}, 134 { "dht", "# Peers excluded from routing due to Bloomfilter", 0 },
138 {"dht", "# Peer selection failed", 0}, 135 { "dht", "# Peer selection failed", 0 },
139 {"dht", "# FIND PEER requests ignored due to Bloomfilter", 0}, 136 { "dht", "# FIND PEER requests ignored due to Bloomfilter", 0 },
140 {"dht", "# FIND PEER requests ignored due to lack of HELLO", 0}, 137 { "dht", "# FIND PEER requests ignored due to lack of HELLO", 0 },
141 {"dht", "# P2P FIND PEER requests processed", 0}, 138 { "dht", "# P2P FIND PEER requests processed", 0 },
142 {"dht", "# P2P GET requests ONLY routed", 0}, 139 { "dht", "# P2P GET requests ONLY routed", 0 },
143 {"dht", "# Preference updates given to core", 0}, 140 { "dht", "# Preference updates given to core", 0 },
144 {"dht", "# REPLIES ignored for CLIENTS (no match)", 0}, 141 { "dht", "# REPLIES ignored for CLIENTS (no match)", 0 },
145 {"dht", "# GET requests from clients injected", 0}, 142 { "dht", "# GET requests from clients injected", 0 },
146 {"dht", "# GET requests received from clients", 0}, 143 { "dht", "# GET requests received from clients", 0 },
147 {"dht", "# GET STOP requests received from clients", 0}, 144 { "dht", "# GET STOP requests received from clients", 0 },
148 {"dht", "# ITEMS stored in datacache", 0}, 145 { "dht", "# ITEMS stored in datacache", 0 },
149 {"dht", "# Good RESULTS found in datacache", 0}, 146 { "dht", "# Good RESULTS found in datacache", 0 },
150 {"dht", "# GET requests given to datacache", 0}, 147 { "dht", "# GET requests given to datacache", 0 },
151 {NULL, NULL, 0} 148 { NULL, NULL, 0 }
152}; 149};
153 150
154 151
155static struct GNUNET_DHT_TEST_Context * 152static struct GNUNET_DHT_TEST_Context *
156stop_ops () 153stop_ops()
157{ 154{
158 struct GetOperation *get_op; 155 struct GetOperation *get_op;
159 struct GNUNET_DHT_TEST_Context *ctx = NULL; 156 struct GNUNET_DHT_TEST_Context *ctx = NULL;
160 157
161 if (NULL != timeout_task) 158 if (NULL != timeout_task)
162 { 159 {
163 ctx = GNUNET_SCHEDULER_cancel (timeout_task); 160 ctx = GNUNET_SCHEDULER_cancel(timeout_task);
164 timeout_task = NULL; 161 timeout_task = NULL;
165 } 162 }
166 if (NULL != put_task) 163 if (NULL != put_task)
167 { 164 {
168 GNUNET_SCHEDULER_cancel (put_task); 165 GNUNET_SCHEDULER_cancel(put_task);
169 put_task = NULL; 166 put_task = NULL;
170 } 167 }
171 if (NULL != get_task) 168 if (NULL != get_task)
172 { 169 {
173 GNUNET_SCHEDULER_cancel (get_task); 170 GNUNET_SCHEDULER_cancel(get_task);
174 get_task = NULL; 171 get_task = NULL;
175 } 172 }
176 while (NULL != (get_op = get_tail)) 173 while (NULL != (get_op = get_tail))
177 { 174 {
178 GNUNET_DHT_get_stop (get_op->get); 175 GNUNET_DHT_get_stop(get_op->get);
179 GNUNET_CONTAINER_DLL_remove (get_head, 176 GNUNET_CONTAINER_DLL_remove(get_head,
180 get_tail, 177 get_tail,
181 get_op); 178 get_op);
182 GNUNET_free (get_op); 179 GNUNET_free(get_op);
183 } 180 }
184 return ctx; 181 return ctx;
185} 182}
186 183
@@ -193,32 +190,32 @@ stop_ops ()
193 * @param emsg error message on failure 190 * @param emsg error message on failure
194 */ 191 */
195static void 192static void
196stats_finished (void *cls, 193stats_finished(void *cls,
197 struct GNUNET_TESTBED_Operation *op, 194 struct GNUNET_TESTBED_Operation *op,
198 const char *emsg) 195 const char *emsg)
199{ 196{
200 struct GNUNET_DHT_TEST_Context *ctx = cls; 197 struct GNUNET_DHT_TEST_Context *ctx = cls;
201 unsigned int i; 198 unsigned int i;
202 199
203 if (NULL != op) 200 if (NULL != op)
204 GNUNET_TESTBED_operation_done (op); 201 GNUNET_TESTBED_operation_done(op);
205 if (NULL != emsg) 202 if (NULL != emsg)
206 { 203 {
207 fprintf (stderr, 204 fprintf(stderr,
208 _("Gathering statistics failed: %s\n"), 205 _("Gathering statistics failed: %s\n"),
209 emsg); 206 emsg);
210 GNUNET_SCHEDULER_cancel (put_task); 207 GNUNET_SCHEDULER_cancel(put_task);
211 GNUNET_DHT_TEST_cleanup (ctx); 208 GNUNET_DHT_TEST_cleanup(ctx);
212 return; 209 return;
213 } 210 }
214 for (i = 0; NULL != stats[i].name; i++) 211 for (i = 0; NULL != stats[i].name; i++)
215 fprintf (stderr, 212 fprintf(stderr,
216 "%6s/%60s = %12llu\n", 213 "%6s/%60s = %12llu\n",
217 stats[i].subsystem, 214 stats[i].subsystem,
218 stats[i].name, 215 stats[i].name,
219 stats[i].total); 216 stats[i].total);
220 GNUNET_DHT_TEST_cleanup (ctx); 217 GNUNET_DHT_TEST_cleanup(ctx);
221 GNUNET_SCHEDULER_shutdown (); 218 GNUNET_SCHEDULER_shutdown();
222} 219}
223 220
224 221
@@ -234,20 +231,20 @@ stats_finished (void *cls,
234 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration 231 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
235 */ 232 */
236static int 233static int
237handle_stats (void *cls, 234handle_stats(void *cls,
238 const struct GNUNET_TESTBED_Peer *peer, 235 const struct GNUNET_TESTBED_Peer *peer,
239 const char *subsystem, 236 const char *subsystem,
240 const char *name, 237 const char *name,
241 uint64_t value, 238 uint64_t value,
242 int is_persistent) 239 int is_persistent)
243{ 240{
244 unsigned int i; 241 unsigned int i;
245 242
246 for (i = 0; NULL != stats[i].name; i++) 243 for (i = 0; NULL != stats[i].name; i++)
247 if ( (0 == strcasecmp (subsystem, 244 if ((0 == strcasecmp(subsystem,
248 stats[i].subsystem)) && 245 stats[i].subsystem)) &&
249 (0 == strcasecmp (name, 246 (0 == strcasecmp(name,
250 stats[i].name)) ) 247 stats[i].name)))
251 stats[i].total += value; 248 stats[i].total += value;
252 return GNUNET_OK; 249 return GNUNET_OK;
253} 250}
@@ -260,9 +257,9 @@ handle_stats (void *cls,
260 * @param cls the 'struct GNUNET_DHT_TestContext' 257 * @param cls the 'struct GNUNET_DHT_TestContext'
261 */ 258 */
262static void 259static void
263shutdown_task (void *cls) 260shutdown_task(void *cls)
264{ 261{
265 (void) stop_ops (); 262 (void)stop_ops();
266} 263}
267 264
268 265
@@ -273,12 +270,12 @@ shutdown_task (void *cls)
273 * @param cls the `struct GNUNET_DHT_TestContext` 270 * @param cls the `struct GNUNET_DHT_TestContext`
274 */ 271 */
275static void 272static void
276timeout_cb (void *cls) 273timeout_cb(void *cls)
277{ 274{
278 timeout_task = NULL; 275 timeout_task = NULL;
279 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 276 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
280 "Timeout\n"); 277 "Timeout\n");
281 GNUNET_SCHEDULER_shutdown (); 278 GNUNET_SCHEDULER_shutdown();
282} 279}
283 280
284 281
@@ -298,75 +295,75 @@ timeout_cb (void *cls)
298 * @param data pointer to the result data 295 * @param data pointer to the result data
299 */ 296 */
300static void 297static void
301dht_get_handler (void *cls, 298dht_get_handler(void *cls,
302 struct GNUNET_TIME_Absolute exp, 299 struct GNUNET_TIME_Absolute exp,
303 const struct GNUNET_HashCode *key, 300 const struct GNUNET_HashCode *key,
304 const struct GNUNET_PeerIdentity *get_path, 301 const struct GNUNET_PeerIdentity *get_path,
305 unsigned int get_path_length, 302 unsigned int get_path_length,
306 const struct GNUNET_PeerIdentity *put_path, 303 const struct GNUNET_PeerIdentity *put_path,
307 unsigned int put_path_length, 304 unsigned int put_path_length,
308 enum GNUNET_BLOCK_Type type, 305 enum GNUNET_BLOCK_Type type,
309 size_t size, 306 size_t size,
310 const void *data) 307 const void *data)
311{ 308{
312 struct GetOperation *get_op = cls; 309 struct GetOperation *get_op = cls;
313 struct GNUNET_HashCode want; 310 struct GNUNET_HashCode want;
314 struct GNUNET_DHT_TEST_Context *ctx; 311 struct GNUNET_DHT_TEST_Context *ctx;
315 312
316 if (sizeof (struct GNUNET_HashCode) != size) 313 if (sizeof(struct GNUNET_HashCode) != size)
317 { 314 {
318 GNUNET_break (0); 315 GNUNET_break(0);
319 return; 316 return;
320 } 317 }
321 GNUNET_CRYPTO_hash (key, 318 GNUNET_CRYPTO_hash(key,
322 sizeof (*key), 319 sizeof(*key),
323 &want); 320 &want);
324 if (0 != memcmp (&want, 321 if (0 != memcmp(&want,
325 data, 322 data,
326 sizeof (want))) 323 sizeof(want)))
327 { 324 {
328 GNUNET_break (0); 325 GNUNET_break(0);
329 return; 326 return;
330 } 327 }
331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 328 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
332 "Get successful\n"); 329 "Get successful\n");
333#if 0 330#if 0
334 { 331 {
335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 332 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
336 "PATH: (get %u, put %u)\n", 333 "PATH: (get %u, put %u)\n",
337 get_path_length, 334 get_path_length,
338 put_path_length); 335 put_path_length);
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 336 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
340 " LOCAL\n"); 337 " LOCAL\n");
341 for (int i = get_path_length - 1; i >= 0; i--) 338 for (int i = get_path_length - 1; i >= 0; i--)
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 339 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
343 " %s\n", 340 " %s\n",
344 GNUNET_i2s (&get_path[i])); 341 GNUNET_i2s(&get_path[i]));
345 for (int i = put_path_length - 1; i >= 0; i--) 342 for (int i = put_path_length - 1; i >= 0; i--)
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 343 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
347 " %s\n", 344 " %s\n",
348 GNUNET_i2s (&put_path[i])); 345 GNUNET_i2s(&put_path[i]));
349 } 346 }
350#endif 347#endif
351 GNUNET_DHT_get_stop (get_op->get); 348 GNUNET_DHT_get_stop(get_op->get);
352 GNUNET_CONTAINER_DLL_remove (get_head, 349 GNUNET_CONTAINER_DLL_remove(get_head,
353 get_tail, 350 get_tail,
354 get_op); 351 get_op);
355 GNUNET_free (get_op); 352 GNUNET_free(get_op);
356 if (NULL != get_head) 353 if (NULL != get_head)
357 return; 354 return;
358 /* all DHT GET operations successful; get stats! */ 355 /* all DHT GET operations successful; get stats! */
359 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 356 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
360 "All DHT operations successful. Obtaining stats!\n"); 357 "All DHT operations successful. Obtaining stats!\n");
361 ok = 0; 358 ok = 0;
362 ctx = stop_ops (); 359 ctx = stop_ops();
363 GNUNET_assert (NULL != ctx); 360 GNUNET_assert(NULL != ctx);
364 (void) GNUNET_TESTBED_get_statistics (NUM_PEERS, 361 (void)GNUNET_TESTBED_get_statistics(NUM_PEERS,
365 my_peers, 362 my_peers,
366 NULL, NULL, 363 NULL, NULL,
367 &handle_stats, 364 &handle_stats,
368 &stats_finished, 365 &stats_finished,
369 ctx); 366 ctx);
370} 367}
371 368
372 369
@@ -377,38 +374,38 @@ dht_get_handler (void *cls,
377 * @param tc Task context 374 * @param tc Task context
378 */ 375 */
379static void 376static void
380do_puts (void *cls) 377do_puts(void *cls)
381{ 378{
382 struct GNUNET_DHT_Handle **hs = cls; 379 struct GNUNET_DHT_Handle **hs = cls;
383 struct GNUNET_HashCode key; 380 struct GNUNET_HashCode key;
384 struct GNUNET_HashCode value; 381 struct GNUNET_HashCode value;
385 382
386 put_task = NULL; 383 put_task = NULL;
387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 384 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
388 "Putting values into DHT\n"); 385 "Putting values into DHT\n");
389 for (unsigned int i = 0; i < NUM_PEERS; i++) 386 for (unsigned int i = 0; i < NUM_PEERS; i++)
390 { 387 {
391 GNUNET_CRYPTO_hash (&i, 388 GNUNET_CRYPTO_hash(&i,
392 sizeof (i), 389 sizeof(i),
393 &key); 390 &key);
394 GNUNET_CRYPTO_hash (&key, 391 GNUNET_CRYPTO_hash(&key,
395 sizeof (key), 392 sizeof(key),
396 &value); 393 &value);
397 GNUNET_DHT_put (hs[i], 394 GNUNET_DHT_put(hs[i],
398 &key, 395 &key,
399 10U, 396 10U,
400 GNUNET_DHT_RO_RECORD_ROUTE | 397 GNUNET_DHT_RO_RECORD_ROUTE |
401 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 398 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
402 GNUNET_BLOCK_TYPE_TEST, 399 GNUNET_BLOCK_TYPE_TEST,
403 sizeof (value), 400 sizeof(value),
404 &value, 401 &value,
405 GNUNET_TIME_UNIT_FOREVER_ABS, 402 GNUNET_TIME_UNIT_FOREVER_ABS,
406 NULL, 403 NULL,
407 NULL); 404 NULL);
408 } 405 }
409 put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY, 406 put_task = GNUNET_SCHEDULER_add_delayed(PUT_FREQUENCY,
410 &do_puts, 407 &do_puts,
411 hs); 408 hs);
412} 409}
413 410
414 411
@@ -416,7 +413,7 @@ do_puts (void *cls)
416 * Start GET operations. 413 * Start GET operations.
417 */ 414 */
418static void 415static void
419start_get (void *cls) 416start_get(void *cls)
420{ 417{
421 struct GNUNET_DHT_Handle **dhts = cls; 418 struct GNUNET_DHT_Handle **dhts = cls;
422 unsigned int i; 419 unsigned int i;
@@ -425,26 +422,26 @@ start_get (void *cls)
425 struct GetOperation *get_op; 422 struct GetOperation *get_op;
426 423
427 get_task = NULL; 424 get_task = NULL;
428 for (i=0;i<NUM_PEERS;i++) 425 for (i = 0; i < NUM_PEERS; i++)
429 {
430 GNUNET_CRYPTO_hash (&i, sizeof (i), &key);
431 for (j=0;j<NUM_PEERS;j++)
432 { 426 {
433 get_op = GNUNET_new (struct GetOperation); 427 GNUNET_CRYPTO_hash(&i, sizeof(i), &key);
434 GNUNET_CONTAINER_DLL_insert (get_head, 428 for (j = 0; j < NUM_PEERS; j++)
435 get_tail, 429 {
436 get_op); 430 get_op = GNUNET_new(struct GetOperation);
437 get_op->get = GNUNET_DHT_get_start (dhts[j], 431 GNUNET_CONTAINER_DLL_insert(get_head,
438 GNUNET_BLOCK_TYPE_TEST, /* type */ 432 get_tail,
439 &key, /*key to search */ 433 get_op);
440 4U, /* replication level */ 434 get_op->get = GNUNET_DHT_get_start(dhts[j],
441 GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 435 GNUNET_BLOCK_TYPE_TEST, /* type */
442 NULL, /* xquery */ 436 &key, /*key to search */
443 0, /* xquery bits */ 437 4U, /* replication level */
444 &dht_get_handler, 438 GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
445 get_op); 439 NULL, /* xquery */
440 0, /* xquery bits */
441 &dht_get_handler,
442 get_op);
443 }
446 } 444 }
447 }
448} 445}
449 446
450 447
@@ -458,26 +455,26 @@ start_get (void *cls)
458 * @param dhts handle to each of the DHTs of the peers 455 * @param dhts handle to each of the DHTs of the peers
459 */ 456 */
460static void 457static void
461run (void *cls, 458run(void *cls,
462 struct GNUNET_DHT_TEST_Context *ctx, 459 struct GNUNET_DHT_TEST_Context *ctx,
463 unsigned int num_peers, 460 unsigned int num_peers,
464 struct GNUNET_TESTBED_Peer **peers, 461 struct GNUNET_TESTBED_Peer **peers,
465 struct GNUNET_DHT_Handle **dhts) 462 struct GNUNET_DHT_Handle **dhts)
466{ 463{
467 GNUNET_assert (NUM_PEERS == num_peers); 464 GNUNET_assert(NUM_PEERS == num_peers);
468 my_peers = peers; 465 my_peers = peers;
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 466 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
470 "Peers setup, starting test\n"); 467 "Peers setup, starting test\n");
471 put_task = GNUNET_SCHEDULER_add_now (&do_puts, 468 put_task = GNUNET_SCHEDULER_add_now(&do_puts,
472 dhts); 469 dhts);
473 get_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 470 get_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
474 &start_get, 471 &start_get,
475 dhts); 472 dhts);
476 timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, 473 timeout_task = GNUNET_SCHEDULER_add_delayed(GET_TIMEOUT,
477 &timeout_cb, 474 &timeout_cb,
478 ctx); 475 ctx);
479 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 476 GNUNET_SCHEDULER_add_shutdown(&shutdown_task,
480 ctx); 477 ctx);
481} 478}
482 479
483 480
@@ -485,44 +482,44 @@ run (void *cls,
485 * Main: start test 482 * Main: start test
486 */ 483 */
487int 484int
488main (int xargc, char *xargv[]) 485main(int xargc, char *xargv[])
489{ 486{
490 const char *cfg_filename; 487 const char *cfg_filename;
491 const char *test_name; 488 const char *test_name;
492 489
493 if (NULL != strstr (xargv[0], "test_dht_2dtorus")) 490 if (NULL != strstr(xargv[0], "test_dht_2dtorus"))
494 { 491 {
495 cfg_filename = "test_dht_2dtorus.conf"; 492 cfg_filename = "test_dht_2dtorus.conf";
496 test_name = "test-dht-2dtorus"; 493 test_name = "test-dht-2dtorus";
497 NUM_PEERS = 16; 494 NUM_PEERS = 16;
498 } 495 }
499 else if (NULL != strstr (xargv[0], "test_dht_line")) 496 else if (NULL != strstr(xargv[0], "test_dht_line"))
500 { 497 {
501 cfg_filename = "test_dht_line.conf"; 498 cfg_filename = "test_dht_line.conf";
502 test_name = "test-dht-line"; 499 test_name = "test-dht-line";
503 NUM_PEERS = 5; 500 NUM_PEERS = 5;
504 } 501 }
505 else if (NULL != strstr (xargv[0], "test_dht_twopeer")) 502 else if (NULL != strstr(xargv[0], "test_dht_twopeer"))
506 { 503 {
507 cfg_filename = "test_dht_line.conf"; 504 cfg_filename = "test_dht_line.conf";
508 test_name = "test-dht-twopeer"; 505 test_name = "test-dht-twopeer";
509 NUM_PEERS = 2; 506 NUM_PEERS = 2;
510 } 507 }
511 else if (NULL != strstr (xargv[0], "test_dht_multipeer")) 508 else if (NULL != strstr(xargv[0], "test_dht_multipeer"))
512 { 509 {
513 cfg_filename = "test_dht_multipeer.conf"; 510 cfg_filename = "test_dht_multipeer.conf";
514 test_name = "test-dht-multipeer"; 511 test_name = "test-dht-multipeer";
515 NUM_PEERS = 10; 512 NUM_PEERS = 10;
516 } 513 }
517 else 514 else
518 { 515 {
519 GNUNET_break (0); 516 GNUNET_break(0);
520 return 1; 517 return 1;
521 } 518 }
522 GNUNET_DHT_TEST_run (test_name, 519 GNUNET_DHT_TEST_run(test_name,
523 cfg_filename, 520 cfg_filename,
524 NUM_PEERS, 521 NUM_PEERS,
525 &run, NULL); 522 &run, NULL);
526 return ok; 523 return ok;
527} 524}
528 525