diff options
Diffstat (limited to 'src/dht/test_dht_monitor.c')
-rw-r--r-- | src/dht/test_dht_monitor.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 8e3bd95ef..63af7e94c 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -237,9 +237,21 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
237 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); | 237 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); |
238 | } | 238 | } |
239 | 239 | ||
240 | /** | ||
241 | * Start test: start GET request from the first node in the line looking for | ||
242 | * the ID of the last node in the line. | ||
243 | * | ||
244 | * @param cls Closure (not used). | ||
245 | * @param tc Task context. | ||
246 | */ | ||
240 | static void | 247 | static void |
241 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 248 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
242 | { | 249 | { |
250 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
251 | { | ||
252 | return; | ||
253 | } | ||
254 | |||
243 | in_test = GNUNET_YES; | 255 | in_test = GNUNET_YES; |
244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); |
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n", | 257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n", |
@@ -291,8 +303,9 @@ put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
291 | 303 | ||
292 | /** | 304 | /** |
293 | * Callback called on each request going through the DHT. | 305 | * Callback called on each request going through the DHT. |
306 | * Prints the info about the intercepted packet and increments a counter. | ||
294 | * | 307 | * |
295 | * @param cls Closure. | 308 | * @param cls Closure (long) # of daemon that got the monitor event. |
296 | * @param mtype Type of the DHT message monitored. | 309 | * @param mtype Type of the DHT message monitored. |
297 | * @param exp When will this value expire. | 310 | * @param exp When will this value expire. |
298 | * @param key Key of the result/request. | 311 | * @param key Key of the result/request. |
@@ -321,11 +334,29 @@ monitor_dht_cb (void *cls, | |||
321 | size_t size) | 334 | size_t size) |
322 | { | 335 | { |
323 | const char *s_key; | 336 | const char *s_key; |
337 | const char *mtype_s; | ||
338 | unsigned int i; | ||
324 | 339 | ||
340 | i = (unsigned int) (long) cls; | ||
325 | s_key = GNUNET_h2s(key); | 341 | s_key = GNUNET_h2s(key); |
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 342 | switch (mtype) |
327 | "%u got a message of type %u for key %s\n", | 343 | { |
328 | cls, mtype, s_key); | 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, | ||
358 | "%u got a message of type %s for key %s\n", | ||
359 | i, mtype_s, s_key); | ||
329 | 360 | ||
330 | if ((mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || | 361 | if ((mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || |
331 | mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) && | 362 | mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) && |