GNUnet  0.18.1
Name Cache service

Store naming information on a GNUnet node. More...

Collaboration diagram for Name Cache service:

Macros

#define GNUNET_NAMECACHE_MAX_VALUE_SIZE   (63 * 1024)
 Maximum size of a value that can be stored in the namecache. More...
 

Typedefs

typedef void(* GNUNET_NAMECACHE_ContinuationWithStatus) (void *cls, int32_t success, const char *emsg)
 Continuation called to notify client about result of the operation. More...
 
typedef void(* GNUNET_NAMECACHE_BlockProcessor) (void *cls, const struct GNUNET_GNSRECORD_Block *block)
 Process a record that was stored in the namecache. More...
 

Functions

struct GNUNET_NAMECACHE_HandleGNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the namecache service. More...
 
void GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h)
 Disconnect from the namecache service (and free associated resources). More...
 
struct GNUNET_NAMECACHE_QueueEntryGNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h, const struct GNUNET_GNSRECORD_Block *block, GNUNET_NAMECACHE_ContinuationWithStatus cont, void *cont_cls)
 Store an item in the namecache. More...
 
struct GNUNET_NAMECACHE_QueueEntryGNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h, const struct GNUNET_HashCode *derived_hash, GNUNET_NAMECACHE_BlockProcessor proc, void *proc_cls)
 Get a result for a particular key from the namecache. More...
 
void GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe)
 Cancel a namecache operation. More...
 

Detailed Description

Store naming information on a GNUnet node.

Naming information can either be records for which this peer/user is authoritative, or blocks which are cached, encrypted naming data from other peers.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_NAMECACHE_MAX_VALUE_SIZE

#define GNUNET_NAMECACHE_MAX_VALUE_SIZE   (63 * 1024)

Maximum size of a value that can be stored in the namecache.

Definition at line 71 of file gnunet_namecache_service.h.

Typedef Documentation

◆ GNUNET_NAMECACHE_ContinuationWithStatus

typedef void(* GNUNET_NAMECACHE_ContinuationWithStatus) (void *cls, int32_t success, const char *emsg)

Continuation called to notify client about result of the operation.

Parameters
clsclosure
successGNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) GNUNET_NO if content was already there or not found GNUNET_YES (or other positive value) on success
emsgNULL on success, otherwise an error message

Definition at line 105 of file gnunet_namecache_service.h.

◆ GNUNET_NAMECACHE_BlockProcessor

typedef void(* GNUNET_NAMECACHE_BlockProcessor) (void *cls, const struct GNUNET_GNSRECORD_Block *block)

Process a record that was stored in the namecache.

Parameters
clsclosure
blockblock that was stored in the namecache

Definition at line 134 of file gnunet_namecache_service.h.

Function Documentation

◆ GNUNET_NAMECACHE_connect()

struct GNUNET_NAMECACHE_Handle* GNUNET_NAMECACHE_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the namecache service.

Parameters
cfgconfiguration to use
Returns
handle to use to access the service

Connect to the namecache service.

Parameters
cfgconfiguration to use
Returns
handle to the GNS service, or NULL on error

Definition at line 405 of file namecache_api.c.

406 {
407  struct GNUNET_NAMECACHE_Handle *h;
408 
410  h->cfg = cfg;
411  reconnect (h);
412  if (NULL == h->mq)
413  {
414  GNUNET_free (h);
415  return NULL;
416  }
417  return h;
418 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(struct GNUNET_NAMECACHE_Handle *h)
Reconnect to namecache service.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Connection to the NAMECACHE service.
Definition: namecache_api.c:95

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_free, GNUNET_new, h, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by run().

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

◆ GNUNET_NAMECACHE_disconnect()

void GNUNET_NAMECACHE_disconnect ( struct GNUNET_NAMECACHE_Handle h)

Disconnect from the namecache service (and free associated resources).

Must not be called from within operation callbacks of the API.

Parameters
hhandle to the namecache
hhandle to the namecache

Definition at line 428 of file namecache_api.c.

429 {
431 
432  GNUNET_break (NULL == h->op_head);
433  while (NULL != (q = h->op_head))
434  {
435  GNUNET_CONTAINER_DLL_remove (h->op_head,
436  h->op_tail,
437  q);
438  GNUNET_free (q);
439  }
440  if (NULL != h->mq)
441  {
443  h->mq = NULL;
444  }
445  if (NULL != h->reconnect_task)
446  {
448  h->reconnect_task = NULL;
449  }
450  GNUNET_free (h);
451 }
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:686
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:943
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
An QueueEntry used to store information for a pending NAMECACHE record operation.
Definition: namecache_api.c:48

References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), h, GNUNET_ARM_Handle::mq, q, and GNUNET_ARM_Handle::reconnect_task.

Referenced by do_shutdown(), and shutdown_task().

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

◆ GNUNET_NAMECACHE_block_cache()

struct GNUNET_NAMECACHE_QueueEntry* GNUNET_NAMECACHE_block_cache ( struct GNUNET_NAMECACHE_Handle h,
const struct GNUNET_GNSRECORD_Block block,
GNUNET_NAMECACHE_ContinuationWithStatus  cont,
void *  cont_cls 
)

Store an item in the namecache.

If the item is already present, it is replaced with the new record.

Parameters
hhandle to the namecache
blockblock to store
contcontinuation to call when done
cont_clsclosure for cont
Returns
handle to abort the request, NULL on error

Definition at line 465 of file namecache_api.c.

469 {
471  struct BlockCacheMessage *msg;
472  struct GNUNET_MQ_Envelope *env;
473  uint32_t rid;
474  size_t blen;
475 
476  if (NULL == h->mq)
477  return NULL;
478  blen = GNUNET_GNSRECORD_block_get_size (block);
479  rid = get_op_id (h);
481  qe->nsh = h;
482  qe->cont = cont;
483  qe->cont_cls = cont_cls;
484  qe->op_id = rid;
486  h->op_tail,
487  qe);
488  /* send msg */
490  blen,
492  msg->gns_header.r_id = htonl (rid);
493  GNUNET_memcpy (&msg[1],
494  block,
495  blen);
496  GNUNET_MQ_send (h->mq,
497  env);
498  return qe;
499 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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:303
#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:57
#define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE
Client to service: cache a block.
static uint32_t get_op_id(struct GNUNET_NAMECACHE_Handle *h)
Get a fresh operation id to distinguish between namecache requests.
Cache a record in the namecache.
Definition: namecache.h:95
GNUNET_DATASTORE_ContinuationWithStatus cont
Function to call after transmission of the request.
void * cont_cls
Closure for cont.

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, env, get_op_id(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_GNSRECORD_block_get_size(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_ARM_Handle::mq, msg, and qe.

Referenced by handle_dht_response(), and refresh_block().

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

◆ GNUNET_NAMECACHE_lookup_block()

struct GNUNET_NAMECACHE_QueueEntry* GNUNET_NAMECACHE_lookup_block ( struct GNUNET_NAMECACHE_Handle h,
const struct GNUNET_HashCode derived_hash,
GNUNET_NAMECACHE_BlockProcessor  proc,
void *  proc_cls 
)

Get a result for a particular key from the namecache.

The processor will only be called once.

Parameters
hhandle to the namecache
derived_hashhash of zone key combined with name to lookup then at the end once with NULL
procfunction to call on the matching block, or with NULL if there is no matching block
proc_clsclosure for proc
Returns
a handle that can be used to cancel, NULL on error

The processor will only be called once.

Parameters
hhandle to the namecache
derived_hashhash of zone key combined with name to lookup
procfunction to call on the matching block, or with NULL if there is no matching block
proc_clsclosure for proc
Returns
a handle that can be used to cancel, NULL on error

Definition at line 514 of file namecache_api.c.

518 {
520  struct LookupBlockMessage *msg;
521  struct GNUNET_MQ_Envelope *env;
522  uint32_t rid;
523 
524  if (NULL == h->mq)
525  return NULL;
527  "Looking for block under %s\n",
528  GNUNET_h2s (derived_hash));
529  rid = get_op_id (h);
531  qe->nsh = h;
532  qe->block_proc = proc;
533  qe->block_proc_cls = proc_cls;
534  qe->op_id = rid;
536  h->op_tail,
537  qe);
538  env = GNUNET_MQ_msg (msg,
540  msg->gns_header.r_id = htonl (rid);
541  msg->query = *derived_hash;
542  GNUNET_MQ_send (h->mq,
543  env);
544  return qe;
545 }
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:72
#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
Client to service: lookup block.
#define LOG(kind,...)
Definition: namecache_api.c:40
Lookup a block in the namecache.
Definition: namecache.h:59

References env, get_op_id(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, h, LOG, GNUNET_ARM_Handle::mq, msg, and qe.

Referenced by recursive_gns_resolution_namecache(), and run().

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

◆ GNUNET_NAMECACHE_cancel()

void GNUNET_NAMECACHE_cancel ( struct GNUNET_NAMECACHE_QueueEntry qe)

Cancel a namecache operation.

The final callback from the operation must not have been done yet. Must be called on any namecache operation that has not yet completed prior to calling GNUNET_NAMECACHE_disconnect.

Parameters
qeoperation to cancel

The final callback from the operation must not have been done yet.

Parameters
qeoperation to cancel

Definition at line 555 of file namecache_api.c.

556 {
557  struct GNUNET_NAMECACHE_Handle *h = qe->nsh;
558 
559  GNUNET_CONTAINER_DLL_remove (h->op_head,
560  h->op_tail,
561  qe);
562  GNUNET_free (qe);
563 }

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, h, and qe.

Referenced by do_shutdown(), GNS_resolver_done(), GNS_resolver_lookup_cancel(), and shutdown_task().

Here is the caller graph for this function: