GNUnet 0.21.2
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 403 of file namecache_api.c.

404{
406
408 h->cfg = cfg;
409 reconnect (h);
410 if (NULL == h->mq)
411 {
412 GNUNET_free (h);
413 return NULL;
414 }
415 return h;
416}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
#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:93

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 426 of file namecache_api.c.

427{
429
430 GNUNET_break (NULL == h->op_head);
431 while (NULL != (q = h->op_head))
432 {
434 h->op_tail,
435 q);
436 GNUNET_free (q);
437 }
438 if (NULL != h->mq)
439 {
441 h->mq = NULL;
442 }
443 if (NULL != h->reconnect_task)
444 {
446 h->reconnect_task = NULL;
447 }
448 GNUNET_free (h);
449}
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:683
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
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:46

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 463 of file namecache_api.c.

467{
469 struct BlockCacheMessage *msg;
470 struct GNUNET_MQ_Envelope *env;
471 uint32_t rid;
472 size_t blen;
473
474 if (NULL == h->mq)
475 return NULL;
476 blen = GNUNET_GNSRECORD_block_get_size (block);
477 rid = get_op_id (h);
479 qe->nsh = h;
480 qe->cont = cont;
481 qe->cont_cls = cont_cls;
482 qe->op_id = rid;
484 h->op_tail,
485 qe);
486 /* send msg */
488 blen,
490 msg->gns_header.r_id = htonl (rid);
491 GNUNET_memcpy (&msg[1],
492 block,
493 blen);
495 env);
496 return qe;
497}
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:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_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 512 of file namecache_api.c.

516{
518 struct LookupBlockMessage *msg;
519 struct GNUNET_MQ_Envelope *env;
520 uint32_t rid;
521
522 if (NULL == h->mq)
523 return NULL;
525 "Looking for block under %s\n",
526 GNUNET_h2s (derived_hash));
527 rid = get_op_id (h);
529 qe->nsh = h;
530 qe->block_proc = proc;
531 qe->block_proc_cls = proc_cls;
532 qe->op_id = rid;
534 h->op_tail,
535 qe);
538 msg->gns_header.r_id = htonl (rid);
539 msg->query = *derived_hash;
541 env);
542 return qe;
543}
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:78
#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
Client to service: lookup block.
#define LOG(kind,...)
Definition: namecache_api.c:38
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 553 of file namecache_api.c.

554{
555 struct GNUNET_NAMECACHE_Handle *h = qe->nsh;
556
558 h->op_tail,
559 qe);
560 GNUNET_free (qe);
561}

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: