API to access the NAMESTORE service. More...
#include "platform.h"
#include "gnunet_error_codes.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
#include "gnunet_signatures.h"
#include "gnunet_gns_service.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... | |
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 40 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 46 of file namestore_api.c.
|
static |
Disconnect from service and then reconnect.
h | our handle |
Definition at line 920 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 269 of file namestore_api.c.
References h, GNUNET_DATASTORE_QueueEntry::next, and qe.
Referenced by handle_lookup_result(), handle_record_result(), handle_record_result_end(), handle_record_store_response(), handle_tx_control_result(), 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 288 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 305 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_lookup_result(), handle_record_result(), handle_record_store_response(), handle_tx_control_result(), and handle_zone_to_name_response().
|
static |
Free ze.
ze | entry to free |
Definition at line 324 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 345 of file namestore_api.c.
References GNUNET_break, GNUNET_GNSRECORD_records_deserialize(), GNUNET_OK, GNUNET_SYSERR, rd, and rd_count.
Referenced by check_lookup_result(), check_record_result(), and check_zone_to_name_response().
|
static |
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE.
cls | |
msg | the message we received |
Definition at line 366 of file namestore_api.c.
References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, 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 395 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 447 of file namestore_api.c.
References find_qe(), free_qe(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_IDENTITY_read_private_key_from_buffer(), 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_RESULT.
cls | |
msg | the message we received |
Definition at line 522 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 564 of file namestore_api.c.
References find_qe(), find_zi(), force_reconnect(), free_qe(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_IDENTITY_read_private_key_from_buffer(), 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 648 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 |
Definition at line 678 of file namestore_api.c.
References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, find_qe(), free_qe(), GNUNET_ERROR_TYPE_DEBUG, h, LOG, msg, qe, and res.
|
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 706 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 745 of file namestore_api.c.
References find_qe(), free_qe(), GNUNET_assert, 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_IDENTITY_read_private_key_from_buffer(), GNUNET_OK, GNUNET_SYSERR, h, LOG, msg, qe, rd, rd_count, res, and zone.
|
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 834 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 849 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_RECORD_LOOKUP_RESPONSE, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT, 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 905 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 957 of file namestore_api.c.
References h.
Referenced by GNUNET_NAMESTORE_records_store2(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_to_name(), records_lookup(), and send_transaction_control_msg().
|
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 1032 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_store2().
|
static |
Definition at line 1196 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_IDENTITY_private_key_get_length(), GNUNET_IDENTITY_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::is_edit_request, LabelLookupMessage::key_len, LabelLookupMessage::label_len, GNUNET_ARM_Handle::mq, msg, pkey, and qe.
Referenced by GNUNET_NAMESTORE_records_edit(), GNUNET_NAMESTORE_records_lookup(), and GNUNET_NAMESTORE_records_lookup2().
|
static |
New API draft.
Experimental
Definition at line 1502 of file namestore_api.c.
References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, env, GNUNET_DATASTORE_QueueEntry::env, get_op_id(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, GNUNET_ARM_Handle::mq, msg, and qe.
Referenced by GNUNET_NAMESTORE_transaction_begin(), GNUNET_NAMESTORE_transaction_commit(), and GNUNET_NAMESTORE_transaction_rollback().