33#include "gnunet_signatures.h"
38#define LOG(kind, ...) GNUNET_log_from (kind, "namecache-api", __VA_ARGS__)
107 struct GNUNET_CLIENT_TransmitHandle *
th;
165 if (
qe->op_id == rid)
209 "Received LOOKUP_BLOCK_RESPONSE\n");
211 ntohl (
msg->gns_header.r_id));
217 if (NULL !=
qe->block_proc)
218 qe->block_proc (
qe->block_proc_cls,
229 memset (buf, 0,
size);
238 if (NULL !=
qe->block_proc)
239 qe->block_proc (
qe->block_proc_cls,
245 if (NULL !=
qe->block_proc)
246 qe->block_proc (
qe->block_proc_cls,
271 "Received BLOCK_CACHE_RESPONSE\n");
273 ntohl (
msg->gns_header.r_id));
276 res = ntohl (
msg->op_result);
283 :
_ (
"Namecache failed to cache block"));
363 while (NULL != (
qe =
h->op_head))
371 _ (
"Error communicating with namecache service"));
375 "Reconnecting to namecache\n");
392 return h->last_op_id_used++;
431 while (NULL != (
q =
h->op_head))
490 msg->gns_header.r_id = htonl (rid);
525 "Looking for block under %s\n",
530 qe->block_proc = proc;
531 qe->block_proc_cls = proc_cls;
538 msg->gns_header.r_id = htonl (rid);
539 msg->query = *derived_hash;
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
API that can be used to manipulate GNS record data.
API that can be used to store naming information on a GNUnet node.
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.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_verify(const struct GNUNET_GNSRECORD_Block *block)
Check if a signature is valid.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
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_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
struct GNUNET_NAMECACHE_Handle * GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the NAMECACHE service.
void(* GNUNET_NAMECACHE_ContinuationWithStatus)(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
void GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from the namecache service (and free associated resources).
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
void(* GNUNET_NAMECACHE_BlockProcessor)(void *cls, const struct GNUNET_GNSRECORD_Block *block)
Process a record that was stored in the namecache.
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.
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.
#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
Client to service: lookup block.
#define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE
Service to client: result of block cache request.
#define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE
Client to service: cache a block.
#define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE
Service to client: result of block lookup.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
common internal definitions for namecache service
static uint32_t get_op_id(struct GNUNET_NAMECACHE_Handle *h)
Get a fresh operation id to distinguish between namecache requests.
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.
static void reconnect(struct GNUNET_NAMECACHE_Handle *h)
Reconnect to namecache service.
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.
static struct GNUNET_NAMECACHE_QueueEntry * find_qe(struct GNUNET_NAMECACHE_Handle *h, uint32_t rid)
Find queue entry for the given rid.
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...
static void force_reconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from service and then reconnect.
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.
static void reconnect_task(void *cls)
Re-establish the connection to the service.
static unsigned int size
Size of the "table".
Cache a record in the namecache.
Response to a request to cache a block.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
struct GNUNET_DATASTORE_QueueEntry * next
This is a linked list.
GNUNET_DATASTORE_ContinuationWithStatus cont
Function to call after transmission of the request.
void * cont_cls
Closure for cont.
Handle to a message queue.
Message handler for a specific message type.
Connection to the NAMECACHE service.
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request (or NULL).
struct GNUNET_TIME_Relative reconnect_delay
Delay introduced before we reconnect.
struct GNUNET_MQ_Handle * mq
Message queue to service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
uint32_t last_op_id_used
The last operation id used for a NAMECACHE operation.
struct GNUNET_NAMECACHE_QueueEntry * op_head
Head of pending namecache queue entries.
int reconnect
Should we reconnect to service due to some serious error?
struct GNUNET_SCHEDULER_Task * reconnect_task
Reconnect task.
struct GNUNET_NAMECACHE_QueueEntry * op_tail
Tail of pending namecache queue entries.
An QueueEntry used to store information for a pending NAMECACHE record operation.
struct GNUNET_NAMECACHE_QueueEntry * prev
Kept in a DLL.
void * cont_cls
Closure for cont.
struct GNUNET_NAMECACHE_QueueEntry * next
Kept in a DLL.
GNUNET_NAMECACHE_ContinuationWithStatus cont
Continuation to call.
GNUNET_NAMECACHE_BlockProcessor block_proc
Function to call with the blocks we get back; or NULL.
struct GNUNET_NAMECACHE_Handle * nsh
Main handle to access the namecache.
uint32_t op_id
The operation id this zone iteration operation has.
void * block_proc_cls
Closure for block_proc.
Entry in list of pending tasks.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
Lookup a block in the namecache.