GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-dht_clients.c File Reference

GNUnet DHT service's client management code. More...

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

Go to the source code of this file.

Data Structures

struct  ClientQueryRecord
 Entry in the local forwarding map for a client's GET request. More...
 
struct  ClientMonitorRecord
 Struct containing paremeters of monitoring requests. More...
 
struct  ClientHandle
 Struct containing information about a client, handle to connect to it, and any pending messages that need to be sent to it. More...
 
struct  FindByUniqueIdContext
 Closure for find_by_unique_id(). More...
 
struct  RemoveByUniqueIdContext
 Closure for remove_by_unique_id(). More...
 
struct  ForwardReplyContext
 Closure for forward_reply() More...
 

Macros

#define LOG_TRAFFIC(kind, ...)   GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
 Should routing details be logged to stderr (for debugging)? More...
 
#define LOG(kind, ...)   GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
 
#define GDS_DHT_SERVICE_INIT(name, run)
 Define "main" method using service macro. More...
 

Functions

static void remove_client_record (struct ClientQueryRecord *record)
 Free data structures associated with the given query. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Functions with this signature are called whenever a local client is connects to us. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Functions with this signature are called whenever a client is disconnected on the network level. More...
 
static void transmit_request (struct ClientQueryRecord *cqr)
 Route the given request via the DHT. More...
 
static void transmit_next_request_task (void *cls)
 Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for transmission. More...
 
static int check_dht_local_put (void *cls, const struct GNUNET_DHT_ClientPutMessage *dht_msg)
 Check DHT PUT messages from the client. More...
 
static void handle_dht_local_put (void *cls, const struct GNUNET_DHT_ClientPutMessage *dht_msg)
 Handler for PUT messages. More...
 
static int check_dht_local_get (void *cls, const struct GNUNET_DHT_ClientGetMessage *get)
 Check DHT GET messages from the client. More...
 
static void handle_local_result (void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
 Handle a result from local datacache for a GET operation. More...
 
static void handle_dht_local_get (void *cls, const struct GNUNET_DHT_ClientGetMessage *get)
 Handler for DHT GET messages from the client. More...
 
static int find_by_unique_id (void *cls, const struct GNUNET_HashCode *key, void *value)
 Function called for each existing DHT record for the given query. More...
 
static int check_dht_local_get_result_seen (void *cls, const struct GNUNET_DHT_ClientGetResultSeenMessage *seen)
 Check "GET result seen" messages from the client. More...
 
static void handle_dht_local_get_result_seen (void *cls, const struct GNUNET_DHT_ClientGetResultSeenMessage *seen)
 Handler for "GET result seen" messages from the client. More...
 
static int remove_by_unique_id (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterator over hash map entries that frees all entries that match the given client and unique ID. More...
 
static void handle_dht_local_get_stop (void *cls, const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg)
 Handler for any generic DHT stop messages, calls the appropriate handler depending on message type (if processed locally) More...
 
static void handle_dht_local_monitor (void *cls, const struct GNUNET_DHT_MonitorStartStopMessage *msg)
 Handler for monitor start messages. More...
 
static void handle_dht_local_monitor_stop (void *cls, const struct GNUNET_DHT_MonitorStartStopMessage *msg)
 Handler for monitor stop messages. More...
 
static int forward_reply (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterator over hash map entries that send a given reply to each of the matching clients. More...
 
void GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
 Handle a reply we've received from another peer. More...
 
void GDS_CLIENTS_process_get (uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *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 (enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
 Check if some client is monitoring GET RESP messages and notify them in that case. More...
 
void GDS_CLIENTS_process_put (uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
 Check if some client is monitoring PUT messages and notify them in that case. More...
 
static void GDS_CLIENTS_init ()
 Initialize client subsystem. More...
 
static void GDS_CLIENTS_stop ()
 Shutdown client subsystem. More...
 
void __attribute__ ((destructor))
 MINIMIZE heap size (way below 128k) since this process doesn't need much. More...
 

Variables

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_SERVICE_HandleGDS_service
 Handle for the service. More...
 
const struct GNUNET_CONFIGURATION_HandleGDS_cfg
 The configuration the DHT service is running with. More...
 
static struct ClientMonitorRecordmonitor_head
 List of active monitoring requests. More...
 
static struct ClientMonitorRecordmonitor_tail
 List of active monitoring requests. More...
 
static struct GNUNET_CONTAINER_MultiHashMapforward_map
 Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. More...
 
static struct GNUNET_CONTAINER_Heapretry_heap
 Heap with all of our client's request, sorted by retry time (earliest on top). More...
 
static struct GNUNET_SCHEDULER_Taskretry_task
 Task that re-transmits requests (using retry_heap). More...
 

Detailed Description

GNUnet DHT service's client management code.

Author
Christian Grothoff
Nathan Evans

Definition in file gnunet-service-dht_clients.c.

Macro Definition Documentation

◆ LOG_TRAFFIC

#define LOG_TRAFFIC (   kind,
  ... 
)    GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)

Should routing details be logged to stderr (for debugging)?

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

Referenced by forward_reply(), handle_dht_local_get(), and handle_dht_local_put().

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)

◆ GDS_DHT_SERVICE_INIT

#define GDS_DHT_SERVICE_INIT (   name,
  run 
)

Define "main" method using service macro.

Parameters
namename of the service, i.e. "dht" or "xdht"
runname of the initializaton method for the service

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

Referenced by run().

Function Documentation

◆ remove_client_record()

static void remove_client_record ( struct ClientQueryRecord record)
static

Free data structures associated with the given query.

Parameters
recordrecord to remove

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

References ClientQueryRecord::ch, ClientHandle::cqr_head, ClientHandle::cqr_tail, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, ClientQueryRecord::hnode, ClientQueryRecord::key, ClientQueryRecord::seen_replies, and ClientQueryRecord::seen_replies_count.

Referenced by client_disconnect_cb(), forward_reply(), and remove_by_unique_id().

269 {
270  struct ClientHandle *ch = record->ch;
271 
273  ch->cqr_tail,
274  record);
277  &record->key,
278  record));
279  if (NULL != record->hnode)
282  record->seen_replies_count,
283  0);
284  GNUNET_free (record);
285 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct ClientQueryRecord * cqr_tail
Linked list of active queries of this client.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. ...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct ClientQueryRecord * cqr_head
Linked list of active queries of this client.
struct ClientHandle * ch
Client responsible for the request.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_HashCode * seen_replies
Replies we have already seen for this request.
unsigned int seen_replies_count
Number of entries in 'seen_replies'.
#define GNUNET_YES
Definition: gnunet_common.h:80
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
struct GNUNET_HashCode key
The key this request was about.
struct GNUNET_CONTAINER_HeapNode * hnode
Pointer to this nodes heap location in the retry-heap (for fast removal)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Functions with this signature are called whenever a local client is connects to us.

Parameters
clsclosure (NULL for dht)
clientidentification of the client
mqmessage queue for talking to client
Returns
our struct ClientHandle for client

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

References ClientQueryRecord::ch, ClientHandle::client, GNUNET_new, mq, and ClientHandle::mq.

301 {
302  struct ClientHandle *ch;
303 
304  ch = GNUNET_new (struct ClientHandle);
305  ch->client = client;
306  ch->mq = mq;
307  return ch;
308 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_MQ_Handle * mq
The message queue to this client.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Functions with this signature are called whenever a client is disconnected on the network level.

Parameters
clsclosure (NULL for dht)
clientidentification of the client
app_ctxour struct ClientHandle for client

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

References ClientQueryRecord::ch, ClientMonitorRecord::ch, ClientHandle::cqr_head, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_log, ClientMonitorRecord::key, monitor, monitor_head, ClientQueryRecord::next, ClientMonitorRecord::next, and remove_client_record().

323 {
324  struct ClientHandle *ch = app_ctx;
325  struct ClientQueryRecord *cqr;
327 
329  "Local client %p disconnects\n",
330  ch);
331  monitor = monitor_head;
332  while (NULL != monitor)
333  {
334  if (monitor->ch == ch)
335  {
336  struct ClientMonitorRecord *next;
337 
338  next = monitor->next;
339  GNUNET_free_non_null (monitor->key);
341  monitor_tail,
342  monitor);
343  GNUNET_free (monitor);
344  monitor = next;
345  }
346  else
347  {
348  monitor = monitor->next;
349  }
350  }
351  while (NULL != (cqr = ch->cqr_head))
352  remove_client_record (cqr);
353  GNUNET_free (ch);
354 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct ClientHandle * ch
Client to notify of these requests.
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
struct ClientMonitorRecord * next
Next element in DLL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct ClientQueryRecord * cqr_head
Linked list of active queries of this client.
Entry in the local forwarding map for a client's GET request.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static struct ClientMonitorRecord * monitor_tail
List of active monitoring requests.
static void remove_client_record(struct ClientQueryRecord *record)
Free data structures associated with the given query.
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:59
Struct containing paremeters of monitoring requests.
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ transmit_request()

static void transmit_request ( struct ClientQueryRecord cqr)
static

Route the given request via the DHT.

This includes updating the bloom filter and retransmission times, building the P2P message and initiating the routing operation.

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

References DHT_BLOOM_SIZE, GDS_NEIGHBOURS_handle_get(), gettext_noop, GNUNET_BLOCK_group_create(), GNUNET_BLOCK_group_destroy(), GNUNET_BLOCK_group_set_seen(), GNUNET_CONSTANTS_BLOOMFILTER_K, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, ClientQueryRecord::key, LOG, ClientQueryRecord::msg_options, ClientQueryRecord::replication, ClientQueryRecord::retry_frequency, ClientQueryRecord::retry_time, ClientQueryRecord::seen_replies, ClientQueryRecord::seen_replies_count, ClientQueryRecord::type, ClientQueryRecord::xquery, and ClientQueryRecord::xquery_size.

Referenced by transmit_next_request_task().

364 {
365  struct GNUNET_BLOCK_Group *bg;
366  struct GNUNET_CONTAINER_BloomFilter *peer_bf;
367 
369  gettext_noop ("# GET requests from clients injected"),
370  1,
371  GNUNET_NO);
373  cqr->type,
375  UINT32_MAX),
376  NULL,
377  0,
378  "seen-set-size",
379  cqr->seen_replies_count,
380  NULL);
382  cqr->seen_replies,
383  cqr->seen_replies_count);
384  peer_bf
389  "Initiating GET for %s, replication %u, already have %u replies\n",
390  GNUNET_h2s (&cqr->key),
391  cqr->replication,
392  cqr->seen_replies_count);
394  cqr->msg_options,
395  cqr->replication,
396  0 /* hop count */ ,
397  &cqr->key,
398  cqr->xquery,
399  cqr->xquery_size,
400  bg,
401  peer_bf);
404 
405  /* exponential back-off for retries.
406  * max GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD (15 min) */
409 }
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
#define DHT_BLOOM_SIZE
Size of the bloom filter the DHT uses to filter peers.
Definition: dht.h:34
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:245
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_CONSTANTS_BLOOMFILTER_K
K-value that must be used for the bloom filters in 'GET' queries.
enum GNUNET_BLOCK_Type type
The type for the data for the GET request.
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Relative retry_frequency
What's the delay between re-try operations that we currently use for this request?
uint32_t replication
Desired replication level.
uint32_t msg_options
Any message options for this request.
#define LOG(kind,...)
size_t xquery_size
Number of bytes in xquery.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_HashCode * seen_replies
Replies we have already seen for this request.
struct GNUNET_BLOCK_Group * GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size,...)
Create a new block group.
Definition: block.c:290
int GDS_NEIGHBOURS_handle_get(enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint32_t desired_replication_level, uint32_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.
unsigned int seen_replies_count
Number of entries in 'seen_replies'.
Block group data.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
struct GNUNET_HashCode key
The key this request was about.
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associcated with a filter in memory, flush to drive if needed (do not free the space o...
struct GNUNET_TIME_Absolute retry_time
What's the next time we should re-try this request?
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
Definition: block.c:206
const void * xquery
Extended query (see gnunet_block_lib.h), allocated at the end of this struct.
int GNUNET_BLOCK_group_set_seen(struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
Update block group to filter out the given results.
Definition: block.c:410
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit_next_request_task()

static void transmit_next_request_task ( void *  cls)
static

Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for transmission.

Then re-schedules itself (unless the heap is empty).

Parameters
clsunused

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

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_SCHEDULER_add_at(), GNUNET_TIME_absolute_get_remaining(), ClientQueryRecord::hnode, GNUNET_TIME_Relative::rel_value_us, ClientQueryRecord::retry_time, and transmit_request().

Referenced by handle_dht_local_get().

421 {
422  struct ClientQueryRecord *cqr;
424 
425  retry_task = NULL;
426  while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap)))
427  {
428  cqr->hnode = NULL;
430  if (delay.rel_value_us > 0)
431  {
432  cqr->hnode
434  cqr,
435  cqr->retry_time.abs_value_us);
436  retry_task
439  NULL);
440  return;
441  }
442  transmit_request (cqr);
443  cqr->hnode
445  cqr,
446  cqr->retry_time.abs_value_us);
447  }
448 }
uint64_t rel_value_us
The actual value.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
static struct GNUNET_SCHEDULER_Task * retry_task
Task that re-transmits requests (using retry_heap).
uint64_t abs_value_us
The actual value.
static void transmit_next_request_task(void *cls)
Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for tr...
Entry in the local forwarding map for a client's GET request.
static void transmit_request(struct ClientQueryRecord *cqr)
Route the given request via the DHT.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static struct GNUNET_CONTAINER_Heap * retry_heap
Heap with all of our client's request, sorted by retry time (earliest on top).
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1223
struct GNUNET_TIME_Absolute retry_time
What's the next time we should re-try this request?
struct GNUNET_CONTAINER_HeapNode * hnode
Pointer to this nodes heap location in the retry-heap (for fast removal)
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_dht_local_put()

static int check_dht_local_put ( void *  cls,
const struct GNUNET_DHT_ClientPutMessage dht_msg 
)
static

Check DHT PUT messages from the client.

Parameters
clsthe client we received this message from
dht_msgthe actual message received
Returns
GNUNET_OK (always)

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

References GNUNET_OK.

461 {
462  /* always well-formed */
463  return GNUNET_OK;
464 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_dht_local_put()

static void handle_dht_local_put ( void *  cls,
const struct GNUNET_DHT_ClientPutMessage dht_msg 
)
static

Handler for PUT messages.

Parameters
clsthe client we received this message from
dht_msgthe actual message received

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

References ClientQueryRecord::ch, ClientHandle::client, GNUNET_DHT_ClientPutMessage::desired_replication_level, DHT_BLOOM_SIZE, GNUNET_DHT_ClientPutMessage::expiration, GDS_CLIENTS_handle_reply(), GDS_CLIENTS_process_put(), GDS_DATACACHE_handle_put(), GDS_NEIGHBOURS_get_id(), GDS_NEIGHBOURS_handle_put(), gettext_noop, GNUNET_CONSTANTS_BLOOMFILTER_K, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GNUNET_DHT_ClientPutMessage::header, GNUNET_DHT_ClientPutMessage::key, LOG, LOG_TRAFFIC, GNUNET_DHT_ClientPutMessage::options, size, GNUNET_MessageHeader::size, and GNUNET_DHT_ClientPutMessage::type.

476 {
477  struct ClientHandle *ch = cls;
478  struct GNUNET_CONTAINER_BloomFilter *peer_bf;
479  uint16_t size;
480 
481  size = ntohs (dht_msg->header.size);
483  gettext_noop ("# PUT requests received from clients"),
484  1,
485  GNUNET_NO);
487  "CLIENT-PUT %s\n",
488  GNUNET_h2s_full (&dht_msg->key));
489  /* give to local clients */
491  "Handling local PUT of %u-bytes for query %s\n",
492  size - sizeof (struct GNUNET_DHT_ClientPutMessage),
493  GNUNET_h2s (&dht_msg->key));
495  &dht_msg->key,
496  0,
497  NULL,
498  0,
499  NULL,
500  ntohl (dht_msg->type),
501  size - sizeof (struct GNUNET_DHT_ClientPutMessage),
502  &dht_msg[1]);
503  /* store locally */
505  &dht_msg->key,
506  0,
507  NULL,
508  ntohl (dht_msg->type),
509  size - sizeof (struct GNUNET_DHT_ClientPutMessage),
510  &dht_msg[1]);
511  /* route to other peers */
512  peer_bf
516  GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type),
517  ntohl (dht_msg->options),
518  ntohl (dht_msg->desired_replication_level),
520  0 /* hop count */,
521  peer_bf,
522  &dht_msg->key,
523  0,
524  NULL,
525  &dht_msg[1],
526  size - sizeof (struct GNUNET_DHT_ClientPutMessage));
527  GDS_CLIENTS_process_put (ntohl (dht_msg->options),
528  ntohl (dht_msg->type),
529  0,
530  ntohl (dht_msg->desired_replication_level),
531  1,
534  &dht_msg->key,
535  &dht_msg[1],
536  size - sizeof (struct GNUNET_DHT_ClientPutMessage));
539 }
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
struct GNUNET_PeerIdentity * GDS_NEIGHBOURS_get_id()
Get the ID of the local node.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
#define DHT_BLOOM_SIZE
Size of the bloom filter the DHT uses to filter peers.
Definition: dht.h:34
#define GNUNET_CONSTANTS_BLOOMFILTER_K
K-value that must be used for the bloom filters in 'GET' queries.
Message to insert data into the DHT, sent from clients to DHT service.
Definition: dht.h:194
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GDS_CLIENTS_handle_reply(struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Handle a reply we've received from another peer.
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:214
uint32_t type
The type of data to insert.
Definition: dht.h:204
void GDS_DATACACHE_handle_put(struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Handle a datum we've received from another peer.
void GDS_CLIENTS_process_put(uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Check if some client is monitoring PUT messages and notify them in that case.
uint32_t options
Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
Definition: dht.h:209
struct GNUNET_SERVICE_Client * client
The handle to this client.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT.
Definition: dht.h:199
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_TIME_AbsoluteNBO expiration
How long should this data persist?
Definition: dht.h:219
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define LOG(kind,...)
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:224
#define LOG_TRAFFIC(kind,...)
Should routing details be logged to stderr (for debugging)?
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associcated with a filter in memory, flush to drive if needed (do not free the space o...
#define gettext_noop(String)
Definition: gettext.h:69
int GDS_NEIGHBOURS_handle_put(enum GNUNET_BLOCK_Type type, enum GNUNET_DHT_RouteOption options, uint32_t desired_replication_level, struct GNUNET_TIME_Absolute expiration_time, uint32_t hop_count, struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *key, unsigned int put_path_length, struct GNUNET_PeerIdentity *put_path, const void *data, size_t data_size)
Perform a PUT operation.
Here is the call graph for this function:

◆ check_dht_local_get()

static int check_dht_local_get ( void *  cls,
const struct GNUNET_DHT_ClientGetMessage get 
)
static

Check DHT GET messages from the client.

Parameters
clsthe client we received this message from
messagethe actual message received
Returns
GNUNET_OK (always)

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

References GNUNET_OK.

552 {
553  /* always well-formed */
554  return GNUNET_OK;
555 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_local_result()

static void handle_local_result ( void *  cls,
enum GNUNET_BLOCK_Type  type,
struct GNUNET_TIME_Absolute  expiration_time,
const struct GNUNET_HashCode key,
unsigned int  put_path_length,
const struct GNUNET_PeerIdentity put_path,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity get_path,
const void *  data,
size_t  data_size 
)
static

Handle a result from local datacache for a GET operation.

Parameters
clsthe struct ClientHandle of the client doing the query
typetype of the block
expiration_timewhen does the content expire
keykey for the content
put_path_lengthnumber of entries in put_path
put_pathpeers the original PUT traversed (if tracked)
get_path_lengthnumber of entries in get_path
get_pathpeers this reply has traversed so far (if tracked)
datapayload of the reply
data_sizenumber of bytes in data

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

References GDS_CLIENTS_handle_reply().

Referenced by handle_dht_local_get().

583 {
584  // FIXME: this needs some clean up: inline the function,
585  // possibly avoid even looking up the client!
586  GDS_CLIENTS_handle_reply (expiration_time,
587  key,
588  0, NULL,
589  put_path_length, put_path,
590  type,
591  data_size, data);
592 }
void GDS_CLIENTS_handle_reply(struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data)
Handle a reply we've received from another peer.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_dht_local_get()

static void handle_dht_local_get ( void *  cls,
const struct GNUNET_DHT_ClientGetMessage get 
)
static

Handler for DHT GET messages from the client.

Parameters
clsthe client we received this message from
messagethe actual message received

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

References ClientQueryRecord::ch, ClientHandle::client, ClientHandle::cqr_head, ClientHandle::cqr_tail, GDS_CLIENTS_process_get(), GDS_DATACACHE_handle_get(), GDS_NEIGHBOURS_get_id(), gettext_noop, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_SECONDS, handle_local_result(), ClientQueryRecord::hnode, ClientQueryRecord::key, LOG, LOG_TRAFFIC, ClientQueryRecord::msg_options, ClientQueryRecord::replication, ClientQueryRecord::retry_frequency, ClientQueryRecord::retry_time, size, transmit_next_request_task(), ClientQueryRecord::type, ClientQueryRecord::unique_id, ClientQueryRecord::xquery, and ClientQueryRecord::xquery_size.

604 {
605  struct ClientHandle *ch = cls;
606  struct ClientQueryRecord *cqr;
607  size_t xquery_size;
608  const char *xquery;
609  uint16_t size;
610 
611  size = ntohs (get->header.size);
612  xquery_size = size - sizeof (struct GNUNET_DHT_ClientGetMessage);
613  xquery = (const char *) &get[1];
616  ("# GET requests received from clients"), 1,
617  GNUNET_NO);
619  "Received GET request for %s from local client %p, xq: %.*s\n",
620  GNUNET_h2s (&get->key),
621  ch->client,
622  xquery_size,
623  xquery);
625  "CLIENT-GET %s\n",
626  GNUNET_h2s_full (&get->key));
627 
628  cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
629  cqr->key = get->key;
630  cqr->ch = ch;
631  cqr->xquery = (void *) &cqr[1];
632  GNUNET_memcpy (&cqr[1], xquery, xquery_size);
636  cqr->unique_id = get->unique_id;
637  cqr->xquery_size = xquery_size;
638  cqr->replication = ntohl (get->desired_replication_level);
639  cqr->msg_options = ntohl (get->options);
640  cqr->type = ntohl (get->type);
642  ch->cqr_tail,
643  cqr);
645  &cqr->key,
646  cqr,
648  GDS_CLIENTS_process_get (ntohl (get->options),
649  ntohl (get->type),
650  0,
651  ntohl (get->desired_replication_level),
652  1,
654  &get->key);
655  /* start remote requests */
656  if (NULL != retry_task)
659  NULL);
660  /* perform local lookup */
662  cqr->type,
663  cqr->xquery,
664  xquery_size,
665  NULL,
667  ch);
669 }
uint64_t unique_id
The unique identifier of this request.
struct GNUNET_PeerIdentity * GDS_NEIGHBOURS_get_id()
Get the ID of the local node.
struct GNUNET_HashCode key
The key to search for.
Definition: dht.h:98
struct ClientQueryRecord * cqr_tail
Linked list of active queries of this client.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
static void handle_local_result(void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
Handle a result from local datacache for a GET operation.
static struct GNUNET_SCHEDULER_Task * retry_task
Task that re-transmits requests (using retry_heap).
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 GNUNET_TIME_UNIT_SECONDS
One second.
enum GNUNET_BLOCK_Type type
The type for the data for the GET request.
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint32_t options
Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
Definition: dht.h:82
static void transmit_next_request_task(void *cls)
Task that looks at the retry_heap and transmits all of the requests on the heap that are ready for tr...
struct ClientQueryRecord * cqr_head
Linked list of active queries of this client.
struct GNUNET_TIME_Relative retry_frequency
What's the delay between re-try operations that we currently use for this request?
uint32_t replication
Desired replication level.
struct ClientHandle * ch
Client responsible for the request.
void GDS_CLIENTS_process_get(uint32_t options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key)
Check if some client is monitoring GET messages and notify them in that case.
#define GNUNET_memcpy(dst, src, n)
uint32_t type
The type for the data for the GET request; actually an 'enum GNUNET_BLOCK_Type'.
Definition: dht.h:93
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
struct GNUNET_SERVICE_Client * client
The handle to this client.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Entry in the local forwarding map for a client's GET request.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
uint32_t msg_options
Any message options for this request.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define LOG(kind,...)
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET.
Definition: dht.h:77
size_t xquery_size
Number of bytes in xquery.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static struct GNUNET_CONTAINER_Heap * retry_heap
Heap with all of our client's request, sorted by retry time (earliest on top).
Allow multiple values with the same key.
#define LOG_TRAFFIC(kind,...)
Should routing details be logged to stderr (for debugging)?
DHT GET message sent from clients to service.
Definition: dht.h:72
enum GNUNET_BLOCK_EvaluationResult GDS_DATACACHE_handle_get(const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, const void *xquery, size_t xquery_size, struct GNUNET_BLOCK_Group *bg, GDS_DATACACHE_GetCallback gc, void *gc_cls)
Handle a GET request we've received from another peer.
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:87
struct GNUNET_HashCode key
The key this request was about.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
struct GNUNET_TIME_Absolute retry_time
What's the next time we should re-try this request?
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_CONTAINER_HeapNode * hnode
Pointer to this nodes heap location in the retry-heap (for fast removal)
const void * xquery
Extended query (see gnunet_block_lib.h), allocated at the end of this struct.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:

◆ find_by_unique_id()

static int find_by_unique_id ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Function called for each existing DHT record for the given query.

Checks if it matches the UID given in the closure and if so returns the entry as a result.

Parameters
clsthe search context
keyquery for the lookup (not used)
valuethe struct ClientQueryRecord
Returns
GNUNET_YES to continue iteration (result not yet found)

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

References FindByUniqueIdContext::cqr, GNUNET_NO, GNUNET_YES, ClientQueryRecord::unique_id, FindByUniqueIdContext::unique_id, and value.

Referenced by handle_dht_local_get_result_seen().

700 {
701  struct FindByUniqueIdContext *fui_ctx = cls;
702  struct ClientQueryRecord *cqr = value;
703 
704  if (cqr->unique_id != fui_ctx->unique_id)
705  return GNUNET_YES;
706  fui_ctx->cqr = cqr;
707  return GNUNET_NO;
708 }
uint64_t unique_id
The unique identifier of this request.
#define GNUNET_NO
Definition: gnunet_common.h:81
static char * value
Value of the record to add/remove.
Closure for find_by_unique_id().
Entry in the local forwarding map for a client's GET request.
struct ClientQueryRecord * cqr
Where to store the result, if found.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the caller graph for this function:

◆ check_dht_local_get_result_seen()

static int check_dht_local_get_result_seen ( void *  cls,
const struct GNUNET_DHT_ClientGetResultSeenMessage seen 
)
static

Check "GET result seen" messages from the client.

Parameters
clsthe client we received this message from
messagethe actual message received
Returns
GNUNET_OK if seen is well-formed

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

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_DHT_ClientGetResultSeenMessage::header, size, and GNUNET_MessageHeader::size.

721 {
722  uint16_t size;
723  unsigned int hash_count;
724 
725  size = ntohs (seen->header.size);
726  hash_count = (size - sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage)) / sizeof (struct GNUNET_HashCode);
727  if (size != sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage) + hash_count * sizeof (struct GNUNET_HashCode))
728  {
729  GNUNET_break (0);
730  return GNUNET_SYSERR;
731  }
732  return GNUNET_OK;
733 }
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:115
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
A 512-bit hashcode.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN.
Definition: dht.h:120

◆ handle_dht_local_get_result_seen()

static void handle_dht_local_get_result_seen ( void *  cls,
const struct GNUNET_DHT_ClientGetResultSeenMessage seen 
)
static

Handler for "GET result seen" messages from the client.

Parameters
clsthe client we received this message from
messagethe actual message received

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

References ClientQueryRecord::ch, ClientHandle::client, FindByUniqueIdContext::cqr, find_by_unique_id(), GNUNET_array_grow, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_memcpy, GNUNET_SERVICE_client_drop(), GNUNET_DHT_ClientGetResultSeenMessage::header, GNUNET_DHT_ClientGetResultSeenMessage::key, ClientQueryRecord::seen_replies, ClientQueryRecord::seen_replies_count, size, GNUNET_MessageHeader::size, GNUNET_DHT_ClientGetResultSeenMessage::unique_id, and FindByUniqueIdContext::unique_id.

745 {
746  struct ClientHandle *ch = cls;
747  uint16_t size;
748  unsigned int hash_count;
749  unsigned int old_count;
750  const struct GNUNET_HashCode *hc;
751  struct FindByUniqueIdContext fui_ctx;
752  struct ClientQueryRecord *cqr;
753 
754  size = ntohs (seen->header.size);
755  hash_count = (size - sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage)) / sizeof (struct GNUNET_HashCode);
756  hc = (const struct GNUNET_HashCode*) &seen[1];
757  fui_ctx.unique_id = seen->unique_id;
758  fui_ctx.cqr = NULL;
760  &seen->key,
762  &fui_ctx);
763  if (NULL == (cqr = fui_ctx.cqr))
764  {
765  GNUNET_break (0);
767  return;
768  }
769  /* finally, update 'seen' list */
770  old_count = cqr->seen_replies_count;
772  cqr->seen_replies_count,
773  cqr->seen_replies_count + hash_count);
774  GNUNET_memcpy (&cqr->seen_replies[old_count],
775  hc,
776  sizeof (struct GNUNET_HashCode) * hash_count);
777 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:115
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. ...
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_memcpy(dst, src, n)
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:136
Closure for find_by_unique_id().
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
struct GNUNET_SERVICE_Client * client
The handle to this client.
Entry in the local forwarding map for a client's GET request.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static unsigned int size
Size of the "table".
Definition: peer.c:67
static int find_by_unique_id(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called for each existing DHT record for the given query.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN.
Definition: dht.h:120
struct GNUNET_HashCode * seen_replies
Replies we have already seen for this request.
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.
unsigned int seen_replies_count
Number of entries in 'seen_replies'.
struct GNUNET_HashCode key
The key we are searching for (to make it easy to find the corresponding GET inside the service)...
Definition: dht.h:131
Here is the call graph for this function:

◆ remove_by_unique_id()

static int remove_by_unique_id ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator over hash map entries that frees all entries that match the given client and unique ID.

Parameters
clsunique ID and client to search for in source routes
keycurrent key code
valuevalue in the hash map, a ClientQueryRecord
Returns
GNUNET_YES (we should continue to iterate)

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

References RemoveByUniqueIdContext::ch, ClientHandle::client, ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_YES, remove_client_record(), ClientQueryRecord::unique_id, RemoveByUniqueIdContext::unique_id, and value.

Referenced by handle_dht_local_get_stop().

810 {
811  const struct RemoveByUniqueIdContext *ctx = cls;
812  struct ClientQueryRecord *cqr = value;
813 
814  if (cqr->unique_id != ctx->unique_id)
815  return GNUNET_YES;
817  "Removing client %p's record for key %s (by unique id)\n",
818  ctx->ch->client,
819  GNUNET_h2s (key));
820  remove_client_record (cqr);
821  return GNUNET_YES;
822 }
uint64_t unique_id
The unique identifier of this request.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Closure for remove_by_unique_id().
static char * value
Value of the record to add/remove.
uint64_t unique_id
Unique ID of the request.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Entry in the local forwarding map for a client's GET request.
struct ClientHandle * ch
Client that issued the removal request.
static void remove_client_record(struct ClientQueryRecord *record)
Free data structures associated with the given query.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_dht_local_get_stop()

static void handle_dht_local_get_stop ( void *  cls,
const struct GNUNET_DHT_ClientGetStopMessage dht_stop_msg 
)
static

Handler for any generic DHT stop messages, calls the appropriate handler depending on message type (if processed locally)

Parameters
clsclient we received this message from
messagethe actual message received

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

References ClientQueryRecord::ch, RemoveByUniqueIdContext::ch, ClientHandle::client, gettext_noop, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_DHT_ClientGetStopMessage::key, LOG, remove_by_unique_id(), GNUNET_DHT_ClientGetStopMessage::unique_id, and RemoveByUniqueIdContext::unique_id.

836 {
837  struct ClientHandle *ch = cls;
839 
842  ("# GET STOP requests received from clients"), 1,
843  GNUNET_NO);
845  "Received GET STOP request for %s from local client %p\n",
846  GNUNET_h2s (&dht_stop_msg->key),
847  ch->client);
848  ctx.ch = ch;
849  ctx.unique_id = dht_stop_msg->unique_id;
851  &dht_stop_msg->key,
853  &ctx);
855 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
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 GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Closure for remove_by_unique_id().
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:58
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
#define LOG(kind,...)
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.
struct GNUNET_HashCode key
Key of this request.
Definition: dht.h:63
static int remove_by_unique_id(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries that frees all entries that match the given client and unique ID...
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ handle_dht_local_monitor()

static void handle_dht_local_monitor ( void *  cls,
const struct GNUNET_DHT_MonitorStartStopMessage msg 
)
static

Handler for monitor start messages.

Parameters
clsthe client we received this message from
msgthe actual message received

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

References ClientQueryRecord::ch, ClientMonitorRecord::ch, ClientHandle::client, GNUNET_DHT_MonitorStartStopMessage::filter_key, ClientMonitorRecord::get, GNUNET_DHT_MonitorStartStopMessage::get, ClientMonitorRecord::get_resp, GNUNET_DHT_MonitorStartStopMessage::get_resp, GNUNET_CONTAINER_DLL_insert, GNUNET_memcpy, GNUNET_new, GNUNET_SERVICE_client_continue(), ClientMonitorRecord::key, GNUNET_DHT_MonitorStartStopMessage::key, ClientMonitorRecord::put, GNUNET_DHT_MonitorStartStopMessage::put, ClientMonitorRecord::type, and GNUNET_DHT_MonitorStartStopMessage::type.

868 {
869  struct ClientHandle *ch = cls;
870  struct ClientMonitorRecord *r;
871 
872  r = GNUNET_new (struct ClientMonitorRecord);
873  r->ch = ch;
874  r->type = ntohl (msg->type);
875  r->get = ntohs (msg->get);
876  r->get_resp = ntohs (msg->get_resp);
877  r->put = ntohs (msg->put);
878  if (0 == ntohs (msg->filter_key))
879  {
880  r->key = NULL;
881  }
882  else
883  {
884  r->key = GNUNET_new (struct GNUNET_HashCode);
885  GNUNET_memcpy (r->key,
886  &msg->key,
887  sizeof (struct GNUNET_HashCode));
888  }
890  monitor_tail,
891  r);
893 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct ClientHandle * ch
Client to notify of these requests.
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
uint32_t type
The type of data desired, GNUNET_BLOCK_TYPE_ANY for all.
Definition: dht.h:298
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:308
uint16_t put
Flag whether to notify about PUT messages.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
enum GNUNET_BLOCK_Type type
Type of blocks that are of interest.
#define GNUNET_memcpy(dst, src, n)
int16_t filter_key
Flag whether to use the provided key to filter messages.
Definition: dht.h:318
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:313
A 512-bit hashcode.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static struct ClientMonitorRecord * monitor_tail
List of active monitoring requests.
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
int16_t get
Flag whether to notify about GET messages.
Definition: dht.h:303
int16_t get
Flag whether to notify about GET messages.
Struct containing paremeters of monitoring requests.
struct GNUNET_HashCode key
The key to filter messages by.
Definition: dht.h:323
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
Here is the call graph for this function:

◆ handle_dht_local_monitor_stop()

static void handle_dht_local_monitor_stop ( void *  cls,
const struct GNUNET_DHT_MonitorStartStopMessage msg 
)
static

Handler for monitor stop messages.

Parameters
clsthe client we received this message from
msgthe actual message received

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

References ClientQueryRecord::ch, ClientMonitorRecord::ch, ClientHandle::client, GNUNET_DHT_MonitorStartStopMessage::filter_key, ClientMonitorRecord::get, GNUNET_DHT_MonitorStartStopMessage::get, ClientMonitorRecord::get_resp, GNUNET_DHT_MonitorStartStopMessage::get_resp, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_SERVICE_client_continue(), ClientMonitorRecord::key, GNUNET_DHT_MonitorStartStopMessage::key, ClientMonitorRecord::next, ClientMonitorRecord::put, GNUNET_DHT_MonitorStartStopMessage::put, ClientMonitorRecord::type, and GNUNET_DHT_MonitorStartStopMessage::type.

905 {
906  struct ClientHandle *ch = cls;
907  struct ClientMonitorRecord *r;
908  int keys_match;
909 
911  for (r = monitor_head; NULL != r; r = r->next)
912  {
913  if (NULL == r->key)
914  {
915  keys_match = (0 == ntohs(msg->filter_key));
916  }
917  else
918  {
919  keys_match = ( (0 != ntohs(msg->filter_key)) &&
920  (! memcmp (r->key,
921  &msg->key,
922  sizeof(struct GNUNET_HashCode))) );
923  }
924  if ( (ch == r->ch) &&
925  (ntohl(msg->type) == r->type) &&
926  (r->get == msg->get) &&
927  (r->get_resp == msg->get_resp) &&
928  (r->put == msg->put) &&
929  keys_match )
930  {
932  monitor_tail,
933  r);
935  GNUNET_free (r);
936  return; /* Delete only ONE entry */
937  }
938  }
939 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct ClientHandle * ch
Client to notify of these requests.
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
uint32_t type
The type of data desired, GNUNET_BLOCK_TYPE_ANY for all.
Definition: dht.h:298
struct ClientMonitorRecord * next
Next element in DLL.
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:308
uint16_t put
Flag whether to notify about PUT messages.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
enum GNUNET_BLOCK_Type type
Type of blocks that are of interest.
int16_t filter_key
Flag whether to use the provided key to filter messages.
Definition: dht.h:318
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:313
A 512-bit hashcode.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static struct ClientMonitorRecord * monitor_tail
List of active monitoring requests.
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
int16_t get
Flag whether to notify about GET messages.
Definition: dht.h:303
int16_t get
Flag whether to notify about GET messages.
Struct containing paremeters of monitoring requests.
struct GNUNET_HashCode key
The key to filter messages by.
Definition: dht.h:323
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ forward_reply()

static int forward_reply ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator over hash map entries that send a given reply to each of the matching clients.

With some tricky recycling of the buffer.

Parameters
clsthe 'struct ForwardReplyContext'
keycurrent key
valuevalue in the hash map, a ClientQueryRecord
Returns
GNUNET_YES (we should continue to iterate), if the result is mal-formed, GNUNET_NO

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

References _, ClientQueryRecord::ch, ClientHandle::client, ForwardReplyContext::data, ForwardReplyContext::data_size, env, GNUNET_DHT_ClientResultMessage::expiration, ForwardReplyContext::expiration, ForwardReplyContext::get_path, GNUNET_DHT_ClientResultMessage::get_path_length, ForwardReplyContext::get_path_length, gettext_noop, GNUNET_array_append, GNUNET_BLOCK_EO_NONE, GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_EVALUATION_OK_DUPLICATE, GNUNET_BLOCK_EVALUATION_OK_LAST, GNUNET_BLOCK_EVALUATION_OK_MORE, GNUNET_BLOCK_EVALUATION_REQUEST_INVALID, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, GNUNET_BLOCK_EVALUATION_RESULT_INVALID, GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT, GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GNUNET_DHT_ClientResultMessage::key, ClientQueryRecord::key, LOG, LOG_TRAFFIC, ClientHandle::mq, ForwardReplyContext::put_path, GNUNET_DHT_ClientResultMessage::put_path_length, ForwardReplyContext::put_path_length, remove_client_record(), ClientQueryRecord::seen_replies, ClientQueryRecord::seen_replies_count, ClientQueryRecord::type, GNUNET_DHT_ClientResultMessage::type, ForwardReplyContext::type, ClientQueryRecord::unique_id, GNUNET_DHT_ClientResultMessage::unique_id, value, ClientQueryRecord::xquery, and ClientQueryRecord::xquery_size.

Referenced by GDS_CLIENTS_handle_reply().

1006 {
1007  struct ForwardReplyContext *frc = cls;
1008  struct ClientQueryRecord *record = value;
1009  struct GNUNET_MQ_Envelope *env;
1010  struct GNUNET_DHT_ClientResultMessage *reply;
1012  int do_free;
1013  struct GNUNET_HashCode ch;
1014  struct GNUNET_PeerIdentity *paths;
1015 
1017  "CLIENT-RESULT %s\n",
1018  GNUNET_h2s_full (key));
1019  if ( (record->type != GNUNET_BLOCK_TYPE_ANY) &&
1020  (record->type != frc->type))
1021  {
1023  "Record type mismatch, not passing request for key %s to local client\n",
1024  GNUNET_h2s (key));
1026  gettext_noop
1027  ("# Key match, type mismatches in REPLY to CLIENT"),
1028  1, GNUNET_NO);
1029  return GNUNET_YES; /* type mismatch */
1030  }
1031  GNUNET_CRYPTO_hash (frc->data, frc->data_size, &ch);
1032  for (unsigned int i = 0; i < record->seen_replies_count; i++)
1033  if (0 == memcmp (&record->seen_replies[i],
1034  &ch,
1035  sizeof (struct GNUNET_HashCode)))
1036  {
1038  "Duplicate reply, not passing request for key %s to local client\n",
1039  GNUNET_h2s (key));
1041  gettext_noop
1042  ("# Duplicate REPLIES to CLIENT request dropped"),
1043  1, GNUNET_NO);
1044  return GNUNET_YES; /* duplicate */
1045  }
1046  eval
1048  record->type,
1049  NULL,
1051  key,
1052  record->xquery,
1053  record->xquery_size,
1054  frc->data,
1055  frc->data_size);
1057  "Evaluation result is %d for key %s for local client's query\n",
1058  (int) eval,
1059  GNUNET_h2s (key));
1060  switch (eval)
1061  {
1063  do_free = GNUNET_YES;
1064  break;
1067  record->seen_replies_count,
1068  ch);
1069  do_free = GNUNET_NO;
1070  break;
1072  /* should be impossible to encounter here */
1073  GNUNET_break (0);
1074  return GNUNET_YES;
1076  GNUNET_break_op (0);
1077  return GNUNET_NO;
1079  GNUNET_break (0);
1080  return GNUNET_NO;
1082  GNUNET_break (0);
1083  return GNUNET_NO;
1085  return GNUNET_YES;
1088  _("Unsupported block type (%u) in request!\n"), record->type);
1089  return GNUNET_NO;
1090  default:
1091  GNUNET_break (0);
1092  return GNUNET_NO;
1093  }
1095  gettext_noop ("# RESULTS queued for clients"),
1096  1,
1097  GNUNET_NO);
1098  env = GNUNET_MQ_msg_extra (reply,
1099  frc->data_size +
1100  (frc->get_path_length + frc->put_path_length) * sizeof (struct GNUNET_PeerIdentity),
1102  reply->type = htonl (frc->type);
1103  reply->get_path_length = htonl (frc->get_path_length);
1104  reply->put_path_length = htonl (frc->put_path_length);
1105  reply->unique_id = record->unique_id;
1107  reply->key = *key;
1108  paths = (struct GNUNET_PeerIdentity *) &reply[1];
1109  GNUNET_memcpy (paths,
1110  frc->put_path,
1111  sizeof (struct GNUNET_PeerIdentity) * frc->put_path_length);
1112  GNUNET_memcpy (&paths[frc->put_path_length],
1113  frc->get_path,
1114  sizeof (struct GNUNET_PeerIdentity) * frc->get_path_length);
1115  GNUNET_memcpy (&paths[frc->get_path_length + frc->put_path_length],
1116  frc->data,
1117  frc->data_size);
1119  "Sending reply to query %s for client %p\n",
1120  GNUNET_h2s (key),
1121  record->ch->client);
1122  GNUNET_MQ_send (record->ch->mq,
1123  env);
1124  if (GNUNET_YES == do_free)
1125  remove_client_record (record);
1126  return GNUNET_YES;
1127 }
Block does not match query (invalid result)
uint64_t unique_id
The unique identifier of this request.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT
Service returns result to client.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
Closure for forward_reply()
const struct GNUNET_PeerIdentity * put_path
PUT path taken.
uint64_t unique_id
Unique ID of the matching GET request.
Definition: dht.h:174
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:163
Any type of block, used as a wildcard when searching.
Definition: w32nsp.c:83
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
enum GNUNET_BLOCK_Type type
The type for the data for the GET request.
Block does not match xquery (valid result, not relevant for the request)
#define GNUNET_NO
Definition: gnunet_common.h:81
enum GNUNET_BLOCK_Type type
Type of the data.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Default behavior.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
unsigned int get_path_length
Number of entries in get_path.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct ClientHandle * ch
Client responsible for the request.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_memcpy(dst, src, n)
static char * value
Value of the record to add/remove.
Valid result, but suppressed because it is a duplicate.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
unsigned int put_path_length
Number of entries in put_path.
struct GNUNET_HashCode key
The key that was searched for.
Definition: dht.h:184
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
Definition: block.c:339
Last possible valid result.
struct GNUNET_TIME_AbsoluteNBO expiration
When does this entry expire?
Definition: dht.h:179
uint32_t type
The type for the data.
Definition: dht.h:157
A 512-bit hashcode.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Entry in the local forwarding map for a client&#39;s GET request.
Valid result, and there may be more.
struct GNUNET_HashCode key
The key used in the DHT.
#define LOG(kind,...)
size_t xquery_size
Number of bytes in xquery.
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to this client.
static void remove_client_record(struct ClientQueryRecord *record)
Free data structures associated with the given query.
struct GNUNET_HashCode * seen_replies
Replies we have already seen for this request.
Specified block type not supported by this plugin.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
The identity of the host (wraps the signing key of the peer).
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:169
unsigned int seen_replies_count
Number of entries in &#39;seen_replies&#39;.
#define LOG_TRAFFIC(kind,...)
Should routing details be logged to stderr (for debugging)?
Query format does not match block type (invalid query).
#define GNUNET_log(kind,...)
size_t data_size
Number of bytes in data.
const struct GNUNET_PeerIdentity * get_path
GET path taken.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
Query is valid, no reply given.
struct GNUNET_TIME_Absolute expiration
Expiration time of the reply.
Reply to a GET send from the service to a client.
Definition: dht.h:147
const void * xquery
Extended query (see gnunet_block_lib.h), allocated at the end of this struct.
#define gettext_noop(String)
Definition: gettext.h:69
const void * data
Embedded payload.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_handle_reply()

void GDS_CLIENTS_handle_reply ( struct GNUNET_TIME_Absolute  expiration,
const struct GNUNET_HashCode key,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity get_path,
unsigned int  put_path_length,
const struct GNUNET_PeerIdentity put_path,
enum GNUNET_BLOCK_Type  type,
size_t  data_size,
const void *  data 
)

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
expirationwhen will the reply expire
keythe query this reply is for
get_path_lengthnumber of peers in get_path
get_pathpath the reply took on get
put_path_lengthnumber of peers in put_path
put_pathpath the reply took on put
typetype of the reply
data_sizenumber of bytes in data
dataapplication payload data

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

References data, ForwardReplyContext::data, data_size, ForwardReplyContext::data_size, expiration, ForwardReplyContext::expiration, forward_reply(), ForwardReplyContext::get_path, ForwardReplyContext::get_path_length, gettext_noop, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, ForwardReplyContext::put_path, ForwardReplyContext::put_path_length, ClientQueryRecord::type, and ForwardReplyContext::type.

Referenced by handle_dht_local_put(), handle_dht_p2p_put(), handle_local_result(), and process_reply_with_path().

1155 {
1156  struct ForwardReplyContext frc;
1157  size_t msize;
1158 
1159  msize = sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size +
1160  (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
1161  if (msize >= GNUNET_MAX_MESSAGE_SIZE)
1162  {
1163  GNUNET_break (0);
1164  return;
1165  }
1167  key))
1168  {
1170  "No matching client for reply for key %s\n",
1171  GNUNET_h2s (key));
1173  gettext_noop ("# REPLIES ignored for CLIENTS (no match)"),
1174  1,
1175  GNUNET_NO);
1176  return; /* no matching request, fast exit! */
1177  }
1178  frc.expiration = expiration;
1179  frc.get_path = get_path;
1180  frc.put_path = put_path;
1181  frc.data = data;
1182  frc.data_size = data_size;
1183  frc.get_path_length = get_path_length;
1184  frc.put_path_length = put_path_length;
1185  frc.type = type;
1187  "Forwarding reply for key %s to client\n",
1188  GNUNET_h2s (key));
1190  key,
1191  &forward_reply,
1192  &frc);
1193 
1194 }
Closure for forward_reply()
static char * expiration
Credential TTL.
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:163
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 GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define LOG(kind,...)
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
The identity of the host (wraps the signing key of the peer).
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:169
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.
static int forward_reply(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries that send a given reply to each of the matching clients.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
Reply to a GET send from the service to a client.
Definition: dht.h:147
#define gettext_noop(String)
Definition: gettext.h:69
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 ( uint32_t  options,
enum GNUNET_BLOCK_Type  type,
uint32_t  hop_count,
uint32_t  desired_replication_level,
unsigned int  path_length,
const struct GNUNET_PeerIdentity 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.

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

References ClientMonitorRecord::ch, GNUNET_DHT_MonitorGetMessage::desired_replication_level, env, GNUNET_DHT_MonitorGetMessage::get_path_length, GNUNET_array_append, GNUNET_BLOCK_TYPE_ANY, GNUNET_free_non_null, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_DHT_MonitorGetMessage::hop_count, ClientMonitorRecord::key, GNUNET_DHT_MonitorGetMessage::key, ClientQueryRecord::key, m, ClientHandle::mq, ClientMonitorRecord::next, GNUNET_DHT_MonitorGetMessage::options, ClientMonitorRecord::type, and GNUNET_DHT_MonitorGetMessage::type.

Referenced by handle_dht_local_get(), and handle_dht_p2p_get().

1217 {
1218  struct ClientMonitorRecord *m;
1219  struct ClientHandle **cl;
1220  unsigned int cl_size;
1221 
1222  cl = NULL;
1223  cl_size = 0;
1224  for (m = monitor_head; NULL != m; m = m->next)
1225  {
1226  if ( ( (GNUNET_BLOCK_TYPE_ANY == m->type) ||
1227  (m->type == type) ) &&
1228  ( (NULL == m->key) ||
1229  (0 == memcmp (key,
1230  m->key,
1231  sizeof(struct GNUNET_HashCode))) ) )
1232  {
1233  struct GNUNET_MQ_Envelope *env;
1234  struct GNUNET_DHT_MonitorGetMessage *mmsg;
1235  struct GNUNET_PeerIdentity *msg_path;
1236  size_t msize;
1237  unsigned int i;
1238 
1239  /* Don't send duplicates */
1240  for (i = 0; i < cl_size; i++)
1241  if (cl[i] == m->ch)
1242  break;
1243  if (i < cl_size)
1244  continue;
1245  GNUNET_array_append (cl,
1246  cl_size,
1247  m->ch);
1248 
1249  msize = path_length * sizeof (struct GNUNET_PeerIdentity);
1250  env = GNUNET_MQ_msg_extra (mmsg,
1251  msize,
1253  mmsg->options = htonl(options);
1254  mmsg->type = htonl(type);
1255  mmsg->hop_count = htonl(hop_count);
1256  mmsg->desired_replication_level = htonl(desired_replication_level);
1257  mmsg->get_path_length = htonl(path_length);
1258  mmsg->key = *key;
1259  msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1260  GNUNET_memcpy (msg_path,
1261  path,
1262  path_length * sizeof (struct GNUNET_PeerIdentity));
1263  GNUNET_MQ_send (m->ch->mq,
1264  env);
1265  }
1266  }
1267  GNUNET_free_non_null (cl);
1268 }
struct ClientHandle * ch
Client to notify of these requests.
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:340
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
Any type of block, used as a wildcard when searching.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct ClientMonitorRecord * next
Next element in DLL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
enum GNUNET_BLOCK_Type type
Type of blocks that are of interest.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:366
A 512-bit hashcode.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET
Receive information about transiting GETs.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t get_path_length
Number of peers recorded in the outgoing path from source to the storage location of this message...
Definition: dht.h:361
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to this client.
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:355
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
The identity of the host (wraps the signing key of the peer).
Struct containing paremeters of monitoring requests.
uint32_t type
The type of data in the request.
Definition: dht.h:345
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Message to monitor get requests going through peer, DHT service -> clients.
Definition: dht.h:330
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t hop_count
Hop count.
Definition: dht.h:350
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 ( enum GNUNET_BLOCK_Type  type,
const struct GNUNET_PeerIdentity get_path,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity put_path,
unsigned int  put_path_length,
struct GNUNET_TIME_Absolute  exp,
const struct GNUNET_HashCode key,
const void *  data,
size_t  size 
)

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

Parameters
typeThe type of data in the result.
get_pathPeers on GET path (or NULL if not recorded).
get_path_lengthnumber of entries in get_path.
put_pathpeers on the PUT path (or NULL if not recorded).
put_path_lengthnumber of entries in get_path.
expExpiration time of the data.
keyKey of the data.
dataPointer to the result data.
sizeNumber of bytes in data.

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

References ClientMonitorRecord::ch, env, GNUNET_DHT_MonitorGetRespMessage::expiration_time, GNUNET_DHT_MonitorGetRespMessage::get_path_length, GNUNET_array_append, GNUNET_BLOCK_TYPE_ANY, GNUNET_free_non_null, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), ClientMonitorRecord::key, GNUNET_DHT_MonitorGetRespMessage::key, ClientQueryRecord::key, m, ClientHandle::mq, ClientMonitorRecord::next, GNUNET_DHT_MonitorGetRespMessage::put_path_length, size, ClientMonitorRecord::type, and GNUNET_DHT_MonitorGetRespMessage::type.

Referenced by process_reply_with_path().

1295 {
1296  struct ClientMonitorRecord *m;
1297  struct ClientHandle **cl;
1298  unsigned int cl_size;
1299 
1300  cl = NULL;
1301  cl_size = 0;
1302  for (m = monitor_head; NULL != m; m = m->next)
1303  {
1304  if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
1305  (NULL == m->key ||
1306  memcmp (key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
1307  {
1308  struct GNUNET_MQ_Envelope *env;
1309  struct GNUNET_DHT_MonitorGetRespMessage *mmsg;
1310  struct GNUNET_PeerIdentity *path;
1311  size_t msize;
1312  unsigned int i;
1313 
1314  /* Don't send duplicates */
1315  for (i = 0; i < cl_size; i++)
1316  if (cl[i] == m->ch)
1317  break;
1318  if (i < cl_size)
1319  continue;
1320  GNUNET_array_append (cl,
1321  cl_size,
1322  m->ch);
1323 
1324  msize = size;
1325  msize += (get_path_length + put_path_length)
1326  * sizeof (struct GNUNET_PeerIdentity);
1327  env = GNUNET_MQ_msg_extra (mmsg,
1328  msize,
1330  mmsg->type = htonl(type);
1331  mmsg->put_path_length = htonl(put_path_length);
1332  mmsg->get_path_length = htonl(get_path_length);
1334  mmsg->key = *key;
1335  path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1336  GNUNET_memcpy (path,
1337  put_path,
1338  put_path_length * sizeof (struct GNUNET_PeerIdentity));
1339  GNUNET_memcpy (path,
1340  get_path,
1341  get_path_length * sizeof (struct GNUNET_PeerIdentity));
1342  GNUNET_memcpy (&path[get_path_length],
1343  data,
1344  size);
1345  GNUNET_MQ_send (m->ch->mq,
1346  env);
1347  }
1348  }
1349  GNUNET_free_non_null (cl);
1350 }
struct ClientHandle * ch
Client to notify of these requests.
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
Any type of block, used as a wildcard when searching.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
uint32_t get_path_length
Length of the GET path that follows (if tracked).
Definition: dht.h:395
struct GNUNET_HashCode key
The key of the corresponding GET request.
Definition: dht.h:405
struct ClientMonitorRecord * next
Next element in DLL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
uint32_t put_path_length
Length of the PUT path that follows (if tracked).
Definition: dht.h:390
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
enum GNUNET_BLOCK_Type type
Type of blocks that are of interest.
#define GNUNET_memcpy(dst, src, n)
A 512-bit hashcode.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to this client.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
The identity of the host (wraps the signing key of the peer).
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP
Receive information about transiting GET responses.
Struct containing paremeters of monitoring requests.
uint32_t type
Content type.
Definition: dht.h:385
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
Definition: dht.h:400
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
Message to monitor get results going through peer, DHT service -> clients.
Definition: dht.h:375
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 ( uint32_t  options,
enum GNUNET_BLOCK_Type  type,
uint32_t  hop_count,
uint32_t  desired_replication_level,
unsigned int  path_length,
const struct GNUNET_PeerIdentity path,
struct GNUNET_TIME_Absolute  exp,
const struct GNUNET_HashCode key,
const void *  data,
size_t  size 
)

Check if some client is monitoring PUT 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 PUT path (or NULL if not recorded).
desired_replication_levelDesired replication level.
expExpiration time of the data.
keyKey under which data is to be stored.
dataPointer to the data carried.
sizeNumber of bytes in data.

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

References ClientMonitorRecord::ch, GNUNET_DHT_MonitorPutMessage::desired_replication_level, env, GNUNET_DHT_MonitorPutMessage::expiration_time, GNUNET_array_append, GNUNET_BLOCK_TYPE_ANY, GNUNET_free_non_null, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_DHT_MonitorPutMessage::hop_count, ClientMonitorRecord::key, GNUNET_DHT_MonitorPutMessage::key, ClientQueryRecord::key, m, ClientHandle::mq, ClientMonitorRecord::next, GNUNET_DHT_MonitorPutMessage::options, GNUNET_DHT_MonitorPutMessage::put_path_length, size, ClientMonitorRecord::type, and GNUNET_DHT_MonitorPutMessage::type.

Referenced by handle_dht_local_put(), and handle_dht_p2p_put().

1379 {
1380  struct ClientMonitorRecord *m;
1381  struct ClientHandle **cl;
1382  unsigned int cl_size;
1383 
1384  cl = NULL;
1385  cl_size = 0;
1386  for (m = monitor_head; NULL != m; m = m->next)
1387  {
1388  if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
1389  (NULL == m->key ||
1390  memcmp (key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
1391  {
1392  struct GNUNET_MQ_Envelope *env;
1393  struct GNUNET_DHT_MonitorPutMessage *mmsg;
1394  struct GNUNET_PeerIdentity *msg_path;
1395  size_t msize;
1396  unsigned int i;
1397 
1398  /* Don't send duplicates */
1399  for (i = 0; i < cl_size; i++)
1400  if (cl[i] == m->ch)
1401  break;
1402  if (i < cl_size)
1403  continue;
1404  GNUNET_array_append (cl,
1405  cl_size,
1406  m->ch);
1407 
1408  msize = size;
1409  msize += path_length * sizeof (struct GNUNET_PeerIdentity);
1410  env = GNUNET_MQ_msg_extra (mmsg,
1411  msize,
1413  mmsg->options = htonl(options);
1414  mmsg->type = htonl(type);
1415  mmsg->hop_count = htonl(hop_count);
1416  mmsg->desired_replication_level = htonl (desired_replication_level);
1417  mmsg->put_path_length = htonl (path_length);
1418  mmsg->key = *key;
1420  msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1421  GNUNET_memcpy (msg_path,
1422  path,
1423  path_length * sizeof (struct GNUNET_PeerIdentity));
1424  GNUNET_memcpy (&msg_path[path_length],
1425  data,
1426  size);
1427  GNUNET_MQ_send (m->ch->mq,
1428  env);
1429  }
1430  }
1431  GNUNET_free_non_null (cl);
1432 }
struct ClientHandle * ch
Client to notify of these requests.
uint32_t hop_count
Hop count so far.
Definition: dht.h:254
struct GNUNET_HashCode * key
Key of data of interest, NULL for all.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT
Receive information about transiting PUTs.
Any type of block, used as a wildcard when searching.
static struct ClientMonitorRecord * monitor_head
List of active monitoring requests.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:259
struct ClientMonitorRecord * next
Next element in DLL.
uint32_t type
The type of data in the request.
Definition: dht.h:249
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
enum GNUNET_BLOCK_Type type
Type of blocks that are of interest.
#define GNUNET_memcpy(dst, src, n)
Message to monitor put requests going through peer, DHT service -> clients.
Definition: dht.h:234
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should this data persist?
Definition: dht.h:270
A 512-bit hashcode.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to this client.
uint32_t put_path_length
Number of peers recorded in the outgoing path from source to the storage location of this message...
Definition: dht.h:265
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
The identity of the host (wraps the signing key of the peer).
Struct containing paremeters of monitoring requests.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:244
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:275
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_init()

static void GDS_CLIENTS_init ( )
static

Initialize client subsystem.

Parameters
serverthe initialized server

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

References GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), and GNUNET_YES.

Referenced by run().

1442 {
1443  forward_map
1445  GNUNET_YES);
1446  retry_heap
1448 }
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. ...
Heap with the minimum cost at the root.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
static struct GNUNET_CONTAINER_Heap * retry_heap
Heap with all of our client&#39;s request, sorted by retry time (earliest on top).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_CLIENTS_stop()

static void GDS_CLIENTS_stop ( )
static

Shutdown client subsystem.

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

References GNUNET_SCHEDULER_cancel().

Referenced by shutdown_task().

1456 {
1457  if (NULL != retry_task)
1458  {
1460  retry_task = NULL;
1461  }
1462 }
static struct GNUNET_SCHEDULER_Task * retry_task
Task that re-transmits requests (using retry_heap).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __attribute__()

void __attribute__ ( (destructor)  )

MINIMIZE heap size (way below 128k) since this process doesn't need much.

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

References GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_multihashmap_destroy(), and GNUNET_CONTAINER_multihashmap_size().

1511 {
1512  if (NULL != retry_heap)
1513  {
1516  retry_heap = NULL;
1517  }
1518  if (NULL != forward_map)
1519  {
1522  forward_map = NULL;
1523  }
1524 }
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. ...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
static struct GNUNET_CONTAINER_Heap * retry_heap
Heap with all of our client&#39;s request, sorted by retry time (earliest on top).
Here is the call graph for this function:

Variable Documentation

◆ GDS_block_context

struct GNUNET_BLOCK_Context* GDS_block_context

◆ GDS_stats

struct GNUNET_STATISTICS_Handle* GDS_stats

◆ GDS_service

struct GNUNET_SERVICE_Handle* GDS_service

Handle for the service.

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

Referenced by core_init(), and run().

◆ GDS_cfg

const struct GNUNET_CONFIGURATION_Handle* GDS_cfg

The configuration the DHT service is running with.

Configuration we use.

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

Referenced by GDS_DATACACHE_init(), GDS_HELLO_init(), GDS_NEIGHBOURS_init(), GDS_NSE_init(), run(), and try_connect().

◆ monitor_head

struct ClientMonitorRecord* monitor_head
static

List of active monitoring requests.

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

Referenced by client_disconnect_cb().

◆ monitor_tail

struct ClientMonitorRecord* monitor_tail
static

List of active monitoring requests.

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

◆ forward_map

struct GNUNET_CONTAINER_MultiHashMap* forward_map
static

Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries.

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

◆ retry_heap

struct GNUNET_CONTAINER_Heap* retry_heap
static

Heap with all of our client's request, sorted by retry time (earliest on top).

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

◆ retry_task

struct GNUNET_SCHEDULER_Task* retry_task
static

Task that re-transmits requests (using retry_heap).

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