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

GNUnet DHT globals. More...

#include "gnunet-service-dht_datacache.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_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *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, unsigned int path_length, const struct GNUNET_DHT_PathElement *path, 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 GDS_DATACACHE_BlockData *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 (enum GNUNET_DHT_RouteOption options, const struct GDS_DATACACHE_BlockData *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...
 

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_MessageHeaderGDS_my_hello
 Our HELLO. 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 34 of file gnunet-service-dht.h.

Function Documentation

◆ GDS_CLIENTS_handle_reply()

void GDS_CLIENTS_handle_reply ( const struct GDS_DATACACHE_BlockData 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
get_path_lengthnumber of entries in get_path
get_pathpath the reply has taken

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

1028 {
1029  struct ForwardReplyContext frc;
1030  size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage)
1031  + bd->data_size
1033  * sizeof(struct GNUNET_DHT_PathElement);
1034 
1035  if (msize >= GNUNET_MAX_MESSAGE_SIZE)
1036  {
1037  GNUNET_break (0);
1038  return;
1039  }
1040  frc.bd = bd;
1041  frc.get_path = get_path;
1042  frc.get_path_length = get_path_length;
1044  "Forwarding reply for query hash %s to client\n",
1045  GNUNET_h2s (query_hash));
1046  if (0 ==
1048  query_hash,
1049  &forward_reply,
1050  &frc))
1051  {
1053  "No matching client for reply for query %s\n",
1054  GNUNET_h2s (query_hash));
1056  "# REPLIES ignored for CLIENTS (no match)",
1057  1,
1058  GNUNET_NO);
1059  }
1060 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
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,...)
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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.
#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()
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:159
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:165
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...

References ForwardReplyContext::bd, data_size, forward_map, forward_reply(), GDS_stats, ForwardReplyContext::get_path, GNUNET_DHT_ClientResultMessage::get_path_length, ForwardReplyContext::get_path_length, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, and GNUNET_DHT_ClientResultMessage::put_path_length.

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,
unsigned int  path_length,
const struct GNUNET_DHT_PathElement path,
const struct GNUNET_HashCode key 
)

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

Parameters
optionsOptions, for instance RecordRoute, DemultiplexEverywhere.
typeThe type of data in the request.
hop_countHop count so far.
path_lengthnumber of entries in path (or 0 if not recorded).
pathpeers on the GET path (or NULL if not recorded).
desired_replication_levelDesired replication level.
keyKey of the requested data.

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.
path_lengthnumber of entries in path (or 0 if not recorded).
pathpeers on the GET path (or NULL if not recorded).
desired_replication_levelDesired replication level.
keyKey of the requested data.

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

1268 {
1269  struct GetActionContext gac = {
1270  .options = options,
1271  .type = type,
1272  .hop_count = hop_count,
1273  .desired_replication_level = desired_replication_level,
1274  .get_path_length = path_length,
1275  .get_path = path,
1276  .key = key
1277  };
1278 
1280  key,
1281  &get_action,
1282  &gac);
1283 }
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 GDS_DATACACHE_BlockData 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 1344 of file gnunet-service-dht_clients.c.

1347 {
1348  struct ResponseActionContext rac = {
1349  .bd = bd,
1350  .get_path = get_path,
1351  .get_path_length = get_path_length
1352  };
1353 
1355  &bd->key,
1356  &response_action,
1357  &rac);
1358 }
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 GDS_DATACACHE_BlockData * bd
const struct GNUNET_DHT_PathElement * get_path

References ResponseActionContext::bd, for_matching_monitors(), ResponseActionContext::get_path, ResponseActionContext::get_path_length, GDS_DATACACHE_BlockData::key, response_action(), and GDS_DATACACHE_BlockData::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 ( enum GNUNET_DHT_RouteOption  options,
const struct GDS_DATACACHE_BlockData 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
optionsrouting options to apply
bddetails about the block
hop_countHop count so far.
desired_replication_levelDesired replication level.

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

1421 {
1422  struct PutActionContext put_ctx = {
1423  .bd = bd,
1424  .hop_count = hop_count,
1425  .desired_replication_level = desired_replication_level,
1426  .options = options
1427  };
1428 
1430  &bd->key,
1431  &put_action,
1432  &put_ctx);
1433 }
static void put_action(void *cls, struct ClientMonitorRecord *m)
Function called on monitors that match a PUT.
Closure for put_action().
const struct GDS_DATACACHE_BlockData * bd

References PutActionContext::bd, PutActionContext::desired_replication_level, for_matching_monitors(), PutActionContext::hop_count, GDS_DATACACHE_BlockData::key, options, put_action(), and GDS_DATACACHE_BlockData::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:

Variable Documentation

◆ GDS_cfg

const struct GNUNET_CONFIGURATION_Handle* GDS_cfg
extern

Configuration we use.

Configuration we use.

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

Referenced by free_hello(), GDS_DATACACHE_init(), GDS_NSE_init(), run(), and try_connect().

◆ GDS_service

struct GNUNET_SERVICE_Handle* GDS_service
extern

Handle for the service.

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

Referenced by check_dht_p2p_put(), and 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_MessageHeader* GDS_my_hello
extern

Our HELLO.

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

Referenced by handle_find_peer(), process_hello(), and shutdown_task().