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"
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_QueueEntry * | find_qe (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid) |
Find the queue entry that matches the rid. More... | |
static struct GNUNET_NAMESTORE_ZoneIterator * | find_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_Handle * | GNUNET_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_QueueEntry * | GNUNET_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_QueueEntry * | GNUNET_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_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) |
struct GNUNET_NAMESTORE_QueueEntry * | GNUNET_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_QueueEntry * | GNUNET_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_QueueEntry * | GNUNET_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_ZoneIterator * | GNUNET_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_ZoneIterator * | GNUNET_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_QueueEntry * | GNUNET_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_QueueEntry * | GNUNET_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... | |
API to access the NAMESTORE service.
Definition in file namestore_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "namestore-api", __VA_ARGS__) |
Definition at line 36 of file namestore_api.c.
#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.
|
static |
Disconnect from service and then reconnect.
h | our handle |
Definition at line 990 of file namestore_api.c.
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().
|
static |
Find the queue entry that matches the rid.
h | namestore handle |
rid | id to look up |
Definition at line 270 of file namestore_api.c.
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().
|
static |
Find the zone iteration entry that matches the rid.
h | namestore handle |
rid | id to look up |
Definition at line 289 of file namestore_api.c.
References h, GNUNET_NAMESTORE_ZoneIterator::next, and GNUNET_NAMESTORE_ZoneIterator::op_id.
Referenced by handle_record_result(), and handle_record_result_end().
|
static |
Free qe.
qe | entry to free |
Definition at line 306 of file namestore_api.c.
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().
|
static |
Free ze.
ze | entry to free |
Definition at line 325 of file namestore_api.c.
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().
|
static |
Check that rd_buf of length rd_len contains rd_count records.
rd_len | length of rd_buf |
rd_buf | buffer with serialized records |
rd_count | number of records expected |
Definition at line 346 of file namestore_api.c.
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().
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE.
cls | |
msg | the message we received |
Definition at line 368 of file namestore_api.c.
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.
|
static |
Check validity of an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
cls | |
msg | the message we received |
Definition at line 397 of file namestore_api.c.
References check_rd(), GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, msg, name, and GNUNET_MessageHeader::size.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
cls | |
msg | the message we received |
Definition at line 449 of file namestore_api.c.
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.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE.
cls | |
msg | the message we received |
Definition at line 524 of file namestore_api.c.
References check_rd(), GNUNET_break, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE.
cls | |
msg | the message we received |
Definition at line 561 of file namestore_api.c.
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.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
cls | |
msg | the message we received |
Definition at line 611 of file namestore_api.c.
References check_rd(), GNUNET_break, GNUNET_SYSERR, msg, name, and GNUNET_MessageHeader::size.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
cls | |
msg | the message we received |
Definition at line 653 of file namestore_api.c.
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.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END.
cls | |
msg | the message we received |
Definition at line 737 of file namestore_api.c.
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.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
qe | the respective entry in the message queue |
msg | the message we received |
Definition at line 776 of file namestore_api.c.
References check_rd(), GNUNET_break, GNUNET_EC_NONE, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
cls | |
msg | the message we received |
Definition at line 815 of file namestore_api.c.
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.
|
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_NAMESTORE_Handle * |
error | error code |
Definition at line 904 of file namestore_api.c.
References force_reconnect(), and h.
Referenced by reconnect().
|
static |
Reconnect to namestore service.
h | the handle to the NAMESTORE service |
Definition at line 919 of file namestore_api.c.
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().
|
static |
Re-establish the connection to the service.
cls | handle to use to re-connect. |
Definition at line 975 of file namestore_api.c.
References h, reconnect(), and GNUNET_ARM_Handle::reconnect_task.
Referenced by force_reconnect().
|
static |
Get a fresh operation id to distinguish between namestore requests.
h | the namestore handle |
Definition at line 1027 of file namestore_api.c.
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().
|
static |
Task launched to warn the user that the namestore is excessively slow and that a query was thus dropped.
cls | a struct GNUNET_NAMESTORE_QueueEntry * |
Definition at line 1102 of file namestore_api.c.
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().
|
static |
Definition at line 1268 of file namestore_api.c.
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().