GNUnet  0.17.6
Macros | Functions | Variables
gnunet-service-dht.h File Reference

GNUnet DHT globals. More...

#include "gnunet-service-dht_datacache.h"
#include "gnunet-service-dht_neighbours.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
Include dependency graph for gnunet-service-dht.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEBUG_DHT   GNUNET_EXTRA_LOGGING
 

Functions

void GDS_u_try_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
 Ask all underlays to connect to peer pid at address. More...
 
void GDS_u_send (struct GDS_Underlay *u, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
 Send message to some other participant over the network. More...
 
void GDS_u_drop (struct GDS_Underlay *u, struct GNUNET_DHTU_PreferenceHandle *ph)
 Drop a hold ph from underlay u. More...
 
struct GNUNET_DHTU_PreferenceHandleGDS_u_hold (struct GDS_Underlay *u, struct GNUNET_DHTU_Target *target)
 Create a hold on target at underlay u. More...
 
bool GDS_CLIENTS_handle_reply (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 we've received from another peer. More...
 
void GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, const struct GNUNET_HashCode *key)
 Check if some client is monitoring GET messages and notify them in that case. More...
 
void GDS_CLIENTS_process_get_resp (const struct GNUNET_DATACACHE_Block *bd, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length)
 Check if some client is monitoring GET RESP messages and notify them in that case. More...
 
void GDS_CLIENTS_process_put (const struct GNUNET_DATACACHE_Block *bd, uint32_t hop_count, uint32_t desired_replication_level)
 Check if some client is monitoring PUT messages and notify them in that case. More...
 
double GDS_NSE_get (void)
 Return the current NSE. More...
 

Variables

const struct GNUNET_CONFIGURATION_HandleGDS_cfg
 Configuration we use. More...
 
struct GNUNET_SERVICE_HandleGDS_service
 Handle for the service. More...
 
struct GNUNET_BLOCK_ContextGDS_block_context
 Our handle to the BLOCK library. More...
 
struct GNUNET_STATISTICS_HandleGDS_stats
 Handle for the statistics service. More...
 
struct GNUNET_HELLO_BuilderGDS_my_hello
 Our HELLO builder. More...
 
struct GNUNET_PeerIdentity GDS_my_identity
 Identity of this peer. More...
 
struct GNUNET_HashCode GDS_my_identity_hash
 Hash of the identity of this peer. More...
 
struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key
 Our private key. More...
 

Detailed Description

GNUnet DHT globals.

Author
Christian Grothoff

Definition in file gnunet-service-dht.h.

Macro Definition Documentation

◆ DEBUG_DHT

#define DEBUG_DHT   GNUNET_EXTRA_LOGGING

Definition at line 35 of file gnunet-service-dht.h.

Function Documentation

◆ GDS_u_try_connect()

void GDS_u_try_connect ( const struct GNUNET_PeerIdentity pid,
const char *  address 
)

Ask all underlays to connect to peer pid at address.

Parameters
pididentity of the peer we would connect to
addressan address of pid

Definition at line 316 of file gnunet-service-dht.c.

318 {
319  for (struct GDS_Underlay *u = u_head;
320  NULL != u;
321  u = u->next)
322  u->dhtu->try_connect (u->dhtu->cls,
323  pid,
324  address);
325 }
static char * address
GNS address for this phone.
static struct GDS_Underlay * u_head
Handles for the DHT underlays.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Information we keep per underlay.
struct GDS_Underlay * next
Kept in a DLL.

References address, GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, GDS_Underlay::next, pid, GNUNET_DHTU_PluginFunctions::try_connect, MyAddress::u, and u_head.

Referenced by GDS_try_connect().

Here is the caller graph for this function:

◆ GDS_u_send()

void GDS_u_send ( struct GDS_Underlay u,
struct GNUNET_DHTU_Target target,
const void *  msg,
size_t  msg_size,
GNUNET_SCHEDULER_TaskCallback  finished_cb,
void *  finished_cb_cls 
)

Send message to some other participant over the network.

Note that sending is not guaranteeing that the other peer actually received the message. For any given target, the DHT must wait for the finished_cb to be called before calling send() again.

Parameters
uunderlay to use for transmission
targetreceiver identification
msgmessage
msg_sizenumber of bytes in msg
finished_cbfunction called once transmission is done (not called if target disconnects, then only the disconnect_cb is called).
finished_cb_clsclosure for finished_cb

Definition at line 329 of file gnunet-service-dht.c.

335 {
336  u->dhtu->send (u->dhtu->cls,
337  target,
338  msg,
339  msg_size,
340  finished_cb,
341  finished_cb_cls);
342 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_DHTU_PluginFunctions * dhtu
Underlay API handle.
void * cls
Closure to pass to all plugin functions.
void(* send)(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.

References GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, msg, GNUNET_DHTU_PluginFunctions::send, and MyAddress::u.

Referenced by do_send().

Here is the caller graph for this function:

◆ GDS_u_drop()

void GDS_u_drop ( struct GDS_Underlay u,
struct GNUNET_DHTU_PreferenceHandle ph 
)

Drop a hold ph from underlay u.

Parameters
uthe underlay controlling the hold
phthe preference handle

Definition at line 346 of file gnunet-service-dht.c.

348 {
349  u->dhtu->drop (ph);
350 }
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no longer request underlay to keep the connection alive.

References GDS_Underlay::dhtu, GNUNET_DHTU_PluginFunctions::drop, ph, and MyAddress::u.

Referenced by GDS_u_disconnect().

Here is the caller graph for this function:

◆ GDS_u_hold()

struct GNUNET_DHTU_PreferenceHandle* GDS_u_hold ( struct GDS_Underlay u,
struct GNUNET_DHTU_Target target 
)

Create a hold on target at underlay u.

Parameters
uthe underlay controlling the target
targetthe peer to hold the connection to

Definition at line 354 of file gnunet-service-dht.c.

356 {
357  return u->dhtu->hold (u->dhtu->cls,
358  target);
359 }
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.

References GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, GNUNET_DHTU_PluginFunctions::hold, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by update_hold().

Here is the caller graph for this function:

◆ GDS_CLIENTS_handle_reply()

bool GDS_CLIENTS_handle_reply ( 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 we've received from another peer.

If the reply matches any of our pending queries, forward it to the respective client(s).

Parameters
bdblock details
query_hashhash of the original query, might not match key in bd
trunc_peerpeer at which the path was truncated, or NULL if path starts at the origin
get_path_lengthnumber of entries in get_path
get_pathpath the reply has taken
Returns
true on success, false on failures

Definition at line 1067 of file gnunet-service-dht_clients.c.

1071 {
1072  struct ForwardReplyContext frc;
1073  size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage)
1074  + bd->data_size
1076  * sizeof(struct GNUNET_DHT_PathElement);
1077  bool truncated = (0 != (bd->ro & GNUNET_DHT_RO_TRUNCATED));
1078 
1079  if (msize >= GNUNET_MAX_MESSAGE_SIZE)
1080  {
1081  GNUNET_break (0);
1082  return false;
1083  }
1084 #if SANITY_CHECKS > 1
1085  if (0 !=
1087  bd->data_size,
1088  bd->expiration_time,
1089  truncated
1090  ? &bd->trunc_peer
1091  : NULL,
1092  bd->put_path,
1093  bd->put_path_length,
1094  get_path,
1095  get_path_length,
1096  &GDS_my_identity))
1097  {
1098  GNUNET_break (0);
1099  return false;
1100  }
1101 #endif
1102  frc.bd = bd;
1103  frc.get_path = get_path;
1104  frc.get_path_length = get_path_length;
1106  "Forwarding reply for query hash %s with GPL %u and PPL %u to client\n",
1107  GNUNET_h2s (query_hash),
1108  get_path_length,
1109  bd->put_path_length);
1110  if (0 ==
1112  query_hash,
1113  &forward_reply,
1114  &frc))
1115  {
1117  "No matching client for reply for query %s\n",
1118  GNUNET_h2s (query_hash));
1120  "# REPLIES ignored for CLIENTS (no match)",
1121  1,
1122  GNUNET_NO);
1123  }
1124  return true;
1125 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_PeerIdentity GDS_my_identity
Identity of this peer.
static enum GNUNET_GenericReturnValue forward_reply(void *cls, const struct GNUNET_HashCode *query_hash, void *value)
Iterator over hash map entries that send a given reply to each of the matching clients.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries.
#define LOG(kind,...)
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
unsigned int GNUNET_DHT_verify_path(const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *bpid, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me)
Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the las...
Definition: dht_api.c:1353
@ GNUNET_DHT_RO_TRUNCATED
Flag set if the path was truncated.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_NO
Definition: gnunet_common.h:98
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Closure for forward_reply()
const struct GNUNET_DHT_PathElement * put_path
PUT path taken by the block, array of peer identities.
const void * data
Actual block data.
enum GNUNET_DHT_RouteOption ro
Options for routing for the block.
struct GNUNET_PeerIdentity trunc_peer
If the path was truncated, this is the peer ID at which the path was truncated.
size_t data_size
Number of bytes in data.
unsigned int put_path_length
Length of the put_path array.
struct GNUNET_TIME_Absolute expiration_time
When does the block expire?
Reply to a GET send from the service to a client.
Definition: dht.h:144
uint32_t put_path_length
Number of peers recorded in the outgoing path from source to the storgage location of this message.
Definition: dht.h:169
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:175
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...

References ForwardReplyContext::bd, GNUNET_DATACACHE_Block::data, data_size, GNUNET_DATACACHE_Block::data_size, GNUNET_DATACACHE_Block::expiration_time, forward_map, forward_reply(), GDS_my_identity, GDS_stats, ForwardReplyContext::get_path, GNUNET_DHT_ClientResultMessage::get_path_length, ForwardReplyContext::get_path_length, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_DHT_RO_TRUNCATED, GNUNET_DHT_verify_path(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, GNUNET_DATACACHE_Block::put_path, GNUNET_DHT_ClientResultMessage::put_path_length, GNUNET_DATACACHE_Block::put_path_length, GNUNET_DATACACHE_Block::ro, and GNUNET_DATACACHE_Block::trunc_peer.

Referenced by check_dht_local_get(), check_dht_p2p_result(), handle_dht_local_put(), and handle_dht_p2p_put().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_process_get()

void GDS_CLIENTS_process_get ( enum GNUNET_DHT_RouteOption  options,
enum GNUNET_BLOCK_Type  type,
uint32_t  hop_count,
uint32_t  desired_replication_level,
const struct GNUNET_HashCode key 
)

Check if some client is monitoring GET messages and notify them in that case.

If tracked, path should include the local peer.

Parameters
optionsOptions, for instance RecordRoute, DemultiplexEverywhere.
typeThe type of data in the request.
hop_countHop count so far.
desired_replication_levelDesired replication level.
keyKey of the requested data.

Definition at line 1402 of file gnunet-service-dht_clients.c.

1407 {
1408  struct GetActionContext gac = {
1409  .options = options,
1410  .type = type,
1411  .hop_count = hop_count,
1412  .desired_replication_level = desired_replication_level,
1413  .key = key
1414  };
1415 
1417  key,
1418  &get_action,
1419  &gac);
1420 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_HashCode key
The key used in the DHT.
static void for_matching_monitors(enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, MonitorAction cb, void *cb_cls)
Call cb on all monitors that watch for blocks of type and key key.
static void get_action(void *cls, struct ClientMonitorRecord *m)
Function called on monitors that match a GET.
Closure for get_action();.
enum GNUNET_DHT_RouteOption options
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References GetActionContext::desired_replication_level, for_matching_monitors(), get_action(), GetActionContext::hop_count, key, options, GetActionContext::options, and type.

Referenced by check_dht_local_get_result_seen(), and handle_dht_p2p_get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_process_get_resp()

void GDS_CLIENTS_process_get_resp ( const struct GNUNET_DATACACHE_Block bd,
const struct GNUNET_DHT_PathElement get_path,
unsigned int  get_path_length 
)

Check if some client is monitoring GET RESP messages and notify them in that case.

Parameters
bdblock details
get_pathPeers on GET path (or NULL if not recorded).
get_path_lengthnumber of entries in get_path.

Definition at line 1496 of file gnunet-service-dht_clients.c.

1499 {
1500  struct ResponseActionContext rac = {
1501  .bd = bd,
1502  .get_path = get_path,
1503  .get_path_length = get_path_length
1504  };
1505 
1507  &bd->key,
1508  &response_action,
1509  &rac);
1510 }
static void response_action(void *cls, struct ClientMonitorRecord *m)
Function called on monitors that match a response.
enum GNUNET_BLOCK_Type type
Type of the block.
struct GNUNET_HashCode key
Key of the block.
Closure for response_action().
const struct GNUNET_DHT_PathElement * get_path
const struct GNUNET_DATACACHE_Block * bd

References ResponseActionContext::bd, for_matching_monitors(), ResponseActionContext::get_path, ResponseActionContext::get_path_length, GNUNET_DATACACHE_Block::key, response_action(), and GNUNET_DATACACHE_Block::type.

Referenced by check_dht_p2p_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_process_put()

void GDS_CLIENTS_process_put ( const struct GNUNET_DATACACHE_Block bd,
uint32_t  hop_count,
uint32_t  desired_replication_level 
)

Check if some client is monitoring PUT messages and notify them in that case.

The path should include our own peer ID (if recorded).

Parameters
bddetails about the block
hop_countHop count so far.
desired_replication_levelDesired replication level.

Definition at line 1584 of file gnunet-service-dht_clients.c.

1587 {
1588  struct PutActionContext put_ctx = {
1589  .bd = bd,
1590  .hop_count = hop_count,
1591  .desired_replication_level = desired_replication_level
1592  };
1593 
1595  &bd->key,
1596  &put_action,
1597  &put_ctx);
1598 }
static void put_action(void *cls, struct ClientMonitorRecord *m)
Function called on monitors that match a PUT.
Closure for put_action().
const struct GNUNET_DATACACHE_Block * bd

References PutActionContext::bd, PutActionContext::desired_replication_level, for_matching_monitors(), PutActionContext::hop_count, GNUNET_DATACACHE_Block::key, put_action(), and GNUNET_DATACACHE_Block::type.

Referenced by handle_dht_local_put(), and handle_dht_p2p_put().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_NSE_get()

double GDS_NSE_get ( void  )

Return the current NSE.

Returns
the current NSE as a logarithm

Definition at line 214 of file gnunet-service-dht.c.

215 {
217 }
static double log_of_network_size_estimate
log of the current network size estimate, used as the point where we switch between random and determ...

References log_of_network_size_estimate.

Referenced by GDS_am_closest_peer(), handle_find_local_hello(), and select_peer().

Here is the caller graph for this function:

Variable Documentation

◆ GDS_cfg

const struct GNUNET_CONFIGURATION_Handle* GDS_cfg
extern

Configuration we use.

Configuration we use.

Definition at line 240 of file gnunet-service-dht_clients.c.

Referenced by GDS_DATACACHE_init(), load_underlay(), and run().

◆ GDS_service

struct GNUNET_SERVICE_Handle* GDS_service
extern

Handle for the service.

Definition at line 235 of file gnunet-service-dht_clients.c.

Referenced by run().

◆ GDS_block_context

struct GNUNET_BLOCK_Context* GDS_block_context
extern

◆ GDS_stats

struct GNUNET_STATISTICS_Handle* GDS_stats
extern

◆ GDS_my_hello

struct GNUNET_HELLO_Builder* GDS_my_hello
extern

Our HELLO builder.

Our HELLO builder.

Definition at line 124 of file gnunet-service-dht.c.

Referenced by broadcast_hello(), check_dht_local_hello_offer(), handle_find_my_hello(), run(), shutdown_task(), u_address_add(), and u_address_del().

◆ GDS_my_identity

struct GNUNET_PeerIdentity GDS_my_identity
extern

◆ GDS_my_identity_hash

struct GNUNET_HashCode GDS_my_identity_hash
extern

Hash of the identity of this peer.

Definition at line 124 of file gnunet-service-dht.c.

Referenced by add_known_to_bloom(), datacache_get_iterator(), handle_find_my_hello(), run(), select_peer(), and send_find_peer_message().

◆ GDS_my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key
extern

Our private key.

Definition at line 124 of file gnunet-service-dht.c.

Referenced by broadcast_hello(), check_dht_local_hello_offer(), handle_find_my_hello(), run(), and sign_path().