diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-27 08:58:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-27 08:58:06 +0000 |
commit | 4f3f80d05ac7101b8049c352d70abe97bc81ab23 (patch) | |
tree | c06793649eddaff22e7363bd97ea70ed2b069950 | |
parent | e83f3d39b93b4a1aa721c6de33a9c1f04c82896d (diff) |
making some files compile
-rw-r--r-- | src/dht/gnunet-service-dht-new.c | 664 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.h | 18 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 124 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_clients.h | 2 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 92 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.h | 14 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_nse.c | 2 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.h | 11 |
8 files changed, 238 insertions, 689 deletions
diff --git a/src/dht/gnunet-service-dht-new.c b/src/dht/gnunet-service-dht-new.c index 17330ddb60..e4ea3891bf 100644 --- a/src/dht/gnunet-service-dht-new.c +++ b/src/dht/gnunet-service-dht-new.c @@ -23,120 +23,43 @@ * @brief GNUnet DHT service * @author Christian Grothoff * @author Nathan Evans - * - * TODO: - * - use OPTION_MULTIPLE instead of linked list for the forward_list.hashmap - * - use different 'struct DHT_MessageContext' for the different types of - * messages (currently rather confusing, especially with things like - * peer bloom filters occuring when processing replies). */ - #include "platform.h" #include "gnunet_block_lib.h" -#include "gnunet_client_lib.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_protocols.h" -#include "gnunet_service_lib.h" -#include "gnunet_nse_service.h" -#include "gnunet_core_service.h" -#include "gnunet_signal_lib.h" #include "gnunet_util_lib.h" -#include "gnunet_datacache_lib.h" #include "gnunet_transport_service.h" #include "gnunet_hello_lib.h" #include "gnunet_dht_service.h" #include "gnunet_statistics_service.h" -#include "dht.h" -#include <fenv.h> - - -/** - * Defines whether find peer requests send their HELLO's outgoing, - * or expect replies to contain hellos. - */ -#define FIND_PEER_WITH_HELLO GNUNET_YES - -#define DEFAULT_CORE_QUEUE_SIZE 32 +#include "gnunet-service-dht.h" +#include "gnunet-service-dht_clients.h" +#include "gnunet-service-dht_datacache.h" +#include "gnunet-service-dht_neighbours.h" +#include "gnunet-service-dht_nse.h" +#include "gnunet-service-dht_routing.h" -/** - * Minimum number of peers we need for "good" routing, - * any less than this and we will allow messages to - * travel much further through the network! - */ -#define MINIMUM_PEER_THRESHOLD 20 -/** - * How long do we wait at most when queueing messages with core - * that we are sending on behalf of other peers. - */ -#define DHT_DEFAULT_P2P_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) - -/** - * Default importance for handling messages on behalf of other peers. - */ -#define DHT_DEFAULT_P2P_IMPORTANCE 0 /** - * How long to keep recent requests around by default. - */ -#define DEFAULT_RECENT_REMOVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) - -/** - * Default time to wait to send find peer messages sent by the dht service. - */ -#define DHT_DEFAULT_FIND_PEER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) - -/** - * Default importance for find peer messages sent by the dht service. - */ -#define DHT_DEFAULT_FIND_PEER_IMPORTANCE 8 - -/** - * Default replication parameter for find peer messages sent by the dht service. - */ -#define DHT_DEFAULT_FIND_PEER_REPLICATION 4 - -/** - * How long at least to wait before sending another find peer request. - */ -#define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) - -/** - * How long at most to wait before sending another find peer request. - */ -#define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 8) - -/** - * How often to update our preference levels for peers in our routing tables. + * Handle for the statistics service. */ -#define DHT_DEFAULT_PREFERENCE_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) +struct GNUNET_STATISTICS_Handle *GDS_stats; /** - * How long at most on average will we allow a reply forward to take - * (before we quit sending out new requests) + * Our handle to the BLOCK library. */ -#define MAX_REQUEST_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) +struct GNUNET_BLOCK_Context *GDS_block_context; /** - * How many time differences between requesting a core send and - * the actual callback to remember. + * The configuration the DHT service is running with */ -#define MAX_REPLY_TIMES 8 - - - +const struct GNUNET_CONFIGURATION_Handle *GDS_cfg; /** - * How many peers have we added since we sent out our last - * find peer request? + * Our HELLO */ -static unsigned int newly_found_peers; +struct GNUNET_MessageHeader *GDS_my_hello; -/** - * Handle for the statistics service. - */ -struct GNUNET_STATISTICS_Handle *stats; /** * Handle to get our current HELLO. @@ -144,474 +67,26 @@ struct GNUNET_STATISTICS_Handle *stats; static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; /** - * The configuration the DHT service is running with - */ -static const struct GNUNET_CONFIGURATION_Handle *cfg; - -/** - * Handle to the core service - */ -static struct GNUNET_CORE_Handle *coreAPI; - -/** * Handle to the transport service, for getting our hello */ static struct GNUNET_TRANSPORT_Handle *transport_handle; -/** - * The identity of our peer. - */ -static struct GNUNET_PeerIdentity my_identity; - -/** - * Our HELLO - */ -static struct GNUNET_MessageHeader *my_hello; - -/** - * Task to run when we shut down, cleaning up all our trash - */ -static GNUNET_SCHEDULER_TaskIdentifier cleanup_task; - -/** - * Recently seen find peer requests. - */ -static struct GNUNET_CONTAINER_MultiHashMap *recent_find_peer_requests; - -/** - * Our handle to the BLOCK library. - */ -static struct GNUNET_BLOCK_Context *block_context; - - - - -/** - * Given the largest send delay, artificially decrease it - * so the next time around we may have a chance at sending - * again. - */ -static void -decrease_max_send_delay (struct GNUNET_TIME_Relative max_time) -{ - unsigned int i; - - for (i = 0; i < MAX_REPLY_TIMES; i++) - { - if (reply_times[i].rel_value == max_time.rel_value) - { - reply_times[i].rel_value = reply_times[i].rel_value / 2; - return; - } - } -} - - -/** - * Find the maximum send time of the recently sent values. - * - * @return the average time between asking core to send a message - * and when the buffer for copying it is passed - */ -static struct GNUNET_TIME_Relative -get_max_send_delay () -{ - unsigned int i; - struct GNUNET_TIME_Relative max_time; - - max_time = GNUNET_TIME_relative_get_zero (); - - for (i = 0; i < MAX_REPLY_TIMES; i++) - { - if (reply_times[i].rel_value > max_time.rel_value) - max_time.rel_value = reply_times[i].rel_value; - } -#if DEBUG_DHT - if (max_time.rel_value > MAX_REQUEST_TIME.rel_value) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Max send delay was %llu\n", - (unsigned long long) max_time.rel_value); -#endif - return max_time; -} - - -static void -increment_stats (const char *value) -{ - if (stats == NULL) - return; - GNUNET_STATISTICS_update (stats, value, 1, GNUNET_NO); -} - - -static void -decrement_stats (const char *value) -{ - if (stats == NULL) - return; - GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO); -} - - - -/** - * Compute the distance between have and target as a 32-bit value. - * Differences in the lower bits must count stronger than differences - * in the higher bits. - * - * @return 0 if have==target, otherwise a number - * that is larger as the distance between - * the two hash codes increases - */ -static unsigned int -distance (const GNUNET_HashCode * target, const GNUNET_HashCode * have) -{ - unsigned int bucket; - unsigned int msb; - unsigned int lsb; - unsigned int i; - - /* We have to represent the distance between two 2^9 (=512)-bit - * numbers as a 2^5 (=32)-bit number with "0" being used for the - * two numbers being identical; furthermore, we need to - * guarantee that a difference in the number of matching - * bits is always represented in the result. - * - * We use 2^32/2^9 numerical values to distinguish between - * hash codes that have the same LSB bit distance and - * use the highest 2^9 bits of the result to signify the - * number of (mis)matching LSB bits; if we have 0 matching - * and hence 512 mismatching LSB bits we return -1 (since - * 512 itself cannot be represented with 9 bits) */ - - /* first, calculate the most significant 9 bits of our - * result, aka the number of LSBs */ - bucket = GNUNET_CRYPTO_hash_matching_bits (target, have); - /* bucket is now a value between 0 and 512 */ - if (bucket == 512) - return 0; /* perfect match */ - if (bucket == 0) - return (unsigned int) -1; /* LSB differs; use max (if we did the bit-shifting - * below, we'd end up with max+1 (overflow)) */ - - /* calculate the most significant bits of the final result */ - msb = (512 - bucket) << (32 - 9); - /* calculate the 32-9 least significant bits of the final result by - * looking at the differences in the 32-9 bits following the - * mismatching bit at 'bucket' */ - lsb = 0; - for (i = bucket + 1; - (i < sizeof (GNUNET_HashCode) * 8) && (i < bucket + 1 + 32 - 9); i++) - { - if (GNUNET_CRYPTO_hash_get_bit (target, i) != - GNUNET_CRYPTO_hash_get_bit (have, i)) - lsb |= (1 << (bucket + 32 - 9 - i)); /* first bit set will be 10, - * last bit set will be 31 -- if - * i does not reach 512 first... */ - } - return msb | lsb; -} - /** - * Return a number that is larger the closer the - * "have" GNUNET_hash code is to the "target". - * - * @return inverse distance metric, non-zero. - * Must fudge the value if NO bits match. - */ -static unsigned int -inverse_distance (const GNUNET_HashCode * target, const GNUNET_HashCode * have) -{ - if (GNUNET_CRYPTO_hash_matching_bits (target, have) == 0) - return 1; /* Never return 0! */ - return ((unsigned int) -1) - distance (target, have); -} - - - -/* Forward declaration */ -static void -update_core_preference (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); - - -/** - * Function called with statistics about the given peer. - * - * @param cls closure - * @param peer identifies the peer - * @param bpm_out set to the current bandwidth limit (sending) for this peer - * @param amount set to the amount that was actually reserved or unreserved; - * either the full requested amount or zero (no partial reservations) - * @param res_delay if the reservation could not be satisfied (amount was 0), how - * long should the client wait until re-trying? - * @param preference current traffic preference for the given peer - */ -static void -update_core_preference_finish (void *cls, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bpm_out, - int32_t amount, - struct GNUNET_TIME_Relative res_delay, - uint64_t preference) -{ - struct PeerInfo *peer_info = cls; - - peer_info->info_ctx = NULL; - GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL, - &update_core_preference, peer_info); -} - -static void -update_core_preference (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct PeerInfo *peer = cls; - uint64_t preference; - unsigned int matching; - - if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) - { - return; - } - matching = - GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, - &peer->id.hashPubKey); - if (matching >= 64) - { -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Peer identifier matches by %u bits, only shifting as much as we can!\n", - matching); -#endif - matching = 63; - } - preference = 1LL << matching; - peer->info_ctx = - GNUNET_CORE_peer_change_preference (coreAPI, &peer->id, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BANDWIDTH_VALUE_MAX, 0, - preference, - &update_core_preference_finish, peer); -} - - - -/** - * Server handler for initiating local dht find peer requests - * - * @param find_msg the actual find peer message - * @param msg_ctx struct containing pertinent information about the request - * - */ -static void -handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, - struct DHT_MessageContext *msg_ctx) -{ - struct GNUNET_MessageHeader *find_peer_result; - struct GNUNET_DHT_FindPeerMessage *find_peer_message; - struct DHT_MessageContext *new_msg_ctx; - struct GNUNET_CONTAINER_BloomFilter *incoming_bloom; - size_t hello_size; - size_t tsize; - GNUNET_HashCode *recent_hash; - struct GNUNET_MessageHeader *other_hello; - size_t other_hello_size; - struct GNUNET_PeerIdentity peer_id; - - find_peer_message = (struct GNUNET_DHT_FindPeerMessage *) find_msg; - GNUNET_break_op (ntohs (find_msg->size) >= - (sizeof (struct GNUNET_DHT_FindPeerMessage))); - if (ntohs (find_msg->size) < sizeof (struct GNUNET_DHT_FindPeerMessage)) - return; - other_hello = NULL; - other_hello_size = 0; - if (ntohs (find_msg->size) > sizeof (struct GNUNET_DHT_FindPeerMessage)) - { - other_hello_size = - ntohs (find_msg->size) - sizeof (struct GNUNET_DHT_FindPeerMessage); - other_hello = GNUNET_malloc (other_hello_size); - memcpy (other_hello, &find_peer_message[1], other_hello_size); - if ((GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) other_hello) == 0) - || (GNUNET_OK != - GNUNET_HELLO_get_id ((struct GNUNET_HELLO_Message *) other_hello, - &peer_id))) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Received invalid HELLO message in find peer request!\n"); - GNUNET_free (other_hello); - return; - } -#if FIND_PEER_WITH_HELLO - if (GNUNET_YES == consider_peer (&peer_id)) - { - increment_stats (STAT_HELLOS_PROVIDED); - GNUNET_TRANSPORT_offer_hello (transport_handle, other_hello, NULL, NULL); - GNUNET_CORE_peer_request_connect (coreAPI, &peer_id, NULL, NULL); - route_message (find_msg, msg_ctx); - GNUNET_free (other_hello); - return; - } - else /* We don't want this peer! */ - { - route_message (find_msg, msg_ctx); - GNUNET_free (other_hello); - return; - } -#endif - } - -#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 (&msg_ctx->key), - ntohs (find_msg->size), sizeof (struct GNUNET_MessageHeader)); -#endif - if (my_hello == NULL) - { -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s': Our HELLO is null, can't return.\n", "DHT"); -#endif - GNUNET_free_non_null (other_hello); - route_message (find_msg, msg_ctx); - return; - } - - incoming_bloom = - GNUNET_CONTAINER_bloomfilter_init (find_peer_message->bloomfilter, - DHT_BLOOM_SIZE, DHT_BLOOM_K); - if (GNUNET_YES == - GNUNET_CONTAINER_bloomfilter_test (incoming_bloom, - &my_identity.hashPubKey)) - { - increment_stats (STAT_BLOOM_FIND_PEER); - GNUNET_CONTAINER_bloomfilter_free (incoming_bloom); - GNUNET_free_non_null (other_hello); - route_message (find_msg, msg_ctx); - return; /* We match the bloomfilter, do not send a response to this peer (they likely already know us!) */ - } - GNUNET_CONTAINER_bloomfilter_free (incoming_bloom); - - /** - * Ignore any find peer requests from a peer we have seen very recently. - */ - if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (recent_find_peer_requests, &msg_ctx->key)) /* We have recently responded to a find peer request for this peer! */ - { - increment_stats ("# dht find peer requests ignored (recently seen!)"); - GNUNET_free_non_null (other_hello); - return; - } - - /** - * Use this check to only allow the peer to respond to find peer requests if - * it would be beneficial to have the requesting peer in this peers routing - * table. Can be used to thwart peers flooding the network with find peer - * requests that we don't care about. However, if a new peer is joining - * the network and has no other peers this is a problem (assume all buckets - * full, no one will respond!). - */ - memcpy (&peer_id.hashPubKey, &msg_ctx->key, sizeof (GNUNET_HashCode)); - if (GNUNET_NO == consider_peer (&peer_id)) - { - increment_stats ("# dht find peer requests ignored (do not need!)"); - GNUNET_free_non_null (other_hello); - route_message (find_msg, msg_ctx); - return; - } - - recent_hash = GNUNET_malloc (sizeof (GNUNET_HashCode)); - memcpy (recent_hash, &msg_ctx->key, sizeof (GNUNET_HashCode)); - if (GNUNET_SYSERR != - GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, - &msg_ctx->key, NULL, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) - { -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding recent remove task for key `%s`!\n", - GNUNET_h2s (&msg_ctx->key)); -#endif - /* Only add a task if there wasn't one for this key already! */ - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 30), - &remove_recent_find_peer, recent_hash); - } - else - { - GNUNET_free (recent_hash); -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received duplicate find peer request too soon!\n"); -#endif - } - - /* Simplistic find_peer functionality, always return our hello */ - hello_size = ntohs (my_hello->size); - tsize = hello_size + sizeof (struct GNUNET_MessageHeader); - - if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) - { - GNUNET_break_op (0); - GNUNET_free_non_null (other_hello); - return; - } - - find_peer_result = GNUNET_malloc (tsize); - find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT); - find_peer_result->size = htons (tsize); - memcpy (&find_peer_result[1], my_hello, hello_size); -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s': Sending hello size %d to requesting peer.\n", "DHT", - hello_size); -#endif - - new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); - memcpy (new_msg_ctx, msg_ctx, sizeof (struct DHT_MessageContext)); - new_msg_ctx->peer = my_identity; - new_msg_ctx->bloom = - GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); - new_msg_ctx->hop_count = 0; - new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make find peer requests a higher priority */ - new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; - increment_stats (STAT_FIND_PEER_ANSWER); - if (GNUNET_DHT_RO_RECORD_ROUTE == - (msg_ctx->msg_options & GNUNET_DHT_RO_RECORD_ROUTE)) - { - new_msg_ctx->msg_options = GNUNET_DHT_RO_RECORD_ROUTE; - new_msg_ctx->path_history_len = msg_ctx->path_history_len; - /* Assign to previous msg_ctx path history, caller should free after our return */ - new_msg_ctx->path_history = msg_ctx->path_history; - } - route_result_message (find_peer_result, new_msg_ctx); - GNUNET_free (new_msg_ctx); - GNUNET_free_non_null (other_hello); - GNUNET_free (find_peer_result); - route_message (find_msg, msg_ctx); -} - - - -/** - * Receive the HELLO from transport service, - * free current and replace if necessary. + * Receive the HELLO from transport service, free current and replace + * if necessary. * * @param cls NULL * @param message HELLO message of peer */ static void -process_hello (void *cls, const struct GNUNET_MessageHeader *message) +process_hello (void *cls, + const struct GNUNET_MessageHeader *message) { -#if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received our `%s' from transport service\n", "HELLO"); -#endif GNUNET_assert (message != NULL); - GNUNET_free_non_null (my_hello); - my_hello = GNUNET_malloc (ntohs (message->size)); - memcpy (my_hello, message, ntohs (message->size)); + GNUNET_free_non_null (GDS_my_hello); + GDS_my_hello = GNUNET_malloc (ntohs (message->size)); + memcpy (GDS_my_hello, message, ntohs (message->size)); } @@ -631,7 +106,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } if (transport_handle != NULL) { - GNUNET_free_non_null (my_hello); GNUNET_TRANSPORT_disconnect (transport_handle); transport_handle = NULL; } @@ -640,20 +114,21 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GDS_ROUTING_done (); GDS_CLIENT_done (); GDS_NSE_done (); - if (stats != NULL) + if (GDS_block_context != NULL) { - GNUNET_STATISTICS_destroy (stats, GNUNET_YES); - stats = NULL; + GNUNET_BLOCK_context_destroy (GDS_block_context); + GDS_block_context = NULL; } - if (block_context != NULL) + if (GDS_stats != NULL) { - GNUNET_BLOCK_context_destroy (block_context); - block_context = NULL; + GNUNET_STATISTICS_destroy (GDS_stats, GNUNET_YES); + GDS_stats = NULL; } + GNUNET_free_non_null (GDS_my_hello); + GDS_my_hello = NULL; } - /** * Process dht requests. * @@ -665,60 +140,31 @@ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { - struct GNUNET_TIME_Relative next_send_time; - unsigned long long temp_config_num; - - cfg = c; + GDS_cfg = c; + GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg); + GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg); + GDS_ROUTING_init (); + GDS_NSE_init (); GDS_DATACACHE_init (); - coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ - DEFAULT_CORE_QUEUE_SIZE, /* queue size */ - NULL, /* Closure passed to DHT functions */ - &core_init, /* Call core_init once connected */ - &handle_core_connect, /* Handle connects */ - &handle_core_disconnect, /* remove peers on disconnects */ - NULL, /* Do we care about "status" updates? */ - NULL, /* Don't want notified about all incoming messages */ - GNUNET_NO, /* For header only inbound notification */ - NULL, /* Don't want notified about all outbound messages */ - GNUNET_NO, /* For header only outbound notification */ - core_handlers); /* Register these handlers */ - - if (coreAPI == NULL) - return; + GDS_CLIENT_init (server); + if (GNUNET_OK != + GDS_NEIGHBOURS_init ()) + { + shutdown_task (NULL, NULL); + return; + } + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, NULL); transport_handle = - GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); - if (transport_handle != NULL) - ghh = GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); - else - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to connect to transport service!\n"); - block_context = GNUNET_BLOCK_context_create (cfg); - lowest_bucket = MAX_BUCKETS - 1; - all_known_peers = GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); - GNUNET_assert (all_known_peers != NULL); - - if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "bucket_size", - &temp_config_num)) - { - bucket_size = (unsigned int) temp_config_num; - } - - stats = GNUNET_STATISTICS_create ("dht", cfg); - next_send_time.rel_value = - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + - GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, - (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / - 2) - - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); - find_peer_context.start = GNUNET_TIME_absolute_get (); - GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, - &find_peer_context); - - /* Scheduled the task to clean up when shutdown is called */ - cleanup_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL); + if (transport_handle == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("Failed to connect to transport service!\n")); + return; + } + ghh = GNUNET_TRANSPORT_get_hello (transport_handle, + &process_hello, NULL); } @@ -733,8 +179,10 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, - NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, + "gnunet-service-dht", + GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-dht.c */ diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h index c2e16151d9..04f3e9fb3a 100644 --- a/src/dht/gnunet-service-dht.h +++ b/src/dht/gnunet-service-dht.h @@ -31,7 +31,7 @@ /** * Configuration we use. */ -extern struct GNUNET_ConfigurationHandle *GDS_cfg; +extern const struct GNUNET_CONFIGURATION_Handle *GDS_cfg; /** @@ -40,4 +40,20 @@ extern struct GNUNET_ConfigurationHandle *GDS_cfg; extern struct GNUNET_BLOCK_Context *GDS_block_context; +/** + * Handle for the statistics service. + */ +extern struct GNUNET_STATISTICS_Handle *GDS_stats; + +/** + * The identity of our peer. + */ +extern struct GNUNET_PeerIdentity GDS_my_identity; + +/** + * Our HELLO + */ +extern struct GNUNET_MessageHeader *GDS_my_hello; + + #endif diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 8790d8fbbb..154d8d98ee 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c @@ -26,21 +26,13 @@ */ #include "platform.h" -#include "gnunet_block_lib.h" -#include "gnunet_util_lib.h" #include "gnunet_protocols.h" -#include "gnunet_nse_service.h" -#include "gnunet_core_service.h" -#include "gnunet_datacache_lib.h" -#include "gnunet_transport_service.h" -#include "gnunet_hello_lib.h" -#include "gnunet_dht_service.h" #include "gnunet_statistics_service.h" -#include "dht_new.h" -#include <fenv.h> +#include "gnunet-service-dht.h" #include "gnunet-service-dht_clients.h" #include "gnunet-service-dht_datacache.h" #include "gnunet-service-dht_neighbours.h" +#include "dht_new.h" /** @@ -179,7 +171,7 @@ struct ClientQueryRecord /** * The type for the data for the GET request. */ - enum GNUNET_BLOCK_Type msg_type; + enum GNUNET_BLOCK_Type type; }; @@ -220,7 +212,7 @@ static GNUNET_SCHEDULER_TaskIdentifier retry_task; static struct ClientList * find_active_client (struct GNUNET_SERVER_Client *client) { - struct ClientList *pos = client_list; + struct ClientList *pos = client_head; struct ClientList *ret; while (pos != NULL) @@ -259,9 +251,9 @@ remove_client_records (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_CONTAINER_multihashmap_remove (forward_map, key, record)); GNUNET_CONTAINER_heap_remove_node (record->hnode); - GNUNET_ARRAY_append (record->seen_replies, + GNUNET_array_append (record->seen_replies, record->seen_replies_count, - 0); + *key); GNUNET_free (record); return GNUNET_YES; } @@ -279,36 +271,24 @@ static void handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) { - struct ClientList *pos = client_list; - struct ClientList *found; + struct ClientList *pos; struct PendingMessage *reply; - found = NULL; - while (pos != NULL) - { - if (pos->client_handle == client) - { - GNUNET_CONTAINER_DLL_remove (client_head, - client_tail, - pos); - found = pos; - break; - } - pos = pos->next; - } - if (found == NULL) - return; - if (found->transmit_handle != NULL) - GNUNET_CONNECTION_notify_transmit_ready_cancel (found->transmit_handle); - while (NULL != (reply = found->pending_head)) + pos = find_active_client (client); + GNUNET_CONTAINER_DLL_remove (client_head, + client_tail, + pos); + if (pos->transmit_handle != NULL) + GNUNET_CONNECTION_notify_transmit_ready_cancel (pos->transmit_handle); + while (NULL != (reply = pos->pending_head)) { - GNUNET_CONTAINER_DLL_remove (found->pending_head, found->pending_tail, + GNUNET_CONTAINER_DLL_remove (pos->pending_head, pos->pending_tail, reply); GNUNET_free (reply); } - GNUNET_CONTAINER_multihashmap_iterate (forward_list.hashmap, - &remove_client_records, found); - GNUNET_free (found); + GNUNET_CONTAINER_multihashmap_iterate (forward_map, + &remove_client_records, pos); + GNUNET_free (pos); } @@ -321,22 +301,24 @@ static void transmit_request (struct ClientQueryRecord *cqr) { int32_t reply_bf_mutator; + struct GNUNET_CONTAINER_BloomFilter *reply_bf; reply_bf_mutator = (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); reply_bf = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator, cqr->seen_replies, cqr->seen_replies_count); - GST_NEIGHBOURS_handle_get (cqr->msg_type, + GDS_NEIGHBOURS_handle_get (cqr->type, cqr->msg_options, cqr->replication, + 0 /* hop count */, &cqr->key, cqr->xquery, cqr->xquery_size, reply_bf, reply_bf_mutator, NULL /* no peers blocked initially */); - GNUNET_CONTAINER_bloomfilter_destroy (reply_bf); + GNUNET_CONTAINER_bloomfilter_free (reply_bf); /* exponential back-off for retries, max 1h */ cqr->retry_frequency = @@ -368,7 +350,7 @@ transmit_next_request_task (void *cls, { cqr->hnode = NULL; delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time); - if (delay.value > 0) + if (delay.rel_value > 0) { cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, cqr->retry_time.abs_value); @@ -412,18 +394,21 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client, size - sizeof (struct GNUNET_DHT_ClientPutMessage), &dht_msg[1]); /* store locally */ - GST_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (dht_msg->expiration), + GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (dht_msg->expiration), &dht_msg->key, 0, NULL, ntohl (dht_msg->type), size - sizeof (struct GNUNET_DHT_ClientPutMessage), &dht_msg[1]); /* route to other peers */ - GST_NEIGHBOURS_handle_put (ntohl (dht_msg->type), + GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type), ntohl (dht_msg->options), ntohl (dht_msg->desired_replication_level), GNUNET_TIME_absolute_ntoh (dht_msg->expiration), + 0 /* hop count */, + NULL /* peer bloom filter */, &dht_msg->key, + 0, NULL, &dht_msg[1], size - sizeof (struct GNUNET_DHT_ClientPutMessage)); GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -444,8 +429,6 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct GNUNET_DHT_ClientGetMessage *get; - const struct GNUNET_MessageHeader *enc_msg; - struct ClientQueryRecord *cqr; size_t xquery_size; const char* xquery; @@ -475,8 +458,8 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, cqr->xquery_size = xquery_size; cqr->replication = ntohl (get->desired_replication_level); cqr->msg_options = ntohl (get->options); - cqr->msg_type = ntohl (get->type); - GNUNET_CONTAINER_multihashmap_put (forward_map, KEY, cqr, + cqr->type = ntohl (get->type); + GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); /* start remote requests */ if (GNUNET_SCHEDULER_NO_TASK != retry_task) @@ -484,7 +467,7 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, retry_task = GNUNET_SCHEDULER_add_now (&transmit_next_request_task, NULL); /* perform local lookup */ GDS_DATACACHE_handle_get (&get->key, - cqr->msg_type, + cqr->type, cqr->xquery, xquery_size, NULL, 0); @@ -493,9 +476,9 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, /** - * Closure for 'remove_by_uid'. + * Closure for 'remove_by_unique_id'. */ -struct RemoveByUidContext +struct RemoveByUniqueIdContext { /** * Client that issued the removal request. @@ -505,26 +488,26 @@ struct RemoveByUidContext /** * Unique ID of the request. */ - uint64_t uid; + uint64_t unique_id; }; /** * Iterator over hash map entries that frees all entries - * that match the given client and UID. + * that match the given client and unique ID. * - * @param cls UID and client to search for in source routes + * @param cls unique ID and client to search for in source routes * @param key current key code * @param value value in the hash map, a ClientQueryRecord * @return GNUNET_YES (we should continue to iterate) */ static int -remove_by_uid (void *cls, const GNUNET_HashCode * key, void *value) +remove_by_unique_id (void *cls, const GNUNET_HashCode * key, void *value) { - const struct RemoveByUidContext *ctx = cls; + const struct RemoveByUniqueIdContext *ctx = cls; struct ClientQueryRecord *record = value; - if (record->uid != ctx->uid) + if (record->unique_id != ctx->unique_id) return GNUNET_YES; return remove_client_records (ctx->client, key, record); } @@ -545,12 +528,13 @@ handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client, { const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg = (const struct GNUNET_DHT_ClientGetStopMessage *) message; + struct RemoveByUniqueIdContext ctx; ctx.client = find_active_client (client); - ctx.uid = &dht_stop_msg.unique_id); + ctx.unique_id = dht_stop_msg->unique_id; GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, &dht_stop_msg->key, - &remove_by_uid, + &remove_by_unique_id, &ctx); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -693,7 +677,7 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value) struct ForwardReplyContext *frc = cls; struct ClientQueryRecord *record = value; struct PendingMessage *pm; - struct ReplyMessage *reply; + struct GNUNET_DHT_ClientResultMessage *reply; enum GNUNET_BLOCK_EvaluationResult eval; int do_free; GNUNET_HashCode ch; @@ -724,7 +708,7 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value) do_free = GNUNET_YES; break; case GNUNET_BLOCK_EVALUATION_OK_MORE: - GNUNET_ARRAY_append (record->seen_replies, + GNUNET_array_append (record->seen_replies, record->seen_replies_count, ch); do_free = GNUNET_NO; @@ -763,7 +747,7 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value) sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size)); pm->next = pm->prev = NULL; } - reply = (struct ReplyMessage*) &pm[1]; + reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1]; reply->unique_id = record->unique_id; add_pending_message (record->client, pm); if (GNUNET_YES == do_free) @@ -800,14 +784,14 @@ GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration, { struct ForwardReplyContext frc; struct PendingMessage *pm; - struct ReplyMessage *reply; + struct GNUNET_DHT_ClientResultMessage *reply; struct GNUNET_PeerIdentity *paths; size_t msize; if (NULL == - GNUNET_CONTAINER_multihashmap_get (foward_map, key)) + GNUNET_CONTAINER_multihashmap_get (forward_map, key)) return; /* no matching request, fast exit! */ - msize = sizeof(struct ReplyMessage) + data_size + + msize = sizeof(struct GNUNET_DHT_ClientResultMessage) + data_size + (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity); if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { @@ -816,7 +800,7 @@ GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration, return; } pm = (struct PendingMessage *) GNUNET_malloc (msize + sizeof (struct PendingMessage)); - reply = (struct ReplyMessage*) &pm[1]; + reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1]; pm->msg = &reply->header; reply->header.size = htons ((uint16_t) msize); reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT); @@ -827,9 +811,9 @@ GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration, reply->expiration = GNUNET_TIME_absolute_hton (expiration); reply->key = *key; paths = (struct GNUNET_PeerIdentity*) &reply[1]; - mempcy (paths, get_path, + memcpy (paths, get_path, sizeof (struct GNUNET_PeerIdentity) * get_path_length); - mempcy (&paths[get_path_length], + memcpy (&paths[get_path_length], put_path, sizeof (struct GNUNET_PeerIdentity) * put_path_length); memcpy (&paths[get_path_length + put_path_length], data, @@ -839,13 +823,13 @@ GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration, frc.data = data; frc.data_size = data_size; frc.type = type; - GNUNET_CONTAINER_multihashmap_get_multiple (foward_map, key, + GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply, &frc); if (GNUNET_NO == frc.do_copy) { /* did not match any of the requests, free! */ - GNUNET_free (buf); + GNUNET_free (pm); } } @@ -865,7 +849,7 @@ GDS_CLIENT_init (struct GNUNET_SERVER_Handle *server) GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET, 0}, {&handle_dht_local_get_stop, NULL, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP, - sizeof (struct GNUNET_DHT_StopMessage) }, + sizeof (struct GNUNET_DHT_ClientGetStopMessage) }, {NULL, NULL, 0, 0} }; forward_map = GNUNET_CONTAINER_multihashmap_create (1024); diff --git a/src/dht/gnunet-service-dht_clients.h b/src/dht/gnunet-service-dht_clients.h index 0bb548f71e..d6d99540fc 100644 --- a/src/dht/gnunet-service-dht_clients.h +++ b/src/dht/gnunet-service-dht_clients.h @@ -27,6 +27,8 @@ #ifndef GNUNET_SERVICE_DHT_CLIENTS_H #define GNUNET_SERVICE_DHT_CLIENTS_H +#include "gnunet_util_lib.h" +#include "gnunet_block_lib.h" /** * Handle a reply we've received from another peer. If the reply diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 48d9d72a6c..8a566ec0e4 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -1509,6 +1509,8 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, /** * Initialize neighbours subsystem. + * + * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int GDS_NEIGHBOURS_init () @@ -1527,7 +1529,7 @@ GDS_NEIGHBOURS_init () &temp_config_num)) bucket_size = (unsigned int) temp_config_num; coreAPI = GNUNET_CORE_connect (GDS_cfg, - DEFAULT_CORE_QUEUE_SIZE, + 1, NULL, &core_init, &handle_core_connect, @@ -1539,6 +1541,18 @@ GDS_NEIGHBOURS_init () if (coreAPI == NULL) return GNUNET_SYSERR; all_known_peers = GNUNET_CONTAINER_multihashmap_create (256); +#if 0 + // FIXME! + next_send_time.rel_value = + DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, + (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / + 2) - + DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); + find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time, + &send_find_peer_message, + &find_peer_context); +#endif return GNUNET_OK; } @@ -1549,7 +1563,8 @@ GDS_NEIGHBOURS_init () void GDS_NEIGHBOURS_done () { - GNUNET_assert (coreAPI != NULL); + if (coreAPI == NULL) + return; GNUNET_CORE_disconnect (coreAPI); coreAPI = NULL; GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_get_size (all_known_peers)); @@ -1564,3 +1579,76 @@ GDS_NEIGHBOURS_done () /* end of gnunet-service-dht_neighbours.c */ + + +#if 0 + +/* Forward declaration */ +static void +update_core_preference (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); + + +/** + * Function called with statistics about the given peer. + * + * @param cls closure + * @param peer identifies the peer + * @param bpm_out set to the current bandwidth limit (sending) for this peer + * @param amount set to the amount that was actually reserved or unreserved; + * either the full requested amount or zero (no partial reservations) + * @param res_delay if the reservation could not be satisfied (amount was 0), how + * long should the client wait until re-trying? + * @param preference current traffic preference for the given peer + */ +static void +update_core_preference_finish (void *cls, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_BANDWIDTH_Value32NBO bpm_out, + int32_t amount, + struct GNUNET_TIME_Relative res_delay, + uint64_t preference) +{ + struct PeerInfo *peer_info = cls; + + peer_info->info_ctx = NULL; + GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL, + &update_core_preference, peer_info); +} + + +static void +update_core_preference (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct PeerInfo *peer = cls; + uint64_t preference; + unsigned int matching; + + if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) + { + return; + } + matching = + GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, + &peer->id.hashPubKey); + if (matching >= 64) + { +#if DEBUG_DHT + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Peer identifier matches by %u bits, only shifting as much as we can!\n", + matching); +#endif + matching = 63; + } + preference = 1LL << matching; + peer->info_ctx = + GNUNET_CORE_peer_change_preference (core_api, &peer->id, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BANDWIDTH_VALUE_MAX, 0, + preference, + &update_core_preference_finish, peer); +} + + +#endif diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h index 70723deac0..e679b41624 100644 --- a/src/dht/gnunet-service-dht_neighbours.h +++ b/src/dht/gnunet-service-dht_neighbours.h @@ -27,6 +27,9 @@ #ifndef GNUNET_SERVICE_DHT_NEIGHBOURS_H #define GNUNET_SERVICE_DHT_NEIGHBOURS_H +#include "gnunet_util_lib.h" +#include "gnunet_block_lib.h" +#include "gnunet_dht_service.h" /** * Perform a PUT operation. Forwards the given request to other @@ -51,7 +54,7 @@ void GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint32_t desired_replication_level, - GNUNET_TIME_Absolute expiration_time, + struct GNUNET_TIME_Absolute expiration_time, uint32_t hop_count, struct GNUNET_CONTAINER_BloomFilter *bf, const GNUNET_HashCode *key, @@ -108,9 +111,9 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, * @param data_size number of bytes in data */ void -GDS_NEIGHBOURS_handle_reply (const GNUNET_PeerIdentity *target, +GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, enum GNUNET_BLOCK_Type type, - GNUNET_TIME_Absolute expiration_time, + struct GNUNET_TIME_Absolute expiration_time, const GNUNET_HashCode *key, unsigned int put_path_length, struct GNUNET_PeerIdentity *put_path, @@ -122,10 +125,13 @@ GDS_NEIGHBOURS_handle_reply (const GNUNET_PeerIdentity *target, /** * Initialize neighbours subsystem. + * + * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -void +int GDS_NEIGHBOURS_init (void); + /** * Shutdown neighbours subsystem. */ diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c index 0715465f56..a6e20fb57c 100644 --- a/src/dht/gnunet-service-dht_nse.c +++ b/src/dht/gnunet-service-dht_nse.c @@ -23,6 +23,8 @@ * @brief GNUnet DHT integration with NSE * @author Christian Grothoff */ +#include "platform.h" +#include "gnunet_nse_service.h" #include "gnunet-service-dht.h" #include "gnunet-service-dht_nse.h" diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h index 3dbae1ee73..6b2246f314 100644 --- a/src/dht/gnunet-service-dht_routing.h +++ b/src/dht/gnunet-service-dht_routing.h @@ -26,6 +26,9 @@ #ifndef GNUNET_SERVICE_DHT_ROUTING_H #define GNUNET_SERVICE_DHT_ROUTING_H +#include "gnunet_util_lib.h" +#include "gnunet_block_lib.h" + /** * Handle a reply (route to origin). Only forwards the reply back to @@ -45,8 +48,8 @@ * @param data_size number of bytes in data */ void -GDS_ROUTING_process (uint32_t type, - GNUNET_TIME_Absolute expiration_time, +GDS_ROUTING_process (enum GNUNET_BLOCK_Type type, + struct GNUNET_TIME_Absolute expiration_time, const GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, @@ -68,8 +71,8 @@ GDS_ROUTING_process (uint32_t type, * @param reply_bf_mutator mutator for reply_bf */ void -GDS_ROUTING_add (const GNUNET_PeerIdentity *sender, - uint32_t type, +GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, + enum GNUNET_BLOCK_Type type, const GNUNET_HashCode *key, const void *xquery, size_t xquery_size, |