API to access the NAMECACHE service. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_namecache_service.h"
#include "namecache.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_NAMECACHE_QueueEntry |
An QueueEntry used to store information for a pending NAMECACHE record operation. More... | |
struct | GNUNET_NAMECACHE_Handle |
Connection to the NAMECACHE service. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "namecache-api", __VA_ARGS__) |
Functions | |
static void | force_reconnect (struct GNUNET_NAMECACHE_Handle *h) |
Disconnect from service and then reconnect. More... | |
static struct GNUNET_NAMECACHE_QueueEntry * | find_qe (struct GNUNET_NAMECACHE_Handle *h, uint32_t rid) |
Find queue entry for the given rid. More... | |
static int | check_lookup_block_response (void *cls, const struct LookupBlockResponseMessage *msg) |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE. More... | |
static void | handle_lookup_block_response (void *cls, const struct LookupBlockResponseMessage *msg) |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE. More... | |
static void | handle_block_cache_response (void *cls, const struct BlockCacheResponseMessage *msg) |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_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_NAMECACHE_Handle *h) |
Reconnect to namecache service. More... | |
static void | reconnect_task (void *cls) |
Re-establish the connection to the service. More... | |
static uint32_t | get_op_id (struct GNUNET_NAMECACHE_Handle *h) |
Get a fresh operation id to distinguish between namecache requests. More... | |
struct GNUNET_NAMECACHE_Handle * | GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Initialize the connection with 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_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. More... | |
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. More... | |
void | GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe) |
Cancel a namecache operation. More... | |
API to access the NAMECACHE service.
Definition in file namecache_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "namecache-api", __VA_ARGS__) |
Definition at line 38 of file namecache_api.c.
|
static |
Disconnect from service and then reconnect.
h | our handle |
Definition at line 356 of file namecache_api.c.
References _, GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_NO, 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_lookup_block_response(), and mq_error_handler().
|
static |
Find queue entry for the given rid.
h | handle to search |
rid | request ID to look for |
Definition at line 158 of file namecache_api.c.
References GNUNET_CONTAINER_DLL_remove, h, GNUNET_DATASTORE_QueueEntry::next, and qe.
Referenced by handle_block_cache_response(), and handle_lookup_block_response().
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE.
cls | the struct GNUNET_NAMECACHE_Handle |
msg | the message we received |
Definition at line 185 of file namecache_api.c.
References GNUNET_OK.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE.
cls | the struct GNUNET_NAMECACHE_Handle |
msg | the message we received |
Definition at line 201 of file namecache_api.c.
References GNUNET_TIME_Absolute::abs_value_us, find_qe(), force_reconnect(), GNUNET_ALIGN, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_block_verify(), GNUNET_memcpy, GNUNET_OK, GNUNET_TIME_absolute_ntoh(), h, LOG, msg, qe, GNUNET_MessageHeader::size, and size.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE.
cls | the struct GNUNET_NAMECACHE_Handle |
msg | the message we received |
Definition at line 263 of file namecache_api.c.
References _, GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_OK, h, LOG, msg, qe, and res.
|
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.
cls | closure with the struct GNUNET_NAMECACHE_Handle * |
error | error code |
Definition at line 297 of file namecache_api.c.
References force_reconnect(), and h.
Referenced by reconnect().
|
static |
Reconnect to namecache service.
h | the handle to the NAMECACHE service |
Definition at line 312 of file namecache_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE, GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, h, handlers, GNUNET_ARM_Handle::mq, and mq_error_handler().
Referenced by GNUNET_NAMECACHE_connect(), and reconnect_task().
|
static |
Re-establish the connection to the service.
cls | handle to use to re-connect. |
Definition at line 341 of file namecache_api.c.
References h, reconnect(), and GNUNET_ARM_Handle::reconnect_task.
Referenced by force_reconnect().
|
static |
Get a fresh operation id to distinguish between namecache requests.
h | the namecache handle |
Definition at line 390 of file namecache_api.c.
References h.
Referenced by GNUNET_NAMECACHE_block_cache(), and GNUNET_NAMECACHE_lookup_block().