diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-12 16:21:04 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-12 16:21:04 +0000 |
commit | b20b2447cf07e57a5ff19c1829b9dc5cdc561352 (patch) | |
tree | f182a75472d3e3a43f69c8245399d443a0e3811d /src/dht/gnunet-service-dht.c | |
parent | a8db4c30c6a21049f2189941e958c4625c4effb3 (diff) | |
download | gnunet-b20b2447cf07e57a5ff19c1829b9dc5cdc561352.tar.gz gnunet-b20b2447cf07e57a5ff19c1829b9dc5cdc561352.zip |
myriad changes
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 9c301183b..43ea630d5 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -87,15 +87,16 @@ | |||
87 | */ | 87 | */ |
88 | #define DEFAULT_MALICIOUS_GET_FREQUENCY 1000 /* Number of milliseconds */ | 88 | #define DEFAULT_MALICIOUS_GET_FREQUENCY 1000 /* Number of milliseconds */ |
89 | 89 | ||
90 | /** | ||
91 | * Type for a malicious request, so we can ignore it during testing | ||
92 | */ | ||
93 | #define DHT_MALICIOUS_MESSAGE_TYPE 42 | ||
94 | /* | 90 | /* |
95 | * Default frequency for sending malicious put messages | 91 | * Default frequency for sending malicious put messages |
96 | */ | 92 | */ |
97 | #define DEFAULT_MALICIOUS_PUT_FREQUENCY 1000 /* Default is in milliseconds */ | 93 | #define DEFAULT_MALICIOUS_PUT_FREQUENCY 1000 /* Default is in milliseconds */ |
98 | 94 | ||
95 | /** | ||
96 | * Type for a malicious request, so we can ignore it during testing | ||
97 | */ | ||
98 | #define DHT_MALICIOUS_MESSAGE_TYPE 42 | ||
99 | |||
99 | #define DHT_DEFAULT_PING_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) | 100 | #define DHT_DEFAULT_PING_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) |
100 | 101 | ||
101 | /** | 102 | /** |
@@ -2537,6 +2538,10 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2537 | static GNUNET_HashCode key; | 2538 | static GNUNET_HashCode key; |
2538 | unsigned int mcsize; | 2539 | unsigned int mcsize; |
2539 | uint32_t random_key; | 2540 | uint32_t random_key; |
2541 | |||
2542 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
2543 | return; | ||
2544 | |||
2540 | put_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); | 2545 | put_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); |
2541 | put_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_PUT); | 2546 | put_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_PUT); |
2542 | put_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE); | 2547 | put_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE); |
@@ -2552,6 +2557,9 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2552 | message_context.msg_options = ntohl (0); | 2557 | message_context.msg_options = ntohl (0); |
2553 | message_context.network_size = estimate_diameter(); | 2558 | message_context.network_size = estimate_diameter(); |
2554 | message_context.peer = &my_identity; | 2559 | message_context.peer = &my_identity; |
2560 | |||
2561 | if (dhtlog_handle != NULL) | ||
2562 | dhtlog_handle->insert_dhtkey(NULL, &key); | ||
2555 | increment_stats(STAT_PUT_START); | 2563 | increment_stats(STAT_PUT_START); |
2556 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key)); | 2564 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key)); |
2557 | route_message(NULL, &put_message.header, &message_context); | 2565 | route_message(NULL, &put_message.header, &message_context); |
@@ -2573,6 +2581,10 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2573 | static GNUNET_HashCode key; | 2581 | static GNUNET_HashCode key; |
2574 | unsigned int mcsize; | 2582 | unsigned int mcsize; |
2575 | uint32_t random_key; | 2583 | uint32_t random_key; |
2584 | |||
2585 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
2586 | return; | ||
2587 | |||
2576 | get_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); | 2588 | get_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); |
2577 | get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET); | 2589 | get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET); |
2578 | get_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE); | 2590 | get_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE); |
@@ -2587,6 +2599,9 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2587 | message_context.msg_options = ntohl (0); | 2599 | message_context.msg_options = ntohl (0); |
2588 | message_context.network_size = estimate_diameter(); | 2600 | message_context.network_size = estimate_diameter(); |
2589 | message_context.peer = &my_identity; | 2601 | message_context.peer = &my_identity; |
2602 | |||
2603 | if (dhtlog_handle != NULL) | ||
2604 | dhtlog_handle->insert_dhtkey(NULL, &key); | ||
2590 | increment_stats(STAT_GET_START); | 2605 | increment_stats(STAT_GET_START); |
2591 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key)); | 2606 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key)); |
2592 | route_message(NULL, &get_message.header, &message_context); | 2607 | route_message(NULL, &get_message.header, &message_context); |
@@ -2717,6 +2732,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2717 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: | 2732 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: |
2718 | if (ntohs(dht_control_msg->variable) > 0) | 2733 | if (ntohs(dht_control_msg->variable) > 0) |
2719 | malicious_get_frequency = ntohs(dht_control_msg->variable); | 2734 | malicious_get_frequency = ntohs(dht_control_msg->variable); |
2735 | if (malicious_get_frequency == 0) | ||
2736 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; | ||
2720 | if (malicious_getter != GNUNET_YES) | 2737 | if (malicious_getter != GNUNET_YES) |
2721 | GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL); | 2738 | GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL); |
2722 | malicious_getter = GNUNET_YES; | 2739 | malicious_getter = GNUNET_YES; |
@@ -2725,6 +2742,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2725 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: | 2742 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: |
2726 | if (ntohs(dht_control_msg->variable) > 0) | 2743 | if (ntohs(dht_control_msg->variable) > 0) |
2727 | malicious_put_frequency = ntohs(dht_control_msg->variable); | 2744 | malicious_put_frequency = ntohs(dht_control_msg->variable); |
2745 | if (malicious_put_frequency == 0) | ||
2746 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; | ||
2728 | if (malicious_putter != GNUNET_YES) | 2747 | if (malicious_putter != GNUNET_YES) |
2729 | GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL); | 2748 | GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL); |
2730 | malicious_putter = GNUNET_YES; | 2749 | malicious_putter = GNUNET_YES; |