diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-04-22 23:14:50 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-04-22 23:14:50 +0000 |
commit | 4c88ecc5e1e6e87061af0bc9981097302a1fb727 (patch) | |
tree | 38c35cac4090123fa893e8862c95152d9967e1ea /src/dht | |
parent | 547d0f8cc90d9a2475bbdef15663a5d40294df01 (diff) | |
download | gnunet-4c88ecc5e1e6e87061af0bc9981097302a1fb727.tar.gz gnunet-4c88ecc5e1e6e87061af0bc9981097302a1fb727.zip |
- Make monitoring test compile again
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/test_dht_monitor.c | 143 |
1 files changed, 103 insertions, 40 deletions
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 63af7e94c..6406201a7 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -302,65 +302,123 @@ put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
302 | } | 302 | } |
303 | 303 | ||
304 | /** | 304 | /** |
305 | * Callback called on each request going through the DHT. | 305 | * Callback called on each GET request going through the DHT. |
306 | * Prints the info about the intercepted packet and increments a counter. | 306 | * Prints the info about the intercepted packet and increments a counter. |
307 | * | 307 | * |
308 | * @param cls Closure (long) # of daemon that got the monitor event. | 308 | * @param cls Closure. |
309 | * @param mtype Type of the DHT message monitored. | 309 | * @param options Options, for instance RecordRoute, DemultiplexEverywhere. |
310 | * @param exp When will this value expire. | 310 | * @param type The type of data in the request. |
311 | * @param key Key of the result/request. | 311 | * @param hop_count Hop count so far. |
312 | * @param get_path Peers on reply path (or NULL if not recorded). | 312 | * @param path_length number of entries in path (or 0 if not recorded). |
313 | * @param path peers on the GET path (or NULL if not recorded). | ||
314 | * @param desired_replication_level Desired replication level. | ||
315 | * @param key Key of the requested data. | ||
316 | */ | ||
317 | void | ||
318 | monitor_get_cb (void *cls, | ||
319 | enum GNUNET_DHT_RouteOption options, | ||
320 | enum GNUNET_BLOCK_Type type, | ||
321 | uint32_t hop_count, | ||
322 | uint32_t desired_replication_level, | ||
323 | unsigned int path_length, | ||
324 | const struct GNUNET_PeerIdentity *path, | ||
325 | const GNUNET_HashCode * key) | ||
326 | { | ||
327 | const char *s_key; | ||
328 | unsigned int i; | ||
329 | |||
330 | i = (unsigned int) (long) cls; | ||
331 | s_key = GNUNET_h2s(key); | ||
332 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
333 | "%u got a GET message for key %s\n", | ||
334 | i, s_key); | ||
335 | |||
336 | if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) | ||
337 | monitor_counter++; | ||
338 | } | ||
339 | |||
340 | |||
341 | /** | ||
342 | * Callback called on each PUT request going through the DHT. | ||
343 | * Prints the info about the intercepted packet and increments a counter. | ||
344 | * | ||
345 | * @param cls Closure. | ||
346 | * @param options Options, for instance RecordRoute, DemultiplexEverywhere. | ||
347 | * @param type The type of data in the request. | ||
348 | * @param hop_count Hop count so far. | ||
349 | * @param path_length number of entries in path (or 0 if not recorded). | ||
350 | * @param path peers on the PUT path (or NULL if not recorded). | ||
351 | * @param desired_replication_level Desired replication level. | ||
352 | * @param exp Expiration time of the data. | ||
353 | * @param key Key under which data is to be stored. | ||
354 | * @param data Pointer to the data carried. | ||
355 | * @param size Number of bytes in data. | ||
356 | */ | ||
357 | void | ||
358 | monitor_put_cb (void *cls, | ||
359 | enum GNUNET_DHT_RouteOption options, | ||
360 | enum GNUNET_BLOCK_Type type, | ||
361 | uint32_t hop_count, | ||
362 | uint32_t desired_replication_level, | ||
363 | unsigned int path_length, | ||
364 | const struct GNUNET_PeerIdentity *path, | ||
365 | struct GNUNET_TIME_Absolute exp, | ||
366 | const GNUNET_HashCode * key, | ||
367 | const void *data, | ||
368 | size_t size) | ||
369 | { | ||
370 | const char *s_key; | ||
371 | unsigned int i; | ||
372 | |||
373 | i = (unsigned int) (long) cls; | ||
374 | s_key = GNUNET_h2s(key); | ||
375 | |||
376 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
377 | "%u got a PUT message for key %s with %u bytes\n", | ||
378 | i, s_key, size); | ||
379 | |||
380 | if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) | ||
381 | monitor_counter++; | ||
382 | } | ||
383 | |||
384 | |||
385 | /** | ||
386 | * Callback called on each GET reply going through the DHT. | ||
387 | * Prints the info about the intercepted packet and increments a counter. | ||
388 | * | ||
389 | * @param cls Closure. | ||
390 | * @param type The type of data in the result. | ||
391 | * @param get_path Peers on GET path (or NULL if not recorded). | ||
313 | * @param get_path_length number of entries in get_path. | 392 | * @param get_path_length number of entries in get_path. |
314 | * @param put_path peers on the PUT path (or NULL if not recorded). | 393 | * @param put_path peers on the PUT path (or NULL if not recorded). |
315 | * @param put_path_length number of entries in get_path. | 394 | * @param put_path_length number of entries in get_path. |
316 | * @param desired_replication_level Desired replication level. | 395 | * @param exp Expiration time of the data. |
317 | * @param type Type of the result/request. | 396 | * @param key Key of the data. |
318 | * @param data Pointer to the result data. | 397 | * @param data Pointer to the result data. |
319 | * @param size Number of bytes in data. | 398 | * @param size Number of bytes in data. |
320 | */ | 399 | */ |
321 | void | 400 | void |
322 | monitor_dht_cb (void *cls, | 401 | monitor_res_cb (void *cls, |
323 | uint16_t mtype, | 402 | enum GNUNET_BLOCK_Type type, |
324 | struct GNUNET_TIME_Absolute exp, | 403 | const struct GNUNET_PeerIdentity *get_path, |
325 | const GNUNET_HashCode * key, | ||
326 | const struct GNUNET_PeerIdentity * get_path, | ||
327 | unsigned int get_path_length, | 404 | unsigned int get_path_length, |
328 | const struct GNUNET_PeerIdentity * put_path, | 405 | const struct GNUNET_PeerIdentity *put_path, |
329 | unsigned int put_path_length, | 406 | unsigned int put_path_length, |
330 | uint32_t desired_replication_level, | 407 | struct GNUNET_TIME_Absolute exp, |
331 | enum GNUNET_DHT_RouteOption options, | 408 | const GNUNET_HashCode * key, |
332 | enum GNUNET_BLOCK_Type type, | ||
333 | const void *data, | 409 | const void *data, |
334 | size_t size) | 410 | size_t size) |
335 | { | 411 | { |
336 | const char *s_key; | 412 | const char *s_key; |
337 | const char *mtype_s; | ||
338 | unsigned int i; | 413 | unsigned int i; |
339 | 414 | ||
340 | i = (unsigned int) (long) cls; | 415 | i = (unsigned int) (long) cls; |
341 | s_key = GNUNET_h2s(key); | 416 | s_key = GNUNET_h2s(key); |
342 | switch (mtype) | ||
343 | { | ||
344 | case 149: | ||
345 | mtype_s = "GET "; | ||
346 | break; | ||
347 | case 150: | ||
348 | mtype_s = "RESULT"; | ||
349 | break; | ||
350 | case 151: | ||
351 | mtype_s = "PUT "; | ||
352 | break; | ||
353 | default: | ||
354 | GNUNET_break (0); | ||
355 | mtype_s = "UNKNOWN!!!"; | ||
356 | } | ||
357 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 417 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
358 | "%u got a message of type %s for key %s\n", | 418 | "%u got a REPLY message for key %s with %u bytes\n", |
359 | i, mtype_s, s_key); | 419 | i, s_key, size); |
360 | 420 | ||
361 | if ((mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || | 421 | if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) |
362 | mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) && | ||
363 | strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) | ||
364 | monitor_counter++; | 422 | monitor_counter++; |
365 | } | 423 | } |
366 | 424 | ||
@@ -419,8 +477,13 @@ peergroup_ready (void *cls, const char *emsg) | |||
419 | { | 477 | { |
420 | d = GNUNET_TESTING_daemon_get (pg, i); | 478 | d = GNUNET_TESTING_daemon_get (pg, i); |
421 | hs[i] = GNUNET_DHT_connect (d->cfg, 32); | 479 | hs[i] = GNUNET_DHT_connect (d->cfg, 32); |
422 | mhs[i] = GNUNET_DHT_monitor_start(hs[i], GNUNET_BLOCK_TYPE_ANY, NULL, | 480 | mhs[i] = GNUNET_DHT_monitor_start(hs[i], |
423 | &monitor_dht_cb, (void *)(long)i); | 481 | GNUNET_BLOCK_TYPE_ANY, |
482 | NULL, | ||
483 | &monitor_get_cb, | ||
484 | &monitor_res_cb, | ||
485 | &monitor_put_cb, | ||
486 | (void *)(long)i); | ||
424 | } | 487 | } |
425 | 488 | ||
426 | if ((NULL == o) || (NULL == d_far)) | 489 | if ((NULL == o) || (NULL == d_far)) |