GNUnet DHT routing code. More...
#include "gnunet_util_lib.h"
#include "gnunet_block_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_dhtu_plugin.h"
#include "gnunet-service-dht_datacache.h"
Go to the source code of this file.
Functions | |
struct PeerInfo * | GDS_NEIGHBOURS_lookup_peer (const struct GNUNET_PeerIdentity *target) |
Lookup peer by peer's identity. More... | |
enum GNUNET_GenericReturnValue | GDS_NEIGHBOURS_handle_put (const struct GNUNET_DATACACHE_Block *bd, uint16_t desired_replication_level, uint16_t hop_count, struct GNUNET_CONTAINER_BloomFilter *bf) |
Perform a PUT operation. More... | |
enum GNUNET_GenericReturnValue | GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint16_t desired_replication_level, uint16_t hop_count, const struct GNUNET_HashCode *key, const void *xquery, size_t xquery_size, struct GNUNET_BLOCK_Group *bg, struct GNUNET_CONTAINER_BloomFilter *peer_bf) |
Perform a GET operation. More... | |
bool | GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, const struct GNUNET_DATACACHE_Block *bd, const struct GNUNET_HashCode *query_hash, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *get_path) |
Handle a reply (route to origin). More... | |
enum GNUNET_GenericReturnValue | GDS_am_closest_peer (const struct GNUNET_HashCode *key, const struct GNUNET_CONTAINER_BloomFilter *bloom) |
Check whether my identity is closer than any known peers. More... | |
void | GDS_try_connect (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri) |
Callback function used to extract URIs from a builder. More... | |
void | GDS_u_connect (void *cls, struct GNUNET_DHTU_Target *target, const struct GNUNET_PeerIdentity *pid, void **ctx) |
Function to call when we connect to a peer and can henceforth transmit to that peer. More... | |
void | GDS_u_disconnect (void *ctx) |
Function to call when we disconnected from a peer and can henceforth cannot transmit to that peer anymore. More... | |
void | GDS_u_receive (void *cls, void **tctx, void **sctx, const void *message, size_t message_size) |
Function to call when we receive a message. More... | |
void | GDS_NEIGHBOURS_broadcast (const struct GNUNET_MessageHeader *msg) |
Send msg to all peers in our buckets. More... | |
enum GNUNET_GenericReturnValue | GDS_NEIGHBOURS_init (void) |
Initialize neighbours subsystem. More... | |
void | GDS_NEIGHBOURS_done (void) |
Shutdown neighbours subsystem. More... | |
struct GNUNET_PeerIdentity * | GDS_NEIGHBOURS_get_id (void) |
Get the ID of the local node. More... | |
GNUnet DHT routing code.
Definition in file gnunet-service-dht_neighbours.h.
struct PeerInfo * GDS_NEIGHBOURS_lookup_peer | ( | const struct GNUNET_PeerIdentity * | target | ) |
Lookup peer by peer's identity.
target | peer to look up |
Definition at line 1446 of file gnunet-service-dht_neighbours.c.
References all_connected_peers, and GNUNET_CONTAINER_multipeermap_get().
Referenced by process().
enum GNUNET_GenericReturnValue GDS_NEIGHBOURS_handle_put | ( | const struct GNUNET_DATACACHE_Block * | bd, |
uint16_t | desired_replication_level, | ||
uint16_t | hop_count, | ||
struct GNUNET_CONTAINER_BloomFilter * | bf | ||
) |
Perform a PUT operation.
Forwards the given request to other peers. Does not store the data locally. Does not give the data to local clients. May do nothing if this is the only peer in the network (or if we are the closest peer in the network).
bd | data about the block |
desired_replication_level | desired replication level |
hop_count | how many hops has this message traversed so far |
bf | Bloom filter of peers this PUT has already traversed |
Definition at line 1220 of file gnunet-service-dht_neighbours.c.
References GNUNET_DATACACHE_Block::data, GNUNET_DATACACHE_Block::data_size, PeerPutMessage::desired_replication_level, do_send(), GNUNET_DATACACHE_Block::expiration_time, GDS_helper_make_put_message(), GDS_helper_put_message_get_size(), GDS_my_identity, GDS_my_identity_hash, GDS_my_private_key, GDS_stats, get_target_peers(), GNUNET_ALIGN, GNUNET_assert, GNUNET_CONTAINER_bloomfilter_add(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_DHT_RO_TRUNCATED, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), PeerPutMessage::header, hello_check(), PeerPutMessage::hop_count, PeerInfo::id, GNUNET_DATACACHE_Block::key, PeerInfo::phash, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, PeerPutMessage::put_path_length, ret, GNUNET_DATACACHE_Block::ro, GNUNET_DATACACHE_Block::trunc_peer, and GNUNET_DATACACHE_Block::type.
Referenced by handle_dht_local_put(), and handle_dht_p2p_put().
enum GNUNET_GenericReturnValue GDS_NEIGHBOURS_handle_get | ( | enum GNUNET_BLOCK_Type | type, |
enum GNUNET_DHT_RouteOption | options, | ||
uint16_t | desired_replication_level, | ||
uint16_t | hop_count, | ||
const struct GNUNET_HashCode * | key, | ||
const void * | xquery, | ||
size_t | xquery_size, | ||
struct GNUNET_BLOCK_Group * | bg, | ||
struct GNUNET_CONTAINER_BloomFilter * | peer_bf | ||
) |
Perform a GET operation.
Forwards the given request to other peers. Does not lookup the key locally. May do nothing if this is the only peer in the network (or if we are the closest peer in the network).
type | type of the block |
options | routing options |
desired_replication_level | desired replication count |
hop_count | how many hops did this request traverse so far? |
key | key for the content |
xquery | extended query |
xquery_size | number of bytes in xquery |
bg | block group to filter replies |
peer_bf | filter for peers not to select (again, updated) |
Definition at line 1331 of file gnunet-service-dht_neighbours.c.
References PeerGetMessage::bloomfilter, PeerGetMessage::desired_replication_level, DHT_BLOOM_SIZE, do_send(), GDS_my_identity, GDS_my_identity_hash, GDS_stats, get_target_peers(), GNUNET_ALIGN, GNUNET_assert, GNUNET_BLOCK_group_serialize(), GNUNET_break, GNUNET_CONTAINER_bloomfilter_add(), GNUNET_CONTAINER_bloomfilter_get_raw_data(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_P2P_GET, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), PeerGetMessage::header, PeerGetMessage::hop_count, PeerInfo::id, key, PeerGetMessage::key, options, PeerGetMessage::options, PeerInfo::phash, PeerGetMessage::result_filter_size, GNUNET_MessageHeader::size, type, GNUNET_MessageHeader::type, and PeerGetMessage::type.
Referenced by handle_dht_p2p_get(), send_find_peer_message(), and transmit_request().
bool GDS_NEIGHBOURS_handle_reply | ( | struct PeerInfo * | pi, |
const struct GNUNET_DATACACHE_Block * | bd, | ||
const struct GNUNET_HashCode * | query_hash, | ||
unsigned int | get_path_length, | ||
const struct GNUNET_DHT_PathElement * | get_path | ||
) |
Handle a reply (route to origin).
Only forwards the reply back to other peers waiting for it. Does not do local caching or forwarding to local clients.
pi | neighbour that should receive the block |
bd | details about the reply |
query_hash | query that was used for the request |
get_path_length | number of entries in put_path |
get_path | peers this reply has traversed so far (if tracked) |
Definition at line 1454 of file gnunet-service-dht_neighbours.c.
References data, GNUNET_DATACACHE_Block::data, data_size, GNUNET_DATACACHE_Block::data_size, do_send(), GNUNET_DATACACHE_Block::expiration_time, PeerResultMessage::expiration_time, GDS_helper_sign_path(), GDS_my_identity, GDS_my_private_key, GDS_stats, PeerResultMessage::get_path_length, GNUNET_ALIGN, GNUNET_assert, GNUNET_B2S, GNUNET_break, GNUNET_break_op, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_DHT_RO_TRUNCATED, GNUNET_DHT_verify_path(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), PeerResultMessage::header, PeerInfo::id, PeerResultMessage::key, PeerResultMessage::options, GNUNET_DHT_PathElement::pred, GNUNET_DATACACHE_Block::put_path, GNUNET_DATACACHE_Block::put_path_length, PeerResultMessage::put_path_length, PeerResultMessage::reserved, GNUNET_DATACACHE_Block::ro, GNUNET_DHT_PathElement::sig, GNUNET_MessageHeader::size, GNUNET_DATACACHE_Block::trunc_peer, GNUNET_MessageHeader::type, GNUNET_DATACACHE_Block::type, and PeerResultMessage::type.
Referenced by handle_find_local_hello(), handle_find_my_hello(), handle_local_result(), and process().
enum GNUNET_GenericReturnValue GDS_am_closest_peer | ( | const struct GNUNET_HashCode * | key, |
const struct GNUNET_CONTAINER_BloomFilter * | bloom | ||
) |
Check whether my identity is closer than any known peers.
If a non-null bloomfilter is given, check if this is the closest peer that hasn't already been routed to.
key | hash code to check closeness to |
bloom | bloomfilter, exclude these entries from the decision |
Definition at line 853 of file gnunet-service-dht_neighbours.c.
References bucket_size, closest_bucket, delta, find_bucket(), GDS_my_identity_hash, GNUNET_assert, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_CRYPTO_hash_xorcmp(), GNUNET_memcmp, GNUNET_NO, GNUNET_YES, PeerBucket::head, k_buckets, key, and PeerInfo::next.
Referenced by handle_dht_local_put(), handle_dht_p2p_get(), and handle_dht_p2p_put().
void GDS_try_connect | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | pid, | ||
const char * | uri | ||
) |
Callback function used to extract URIs from a builder.
Called when we should consider connecting to a peer.
cls | closure |
pid | pointing to a struct GNUNET_PeerIdentity * |
uri | one of the URIs |
Called when we should consider connecting to a peer.
cls | closure pointing to a struct GNUNET_PeerIdentity * |
uri | one of the URIs |
Definition at line 2665 of file gnunet-service-dht_neighbours.c.
References bucket_size, find_bucket(), GDS_my_identity, GDS_u_try_connect(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_memcmp, PeerBucket::head, k_buckets, MAX_BUCKETS, PeerInfo::next, PeerBucket::peers_size, pid, and uri.
Referenced by handle_dht_local_hello_offer(), and hello_check().
void GDS_u_connect | ( | void * | cls, |
struct GNUNET_DHTU_Target * | target, | ||
const struct GNUNET_PeerIdentity * | pid, | ||
void ** | ctx | ||
) |
Function to call when we connect to a peer and can henceforth transmit to that peer.
cls | the closure, must be a struct GDS_Underlay | |
target | handle to the target, pointer will remain valid until disconnect_cb is called | |
pid | peer identity, pointer will remain valid until disconnect_cb is called | |
[out] | ctx | storage space for DHT to use in association with this target |
Definition at line 643 of file gnunet-service-dht_neighbours.c.
References all_connected_peers, bucket_size, closest_bucket, ctx, disable_try_connect, find_bucket(), find_peer_task, GDS_my_identity, GDS_stats, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MAX, GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_YES, PeerBucket::head, PeerInfo::id, k_buckets, MAX_BUCKETS, newly_found_peers, PeerInfo::peer_bucket, PeerBucket::peers_size, PeerInfo::phash, Target::pi, pid, send_find_peer_message(), t, PeerInfo::t_head, PeerInfo::t_tail, PeerBucket::tail, u, and update_hold().
Referenced by load_underlay().
void GDS_u_disconnect | ( | void * | ctx | ) |
Function to call when we disconnected from a peer and can henceforth cannot transmit to that peer anymore.
[in] | ctx | storage space used by the DHT in association with this target |
Definition at line 721 of file gnunet-service-dht_neighbours.c.
References all_connected_peers, bucket_size, closest_bucket, ctx, disable_try_connect, find_peer_task, GDS_stats, GDS_u_drop(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, PeerBucket::head, PeerInfo::hello, PeerInfo::id, k_buckets, PeerInfo::peer_bucket, PeerBucket::peers_size, t, PeerInfo::t_head, PeerInfo::t_tail, PeerBucket::tail, and update_hold().
Referenced by load_underlay().
void GDS_u_receive | ( | void * | cls, |
void ** | tctx, | ||
void ** | sctx, | ||
const void * | message, | ||
size_t | message_size | ||
) |
Function to call when we receive a message.
cls | the closure | |
[in,out] | tctx | ctx of target address where we received the message from |
[in,out] | sctx | ctx of our own source address at which we received the message |
message | the message we received | |
message_size | number of bytes in message |
Definition at line 2596 of file gnunet-service-dht_neighbours.c.
References GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_DHT_P2P_GET, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_MESSAGE_TYPE_DHT_P2P_PUT, GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT, GNUNET_MQ_handle_message(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_OK, mh, and t.
Referenced by load_underlay().
void GDS_NEIGHBOURS_broadcast | ( | const struct GNUNET_MessageHeader * | msg | ) |
Send msg to all peers in our buckets.
msg | message to broadcast |
Definition at line 2721 of file gnunet-service-dht_neighbours.c.
References bucket_size, closest_bucket, do_send(), PeerBucket::head, k_buckets, msg, and PeerInfo::next.
Referenced by broadcast_hello().
enum GNUNET_GenericReturnValue GDS_NEIGHBOURS_init | ( | void | ) |
Initialize neighbours subsystem.
Definition at line 2743 of file gnunet-service-dht_neighbours.c.
References all_connected_peers, bucket_size, cache_results, disable_try_connect, GDS_cfg, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_OK, GNUNET_YES, and consensus-simulation::int.
Referenced by run().
void GDS_NEIGHBOURS_done | ( | void | ) |
Shutdown neighbours subsystem.
Definition at line 2769 of file gnunet-service-dht_neighbours.c.
References all_connected_peers, find_peer_task, GNUNET_assert, GNUNET_CONTAINER_multipeermap_destroy(), and GNUNET_CONTAINER_multipeermap_size().
Referenced by shutdown_task().
struct GNUNET_PeerIdentity * GDS_NEIGHBOURS_get_id | ( | void | ) |
Get the ID of the local node.
Definition at line 2782 of file gnunet-service-dht_neighbours.c.
References GDS_my_identity.