GNUnet  0.20.0
namestore_api.c File Reference

API to access the NAMESTORE service. More...

#include "platform.h"
#include "gnunet_error_codes.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
#include "gnunet_signatures.h"
#include "gnunet_gns_service.h"
#include "gnunet_namestore_service.h"
#include "namestore.h"
Include dependency graph for namestore_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_NAMESTORE_QueueEntry
 An QueueEntry used to store information for a pending NAMESTORE record operation. More...
 
struct  GNUNET_NAMESTORE_ZoneIterator
 Handle for a zone iterator operation. More...
 
struct  GNUNET_NAMESTORE_Handle
 Connection to the NAMESTORE service. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "namestore-api", __VA_ARGS__)
 
#define NAMESTORE_DELAY_TOLERANCE   GNUNET_TIME_UNIT_MINUTES
 We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail. More...
 

Functions

static void force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
 Disconnect from service and then reconnect. More...
 
static struct GNUNET_NAMESTORE_QueueEntryfind_qe (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
 Find the queue entry that matches the rid. More...
 
static struct GNUNET_NAMESTORE_ZoneIteratorfind_zi (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
 Find the zone iteration entry that matches the rid. More...
 
static void free_qe (struct GNUNET_NAMESTORE_QueueEntry *qe)
 Free qe. More...
 
static void free_ze (struct GNUNET_NAMESTORE_ZoneIterator *ze)
 Free ze. More...
 
static int check_rd (size_t rd_len, const void *rd_buf, unsigned int rd_count)
 Check that rd_buf of length rd_len contains rd_count records. More...
 
static void handle_record_store_response (void *cls, const struct RecordStoreResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE. More...
 
static int check_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg)
 Check validity of an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE. More...
 
static void handle_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE. More...
 
static int check_record_result (void *cls, const struct RecordResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT. More...
 
static void handle_record_result (void *cls, const struct RecordResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT. More...
 
static void handle_record_result_end (void *cls, const struct GNUNET_NAMESTORE_Header *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END. More...
 
static void handle_tx_control_result (void *cls, const struct TxControlResultMessage *msg)
 
static int check_zone_to_name_response (void *cls, const struct ZoneToNameResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE. More...
 
static void handle_zone_to_name_response (void *cls, const struct ZoneToNameResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void reconnect (struct GNUNET_NAMESTORE_Handle *h)
 Reconnect to namestore service. More...
 
static void reconnect_task (void *cls)
 Re-establish the connection to the service. More...
 
static uint32_t get_op_id (struct GNUNET_NAMESTORE_Handle *h)
 Get a fresh operation id to distinguish between namestore requests. More...
 
struct GNUNET_NAMESTORE_HandleGNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the connection with the NAMESTORE service. More...
 
void GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
 Disconnect from the namestore service (and free associated resources). More...
 
static void warn_delay (void *cls)
 Task launched to warn the user that the namestore is excessively slow and that a query was thus dropped. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Store an item in the namestore. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_store2 (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, unsigned int rd_set_count, const struct GNUNET_NAMESTORE_RecordInfo *record_info, unsigned int *rds_sent, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Store one or more record sets in the namestore. More...
 
static struct GNUNET_NAMESTORE_QueueEntryrecords_lookup (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, int is_edit_request, enum GNUNET_GNSRECORD_Filter filter)
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
 Lookup an item in the namestore. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, enum GNUNET_GNSRECORD_Filter filter)
 Lookup an item in the namestore with GNSRECORD filter. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_edit (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, const struct GNUNET_IDENTITY_PublicKey *value_zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
 Look for an existing PKEY delegation record for a given public key. More...
 
struct GNUNET_NAMESTORE_ZoneIteratorGNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
 
struct GNUNET_NAMESTORE_ZoneIteratorGNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
 Starts a new zone iteration (used to periodically PUT all of our records into our DHT). More...
 
void GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
 Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record. More...
 
void GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
 Stops iteration and releases the namestore handle for further calls. More...
 
void GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
 Cancel a namestore operation. More...
 
static struct GNUNET_NAMESTORE_QueueEntrysend_transaction_control_msg (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls, enum GNUNET_NAMESTORE_TxControl ctrl)
 New API draft. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 New API draft. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Commit a namestore transaction. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Begin rollback all actions in a transaction. More...
 

Detailed Description

API to access the NAMESTORE service.

Author
Martin Schanzenbach
Matthias Wachs
Christian Grothoff

Definition in file namestore_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "namestore-api", __VA_ARGS__)

Definition at line 40 of file namestore_api.c.

◆ NAMESTORE_DELAY_TOLERANCE

#define NAMESTORE_DELAY_TOLERANCE   GNUNET_TIME_UNIT_MINUTES

We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail.

Definition at line 46 of file namestore_api.c.

Function Documentation

◆ force_reconnect()

static void force_reconnect ( struct GNUNET_NAMESTORE_Handle h)
static

Disconnect from service and then reconnect.

Parameters
hour handle

Definition at line 920 of file namestore_api.c.

921 {
924 
926  h->mq = NULL;
927  while (NULL != (ze = h->z_head))
928  {
929  if (NULL != ze->error_cb)
930  ze->error_cb (ze->error_cb_cls);
931  free_ze (ze);
932  }
933  while (NULL != (qe = h->op_head))
934  {
935  if (NULL != qe->error_cb)
936  qe->error_cb (qe->error_cb_cls);
937  if (NULL != qe->cont)
938  qe->cont (qe->cont_cls,
940  free_qe (qe);
941  }
942 
943  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to namestore\n");
944  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
945  h->reconnect_task =
946  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect_task, h);
947 }
@ GNUNET_EC_NAMESTORE_UNKNOWN
Unknown namestore error.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1272
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void free_qe(struct GNUNET_NAMESTORE_QueueEntry *qe)
Free qe.
static void free_ze(struct GNUNET_NAMESTORE_ZoneIterator *ze)
Free ze.
static void reconnect_task(void *cls)
Re-establish the connection to the service.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
GNUNET_DATASTORE_ContinuationWithStatus cont
Function to call after transmission of the request.
void * cont_cls
Closure for cont.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:53
Handle for a zone iterator operation.
void * error_cb_cls
Closure for error_cb.
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, GNUNET_NAMESTORE_ZoneIterator::error_cb, GNUNET_NAMESTORE_ZoneIterator::error_cb_cls, free_qe(), free_ze(), GNUNET_EC_NAMESTORE_UNKNOWN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, GNUNET_ARM_Handle::mq, qe, GNUNET_ARM_Handle::reconnect_task, and reconnect_task().

Referenced by handle_record_result(), handle_record_result_end(), and mq_error_handler().

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

◆ find_qe()

static struct GNUNET_NAMESTORE_QueueEntry* find_qe ( struct GNUNET_NAMESTORE_Handle h,
uint32_t  rid 
)
static

Find the queue entry that matches the rid.

Parameters
hnamestore handle
ridid to look up
Returns
NULL if rid was not found

Definition at line 269 of file namestore_api.c.

270 {
272 
273  for (qe = h->op_head; qe != NULL; qe = qe->next)
274  if (qe->op_id == rid)
275  return qe;
276  return NULL;
277 }
struct GNUNET_DATASTORE_QueueEntry * next
This is a linked list.

References h, GNUNET_DATASTORE_QueueEntry::next, and qe.

Referenced by handle_lookup_result(), handle_record_result(), handle_record_result_end(), handle_record_store_response(), handle_tx_control_result(), and handle_zone_to_name_response().

Here is the caller graph for this function:

◆ find_zi()

static struct GNUNET_NAMESTORE_ZoneIterator* find_zi ( struct GNUNET_NAMESTORE_Handle h,
uint32_t  rid 
)
static

Find the zone iteration entry that matches the rid.

Parameters
hnamestore handle
ridid to look up
Returns
NULL if rid was not found

Definition at line 288 of file namestore_api.c.

289 {
291 
292  for (ze = h->z_head; ze != NULL; ze = ze->next)
293  if (ze->op_id == rid)
294  return ze;
295  return NULL;
296 }
struct GNUNET_NAMESTORE_ZoneIterator * next
Kept in a DLL.
uint32_t op_id
The operation id this zone iteration operation has.

References h, GNUNET_NAMESTORE_ZoneIterator::next, and GNUNET_NAMESTORE_ZoneIterator::op_id.

Referenced by handle_record_result(), and handle_record_result_end().

Here is the caller graph for this function:

◆ free_qe()

static void free_qe ( struct GNUNET_NAMESTORE_QueueEntry qe)
static

Free qe.

Parameters
qeentry to free

Definition at line 305 of file namestore_api.c.

306 {
307  struct GNUNET_NAMESTORE_Handle *h = qe->h;
308 
309  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, qe);
310  if (NULL != qe->env)
312  if (NULL != qe->timeout_task)
313  GNUNET_SCHEDULER_cancel (qe->timeout_task);
314  GNUNET_free (qe);
315 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:285
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
Connection to the NAMESTORE service.

References GNUNET_DATASTORE_QueueEntry::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), GNUNET_SCHEDULER_cancel(), h, GNUNET_DATASTORE_QueueEntry::h, and qe.

Referenced by force_reconnect(), GNUNET_NAMESTORE_cancel(), handle_lookup_result(), handle_record_result(), handle_record_store_response(), handle_tx_control_result(), and handle_zone_to_name_response().

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

◆ free_ze()

static void free_ze ( struct GNUNET_NAMESTORE_ZoneIterator ze)
static

Free ze.

Parameters
zeentry to free

Definition at line 324 of file namestore_api.c.

325 {
326  struct GNUNET_NAMESTORE_Handle *h = ze->h;
327 
328  GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, ze);
329  if (NULL != ze->env)
330  GNUNET_MQ_discard (ze->env);
331  GNUNET_free (ze);
332 }
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.

References GNUNET_NAMESTORE_ZoneIterator::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), h, and GNUNET_NAMESTORE_ZoneIterator::h.

Referenced by force_reconnect(), GNUNET_NAMESTORE_zone_iteration_stop(), and handle_record_result_end().

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

◆ check_rd()

static int check_rd ( size_t  rd_len,
const void *  rd_buf,
unsigned int  rd_count 
)
static

Check that rd_buf of length rd_len contains rd_count records.

Parameters
rd_lenlength of rd_buf
rd_bufbuffer with serialized records
rd_countnumber of records expected
Returns
GNUNET_OK if rd_buf is well-formed

Definition at line 345 of file namestore_api.c.

346 {
348 
349  if (GNUNET_OK !=
351  {
352  GNUNET_break (0);
353  return GNUNET_SYSERR;
354  }
355  return GNUNET_OK;
356 }
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_break, GNUNET_GNSRECORD_records_deserialize(), GNUNET_OK, GNUNET_SYSERR, rd, and rd_count.

Referenced by check_lookup_result(), check_record_result(), and check_zone_to_name_response().

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

◆ handle_record_store_response()

static void handle_record_store_response ( void *  cls,
const struct RecordStoreResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 366 of file namestore_api.c.

368 {
369  struct GNUNET_NAMESTORE_Handle *h = cls;
371  enum GNUNET_ErrorCode res;
372 
373  qe = find_qe (h, ntohl (msg->gns_header.r_id));
374  res = ntohl (msg->ec);
376  "Received RECORD_STORE_RESPONSE with result %d\n",
377  res);
378  if (NULL == qe)
379  return;
380  if (NULL != qe->cont)
381  qe->cont (qe->cont_cls, res);
382  free_qe (qe);
383 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_ErrorCode
Taler error codes.
static int res
static struct GNUNET_NAMESTORE_QueueEntry * find_qe(struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
Find the queue entry that matches the rid.
#define LOG(kind,...)
Definition: namestore_api.c:40

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, h, LOG, msg, qe, and res.

Here is the call graph for this function:

◆ check_lookup_result()

static int check_lookup_result ( void *  cls,
const struct LabelLookupResponseMessage msg 
)
static

Check validity of an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 395 of file namestore_api.c.

396 {
397  const char *name;
398  size_t exp_msg_len;
399  size_t msg_len;
400  size_t name_len;
401  size_t rd_len;
402  size_t key_len;
403 
404  (void) cls;
405  rd_len = ntohs (msg->rd_len);
406  msg_len = ntohs (msg->gns_header.header.size);
407  name_len = ntohs (msg->name_len);
408  key_len = ntohs (msg->key_len);
409  exp_msg_len = sizeof(*msg) + name_len + rd_len + key_len;
410  if (0 != ntohs (msg->reserved))
411  {
412  GNUNET_break (0);
413  return GNUNET_SYSERR;
414  }
415  if (msg_len != exp_msg_len)
416  {
417  GNUNET_break (0);
418  return GNUNET_SYSERR;
419  }
420  name = (const char *) &msg[1] + key_len;
421  if ((name_len > 0) && ('\0' != name[name_len - 1]))
422  {
423  GNUNET_break (0);
424  return GNUNET_SYSERR;
425  }
426  if (GNUNET_NO == ntohs (msg->found))
427  {
428  if (0 != ntohs (msg->rd_count))
429  {
430  GNUNET_break (0);
431  return GNUNET_SYSERR;
432  }
433  return GNUNET_OK;
434  }
435  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
436 }
@ GNUNET_NO
static int check_rd(size_t rd_len, const void *rd_buf, unsigned int rd_count)
Check that rd_buf of length rd_len contains rd_count records.
const char * name
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References check_rd(), GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, msg, name, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_lookup_result()

static void handle_lookup_result ( void *  cls,
const struct LabelLookupResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 447 of file namestore_api.c.

448 {
449  struct GNUNET_NAMESTORE_Handle *h = cls;
451  struct GNUNET_IDENTITY_PrivateKey private_key;
452  const char *name;
453  const char *rd_tmp;
454  size_t name_len;
455  size_t rd_len;
456  size_t key_len;
457  size_t kbytes_read;
458  unsigned int rd_count;
459  int16_t found = (int16_t) ntohs (msg->found);
460 
461  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_LOOKUP_RESULT (found=%i)\n",
462  found);
463  qe = find_qe (h, ntohl (msg->gns_header.r_id));
464  if (NULL == qe)
465  return;
466  rd_len = ntohs (msg->rd_len);
467  rd_count = ntohs (msg->rd_count);
468  name_len = ntohs (msg->name_len);
469  key_len = ntohs (msg->key_len);
472  key_len,
473  &private_key,
474  &kbytes_read));
475  GNUNET_assert (kbytes_read == key_len);
476  name = (const char *) &msg[1] + key_len;
477  if (GNUNET_NO == found)
478  {
479  /* label was not in namestore */
480  if (NULL != qe->proc)
481  qe->proc (qe->proc_cls, &private_key, name, 0, NULL);
482  free_qe (qe);
483  return;
484  }
485  if (GNUNET_SYSERR == found)
486  {
487  if (NULL != qe->error_cb)
488  qe->error_cb (qe->error_cb_cls);
489  free_qe (qe);
490  return;
491  }
492 
493  rd_tmp = &name[name_len];
494  {
496 
497  GNUNET_assert (
498  GNUNET_OK ==
500  if (0 == name_len)
501  name = NULL;
502  if (NULL != qe->proc)
503  qe->proc (qe->proc_cls,
504  &private_key,
505  name,
506  rd_count,
507  (rd_count > 0) ? rd : NULL);
508  }
509  free_qe (qe);
510 }
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PrivateKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PrivateKey from a compact buffer.
Definition: identity_api.c:908
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A private key for an identity as per LSD0001.

References find_qe(), free_qe(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_IDENTITY_read_private_key_from_buffer(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, h, LOG, msg, name, qe, rd, and rd_count.

Here is the call graph for this function:

◆ check_record_result()

static int check_record_result ( void *  cls,
const struct RecordResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.

Parameters
cls
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 522 of file namestore_api.c.

523 {
524  const char *name;
525  size_t msg_len;
526  size_t name_len;
527  size_t rd_len;
528  size_t key_len;
529 
530  (void) cls;
531  rd_len = ntohs (msg->rd_len);
532  msg_len = ntohs (msg->gns_header.header.size);
533  key_len = ntohs (msg->key_len);
534  name_len = ntohs (msg->name_len);
535  if (msg_len != sizeof(struct RecordResultMessage) + key_len + name_len
536  + rd_len)
537  {
538  GNUNET_break (0);
539  return GNUNET_SYSERR;
540  }
541  name = (const char *) &msg[1] + key_len;
542  if ((0 == name_len) || ('\0' != name[name_len - 1]))
543  {
544  GNUNET_break (0);
545  return GNUNET_SYSERR;
546  }
547  if (0 == key_len)
548  {
549  GNUNET_break (0);
550  return GNUNET_SYSERR;
551  }
552  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
553 }
Record is returned from the namestore (as authority).
Definition: namestore.h:292

References check_rd(), GNUNET_break, GNUNET_SYSERR, msg, name, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_record_result()

static void handle_record_result ( void *  cls,
const struct RecordResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.

Parameters
cls
msgthe message we received

Definition at line 564 of file namestore_api.c.

565 {
566  struct GNUNET_NAMESTORE_Handle *h = cls;
569  struct GNUNET_IDENTITY_PrivateKey private_key;
570  const char *name;
571  const char *rd_tmp;
572  size_t name_len;
573  size_t rd_len;
574  size_t key_len;
575  size_t kbytes_read;
576  unsigned int rd_count;
577 
578  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT\n");
579  rd_len = ntohs (msg->rd_len);
580  rd_count = ntohs (msg->rd_count);
581  name_len = ntohs (msg->name_len);
582  key_len = ntohs (msg->key_len);
583  ze = find_zi (h, ntohl (msg->gns_header.r_id));
584  qe = find_qe (h, ntohl (msg->gns_header.r_id));
585  if ((NULL == ze) && (NULL == qe))
586  return; /* rid not found */
587  if ((NULL != ze) && (NULL != qe))
588  {
589  GNUNET_break (0); /* rid ambiguous */
590  force_reconnect (h);
591  return;
592  }
593  name = (const char *) &msg[1] + key_len;
596  key_len,
597  &private_key,
598  &kbytes_read));
599  GNUNET_assert (kbytes_read == key_len);
600  rd_tmp = &name[name_len];
601  {
603 
604  GNUNET_assert (
605  GNUNET_OK ==
607  if (0 == name_len)
608  name = NULL;
609  if (NULL != qe)
610  {
611  if (NULL != qe->proc)
612  qe->proc (qe->proc_cls,
613  &private_key,
614  name,
615  rd_count,
616  (rd_count > 0) ? rd : NULL);
617  free_qe (qe);
618  return;
619  }
620  if (NULL != ze)
621  {
622  // Store them here because a callback could free ze
625  void *proc_cls = ze->proc_cls;
626  proc = ze->proc;
627  proc2 = ze->proc2;
628  if (NULL != proc)
629  proc (proc_cls, &private_key, name, rd_count, rd);
630  if (NULL != proc2)
631  proc2 (proc_cls, &private_key, name,
633  return;
634  }
635  }
636  GNUNET_assert (0);
637 }
void(* GNUNET_NAMESTORE_RecordSetMonitor)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
Process a record set that was stored in the namestore.
void(* GNUNET_NAMESTORE_RecordMonitor)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
static void force_reconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from service and then reconnect.
static struct GNUNET_NAMESTORE_ZoneIterator * find_zi(struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
Find the zone iteration entry that matches the rid.
GNUNET_NAMESTORE_RecordSetMonitor proc2
The continuation to call with the results.
void * proc_cls
Closure for proc.
GNUNET_NAMESTORE_RecordMonitor proc
The continuation to call with the results.

References find_qe(), find_zi(), force_reconnect(), free_qe(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_IDENTITY_read_private_key_from_buffer(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), h, LOG, msg, name, GNUNET_NAMESTORE_ZoneIterator::proc, GNUNET_NAMESTORE_ZoneIterator::proc2, GNUNET_NAMESTORE_ZoneIterator::proc_cls, qe, rd, and rd_count.

Here is the call graph for this function:

◆ handle_record_result_end()

static void handle_record_result_end ( void *  cls,
const struct GNUNET_NAMESTORE_Header msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END.

Parameters
cls
msgthe message we received

Definition at line 648 of file namestore_api.c.

649 {
650  struct GNUNET_NAMESTORE_Handle *h = cls;
653 
654  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT_END\n");
655  ze = find_zi (h, ntohl (msg->r_id));
656  qe = find_qe (h, ntohl (msg->r_id));
657  if ((NULL == ze) && (NULL == qe))
658  return; /* rid not found */
659  if ((NULL != ze) && (NULL != qe))
660  {
661  GNUNET_break (0); /* rid ambiguous */
662  force_reconnect (h);
663  return;
664  }
665  LOG (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration completed!\n");
666  if (NULL == ze)
667  {
668  GNUNET_break (0);
669  force_reconnect (h);
670  return;
671  }
672  if (NULL != ze->finish_cb)
673  ze->finish_cb (ze->finish_cb_cls);
674  free_ze (ze);
675 }
void * finish_cb_cls
Closure for error_cb.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.

References find_qe(), find_zi(), GNUNET_NAMESTORE_ZoneIterator::finish_cb, GNUNET_NAMESTORE_ZoneIterator::finish_cb_cls, force_reconnect(), free_ze(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, h, LOG, msg, and qe.

Here is the call graph for this function:

◆ handle_tx_control_result()

static void handle_tx_control_result ( void *  cls,
const struct TxControlResultMessage msg 
)
static

Definition at line 678 of file namestore_api.c.

680 {
681  struct GNUNET_NAMESTORE_Handle *h = cls;
683  enum GNUNET_ErrorCode res;
684 
685  qe = find_qe (h, ntohl (msg->gns_header.r_id));
686  res = ntohs (msg->ec);
688  "Received TX_CONTROL_RESULT with result %d\n",
689  res);
690  if (NULL == qe)
691  return;
692  if (NULL != qe->cont)
693  qe->cont (qe->cont_cls, res);
694  free_qe (qe);
695 }

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, h, LOG, msg, qe, and res.

Here is the call graph for this function:

◆ check_zone_to_name_response()

static int check_zone_to_name_response ( void *  cls,
const struct ZoneToNameResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.

Parameters
qethe respective entry in the message queue
msgthe message we received
Returns
GNUNET_OK on success, GNUNET_SYSERR if message malformed

Definition at line 706 of file namestore_api.c.

708 {
709  size_t name_len;
710  size_t rd_ser_len;
711  size_t key_len;
712  const char *name_tmp;
713 
714  (void) cls;
715  if (GNUNET_EC_NONE != ntohl (msg->ec))
716  return GNUNET_OK;
717  key_len = ntohs (msg->key_len);
718  name_len = ntohs (msg->name_len);
719  rd_ser_len = ntohs (msg->rd_len);
720  if (ntohs (msg->gns_header.header.size) !=
721  sizeof(struct ZoneToNameResponseMessage) + key_len + name_len
722  + rd_ser_len)
723  {
724  GNUNET_break (0);
725  return GNUNET_SYSERR;
726  }
727  name_tmp = (const char *) &msg[1] + key_len;
728  if ((name_len > 0) && ('\0' != name_tmp[name_len - 1]))
729  {
730  GNUNET_break (0);
731  return GNUNET_SYSERR;
732  }
733  return check_rd (rd_ser_len, &name_tmp[name_len], ntohs (msg->rd_count));
734 }
@ GNUNET_EC_NONE
No error (success).
Respone for zone to name lookup.
Definition: namestore.h:246

References check_rd(), GNUNET_break, GNUNET_EC_NONE, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_zone_to_name_response()

static void handle_zone_to_name_response ( void *  cls,
const struct ZoneToNameResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 745 of file namestore_api.c.

747 {
748  struct GNUNET_NAMESTORE_Handle *h = cls;
751  enum GNUNET_ErrorCode res;
752  size_t name_len;
753  size_t rd_ser_len;
754  unsigned int rd_count;
755  const char *name_tmp;
756  const char *rd_tmp;
757  size_t key_len;
758  size_t kbytes_read;
759 
760  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n");
761  qe = find_qe (h, ntohl (msg->gns_header.r_id));
762  if (NULL == qe)
763  {
765  "Response queue already gone...\n");
766  return;
767  }
768  res = ntohl (msg->ec);
769  key_len = ntohs (msg->key_len);
772  key_len,
773  &zone,
774  &kbytes_read));
775  GNUNET_assert (kbytes_read == key_len);
776  switch (res)
777  {
778  break;
779 
782  "Namestore has no result for zone to name mapping \n");
783  if (NULL != qe->proc)
784  qe->proc (qe->proc_cls, &zone, NULL, 0, NULL);
785  free_qe (qe);
786  return;
787 
788  case GNUNET_EC_NONE:
790  "Namestore has result for zone to name mapping \n");
791  name_len = ntohs (msg->name_len);
792  rd_count = ntohs (msg->rd_count);
793  rd_ser_len = ntohs (msg->rd_len);
794  name_tmp = (const char *) &msg[1] + key_len;
795  rd_tmp = &name_tmp[name_len];
796  {
798 
801  rd_tmp,
802  rd_count,
803  rd));
804  /* normal end, call continuation with result */
805  if (NULL != qe->proc)
806  qe->proc (qe->proc_cls, &zone, name_tmp, rd_count, rd);
807  /* return is important here: break would call continuation with error! */
808  free_qe (qe);
809  return;
810  }
811 
812  default:
814  "An error occurred during zone to name operation: %s\n",
816  break;
817  }
818  /* error case, call continuation with error */
819  if (NULL != qe->error_cb)
820  qe->error_cb (qe->error_cb_cls);
821  free_qe (qe);
822 }
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
@ GNUNET_EC_NAMESTORE_NO_RESULTS
No results given.
static char * zone
Name of the zone being managed.
@ GNUNET_ERROR_TYPE_WARNING

References find_qe(), free_qe(), GNUNET_assert, GNUNET_EC_NAMESTORE_NO_RESULTS, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_ErrorCode_get_hint(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_IDENTITY_read_private_key_from_buffer(), GNUNET_OK, GNUNET_SYSERR, h, LOG, msg, qe, rd, rd_count, res, and zone.

Here is the call graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_NAMESTORE_Handle *
errorerror code

Definition at line 834 of file namestore_api.c.

835 {
836  struct GNUNET_NAMESTORE_Handle *h = cls;
837 
838  (void) error;
839  force_reconnect (h);
840 }

References force_reconnect(), and h.

Referenced by reconnect().

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

◆ reconnect()

static void reconnect ( struct GNUNET_NAMESTORE_Handle h)
static

Reconnect to namestore service.

Parameters
hthe handle to the NAMESTORE service

Definition at line 849 of file namestore_api.c.

850 {
852  { GNUNET_MQ_hd_fixed_size (record_store_response,
855  h),
856  GNUNET_MQ_hd_var_size (zone_to_name_response,
859  h),
860  GNUNET_MQ_hd_var_size (record_result,
862  struct RecordResultMessage,
863  h),
864  GNUNET_MQ_hd_fixed_size (record_result_end,
867  h),
868  GNUNET_MQ_hd_var_size (lookup_result,
871  h),
872  GNUNET_MQ_hd_fixed_size (tx_control_result,
874  struct TxControlResultMessage,
875  h),
879 
880  GNUNET_assert (NULL == h->mq);
881  h->mq =
883  if (NULL == h->mq)
884  return;
885  /* re-transmit pending requests that waited for a reconnect... */
886  for (it = h->z_head; NULL != it; it = it->next)
887  {
888  GNUNET_MQ_send (h->mq, it->env);
889  it->env = NULL;
890  }
891  for (qe = h->op_head; NULL != qe; qe = qe->next)
892  {
893  GNUNET_MQ_send (h->mq, qe->env);
894  qe->env = NULL;
895  }
896 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END
Service to client: end of list of results.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT
Return status message for control message.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
Service to client: here is a (plaintext) record you requested.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
Service to client: result of zone-to-name lookup.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
Service to client: result of store operation.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
Service to client: lookup label.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Message handler for a specific message type.
Generic namestore message with op id.
Definition: namestore.h:41
Response to a record storage request.
Definition: namestore.h:114
Result of a transaction control message.
Definition: namestore.h:357

References GNUNET_ARM_Handle::cfg, GNUNET_DATASTORE_QueueEntry::env, GNUNET_NAMESTORE_ZoneIterator::env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_send(), h, handlers, GNUNET_ARM_Handle::mq, mq_error_handler(), GNUNET_DATASTORE_QueueEntry::next, GNUNET_NAMESTORE_ZoneIterator::next, and qe.

Referenced by GNUNET_NAMESTORE_connect(), and reconnect_task().

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

◆ reconnect_task()

static void reconnect_task ( void *  cls)
static

Re-establish the connection to the service.

Parameters
clshandle to use to re-connect.

Definition at line 905 of file namestore_api.c.

906 {
907  struct GNUNET_NAMESTORE_Handle *h = cls;
908 
909  h->reconnect_task = NULL;
910  reconnect (h);
911 }
static void reconnect(struct GNUNET_NAMESTORE_Handle *h)
Reconnect to namestore service.

References h, reconnect(), and GNUNET_ARM_Handle::reconnect_task.

Referenced by force_reconnect().

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

◆ get_op_id()

static uint32_t get_op_id ( struct GNUNET_NAMESTORE_Handle h)
static

Get a fresh operation id to distinguish between namestore requests.

Parameters
hthe namestore handle
Returns
next operation id to use

Definition at line 957 of file namestore_api.c.

958 {
959  return h->last_op_id_used++;
960 }

References h.

Referenced by GNUNET_NAMESTORE_records_store2(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_to_name(), records_lookup(), and send_transaction_control_msg().

Here is the caller graph for this function:

◆ warn_delay()

static void warn_delay ( void *  cls)
static

Task launched to warn the user that the namestore is excessively slow and that a query was thus dropped.

Parameters
clsa struct GNUNET_NAMESTORE_QueueEntry *

Definition at line 1032 of file namestore_api.c.

1033 {
1034  struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
1035 
1036  qe->timeout_task = NULL;
1038  "Did not receive response from namestore after %s!\n",
1040  GNUNET_YES));
1041  if (NULL != qe->cont)
1042  {
1044  qe->cont = NULL;
1045  }
1047 }
@ GNUNET_YES
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:569
#define NAMESTORE_DELAY_TOLERANCE
We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail.
Definition: namestore_api.c:46

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, GNUNET_EC_NAMESTORE_UNKNOWN, GNUNET_ERROR_TYPE_WARNING, GNUNET_NAMESTORE_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, LOG, NAMESTORE_DELAY_TOLERANCE, and qe.

Referenced by GNUNET_NAMESTORE_records_store2().

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

◆ records_lookup()

static struct GNUNET_NAMESTORE_QueueEntry* records_lookup ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_IDENTITY_PrivateKey pkey,
const char *  label,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  rm,
void *  rm_cls,
int  is_edit_request,
enum GNUNET_GNSRECORD_Filter  filter 
)
static

Definition at line 1196 of file namestore_api.c.

1206 {
1208  struct GNUNET_MQ_Envelope *env;
1209  struct LabelLookupMessage *msg;
1210  size_t label_len;
1211  size_t key_len;
1212 
1213  if (1 == (label_len = strlen (label) + 1))
1214  {
1215  GNUNET_break (0);
1216  return NULL;
1217  }
1218 
1220  qe->h = h;
1221  qe->error_cb = error_cb;
1222  qe->error_cb_cls = error_cb_cls;
1223  qe->proc = rm;
1224  qe->proc_cls = rm_cls;
1225  qe->op_id = get_op_id (h);
1226  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1227 
1230  label_len + key_len,
1232  msg->gns_header.r_id = htonl (qe->op_id);
1234  &msg[1],
1235  key_len);
1236 
1237  msg->key_len = htons (key_len);
1238  msg->is_edit_request = htons (is_edit_request);
1239  msg->label_len = htons (label_len);
1240  msg->filter = htons (filter);
1241  GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len);
1242  if (NULL == h->mq)
1243  qe->env = env;
1244  else
1245  GNUNET_MQ_send (h->mq, env);
1246  return qe;
1247 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:479
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
ssize_t GNUNET_IDENTITY_write_private_key_to_buffer(const struct GNUNET_IDENTITY_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PrivateKey to a compact buffer.
Definition: identity_api.c:933
ssize_t GNUNET_IDENTITY_private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Get the compacted length of a GNUNET_IDENTITY_PrivateKey.
Definition: identity_api.c:809
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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:63
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
Client to service: lookup label.
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
Lookup a label.
Definition: namestore.h:132
uint16_t key_len
Length of the zone key.
Definition: namestore.h:156
uint16_t is_edit_request
GNUNET_YES if this lookup corresponds to an edit request.
Definition: namestore.h:146
uint16_t label_len
Length of the name.
Definition: namestore.h:141

References env, GNUNET_DATASTORE_QueueEntry::env, error_cb(), filter, get_op_id(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_IDENTITY_private_key_get_length(), GNUNET_IDENTITY_write_private_key_to_buffer(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, LabelLookupMessage::is_edit_request, LabelLookupMessage::key_len, LabelLookupMessage::label_len, GNUNET_ARM_Handle::mq, msg, pkey, and qe.

Referenced by GNUNET_NAMESTORE_records_edit(), GNUNET_NAMESTORE_records_lookup(), and GNUNET_NAMESTORE_records_lookup2().

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

◆ send_transaction_control_msg()

static struct GNUNET_NAMESTORE_QueueEntry* send_transaction_control_msg ( struct GNUNET_NAMESTORE_Handle h,
GNUNET_NAMESTORE_ContinuationWithStatus  cont,
void *  cont_cls,
enum GNUNET_NAMESTORE_TxControl  ctrl 
)
static

New API draft.

Experimental

Definition at line 1502 of file namestore_api.c.

1506 {
1508  struct GNUNET_MQ_Envelope *env;
1509  struct TxControlMessage *msg;
1510  uint32_t rid;
1511 
1512  rid = get_op_id (h);
1514  qe->h = h;
1515  qe->cont = cont;
1516  qe->cont_cls = cont_cls;
1517  qe->op_id = rid;
1518  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1519 
1521  msg->gns_header.r_id = htonl (rid);
1522  msg->control = htons (ctrl);
1523  if (NULL == h->mq)
1524  qe->env = env;
1525  else
1526  GNUNET_MQ_send (h->mq, env);
1527  return qe;
1528  GNUNET_break (0);
1529  return NULL;
1530 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL
Message type for Begin, Commit or Rollback.
Send a transaction control message.
Definition: namestore.h:335

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, env, GNUNET_DATASTORE_QueueEntry::env, get_op_id(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, GNUNET_ARM_Handle::mq, msg, and qe.

Referenced by GNUNET_NAMESTORE_transaction_begin(), GNUNET_NAMESTORE_transaction_commit(), and GNUNET_NAMESTORE_transaction_rollback().

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