GNUnet  0.17.6
Data Structures | Macros | Functions
namestore_api.c File Reference

API to access the NAMESTORE service. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_constants.h"
#include "gnunet_dnsparser_lib.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 int check_record_store_response (void *cls, const struct RecordStoreResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE. 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 int check_tx_control_result (void *cls, const struct TxControlResultMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT. 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, 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)
 
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_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 41 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 47 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 957 of file namestore_api.c.

958 {
961 
963  h->mq = NULL;
964  while (NULL != (ze = h->z_head))
965  {
966  if (NULL != ze->error_cb)
967  ze->error_cb (ze->error_cb_cls);
968  free_ze (ze);
969  }
970  while (NULL != (qe = h->op_head))
971  {
972  if (NULL != qe->error_cb)
973  qe->error_cb (qe->error_cb_cls);
974  if (NULL != qe->cont)
975  qe->cont (qe->cont_cls,
977  "failure in communication with namestore service");
978  free_qe (qe);
979  }
980 
981  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to namestore\n");
982  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
983  h->reconnect_task =
984  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect_task, h);
985 }
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_SYSERR
Definition: gnunet_common.h:97
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:685
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:1254
#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:54
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_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, 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(), handle_zone_to_name_response(), 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 270 of file namestore_api.c.

271 {
273 
274  for (qe = h->op_head; qe != NULL; qe = qe->next)
275  if (qe->op_id == rid)
276  return qe;
277  return NULL;
278 }
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 289 of file namestore_api.c.

290 {
292 
293  for (ze = h->z_head; ze != NULL; ze = ze->next)
294  if (ze->op_id == rid)
295  return ze;
296  return NULL;
297 }
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 306 of file namestore_api.c.

307 {
308  struct GNUNET_NAMESTORE_Handle *h = qe->h;
309 
310  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, qe);
311  if (NULL != qe->env)
313  if (NULL != qe->timeout_task)
314  GNUNET_SCHEDULER_cancel (qe->timeout_task);
315  GNUNET_free (qe);
316 }
#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:283
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
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 325 of file namestore_api.c.

326 {
327  struct GNUNET_NAMESTORE_Handle *h = ze->h;
328 
329  GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, ze);
330  if (NULL != ze->env)
331  GNUNET_MQ_discard (ze->env);
332  GNUNET_free (ze);
333 }
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 346 of file namestore_api.c.

347 {
348  struct GNUNET_GNSRECORD_Data rd[rd_count];
349 
350  if (GNUNET_OK !=
351  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_buf, rd_count, rd))
352  {
353  GNUNET_break (0);
354  return GNUNET_SYSERR;
355  }
356  return GNUNET_OK;
357 }
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
Definition: gnunet_common.h:99
#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, and GNUNET_SYSERR.

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:

◆ check_record_store_response()

static int check_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
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 368 of file namestore_api.c.

370 {
371  const char *emsg;
372  size_t msg_len;
373  size_t emsg_len;
374 
375  (void) cls;
376  msg_len = ntohs (msg->gns_header.header.size);
377  emsg_len = ntohs (msg->emsg_len);
378  if (0 != ntohs (msg->reserved))
379  {
380  GNUNET_break (0);
381  return GNUNET_SYSERR;
382  }
383  if (msg_len != sizeof(struct RecordStoreResponseMessage) + emsg_len)
384  {
385  GNUNET_break (0);
386  return GNUNET_SYSERR;
387  }
388  emsg = (const char *) &msg[1];
389  if ((0 != emsg_len) && ('\0' != emsg[emsg_len - 1]))
390  {
391  GNUNET_break (0);
392  return GNUNET_SYSERR;
393  }
394  return GNUNET_OK;
395 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Response to a record storage request.
Definition: namestore.h:113

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.

◆ 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 406 of file namestore_api.c.

408 {
409  struct GNUNET_NAMESTORE_Handle *h = cls;
411  int res;
412  const char *emsg;
413 
414  qe = find_qe (h, ntohl (msg->gns_header.r_id));
415  emsg = (const char *) &msg[1];
416  res = ntohl (msg->op_result);
418  "Received RECORD_STORE_RESPONSE with result %d\n",
419  res);
420  if (NULL == qe)
421  return;
422  if (NULL != qe->cont)
423  qe->cont (qe->cont_cls, res,
424  (GNUNET_OK == res) ? NULL : emsg);
425  free_qe (qe);
426 }
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:41

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, 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 438 of file namestore_api.c.

439 {
440  const char *name;
441  size_t exp_msg_len;
442  size_t msg_len;
443  size_t name_len;
444  size_t rd_len;
445 
446  (void) cls;
447  rd_len = ntohs (msg->rd_len);
448  msg_len = ntohs (msg->gns_header.header.size);
449  name_len = ntohs (msg->name_len);
450  exp_msg_len = sizeof(*msg) + name_len + rd_len;
451  if (msg_len != exp_msg_len)
452  {
453  GNUNET_break (0);
454  return GNUNET_SYSERR;
455  }
456  name = (const char *) &msg[1];
457  if ((name_len > 0) && ('\0' != name[name_len - 1]))
458  {
459  GNUNET_break (0);
460  return GNUNET_SYSERR;
461  }
462  if (GNUNET_NO == ntohs (msg->found))
463  {
464  if (0 != ntohs (msg->rd_count))
465  {
466  GNUNET_break (0);
467  return GNUNET_SYSERR;
468  }
469  return GNUNET_OK;
470  }
471  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
472 }
@ GNUNET_NO
Definition: gnunet_common.h:98
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

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 483 of file namestore_api.c.

484 {
485  struct GNUNET_NAMESTORE_Handle *h = cls;
487  const char *name;
488  const char *rd_tmp;
489  size_t name_len;
490  size_t rd_len;
491  unsigned int rd_count;
492  int16_t found = (int16_t) ntohs (msg->found);
493 
494  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_LOOKUP_RESULT (found=%i)\n",
495  found);
496  qe = find_qe (h, ntohl (msg->gns_header.r_id));
497  if (NULL == qe)
498  return;
499  rd_len = ntohs (msg->rd_len);
500  rd_count = ntohs (msg->rd_count);
501  name_len = ntohs (msg->name_len);
502  name = (const char *) &msg[1];
503  if (GNUNET_NO == found)
504  {
505  /* label was not in namestore */
506  if (NULL != qe->proc)
507  qe->proc (qe->proc_cls, &msg->private_key, name, 0, NULL);
508  free_qe (qe);
509  return;
510  }
511  if (GNUNET_SYSERR == found)
512  {
513  if (NULL != qe->error_cb)
514  qe->error_cb (qe->error_cb_cls);
515  free_qe (qe);
516  return;
517  }
518 
519  rd_tmp = &name[name_len];
520  {
521  struct GNUNET_GNSRECORD_Data rd[rd_count];
522 
523  GNUNET_assert (
524  GNUNET_OK ==
525  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_tmp, rd_count, rd));
526  if (0 == name_len)
527  name = NULL;
528  if (NULL != qe->proc)
529  qe->proc (qe->proc_cls,
530  &msg->private_key,
531  name,
532  rd_count,
533  (rd_count > 0) ? rd : NULL);
534  }
535  free_qe (qe);
536 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

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

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 548 of file namestore_api.c.

549 {
550  static struct GNUNET_IDENTITY_PrivateKey priv_dummy;
551  const char *name;
552  size_t msg_len;
553  size_t name_len;
554  size_t rd_len;
555 
556  (void) cls;
557  rd_len = ntohs (msg->rd_len);
558  msg_len = ntohs (msg->gns_header.header.size);
559  name_len = ntohs (msg->name_len);
560  if (0 != ntohs (msg->reserved))
561  {
562  GNUNET_break (0);
563  return GNUNET_SYSERR;
564  }
565  if (msg_len != sizeof(struct RecordResultMessage) + name_len + rd_len)
566  {
567  GNUNET_break (0);
568  return GNUNET_SYSERR;
569  }
570  name = (const char *) &msg[1];
571  if ((0 == name_len) || ('\0' != name[name_len - 1]))
572  {
573  GNUNET_break (0);
574  return GNUNET_SYSERR;
575  }
576  if (0 == GNUNET_memcmp (&msg->private_key, &priv_dummy))
577  {
578  GNUNET_break (0);
579  return GNUNET_SYSERR;
580  }
581  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
582 }
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
A private key for an identity as per LSD0001.
Record is returned from the namestore (as authority).
Definition: namestore.h:283

References check_rd(), GNUNET_break, GNUNET_memcmp, 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 593 of file namestore_api.c.

594 {
595  struct GNUNET_NAMESTORE_Handle *h = cls;
598  const char *name;
599  const char *rd_tmp;
600  size_t name_len;
601  size_t rd_len;
602  unsigned int rd_count;
603 
604  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT\n");
605  rd_len = ntohs (msg->rd_len);
606  rd_count = ntohs (msg->rd_count);
607  name_len = ntohs (msg->name_len);
608  ze = find_zi (h, ntohl (msg->gns_header.r_id));
609  qe = find_qe (h, ntohl (msg->gns_header.r_id));
610  if ((NULL == ze) && (NULL == qe))
611  return; /* rid not found */
612  if ((NULL != ze) && (NULL != qe))
613  {
614  GNUNET_break (0); /* rid ambiguous */
615  force_reconnect (h);
616  return;
617  }
618  name = (const char *) &msg[1];
619  rd_tmp = &name[name_len];
620  {
621  struct GNUNET_GNSRECORD_Data rd[rd_count];
622 
623  GNUNET_assert (
624  GNUNET_OK ==
625  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_tmp, rd_count, rd));
626  if (0 == name_len)
627  name = NULL;
628  if (NULL != qe)
629  {
630  if (NULL != qe->proc)
631  qe->proc (qe->proc_cls,
632  &msg->private_key,
633  name,
634  rd_count,
635  (rd_count > 0) ? rd : NULL);
636  free_qe (qe);
637  return;
638  }
639  if (NULL != ze)
640  {
641  if (NULL != ze->proc)
642  ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd);
643  if (NULL != ze->proc2)
644  ze->proc2 (ze->proc_cls, &msg->private_key, name,
645  rd_count, rd, GNUNET_TIME_absolute_ntoh (msg->expire));
646  return;
647  }
648  }
649  GNUNET_assert (0);
650 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:736
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_OK, GNUNET_TIME_absolute_ntoh(), h, LOG, msg, name, GNUNET_NAMESTORE_ZoneIterator::proc, GNUNET_NAMESTORE_ZoneIterator::proc2, GNUNET_NAMESTORE_ZoneIterator::proc_cls, and qe.

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 661 of file namestore_api.c.

662 {
663  struct GNUNET_NAMESTORE_Handle *h = cls;
666 
667  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT_END\n");
668  ze = find_zi (h, ntohl (msg->r_id));
669  qe = find_qe (h, ntohl (msg->r_id));
670  if ((NULL == ze) && (NULL == qe))
671  return; /* rid not found */
672  if ((NULL != ze) && (NULL != qe))
673  {
674  GNUNET_break (0); /* rid ambiguous */
675  force_reconnect (h);
676  return;
677  }
678  LOG (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration completed!\n");
679  if (NULL == ze)
680  {
681  GNUNET_break (0);
682  force_reconnect (h);
683  return;
684  }
685  if (NULL != ze->finish_cb)
686  ze->finish_cb (ze->finish_cb_cls);
687  free_ze (ze);
688 }
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:

◆ check_tx_control_result()

static int check_tx_control_result ( void *  cls,
const struct TxControlResultMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT.

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 699 of file namestore_api.c.

701 {
702  const char *err_tmp;
703  size_t err_len;
704 
705  (void) cls;
706  err_len = ntohs (msg->gns_header.header.size)
707  - sizeof (struct TxControlResultMessage);
708  if ((GNUNET_YES == ntohs (msg->success)) && (err_len > 0))
709  {
710  GNUNET_break (0);
711  return GNUNET_SYSERR;
712  }
713  err_tmp = (const char *) &msg[1];
714  if ((err_len > 0) && ('\0' != err_tmp[err_len - 1]))
715  {
716  GNUNET_break (0);
717  return GNUNET_SYSERR;
718  }
719  return GNUNET_OK;
720 }
@ GNUNET_YES
Result of a transaction control message.
Definition: namestore.h:352

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, msg, and GNUNET_MessageHeader::size.

◆ handle_tx_control_result()

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

Definition at line 723 of file namestore_api.c.

725 {
726  struct GNUNET_NAMESTORE_Handle *h = cls;
728  int res;
729  const char *emsg;
730 
731  qe = find_qe (h, ntohl (msg->gns_header.r_id));
732  emsg = (const char *) &msg[1];
733  res = ntohs (msg->success);
735  "Received TX_CONTROL_RESULT with result %d\n",
736  res);
737  if (NULL == qe)
738  return;
739  if (NULL != qe->cont)
740  qe->cont (qe->cont_cls, res,
741  (GNUNET_YES == res) ? NULL : emsg);
742  free_qe (qe);
743 }

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, 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 754 of file namestore_api.c.

756 {
757  size_t name_len;
758  size_t rd_ser_len;
759  const char *name_tmp;
760 
761  (void) cls;
762  if (GNUNET_OK != ntohs (msg->res))
763  return GNUNET_OK;
764  name_len = ntohs (msg->name_len);
765  rd_ser_len = ntohs (msg->rd_len);
766  if (ntohs (msg->gns_header.header.size) !=
767  sizeof(struct ZoneToNameResponseMessage) + name_len + rd_ser_len)
768  {
769  GNUNET_break (0);
770  return GNUNET_SYSERR;
771  }
772  name_tmp = (const char *) &msg[1];
773  if ((name_len > 0) && ('\0' != name_tmp[name_len - 1]))
774  {
775  GNUNET_break (0);
776  return GNUNET_SYSERR;
777  }
778  return check_rd (rd_ser_len, &name_tmp[name_len], ntohs (msg->rd_count));
779 }
Respone for zone to name lookup.
Definition: namestore.h:240

References check_rd(), GNUNET_break, 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 790 of file namestore_api.c.

792 {
793  struct GNUNET_NAMESTORE_Handle *h = cls;
795  int res;
796  size_t name_len;
797  size_t rd_ser_len;
798  unsigned int rd_count;
799  const char *name_tmp;
800  const char *rd_tmp;
801 
802  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n");
803  qe = find_qe (h, ntohl (msg->gns_header.r_id));
804  if (NULL == qe)
805  {
807  "Response queue already gone...\n");
808  return;
809  }
810  res = ntohs (msg->res);
811  switch (res)
812  {
813  case GNUNET_SYSERR:
815  "An error occurred during zone to name operation\n");
816  break;
817 
818  case GNUNET_NO:
820  "Namestore has no result for zone to name mapping \n");
821  if (NULL != qe->proc)
822  qe->proc (qe->proc_cls, &msg->zone, NULL, 0, NULL);
823  free_qe (qe);
824  return;
825 
826  case GNUNET_YES:
828  "Namestore has result for zone to name mapping \n");
829  name_len = ntohs (msg->name_len);
830  rd_count = ntohs (msg->rd_count);
831  rd_ser_len = ntohs (msg->rd_len);
832  name_tmp = (const char *) &msg[1];
833  rd_tmp = &name_tmp[name_len];
834  {
835  struct GNUNET_GNSRECORD_Data rd[rd_count];
836 
839  rd_tmp,
840  rd_count,
841  rd));
842  /* normal end, call continuation with result */
843  if (NULL != qe->proc)
844  qe->proc (qe->proc_cls, &msg->zone, name_tmp, rd_count, rd);
845  /* return is important here: break would call continuation with error! */
846  free_qe (qe);
847  return;
848  }
849 
850  default:
851  GNUNET_break (0);
852  force_reconnect (h);
853  return;
854  }
855  /* error case, call continuation with error */
856  if (NULL != qe->error_cb)
857  qe->error_cb (qe->error_cb_cls);
858  free_qe (qe);
859 }
@ GNUNET_ERROR_TYPE_WARNING

References find_qe(), force_reconnect(), free_qe(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNSRECORD_records_deserialize(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, h, LOG, msg, qe, and res.

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 871 of file namestore_api.c.

872 {
873  struct GNUNET_NAMESTORE_Handle *h = cls;
874 
875  (void) error;
876  force_reconnect (h);
877 }

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 886 of file namestore_api.c.

887 {
889  { GNUNET_MQ_hd_var_size (record_store_response,
892  h),
893  GNUNET_MQ_hd_var_size (zone_to_name_response,
896  h),
897  GNUNET_MQ_hd_var_size (record_result,
899  struct RecordResultMessage,
900  h),
901  GNUNET_MQ_hd_fixed_size (record_result_end,
904  h),
905  GNUNET_MQ_hd_var_size (lookup_result,
908  h),
909  GNUNET_MQ_hd_var_size (tx_control_result,
911  struct TxControlResultMessage,
912  h),
916 
917  GNUNET_assert (NULL == h->mq);
918  h->mq =
920  if (NULL == h->mq)
921  return;
922  /* re-transmit pending requests that waited for a reconnect... */
923  for (it = h->z_head; NULL != it; it = it->next)
924  {
925  GNUNET_MQ_send (h->mq, it->env);
926  it->env = NULL;
927  }
928  for (qe = h->op_head; NULL != qe; qe = qe->next)
929  {
930  GNUNET_MQ_send (h->mq, qe->env);
931  qe->env = NULL;
932  }
933 }
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:1055
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:302
#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

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 942 of file namestore_api.c.

943 {
944  struct GNUNET_NAMESTORE_Handle *h = cls;
945 
946  h->reconnect_task = NULL;
947  reconnect (h);
948 }
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 995 of file namestore_api.c.

996 {
997  return h->last_op_id_used++;
998 }

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 1070 of file namestore_api.c.

1071 {
1072  struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
1073 
1074  qe->timeout_task = NULL;
1076  "Did not receive response from namestore after %s!\n",
1078  GNUNET_YES));
1079  if (NULL != qe->cont)
1080  {
1081  qe->cont (qe->cont_cls, GNUNET_SYSERR, "timeout");
1082  qe->cont = NULL;
1083  }
1085 }
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:570
#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:47

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, GNUNET_ERROR_TYPE_WARNING, GNUNET_NAMESTORE_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, 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 
)
static

Definition at line 1214 of file namestore_api.c.

1223 {
1225  struct GNUNET_MQ_Envelope *env;
1226  struct LabelLookupMessage *msg;
1227  size_t label_len;
1228 
1229  if (1 == (label_len = strlen (label) + 1))
1230  {
1231  GNUNET_break (0);
1232  return NULL;
1233  }
1234 
1236  qe->h = h;
1237  qe->error_cb = error_cb;
1238  qe->error_cb_cls = error_cb_cls;
1239  qe->proc = rm;
1240  qe->proc_cls = rm_cls;
1241  qe->op_id = get_op_id (h);
1242  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1243 
1245  label_len,
1247  msg->gns_header.r_id = htonl (qe->op_id);
1248  msg->zone = *pkey;
1249  msg->is_edit_request = htonl (is_edit_request);
1250  msg->label_len = htonl (label_len);
1251  GNUNET_memcpy (&msg[1], label, label_len);
1252  if (NULL == h->mq)
1253  qe->env = env;
1254  else
1255  GNUNET_MQ_send (h->mq, env);
1256  return qe;
1257 }
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.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#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:56
#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:144
uint32_t is_edit_request
GNUNET_YES if this lookup corresponds to an edit request.
Definition: namestore.h:158
uint32_t label_len
Length of the name.
Definition: namestore.h:153

References env, GNUNET_DATASTORE_QueueEntry::env, error_cb(), get_op_id(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, 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::label_len, GNUNET_ARM_Handle::mq, msg, pkey, and qe.

Referenced by GNUNET_NAMESTORE_records_edit(), and GNUNET_NAMESTORE_records_lookup().

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 1471 of file namestore_api.c.

1475 {
1477  struct GNUNET_MQ_Envelope *env;
1478  struct TxControlMessage *msg;
1479  uint32_t rid;
1480 
1481  rid = get_op_id (h);
1483  qe->h = h;
1484  qe->cont = cont;
1485  qe->cont_cls = cont_cls;
1486  qe->op_id = rid;
1487  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1488 
1490  msg->gns_header.r_id = htonl (rid);
1491  msg->control = htons (ctrl);
1492  if (NULL == h->mq)
1493  qe->env = env;
1494  else
1495  GNUNET_MQ_send (h->mq, env);
1496  return qe;
1497  GNUNET_break (0);
1498  return NULL;
1499 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:71
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL
Message type for Begin, Commit or Rollback.
Send a transaction control message.
Definition: namestore.h:330

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: