GNUnet 0.22.2
namestore_api.c File Reference

API to access the NAMESTORE service. More...

#include "gnunet_protocols.h"
#include "gnunet_error_codes.h"
#include "gnunet_util_lib.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_generic_response (void *cls, const struct NamestoreResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_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_edit_record_set_response (void *cls, const struct EditRecordSetResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE. More...
 
static void handle_edit_record_set_response (void *cls, const struct EditRecordSetResponseMessage *msg)
 Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_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_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_record_set_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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_CRYPTO_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)
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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_CRYPTO_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_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *zone, const struct GNUNET_CRYPTO_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_CRYPTO_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_CRYPTO_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...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, const char *editor_hint, GNUNET_NAMESTORE_EditRecordSetBeginCallback edit_cb, void *edit_cb_cls)
 New API draft. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, const char *editor_hint, const char *editor_hint_replacement, GNUNET_NAMESTORE_ContinuationWithStatus finished_cb, void *finished_cls)
 If the current advisory lock is set to the provided editor hint, this API cancels the editing of a record set and unsets the advisory lock in database. 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 36 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 42 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 990 of file namestore_api.c.

991{
994
996 h->mq = NULL;
997 while (NULL != (ze = h->z_head))
998 {
999 if (NULL != ze->error_cb)
1000 ze->error_cb (ze->error_cb_cls);
1001 free_ze (ze);
1002 }
1003 while (NULL != (qe = h->op_head))
1004 {
1005 if (NULL != qe->error_cb)
1006 qe->error_cb (qe->error_cb_cls);
1007 if (NULL != qe->cont)
1008 qe->cont (qe->cont_cls,
1010 free_qe (qe);
1011 }
1012
1013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to namestore\n");
1014 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
1015 h->reconnect_task =
1016 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect_task, h);
1017}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
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:700
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:1277
#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.
@ GNUNET_EC_NAMESTORE_UNKNOWN
Unknown namestore error.
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:49
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 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_edit_record_set_response(), handle_generic_response(), handle_lookup_result(), handle_record_result(), handle_record_result_end(), 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:285
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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_edit_record_set_response(), handle_generic_response(), handle_lookup_result(), handle_record_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)
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{
349
350 if (GNUNET_OK !=
352 {
353 GNUNET_break (0);
354 return GNUNET_SYSERR;
355 }
356 return GNUNET_OK;
357}
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_edit_record_set_response(), 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_generic_response()

static void handle_generic_response ( void *  cls,
const struct NamestoreResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 368 of file namestore_api.c.

370{
371 struct GNUNET_NAMESTORE_Handle *h = cls;
374
375 qe = find_qe (h, ntohl (msg->gns_header.r_id));
376 res = ntohl (msg->ec);
378 "Received GENERIC_RESPONSE with result %s\n",
380 if (NULL == qe)
381 return;
382 if (NULL != qe->cont)
383 qe->cont (qe->cont_cls, res);
384 free_qe (qe);
385}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static char * res
Currently read line or NULL on EOF.
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:36
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
GNUNET_ErrorCode
Taler error codes.

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

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

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

450{
451 struct GNUNET_NAMESTORE_Handle *h = cls;
453 struct GNUNET_CRYPTO_PrivateKey private_key;
454 const char *name;
455 const char *rd_tmp;
456 size_t name_len;
457 size_t rd_len;
458 size_t key_len;
459 size_t kbytes_read;
460 unsigned int rd_count;
461 int16_t found = (int16_t) ntohs (msg->found);
462
463 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_LOOKUP_RESULT (found=%i)\n",
464 found);
465 qe = find_qe (h, ntohl (msg->gns_header.r_id));
466 if (NULL == qe)
467 return;
468 rd_len = ntohs (msg->rd_len);
469 rd_count = ntohs (msg->rd_count);
470 name_len = ntohs (msg->name_len);
471 key_len = ntohs (msg->key_len);
474 key_len,
475 &private_key,
476 &kbytes_read));
477 GNUNET_assert (kbytes_read == key_len);
478 name = (const char *) &msg[1] + key_len;
479 if (GNUNET_NO == found)
480 {
481 /* label was not in namestore */
482 if (NULL != qe->proc)
483 qe->proc (qe->proc_cls, &private_key, name, 0, NULL);
484 free_qe (qe);
485 return;
486 }
487 if (GNUNET_SYSERR == found)
488 {
489 if (NULL != qe->error_cb)
490 qe->error_cb (qe->error_cb_cls);
491 free_qe (qe);
492 return;
493 }
494
495 rd_tmp = &name[name_len];
496 {
498
500 GNUNET_OK ==
502 if (0 == name_len)
503 name = NULL;
504 if (NULL != qe->proc)
505 qe->proc (qe->proc_cls,
506 &private_key,
507 name,
508 rd_count,
509 (rd_count > 0) ? rd : NULL);
510 }
511 free_qe (qe);
512}
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:146
#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_CRYPTO_read_private_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, h, LOG, msg, name, qe, rd, and rd_count.

Here is the call graph for this function:

◆ check_edit_record_set_response()

static int check_edit_record_set_response ( void *  cls,
const struct EditRecordSetResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE.

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

Definition at line 524 of file namestore_api.c.

526{
527 const char *editor_hint;
528 size_t msg_len;
529 size_t editor_hint_len;
530 size_t rd_len;
531
532 (void) cls;
533 rd_len = ntohs (msg->rd_len);
534 msg_len = ntohs (msg->gns_header.header.size);
535 editor_hint_len = ntohs (msg->editor_hint_len);
536 if (msg_len != sizeof(struct EditRecordSetResponseMessage) + editor_hint_len
537 + rd_len)
538 {
539 GNUNET_break (0);
540 return GNUNET_SYSERR;
541 }
542 editor_hint = (const char *) &msg[1];
543 if ((0 == editor_hint_len) || ('\0' != editor_hint[editor_hint_len - 1]))
544 {
545 GNUNET_break (0);
546 return GNUNET_SYSERR;
547 }
548 return check_rd (rd_len, &editor_hint[editor_hint_len], ntohs (
549 msg->rd_count));
550}
Response to RecordSetEditMessage.
Definition: namestore.h:142

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

Here is the call graph for this function:

◆ handle_edit_record_set_response()

static void handle_edit_record_set_response ( void *  cls,
const struct EditRecordSetResponseMessage msg 
)
static

Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE.

Parameters
cls
msgthe message we received

Definition at line 561 of file namestore_api.c.

563{
564 struct GNUNET_NAMESTORE_Handle *h = cls;
566 const char *editor_hint;
567 const char *rd_tmp;
568 size_t rd_len;
569 size_t editor_hint_len;
570 unsigned int rd_count;
571
572 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received EDIT_RECORD_SET_RESPONSE\n");
573 rd_len = ntohs (msg->rd_len);
574 rd_count = ntohs (msg->rd_count);
575 editor_hint_len = ntohs (msg->editor_hint_len);
576 qe = find_qe (h, ntohl (msg->gns_header.r_id));
577 if (NULL == qe)
578 return; /* rid not found */
579 editor_hint = (const char *) &msg[1];
580 rd_tmp = &editor_hint[editor_hint_len];
581 {
583
585 GNUNET_OK ==
587 if (0 == editor_hint_len)
588 editor_hint = NULL;
589 if (NULL != qe->edit_proc)
590 qe->edit_proc (qe->proc_cls,
591 ntohs (msg->ec),
592 rd_count,
593 (rd_count > 0) ? rd : NULL,
594 editor_hint);
595 free_qe (qe);
596 return;
597 }
598 GNUNET_assert (0);
599}

References find_qe(), free_qe(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_OK, h, LOG, msg, 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 611 of file namestore_api.c.

612{
613 const char *name;
614 size_t msg_len;
615 size_t name_len;
616 size_t rd_len;
617 size_t key_len;
618
619 (void) cls;
620 rd_len = ntohs (msg->rd_len);
621 msg_len = ntohs (msg->gns_header.header.size);
622 key_len = ntohs (msg->key_len);
623 name_len = ntohs (msg->name_len);
624 if (msg_len != sizeof(struct RecordResultMessage) + key_len + name_len
625 + rd_len)
626 {
627 GNUNET_break (0);
628 return GNUNET_SYSERR;
629 }
630 name = (const char *) &msg[1] + key_len;
631 if ((0 == name_len) || ('\0' != name[name_len - 1]))
632 {
633 GNUNET_break (0);
634 return GNUNET_SYSERR;
635 }
636 if (0 == key_len)
637 {
638 GNUNET_break (0);
639 return GNUNET_SYSERR;
640 }
641 return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
642}
Record is returned from the namestore (as authority).
Definition: namestore.h:415

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

654{
655 struct GNUNET_NAMESTORE_Handle *h = cls;
658 struct GNUNET_CRYPTO_PrivateKey private_key;
659 const char *name;
660 const char *rd_tmp;
661 size_t name_len;
662 size_t rd_len;
663 size_t key_len;
664 size_t kbytes_read;
665 unsigned int rd_count;
666
667 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT\n");
668 rd_len = ntohs (msg->rd_len);
669 rd_count = ntohs (msg->rd_count);
670 name_len = ntohs (msg->name_len);
671 key_len = ntohs (msg->key_len);
672 ze = find_zi (h, ntohl (msg->gns_header.r_id));
673 qe = find_qe (h, ntohl (msg->gns_header.r_id));
674 if ((NULL == ze) && (NULL == qe))
675 return; /* rid not found */
676 if ((NULL != ze) && (NULL != qe))
677 {
678 GNUNET_break (0); /* rid ambiguous */
680 return;
681 }
682 name = (const char *) &msg[1] + key_len;
685 key_len,
686 &private_key,
687 &kbytes_read));
688 GNUNET_assert (kbytes_read == key_len);
689 rd_tmp = &name[name_len];
690 {
692
694 GNUNET_OK ==
696 if (0 == name_len)
697 name = NULL;
698 if (NULL != qe)
699 {
700 if (NULL != qe->proc)
701 qe->proc (qe->proc_cls,
702 &private_key,
703 name,
704 rd_count,
705 (rd_count > 0) ? rd : NULL);
706 free_qe (qe);
707 return;
708 }
709 if (NULL != ze)
710 {
711 // Store them here because a callback could free ze
714 void *proc_cls = ze->proc_cls;
715 proc = ze->proc;
716 proc2 = ze->proc2;
717 if (NULL != proc)
718 proc (proc_cls, &private_key, name, rd_count, rd);
719 if (NULL != proc2)
720 proc2 (proc_cls, &private_key, name,
722 return;
723 }
724 }
725 GNUNET_assert (0);
726}
void(* GNUNET_NAMESTORE_RecordMonitor)(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
void(* GNUNET_NAMESTORE_RecordSetMonitor)(void *cls, const struct GNUNET_CRYPTO_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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
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_CRYPTO_read_private_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), 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 737 of file namestore_api.c.

738{
739 struct GNUNET_NAMESTORE_Handle *h = cls;
742
743 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT_END\n");
744 ze = find_zi (h, ntohl (msg->r_id));
745 qe = find_qe (h, ntohl (msg->r_id));
746 if ((NULL == ze) && (NULL == qe))
747 return; /* rid not found */
748 if ((NULL != ze) && (NULL != qe))
749 {
750 GNUNET_break (0); /* rid ambiguous */
752 return;
753 }
754 LOG (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration completed!\n");
755 if (NULL == ze)
756 {
757 GNUNET_break (0);
759 return;
760 }
761 if (NULL != ze->finish_cb)
762 ze->finish_cb (ze->finish_cb_cls);
763 free_ze (ze);
764}
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_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 776 of file namestore_api.c.

778{
779 size_t name_len;
780 size_t rd_ser_len;
781 size_t key_len;
782 const char *name_tmp;
783
784 (void) cls;
785 if (GNUNET_EC_NONE != ntohl (msg->ec))
786 return GNUNET_OK;
787 key_len = ntohs (msg->key_len);
788 name_len = ntohs (msg->name_len);
789 rd_ser_len = ntohs (msg->rd_len);
790 if (ntohs (msg->gns_header.header.size) !=
791 sizeof(struct ZoneToNameResponseMessage) + key_len + name_len
792 + rd_ser_len)
793 {
794 GNUNET_break (0);
795 return GNUNET_SYSERR;
796 }
797 name_tmp = (const char *) &msg[1] + key_len;
798 if ((name_len > 0) && ('\0' != name_tmp[name_len - 1]))
799 {
800 GNUNET_break (0);
801 return GNUNET_SYSERR;
802 }
803 return check_rd (rd_ser_len, &name_tmp[name_len], ntohs (msg->rd_count));
804}
@ GNUNET_EC_NONE
No error (success).
Response for zone to name lookup.
Definition: namestore.h:369

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

817{
818 struct GNUNET_NAMESTORE_Handle *h = cls;
820 struct GNUNET_CRYPTO_PrivateKey zone;
822 size_t name_len;
823 size_t rd_ser_len;
824 unsigned int rd_count;
825 const char *name_tmp;
826 const char *rd_tmp;
827 size_t key_len;
828 size_t kbytes_read;
829
830 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n");
831 qe = find_qe (h, ntohl (msg->gns_header.r_id));
832 if (NULL == qe)
833 {
835 "Response queue already gone...\n");
836 return;
837 }
838 res = ntohl (msg->ec);
839 key_len = ntohs (msg->key_len);
842 key_len,
843 &zone,
844 &kbytes_read));
845 GNUNET_assert (kbytes_read == key_len);
846 switch (res)
847 {
848 break;
849
852 "Namestore has no result for zone to name mapping \n");
853 if (NULL != qe->proc)
854 qe->proc (qe->proc_cls, &zone, NULL, 0, NULL);
855 free_qe (qe);
856 return;
857
858 case GNUNET_EC_NONE:
860 "Namestore has result for zone to name mapping \n");
861 name_len = ntohs (msg->name_len);
862 rd_count = ntohs (msg->rd_count);
863 rd_ser_len = ntohs (msg->rd_len);
864 name_tmp = (const char *) &msg[1] + key_len;
865 rd_tmp = &name_tmp[name_len];
866 {
868
871 rd_tmp,
872 rd_count,
873 rd));
874 /* normal end, call continuation with result */
875 if (NULL != qe->proc)
876 qe->proc (qe->proc_cls, &zone, name_tmp, rd_count, rd);
877 /* return is important here: break would call continuation with error! */
878 free_qe (qe);
879 return;
880 }
881
882 default:
884 "An error occurred during zone to name operation: %s\n",
886 break;
887 }
888 /* error case, call continuation with error */
889 if (NULL != qe->error_cb)
890 qe->error_cb (qe->error_cb_cls);
891 free_qe (qe);
892}
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_EC_NAMESTORE_NO_RESULTS
No results given.

References find_qe(), free_qe(), GNUNET_assert, GNUNET_CRYPTO_read_private_key_from_buffer(), 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_OK, GNUNET_SYSERR, h, LOG, msg, qe, rd, rd_count, 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 904 of file namestore_api.c.

905{
906 struct GNUNET_NAMESTORE_Handle *h = cls;
907
908 (void) error;
910}

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

920{
922 { GNUNET_MQ_hd_fixed_size (generic_response,
925 h),
926 GNUNET_MQ_hd_var_size (zone_to_name_response,
929 h),
930 GNUNET_MQ_hd_var_size (record_result,
932 struct RecordResultMessage,
933 h),
934 GNUNET_MQ_hd_fixed_size (record_result_end,
937 h),
938 GNUNET_MQ_hd_var_size (lookup_result,
941 h),
942 GNUNET_MQ_hd_var_size (edit_record_set_response,
945 h),
949
950 GNUNET_assert (NULL == h->mq);
951 h->mq =
953 if (NULL == h->mq)
954 return;
955 /* re-transmit pending requests that waited for a reconnect... */
956 for (it = h->z_head; NULL != it; it = it->next)
957 {
958 GNUNET_MQ_send (h->mq, it->env);
959 it->env = NULL;
960 }
961 for (qe = h->op_head; NULL != qe; qe = qe->next)
962 {
963 GNUNET_MQ_send (h->mq, qe->env);
964 qe->env = NULL;
965 }
966}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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:1060
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:305
#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_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_GENERIC_RESPONSE
Service to client: result of store operation.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
Service to client: lookup label.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE
Return record set to edit with previous editor hint/advisory lock.
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:125

References GNUNET_ARM_Handle::cfg, GNUNET_DATASTORE_QueueEntry::env, GNUNET_NAMESTORE_ZoneIterator::env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE, 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_SET_EDIT_RESPONSE, 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 975 of file namestore_api.c.

976{
977 struct GNUNET_NAMESTORE_Handle *h = cls;
978
979 h->reconnect_task = NULL;
980 reconnect (h);
981}
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 1027 of file namestore_api.c.

1028{
1029 return h->last_op_id_used++;
1030}

References h.

Referenced by GNUNET_NAMESTORE_record_set_edit_begin(), GNUNET_NAMESTORE_record_set_edit_cancel(), GNUNET_NAMESTORE_records_store(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_to_name(), and records_lookup().

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

1103{
1104 struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
1105
1106 qe->timeout_task = NULL;
1108 "Did not receive response from namestore after %s!\n",
1110 GNUNET_YES));
1111 if (NULL != qe->cont)
1112 {
1114 qe->cont = NULL;
1115 }
1117}
@ 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:579
#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:42

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_store().

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_CRYPTO_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 
)
static

Definition at line 1268 of file namestore_api.c.

1277{
1279 struct GNUNET_MQ_Envelope *env;
1280 struct LabelLookupMessage *msg;
1281 size_t label_len;
1282 size_t key_len;
1283
1284 if (1 == (label_len = strlen (label) + 1))
1285 {
1286 GNUNET_break (0);
1287 return NULL;
1288 }
1289
1291 qe->h = h;
1292 qe->error_cb = error_cb;
1293 qe->error_cb_cls = error_cb_cls;
1294 qe->proc = rm;
1295 qe->proc_cls = rm_cls;
1296 qe->op_id = get_op_id (h);
1297 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1298
1303 msg->gns_header.r_id = htonl (qe->op_id);
1305 &msg[1],
1306 key_len);
1307
1308 msg->key_len = htons (key_len);
1309 msg->label_len = htons (label_len);
1310 msg->filter = htons (filter);
1311 GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len);
1312 if (NULL == h->mq)
1313 qe->env = env;
1314 else
1315 GNUNET_MQ_send (h->mq, env);
1316 return qe;
1317}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:480
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_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:64
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
Definition: crypto_pkey.c:172
#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:61
#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:179
uint16_t key_len
Length of the zone key.
Definition: namestore.h:203
uint16_t label_len
Length of the name.
Definition: namestore.h:188

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

Referenced by 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: