_("Failed to connect to the DHT service!\n"));
return GNUNET_NO;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting to process replies from DHT\n");
GNUNET_CLIENT_receive (handle->client,
&service_message_handler,
handle,
if (GNUNET_YES == head->free_on_send)
GNUNET_free (head);
process_pending_messages (handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Forwarded request of %u bytes to DHT service\n",
+ (unsigned int) tsize);
return tsize;
}
uid = GNUNET_ntohll (dht_msg->unique_id);
if (uid != rh->uid)
- return GNUNET_YES;
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Reply UID did not match request UID\n");
+ return GNUNET_YES;
+ }
enc_size = ntohs (dht_msg->header.size) - sizeof (struct GNUNET_DHT_RouteResultMessage);
if (enc_size < sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break (0);
return GNUNET_NO;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing reply.\n");
rh->iter (rh->iter_cls,
&rh->key,
enc_msg);
{
struct GNUNET_DHT_Handle *handle = cls;
const struct GNUNET_DHT_RouteResultMessage *dht_msg;
-
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%s called\n",
+ __FUNCTION__);
if (msg == NULL)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Error receiving data from DHT service, reconnecting\n");
reconnect (handle);
return;
}
return;
}
dht_msg = (const struct GNUNET_DHT_RouteResultMessage *) msg;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Comparing reply `%s' against %u pending requests.\n",
+ GNUNET_h2s (&dht_msg->key),
+ GNUNET_CONTAINER_multihashmap_size (handle->active_requests));
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests,
&dht_msg->key,
&process_reply,
(void*) dht_msg);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Continuing to process replies from DHT\n");
GNUNET_CLIENT_receive (handle->client,
&service_message_handler,
handle, GNUNET_TIME_UNIT_FOREVER_REL);
pending);
pending->in_pending_queue = GNUNET_YES;
process_pending_messages (handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DHT route start request processed, returning %p\n",
+ route_handle);
return route_handle;
}
route_handle));
GNUNET_free(route_handle->message);
GNUNET_free(route_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DHT route stop request processed\n");
}
put_msg->type = htons (type);
put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
memcpy (&put_msg[1], data, size);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting route for %u byte `%s' message\n",
+ (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size),
+ "PUT");
GNUNET_break (NULL ==
GNUNET_DHT_route_start (handle,
key,
size_t payload;
if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_GET_RESULT)
- return;
+ {
+ GNUNET_break (0);
+ return;
+ }
GNUNET_assert (ntohs (reply->size) >=
sizeof (struct GNUNET_DHT_GetResultMessage));
get_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET);
get_msg.header.size = htons (sizeof (struct GNUNET_DHT_GetMessage));
get_msg.type = htons (type);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting route for %u byte `%s' message\n",
+ (unsigned int) sizeof (struct GNUNET_DHT_GetMessage),
+ "GET");
get_handle->route_handle =
GNUNET_DHT_route_start (handle,
key,
#define REAL_DISTANCE GNUNET_NO
#define EXTRA_CHECKS GNUNET_NO
+
/**
* How many buckets will we allow total.
*/
off += msize;
}
process_pending_messages (client);
+#if DEBUG_DHT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted %u bytes of replies to client\n",
+ (unsigned int) off);
+#endif
return off;
}
static void
send_reply_to_client (struct ClientList *client,
const struct GNUNET_MessageHeader *message,
- unsigned long long uid)
+ unsigned long long uid,
+ const GNUNET_HashCode *key)
{
struct GNUNET_DHT_RouteResultMessage *reply;
struct PendingMessage *pending_message;
reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_RESULT);
reply->header.size = htons (tsize);
reply->unique_id = GNUNET_htonll (uid);
+ reply->key = *key;
memcpy (&reply[1], message, msize);
add_pending_message (client, pending_message);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Have no record of response key %s uid %llu\n", my_short_id,
- "DHT", GNUNET_h2s (message_context->key), message_context->unique_id);
+ "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id);
#endif
#if DEBUG_DHT_ROUTING
if ((debug_routes_extended) && (dhtlog_handle != NULL))
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Sending response key %s uid %llu to client\n", my_short_id,
- "DHT", GNUNET_h2s (message_context->key), message_context->unique_id);
+ "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id);
#endif
#if DEBUG_DHT_ROUTING
if ((debug_routes_extended) && (dhtlog_handle != NULL))
if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_GET_RESULT)
increment_stats(STAT_GET_REPLY);
- send_reply_to_client(pos->client, msg, message_context->unique_id);
+ send_reply_to_client(pos->client, msg,
+ message_context->unique_id,
+ &message_context->key);
}
else /* Send to peer */
{
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Forwarding response key %s uid %llu to peer %s\n", my_short_id,
- "DHT", GNUNET_h2s (message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id));
+ "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id));
#endif
#if DEBUG_DHT_ROUTING
if ((debug_routes_extended) && (dhtlog_handle != NULL))
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': NOT Forwarding response (bloom match) key %s uid %llu to peer %s\n", my_short_id,
- "DHT", GNUNET_h2s (message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id));
+ "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id));
#endif
}
}
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Received `%s' request, message type %u, key %s, uid %llu\n", my_short_id,
- "DHT", "GET", get_type, GNUNET_h2s (message_context->key),
+ "DHT", "GET", get_type, GNUNET_h2s (&message_context->key),
message_context->unique_id);
#endif
increment_stats(STAT_GETS);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Received `%s' request from client, key %s (msg size %d, we expected %d)\n",
- my_short_id, "DHT", "FIND PEER", GNUNET_h2s (message_context->key),
+ my_short_id, "DHT", "FIND PEER", GNUNET_h2s (&message_context->key),
ntohs (find_msg->size),
sizeof (struct GNUNET_MessageHeader));
#endif
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n",
- my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (message_context->key), message_context->unique_id);
+ my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&message_context->key), message_context->unique_id);
#endif
#if DEBUG_DHT_ROUTING
if (message_context->hop_count == 0) /* Locally initiated request */
#if DEBUG_DHT > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Created new forward source info for %s uid %llu\n", my_short_id,
- "DHT", GNUNET_h2s (msg_ctx->key), msg_ctx->unique_id);
+ "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id);
#endif
return GNUNET_YES;
}
nearest_buf = GNUNET_strdup(GNUNET_i2s(&nearest->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", my_short_id,
- "DHT", GNUNET_h2s (message_context->key), message_context->unique_id, GNUNET_i2s(&selected->id), nearest_buf, GNUNET_CRYPTO_hash_matching_bits(&nearest->id.hashPubKey, message_context->key), distance(&nearest->id.hashPubKey, message_context->key));
+ "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&selected->id), nearest_buf, GNUNET_CRYPTO_hash_matching_bits(&nearest->id.hashPubKey, message_context->key), distance(&nearest->id.hashPubKey, message_context->key));
GNUNET_free(nearest_buf);
#endif
#if DEBUG_DHT_ROUTING
const struct GNUNET_DHT_RouteMessage *dht_msg = (const struct GNUNET_DHT_RouteMessage *) message;
const struct GNUNET_MessageHeader *enc_msg;
struct DHT_MessageContext message_context;
+
enc_msg = (const struct GNUNET_MessageHeader *) &dht_msg[1];
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Received `%s' request from client, message type %d, key %s, uid %llu\n",
- my_short_id, "DHT", "GENERIC", enc_type, GNUNET_h2s (&dht_msg->key),
+ my_short_id,
+ "DHT",
+ "GENERIC",
+ ntohs (message->type),
+ GNUNET_h2s (&dht_msg->key),
GNUNET_ntohll (dht_msg->unique_id));
#endif
#if DEBUG_DHT_ROUTING
if (malicious_getter != GNUNET_YES)
GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL);
malicious_getter = GNUNET_YES;
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency);
break;
case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
if (ntohs(dht_control_msg->variable) > 0)
if (malicious_putter != GNUNET_YES)
GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL);
malicious_putter = GNUNET_YES;
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency);
break;
case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP:
#if DEBUG_DHT_ROUTING
dhtlog_handle->set_malicious(&my_identity);
#endif
malicious_dropper = GNUNET_YES;
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious DROP behavior\n", my_short_id, "DHT");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "%s:%s Initiating malicious DROP behavior\n", my_short_id, "DHT");
break;
default:
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Unknown control command type `%d'!\n", ntohs(dht_control_msg->command));
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ "%s:%s Unknown control command type `%d'!\n",
+ my_short_id, "DHT",
+ ntohs(dht_control_msg->command));
+ break;
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
#include "gnunet_dht_service.h"
#include "gnunet_hello_lib.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define VERBOSE_ARM GNUNET_NO
static void
end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- /* do work here */
- sleep(2);
GNUNET_SCHEDULER_cancel (sched, die_task);
-
- GNUNET_DHT_disconnect (p1.dht_handle);
die_task = GNUNET_SCHEDULER_NO_TASK;
-
- if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "DHT disconnected, returning FAIL!\n");
- ok = 365;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "DHT disconnected, returning success!\n");
- ok = 0;
- }
+ GNUNET_DHT_disconnect (p1.dht_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DHT disconnected, returning success!\n");
+ ok = 0;
}
static void
fprintf (stderr, "Ending on an unhappy note.\n");
#endif
- if ((retry_context.peer_ctx != NULL) && (retry_context.peer_ctx->find_peer_handle != NULL))
+ if ( (retry_context.peer_ctx != NULL) &&
+ (retry_context.peer_ctx->find_peer_handle != NULL) )
GNUNET_DHT_find_peer_stop(retry_context.peer_ctx->find_peer_handle);
+ if ( (retry_context.peer_ctx != NULL) &&
+ (retry_context.peer_ctx->get_handle != NULL) )
+ GNUNET_DHT_get_stop (retry_context.peer_ctx->get_handle);
if (retry_context.retry_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel(sched, retry_context.retry_task);
GNUNET_DHT_disconnect (p1.dht_handle);
-
ok = 1;
- return;
-}
-
-#if HAVE_MALICIOUS
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-void test_set_peer_malicious_drop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct PeerContext *peer = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_drop!\n");
- if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
-
- GNUNET_assert (peer->dht_handle != NULL);
-
- GNUNET_DHT_set_malicious_dropper (peer->dht_handle, &end, &p1);
-}
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-void test_set_peer_malicious_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct PeerContext *peer = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_put!\n");
- if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
-
- GNUNET_assert (peer->dht_handle != NULL);
-
- GNUNET_DHT_set_malicious_putter (peer->dht_handle, 750, &test_set_peer_malicious_drop, &p1);
-}
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-static void
-test_set_peer_malicious_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct PeerContext *peer = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_set_peer_malicious_get!\n");
- if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
-
- GNUNET_assert (peer->dht_handle != NULL);
-
- GNUNET_DHT_set_malicious_getter (peer->dht_handle, 1500, &test_set_peer_malicious_put, &p1);
}
-#endif
/**
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_find_peer_stop!\n");
if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (sched, die_task);
+ GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
+ return;
+ }
GNUNET_assert (peer->dht_handle != NULL);
GNUNET_DHT_find_peer_stop (peer->find_peer_handle);
#if HAVE_MALICIOUS
- GNUNET_SCHEDULER_add_now (sched,
- &test_set_peer_malicious_get, &p1);
-#else
- GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1),
- &end, &p1);
+ GNUNET_DHT_set_malicious_getter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS);
+ GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS);
+ GNUNET_DHT_set_malicious_dropper (peer->dht_handle);
#endif
-
+ GNUNET_SCHEDULER_add_delayed(sched,
+ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1),
+ &end, &p1);
}
}
if (retry_ctx->peer_ctx->find_peer_handle == NULL)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
- else
- retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx);
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (sched, die_task);
+ GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
+ return;
+ }
+ retry_ctx->retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_ctx->next_timeout, &retry_find_peer_stop, retry_ctx);
}
/**
&test_find_peer_processor, &retry_context);
if (peer->find_peer_handle == NULL)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
- else
- retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_context.next_timeout, &retry_find_peer_stop, &retry_context);
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (sched, die_task);
+ GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
+ return;
+ }
+ retry_context.retry_task = GNUNET_SCHEDULER_add_delayed(sched, retry_context.next_timeout, &retry_find_peer_stop, &retry_context);
}
/**
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_get_stop!\n");
if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (sched, die_task);
+ GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
+ return;
+ }
GNUNET_assert (peer->dht_handle != NULL);
GNUNET_DHT_get_stop (peer->get_handle);
GNUNET_SCHEDULER_add_now(sched,
peer->get_handle =
GNUNET_DHT_get_start (peer->dht_handle,
TOTAL_TIMEOUT,
- 49 /* fixme: use test type */,
+ GNUNET_BLOCK_TYPE_TEST,
&hash,
GNUNET_DHT_RO_NONE,
NULL, 0,
&test_get_iterator, NULL);
if (peer->get_handle == NULL)
- GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_cancel (sched, die_task);
+ GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);
+ return;
+ }
}
/**
GNUNET_DHT_put (peer->dht_handle, &hash,
GNUNET_DHT_RO_NONE,
- 49 /* fixme: use test type */,
+ GNUNET_BLOCK_TYPE_TEST,
data_size, data,
GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT),
TOTAL_TIMEOUT,
PORT = 2092
[dht]
-DEBUG = NO
+DEBUG = YES
PORT = 12370
[transport]