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 1466 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 261 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().

262 {
263  struct ClientHandle *ch = record->ch;
264 
266  ch->cqr_tail,
267  record);
270  &record->key,
271  record));
272  if (NULL != record->hnode)
275  record->seen_replies_count,
276  0);
277  GNUNET_free(record);
278 }
#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:77
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 291 of file gnunet-service-dht_clients.c.

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

294 {
295  struct ClientHandle *ch;
296 
297  ch = GNUNET_new(struct ClientHandle);
298  ch->client = client;
299  ch->mq = mq;
300  return ch;
301 }
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 313 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().

316 {
317  struct ClientHandle *ch = app_ctx;
318  struct ClientQueryRecord *cqr;
320 
322  "Local client %p disconnects\n",
323  ch);
324  monitor = monitor_head;
325  while (NULL != monitor)
326  {
327  if (monitor->ch == ch)
328  {
329  struct ClientMonitorRecord *next;
330 
331  next = monitor->next;
332  GNUNET_free_non_null(monitor->key);
334  monitor_tail,
335  monitor);
336  GNUNET_free(monitor);
337  monitor = next;
338  }
339  else
340  {
341  monitor = monitor->next;
342  }
343  }
344  while (NULL != (cqr = ch->cqr_head))
346  GNUNET_free(ch);
347 }
#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 356 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().

357 {
358  struct GNUNET_BLOCK_Group *bg;
359  struct GNUNET_CONTAINER_BloomFilter *peer_bf;
360 
362  gettext_noop("# GET requests from clients injected"),
363  1,
364  GNUNET_NO);
366  cqr->type,
368  UINT32_MAX),
369  NULL,
370  0,
371  "seen-set-size",
372  cqr->seen_replies_count,
373  NULL);
375  cqr->seen_replies,
376  cqr->seen_replies_count);
377  peer_bf
382  "Initiating GET for %s, replication %u, already have %u replies\n",
383  GNUNET_h2s(&cqr->key),
384  cqr->replication,
385  cqr->seen_replies_count);
387  cqr->msg_options,
388  cqr->replication,
389  0 /* hop count */,
390  &cqr->key,
391  cqr->xquery,
392  cqr->xquery_size,
393  bg,
394  peer_bf);
397 
398  /* exponential back-off for retries.
399  * max GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD (15 min) */
402 }
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:246
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:78
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:288
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:204
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:408
#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 413 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().

414 {
415  struct ClientQueryRecord *cqr;
417 
418  retry_task = NULL;
419  while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root(retry_heap)))
420  {
421  cqr->hnode = NULL;
423  if (delay.rel_value_us > 0)
424  {
425  cqr->hnode
427  cqr,
428  cqr->retry_time.abs_value_us);
429  retry_task
432  NULL);
433  return;
434  }
435  transmit_request(cqr);
436  cqr->hnode
438  cqr,
439  cqr->retry_time.abs_value_us);
440  }
441 }
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:1214
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 452 of file gnunet-service-dht_clients.c.

References GNUNET_OK.

454 {
455  /* always well-formed */
456  return GNUNET_OK;
457 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ 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 467 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.

469 {
470  struct ClientHandle *ch = cls;
471  struct GNUNET_CONTAINER_BloomFilter *peer_bf;
472  uint16_t size;
473 
474  size = ntohs(dht_msg->header.size);
476  gettext_noop("# PUT requests received from clients"),
477  1,
478  GNUNET_NO);
480  "CLIENT-PUT %s\n",
481  GNUNET_h2s_full(&dht_msg->key));
482  /* give to local clients */
484  "Handling local PUT of %u-bytes for query %s\n",
485  size - sizeof(struct GNUNET_DHT_ClientPutMessage),
486  GNUNET_h2s(&dht_msg->key));
488  &dht_msg->key,
489  0,
490  NULL,
491  0,
492  NULL,
493  ntohl(dht_msg->type),
494  size - sizeof(struct GNUNET_DHT_ClientPutMessage),
495  &dht_msg[1]);
496  /* store locally */
498  &dht_msg->key,
499  0,
500  NULL,
501  ntohl(dht_msg->type),
502  size - sizeof(struct GNUNET_DHT_ClientPutMessage),
503  &dht_msg[1]);
504  /* route to other peers */
505  peer_bf
509  GDS_NEIGHBOURS_handle_put(ntohl(dht_msg->type),
510  ntohl(dht_msg->options),
511  ntohl(dht_msg->desired_replication_level),
513  0 /* hop count */,
514  peer_bf,
515  &dht_msg->key,
516  0,
517  NULL,
518  &dht_msg[1],
519  size - sizeof(struct GNUNET_DHT_ClientPutMessage));
520  GDS_CLIENTS_process_put(ntohl(dht_msg->options),
521  ntohl(dht_msg->type),
522  0,
523  ntohl(dht_msg->desired_replication_level),
524  1,
527  &dht_msg->key,
528  &dht_msg[1],
529  size - sizeof(struct GNUNET_DHT_ClientPutMessage));
532 }
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:671
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:186
#define GNUNET_NO
Definition: gnunet_common.h:78
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:205
uint32_t type
The type of data to insert.
Definition: dht.h:195
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:200
struct GNUNET_SERVICE_Client * client
The handle to this client.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT.
Definition: dht.h:190
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:210
static unsigned int size
Size of the "table".
Definition: peer.c:66
#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:215
#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:2234
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 543 of file gnunet-service-dht_clients.c.

References GNUNET_OK.

545 {
546  /* always well-formed */
547  return GNUNET_OK;
548 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ 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 566 of file gnunet-service-dht_clients.c.

References GDS_CLIENTS_handle_reply().

Referenced by handle_dht_local_get().

576 {
577  // FIXME: this needs some clean up: inline the function,
578  // possibly avoid even looking up the client!
579  GDS_CLIENTS_handle_reply(expiration_time,
580  key,
581  0, NULL,
582  put_path_length, put_path,
583  type,
584  data_size, data);
585 }
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 595 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.

597 {
598  struct ClientHandle *ch = cls;
599  struct ClientQueryRecord *cqr;
600  size_t xquery_size;
601  const char *xquery;
602  uint16_t size;
603 
604  size = ntohs(get->header.size);
605  xquery_size = size - sizeof(struct GNUNET_DHT_ClientGetMessage);
606  xquery = (const char *)&get[1];
609  ("# GET requests received from clients"), 1,
610  GNUNET_NO);
612  "Received GET request for %s from local client %p, xq: %.*s\n",
613  GNUNET_h2s(&get->key),
614  ch->client,
615  xquery_size,
616  xquery);
618  "CLIENT-GET %s\n",
619  GNUNET_h2s_full(&get->key));
620 
621  cqr = GNUNET_malloc(sizeof(struct ClientQueryRecord) + xquery_size);
622  cqr->key = get->key;
623  cqr->ch = ch;
624  cqr->xquery = (void *)&cqr[1];
625  GNUNET_memcpy(&cqr[1], xquery, xquery_size);
629  cqr->unique_id = get->unique_id;
630  cqr->xquery_size = xquery_size;
631  cqr->replication = ntohl(get->desired_replication_level);
632  cqr->msg_options = ntohl(get->options);
633  cqr->type = ntohl(get->type);
635  ch->cqr_tail,
636  cqr);
638  &cqr->key,
639  cqr,
641  GDS_CLIENTS_process_get(ntohl(get->options),
642  ntohl(get->type),
643  0,
644  ntohl(get->desired_replication_level),
645  1,
647  &get->key);
648  /* start remote requests */
649  if (NULL != retry_task)
652  NULL);
653  /* perform local lookup */
655  cqr->type,
656  cqr->xquery,
657  xquery_size,
658  NULL,
660  ch);
662 }
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:95
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
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:79
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.
uint32_t type
The type for the data for the GET request; actually an 'enum GNUNET_BLOCK_Type'.
Definition: dht.h:90
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:1264
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:66
#define LOG(kind,...)
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET.
Definition: dht.h:74
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:70
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:84
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:2234
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:956
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 689 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().

692 {
693  struct FindByUniqueIdContext *fui_ctx = cls;
694  struct ClientQueryRecord *cqr = value;
695 
696  if (cqr->unique_id != fui_ctx->unique_id)
697  return GNUNET_YES;
698  fui_ctx->cqr = cqr;
699  return GNUNET_NO;
700 }
uint64_t unique_id
The unique identifier of this request.
#define GNUNET_NO
Definition: gnunet_common.h:78
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:77
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 711 of file gnunet-service-dht_clients.c.

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

713 {
714  uint16_t size;
715  unsigned int hash_count;
716 
717  size = ntohs(seen->header.size);
718  hash_count = (size - sizeof(struct GNUNET_DHT_ClientGetResultSeenMessage)) / sizeof(struct GNUNET_HashCode);
719  if (size != sizeof(struct GNUNET_DHT_ClientGetResultSeenMessage) + hash_count * sizeof(struct GNUNET_HashCode))
720  {
721  GNUNET_break(0);
722  return GNUNET_SYSERR;
723  }
724  return GNUNET_OK;
725 }
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:111
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN.
Definition: dht.h:115

◆ 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 735 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.

737 {
738  struct ClientHandle *ch = cls;
739  uint16_t size;
740  unsigned int hash_count;
741  unsigned int old_count;
742  const struct GNUNET_HashCode *hc;
743  struct FindByUniqueIdContext fui_ctx;
744  struct ClientQueryRecord *cqr;
745 
746  size = ntohs(seen->header.size);
747  hash_count = (size - sizeof(struct GNUNET_DHT_ClientGetResultSeenMessage)) / sizeof(struct GNUNET_HashCode);
748  hc = (const struct GNUNET_HashCode*)&seen[1];
749  fui_ctx.unique_id = seen->unique_id;
750  fui_ctx.cqr = NULL;
752  &seen->key,
754  &fui_ctx);
755  if (NULL == (cqr = fui_ctx.cqr))
756  {
757  GNUNET_break(0);
759  return;
760  }
761  /* finally, update 'seen' list */
762  old_count = cqr->seen_replies_count;
764  cqr->seen_replies_count,
765  cqr->seen_replies_count + hash_count);
766  GNUNET_memcpy(&cqr->seen_replies[old_count],
767  hc,
768  sizeof(struct GNUNET_HashCode) * hash_count);
769 }
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:111
static struct GNUNET_CONTAINER_MultiHashMap * forward_map
Hashmap for fast key based lookup, maps keys to struct ClientQueryRecord entries. ...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:131
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:2315
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:66
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:115
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:126
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 798 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().

801 {
802  const struct RemoveByUniqueIdContext *ctx = cls;
803  struct ClientQueryRecord *cqr = value;
804 
805  if (cqr->unique_id != ctx->unique_id)
806  return GNUNET_YES;
808  "Removing client %p's record for key %s (by unique id)\n",
809  ctx->ch->client,
810  GNUNET_h2s(key));
812  return GNUNET_YES;
813 }
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:77
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 825 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.

827 {
828  struct ClientHandle *ch = cls;
830 
833  ("# GET STOP requests received from clients"), 1,
834  GNUNET_NO);
836  "Received GET STOP request for %s from local client %p\n",
837  GNUNET_h2s(&dht_stop_msg->key),
838  ch->client);
839  ctx.ch = ch;
840  ctx.unique_id = dht_stop_msg->unique_id;
842  &dht_stop_msg->key,
844  &ctx);
846 }
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:78
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:57
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:62
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:2234
#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 857 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.

859 {
860  struct ClientHandle *ch = cls;
861  struct ClientMonitorRecord *r;
862 
863  r = GNUNET_new(struct ClientMonitorRecord);
864  r->ch = ch;
865  r->type = ntohl(msg->type);
866  r->get = ntohs(msg->get);
867  r->get_resp = ntohs(msg->get_resp);
868  r->put = ntohs(msg->put);
869  if (0 == ntohs(msg->filter_key))
870  {
871  r->key = NULL;
872  }
873  else
874  {
875  r->key = GNUNET_new(struct GNUNET_HashCode);
876  GNUNET_memcpy(r->key,
877  &msg->key,
878  sizeof(struct GNUNET_HashCode));
879  }
881  monitor_tail,
882  r);
884 }
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:285
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:295
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.
int16_t filter_key
Flag whether to use the provided key to filter messages.
Definition: dht.h:305
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:300
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:290
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:310
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
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 894 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.

896 {
897  struct ClientHandle *ch = cls;
898  struct ClientMonitorRecord *r;
899  int keys_match;
900 
902  for (r = monitor_head; NULL != r; r = r->next)
903  {
904  if (NULL == r->key)
905  {
906  keys_match = (0 == ntohs(msg->filter_key));
907  }
908  else
909  {
910  keys_match = ((0 != ntohs(msg->filter_key)) &&
911  (!memcmp(r->key,
912  &msg->key,
913  sizeof(struct GNUNET_HashCode))));
914  }
915  if ((ch == r->ch) &&
916  (ntohl(msg->type) == r->type) &&
917  (r->get == msg->get) &&
918  (r->get_resp == msg->get_resp) &&
919  (r->put == msg->put) &&
920  keys_match)
921  {
923  monitor_tail,
924  r);
926  GNUNET_free(r);
927  return; /* Delete only ONE entry */
928  }
929  }
930 }
#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:285
struct ClientMonitorRecord * next
Next element in DLL.
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:295
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:305
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:300
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:290
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:310
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
#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 991 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, record(), 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().

994 {
995  struct ForwardReplyContext *frc = cls;
996  struct ClientQueryRecord *record = value;
997  struct GNUNET_MQ_Envelope *env;
998  struct GNUNET_DHT_ClientResultMessage *reply;
1000  int do_free;
1001  struct GNUNET_HashCode ch;
1002  struct GNUNET_PeerIdentity *paths;
1003 
1005  "CLIENT-RESULT %s\n",
1006  GNUNET_h2s_full(key));
1007  if ((record->type != GNUNET_BLOCK_TYPE_ANY) &&
1008  (record->type != frc->type))
1009  {
1011  "Record type mismatch, not passing request for key %s to local client\n",
1012  GNUNET_h2s(key));
1014  gettext_noop
1015  ("# Key match, type mismatches in REPLY to CLIENT"),
1016  1, GNUNET_NO);
1017  return GNUNET_YES; /* type mismatch */
1018  }
1019  GNUNET_CRYPTO_hash(frc->data, frc->data_size, &ch);
1020  for (unsigned int i = 0; i < record->seen_replies_count; i++)
1021  if (0 == memcmp(&record->seen_replies[i],
1022  &ch,
1023  sizeof(struct GNUNET_HashCode)))
1024  {
1026  "Duplicate reply, not passing request for key %s to local client\n",
1027  GNUNET_h2s(key));
1029  gettext_noop
1030  ("# Duplicate REPLIES to CLIENT request dropped"),
1031  1, GNUNET_NO);
1032  return GNUNET_YES; /* duplicate */
1033  }
1034  eval
1036  record->type,
1037  NULL,
1039  key,
1040  record->xquery,
1041  record->xquery_size,
1042  frc->data,
1043  frc->data_size);
1045  "Evaluation result is %d for key %s for local client's query\n",
1046  (int)eval,
1047  GNUNET_h2s(key));
1048  switch (eval)
1049  {
1051  do_free = GNUNET_YES;
1052  break;
1053 
1056  record->seen_replies_count,
1057  ch);
1058  do_free = GNUNET_NO;
1059  break;
1060 
1062  /* should be impossible to encounter here */
1063  GNUNET_break(0);
1064  return GNUNET_YES;
1065 
1067  GNUNET_break_op(0);
1068  return GNUNET_NO;
1069 
1071  GNUNET_break(0);
1072  return GNUNET_NO;
1073 
1075  GNUNET_break(0);
1076  return GNUNET_NO;
1077 
1079  return GNUNET_YES;
1080 
1083  _("Unsupported block type (%u) in request!\n"), record->type);
1084  return GNUNET_NO;
1085 
1086  default:
1087  GNUNET_break(0);
1088  return GNUNET_NO;
1089  }
1091  gettext_noop("# RESULTS queued for clients"),
1092  1,
1093  GNUNET_NO);
1094  env = GNUNET_MQ_msg_extra(reply,
1095  frc->data_size +
1096  (frc->get_path_length + frc->put_path_length) * sizeof(struct GNUNET_PeerIdentity),
1098  reply->type = htonl(frc->type);
1099  reply->get_path_length = htonl(frc->get_path_length);
1100  reply->put_path_length = htonl(frc->put_path_length);
1101  reply->unique_id = record->unique_id;
1103  reply->key = *key;
1104  paths = (struct GNUNET_PeerIdentity *)&reply[1];
1105  GNUNET_memcpy(paths,
1106  frc->put_path,
1107  sizeof(struct GNUNET_PeerIdentity) * frc->put_path_length);
1108  GNUNET_memcpy(&paths[frc->put_path_length],
1109  frc->get_path,
1110  sizeof(struct GNUNET_PeerIdentity) * frc->get_path_length);
1111  GNUNET_memcpy(&paths[frc->get_path_length + frc->put_path_length],
1112  frc->data,
1113  frc->data_size);
1115  "Sending reply to query %s for client %p\n",
1116  GNUNET_h2s(key),
1117  record->ch->client);
1118  GNUNET_MQ_send(record->ch->mq,
1119  env);
1120  if (GNUNET_YES == do_free)
1121  remove_client_record(record);
1122  return GNUNET_YES;
1123 }
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:167
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:156
Any type of block, used as a wildcard when searching.
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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Block does not match xquery (valid result, not relevant for the request)
#define GNUNET_NO
Definition: gnunet_common.h:78
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:181
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
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:177
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:337
Last possible valid result.
struct GNUNET_TIME_AbsoluteNBO expiration
When does this entry expire?
Definition: dht.h:172
uint32_t type
The type for the data.
Definition: dht.h:150
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:162
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.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
const struct GNUNET_PeerIdentity * get_path
GET path taken.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
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:655
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:141
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 1142 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().

1151 {
1152  struct ForwardReplyContext frc;
1153  size_t msize;
1154 
1155  msize = sizeof(struct GNUNET_DHT_ClientResultMessage) + data_size +
1157  if (msize >= GNUNET_MAX_MESSAGE_SIZE)
1158  {
1159  GNUNET_break(0);
1160  return;
1161  }
1163  key))
1164  {
1166  "No matching client for reply for key %s\n",
1167  GNUNET_h2s(key));
1169  gettext_noop("# REPLIES ignored for CLIENTS (no match)"),
1170  1,
1171  GNUNET_NO);
1172  return; /* no matching request, fast exit! */
1173  }
1174  frc.expiration = expiration;
1175  frc.get_path = get_path;
1176  frc.put_path = put_path;
1177  frc.data = data;
1178  frc.data_size = data_size;
1179  frc.get_path_length = get_path_length;
1180  frc.put_path_length = put_path_length;
1181  frc.type = type;
1183  "Forwarding reply for key %s to client\n",
1184  GNUNET_h2s(key));
1186  key,
1187  &forward_reply,
1188  &frc);
1189 }
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:156
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:78
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:162
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:141
#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 1205 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().

1212 {
1213  struct ClientMonitorRecord *m;
1214  struct ClientHandle **cl;
1215  unsigned int cl_size;
1216 
1217  cl = NULL;
1218  cl_size = 0;
1219  for (m = monitor_head; NULL != m; m = m->next)
1220  {
1221  if (((GNUNET_BLOCK_TYPE_ANY == m->type) ||
1222  (m->type == type)) &&
1223  ((NULL == m->key) ||
1224  (0 == memcmp(key,
1225  m->key,
1226  sizeof(struct GNUNET_HashCode)))))
1227  {
1228  struct GNUNET_MQ_Envelope *env;
1229  struct GNUNET_DHT_MonitorGetMessage *mmsg;
1230  struct GNUNET_PeerIdentity *msg_path;
1231  size_t msize;
1232  unsigned int i;
1233 
1234  /* Don't send duplicates */
1235  for (i = 0; i < cl_size; i++)
1236  if (cl[i] == m->ch)
1237  break;
1238  if (i < cl_size)
1239  continue;
1241  cl_size,
1242  m->ch);
1243 
1244  msize = path_length * sizeof(struct GNUNET_PeerIdentity);
1245  env = GNUNET_MQ_msg_extra(mmsg,
1246  msize,
1248  mmsg->options = htonl(options);
1249  mmsg->type = htonl(type);
1250  mmsg->hop_count = htonl(hop_count);
1251  mmsg->desired_replication_level = htonl(desired_replication_level);
1252  mmsg->get_path_length = htonl(path_length);
1253  mmsg->key = *key;
1254  msg_path = (struct GNUNET_PeerIdentity *)&mmsg[1];
1255  GNUNET_memcpy(msg_path,
1256  path,
1257  path_length * sizeof(struct GNUNET_PeerIdentity));
1258  GNUNET_MQ_send(m->ch->mq,
1259  env);
1260  }
1261  }
1263 }
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:326
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:352
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:347
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:341
#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:331
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Message to monitor get requests going through peer, DHT service -> clients.
Definition: dht.h:317
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:351
uint32_t hop_count
Hop count.
Definition: dht.h:336
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 1281 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().

1290 {
1291  struct ClientMonitorRecord *m;
1292  struct ClientHandle **cl;
1293  unsigned int cl_size;
1294 
1295  cl = NULL;
1296  cl_size = 0;
1297  for (m = monitor_head; NULL != m; m = m->next)
1298  {
1299  if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
1300  (NULL == m->key ||
1301  memcmp(key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
1302  {
1303  struct GNUNET_MQ_Envelope *env;
1304  struct GNUNET_DHT_MonitorGetRespMessage *mmsg;
1305  struct GNUNET_PeerIdentity *path;
1306  size_t msize;
1307  unsigned int i;
1308 
1309  /* Don't send duplicates */
1310  for (i = 0; i < cl_size; i++)
1311  if (cl[i] == m->ch)
1312  break;
1313  if (i < cl_size)
1314  continue;
1316  cl_size,
1317  m->ch);
1318 
1319  msize = size;
1320  msize += (get_path_length + put_path_length)
1321  * sizeof(struct GNUNET_PeerIdentity);
1322  env = GNUNET_MQ_msg_extra(mmsg,
1323  msize,
1325  mmsg->type = htonl(type);
1326  mmsg->put_path_length = htonl(put_path_length);
1327  mmsg->get_path_length = htonl(get_path_length);
1329  mmsg->key = *key;
1330  path = (struct GNUNET_PeerIdentity *)&mmsg[1];
1331  GNUNET_memcpy(path,
1332  put_path,
1333  put_path_length * sizeof(struct GNUNET_PeerIdentity));
1334  GNUNET_memcpy(path,
1335  get_path,
1336  get_path_length * sizeof(struct GNUNET_PeerIdentity));
1337  GNUNET_memcpy(&path[get_path_length],
1338  data,
1339  size);
1340  GNUNET_MQ_send(m->ch->mq,
1341  env);
1342  }
1343  }
1345 }
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:379
struct GNUNET_HashCode key
The key of the corresponding GET request.
Definition: dht.h:389
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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:374
#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.
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:66
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:369
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:351
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
Definition: dht.h:384
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:655
Message to monitor get results going through peer, DHT service -> clients.
Definition: dht.h:360
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 1364 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().

1374 {
1375  struct ClientMonitorRecord *m;
1376  struct ClientHandle **cl;
1377  unsigned int cl_size;
1378 
1379  cl = NULL;
1380  cl_size = 0;
1381  for (m = monitor_head; NULL != m; m = m->next)
1382  {
1383  if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
1384  (NULL == m->key ||
1385  memcmp(key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
1386  {
1387  struct GNUNET_MQ_Envelope *env;
1388  struct GNUNET_DHT_MonitorPutMessage *mmsg;
1389  struct GNUNET_PeerIdentity *msg_path;
1390  size_t msize;
1391  unsigned int i;
1392 
1393  /* Don't send duplicates */
1394  for (i = 0; i < cl_size; i++)
1395  if (cl[i] == m->ch)
1396  break;
1397  if (i < cl_size)
1398  continue;
1400  cl_size,
1401  m->ch);
1402 
1403  msize = size;
1404  msize += path_length * sizeof(struct GNUNET_PeerIdentity);
1405  env = GNUNET_MQ_msg_extra(mmsg,
1406  msize,
1408  mmsg->options = htonl(options);
1409  mmsg->type = htonl(type);
1410  mmsg->hop_count = htonl(hop_count);
1411  mmsg->desired_replication_level = htonl(desired_replication_level);
1412  mmsg->put_path_length = htonl(path_length);
1413  mmsg->key = *key;
1415  msg_path = (struct GNUNET_PeerIdentity *)&mmsg[1];
1416  GNUNET_memcpy(msg_path,
1417  path,
1418  path_length * sizeof(struct GNUNET_PeerIdentity));
1419  GNUNET_memcpy(&msg_path[path_length],
1420  data,
1421  size);
1422  GNUNET_MQ_send(m->ch->mq,
1423  env);
1424  }
1425  }
1427 }
struct ClientHandle * ch
Client to notify of these requests.
uint32_t hop_count
Hop count so far.
Definition: dht.h:243
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:248
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct ClientMonitorRecord * next
Next element in DLL.
uint32_t type
The type of data in the request.
Definition: dht.h:238
#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.
Message to monitor put requests going through peer, DHT service -> clients.
Definition: dht.h:224
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should this data persist?
Definition: dht.h:259
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:66
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:254
#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:351
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:233
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:655
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:264
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 1436 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().

1437 {
1438  forward_map
1440  GNUNET_YES);
1441  retry_heap
1443 }
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:77
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 1450 of file gnunet-service-dht_clients.c.

References GNUNET_SCHEDULER_cancel().

Referenced by shutdown_task().

1451 {
1452  if (NULL != retry_task)
1453  {
1455  retry_task = NULL;
1456  }
1457 }
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:956
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 1504 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().

1506 {
1507  if (NULL != retry_heap)
1508  {
1511  retry_heap = NULL;
1512  }
1513  if (NULL != forward_map)
1514  {
1517  forward_map = NULL;
1518  }
1519 }
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 222 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 227 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 232 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 237 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 242 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 247 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 252 of file gnunet-service-dht_clients.c.