![]() |
GNUnet
0.11.x
|
namestore for the GNUnet naming system More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dnsparser_lib.h"
#include "gnunet_gns_service.h"
#include "gnunet_namecache_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_namestore_plugin.h"
#include "gnunet_statistics_service.h"
#include "gnunet_signatures.h"
#include "namestore.h"
Go to the source code of this file.
Data Structures | |
struct | ZoneIteration |
A namestore iteration operation. More... | |
struct | NamestoreClient |
A namestore client. More... | |
struct | ZoneMonitor |
A namestore monitor. More... | |
struct | CacheOperation |
Pending operation on the namecache. More... | |
struct | StoreActivity |
Information for an ongoing handle_record_store() operation. More... | |
struct | NickCache |
Entry in list of cached nick resolutions. More... | |
struct | RecordLookupContext |
Closure for lookup_it(). More... | |
struct | ZoneToNameCtx |
Context for record remove operations passed from handle_zone_to_name to handle_zone_to_name_it as closure. More... | |
struct | ZoneIterationProcResult |
Context for record remove operations passed from run_zone_iteration_round to zone_iterate_proc as closure. More... | |
Macros | |
#define | LOG_STRERROR_FILE(kind, syscall, filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
#define | MONITOR_STALL_WARN_DELAY GNUNET_TIME_UNIT_MINUTES |
If a monitor takes more than 1 minute to process an event, print a warning. More... | |
#define | NC_SIZE 16 |
Size of the cache used by get_nick_record() More... | |
Functions | |
static void | cleanup_task (void *cls) |
Task run during shutdown. More... | |
static void | free_store_activity (struct StoreActivity *sa) |
Release memory used by sa. More... | |
static void | lookup_nick_it (void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Function called with the records for the GNUNET_GNS_EMPTY_LABEL_AT label in the zone. More... | |
static void | cache_nick (const struct GNUNET_IDENTITY_PrivateKey *zone, const struct GNUNET_GNSRECORD_Data *nick) |
Add entry to the cache for zone and nick. More... | |
static struct GNUNET_GNSRECORD_Data * | get_nick_record (const struct GNUNET_IDENTITY_PrivateKey *zone) |
Return the NICK record for the zone (if it exists). More... | |
static void | merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, unsigned int rd2_length, const struct GNUNET_GNSRECORD_Data *rd2, unsigned int *rdc_res, struct GNUNET_GNSRECORD_Data **rd_res) |
Merge the nick record nick_rd with the rest of the record set given in rd2. More... | |
static void | send_lookup_response (struct NamestoreClient *nc, uint32_t request_id, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Generate a struct LookupNameResponseMessage and send it to the given client using the given notification context. More... | |
static void | send_store_response (struct NamestoreClient *nc, int res, uint32_t rid) |
Send response to the store request to the client. More... | |
static void | zone_iteration_done_client_continue (struct ZoneIteration *zi) |
Function called once we are done with the zone iteration and allow the zone iteration client to send us more messages. More... | |
static void | finish_cache_operation (void *cls, int32_t success, const char *emsg) |
Cache operation complete, clean up. More... | |
static void | refresh_block (struct NamestoreClient *nc, struct ZoneIteration *zi, uint32_t rid, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
We just touched the plaintext information about a name in our zone; refresh the corresponding (encrypted) block in the namecache. More... | |
static void | warn_monitor_slow (void *cls) |
Print a warning that one of our monitors is no longer reacting. More... | |
static void | continue_store_activity (struct StoreActivity *sa) |
Continue processing the sa. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
Called whenever a client is disconnected. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
Add a client to our list of active clients. More... | |
static void | lookup_it (void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Function called by the namestore plugin when we are trying to lookup a record as part of handle_record_lookup(). More... | |
static int | check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message. More... | |
static void | handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message. More... | |
static int | check_record_store (void *cls, const struct RecordStoreMessage *rp_msg) |
Checks a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message. More... | |
static void | handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message. More... | |
static void | handle_zone_to_name_it (void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Zone to name iterator. More... | |
static void | handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message. More... | |
static void | zone_iterate_proc (void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Process results for zone iteration from database. More... | |
static void | run_zone_iteration_round (struct ZoneIteration *zi, uint64_t limit) |
Perform the next round of the zone iteration. More... | |
static void | handle_iteration_start (void *cls, const struct ZoneIterationStartMessage *zis_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message. More... | |
static void | handle_iteration_stop (void *cls, const struct ZoneIterationStopMessage *zis_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message. More... | |
static void | handle_iteration_next (void *cls, const struct ZoneIterationNextMessage *zis_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message. More... | |
static void | monitor_unblock (struct ZoneMonitor *zm) |
Function called when the monitor is ready for more data, and we should thus unblock PUT operations that were blocked on the monitor not being ready. More... | |
static void | monitor_sync (struct ZoneMonitor *zm) |
Send 'sync' message to zone monitor, we're now in sync. More... | |
static void | monitor_iteration_next (void *cls) |
Obtain the next datum during the zone monitor's zone initial iteration. More... | |
static void | monitor_iterate_cb (void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
A GNUNET_NAMESTORE_RecordIterator for monitors. More... | |
static void | handle_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message. More... | |
static void | handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm) |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service) |
Process namestore requests. More... | |
GNUNET_SERVICE_MAIN ("namestore", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(record_store, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, struct RecordStoreMessage, NULL), GNUNET_MQ_hd_var_size(record_lookup, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, struct LabelLookupMessage, NULL), GNUNET_MQ_hd_fixed_size(zone_to_name, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, struct ZoneToNameMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, struct ZoneIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, struct ZoneIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, struct ZoneIterationStopMessage, NULL), GNUNET_MQ_hd_fixed_size(monitor_start, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, struct ZoneMonitorStartMessage, NULL), GNUNET_MQ_hd_fixed_size(monitor_next, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, struct ZoneMonitorNextMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static struct NickCache | nick_cache [16] |
We cache nick records to reduce DB load. More... | |
static const struct GNUNET_IDENTITY_PrivateKey | zero |
Public key of all zeros. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | GSN_cfg |
Configuration handle. More... | |
static struct GNUNET_STATISTICS_Handle * | statistics |
Handle to the statistics service. More... | |
static struct GNUNET_NAMECACHE_Handle * | namecache |
Namecache handle. More... | |
static struct GNUNET_NAMESTORE_PluginFunctions * | GSN_database |
Database handle. More... | |
static char * | db_lib_name |
Name of the database plugin. More... | |
static struct CacheOperation * | cop_head |
Head of cop DLL. More... | |
static struct CacheOperation * | cop_tail |
Tail of cop DLL. More... | |
static struct ZoneMonitor * | monitor_head |
First active zone monitor. More... | |
static struct ZoneMonitor * | monitor_tail |
Last active zone monitor. More... | |
static struct StoreActivity * | sa_head |
Head of DLL of monitor-blocked store activities. More... | |
static struct StoreActivity * | sa_tail |
Tail of DLL of monitor-blocked store activities. More... | |
static struct GNUNET_NotificationContext * | monitor_nc |
Notification context shared by all monitors. More... | |
static int | cache_keys |
Optimize block insertion by caching map of private keys to public keys in memory? More... | |
static int | disable_namecache |
Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record. More... | |
namestore for the GNUnet naming system
Definition in file gnunet-service-namestore.c.
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) | GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
Definition at line 38 of file gnunet-service-namestore.c.
#define MONITOR_STALL_WARN_DELAY GNUNET_TIME_UNIT_MINUTES |
If a monitor takes more than 1 minute to process an event, print a warning.
Definition at line 44 of file gnunet-service-namestore.c.
Referenced by continue_store_activity(), handle_monitor_next(), monitor_unblock(), and warn_monitor_slow().
#define NC_SIZE 16 |
Size of the cache used by get_nick_record()
Definition at line 49 of file gnunet-service-namestore.c.
Referenced by cache_nick(), and get_nick_record().
|
static |
Task run during shutdown.
cls | unused |
Definition at line 420 of file gnunet-service-namestore.c.
References db_lib_name, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NAMECACHE_cancel(), GNUNET_NAMECACHE_disconnect(), GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_PLUGIN_unload(), GNUNET_STATISTICS_destroy(), and CacheOperation::qe.
Referenced by run().
|
static |
Release memory used by sa.
sa | activity to free |
Definition at line 461 of file gnunet-service-namestore.c.
References StoreActivity::conv_name, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.
Referenced by client_disconnect_cb(), and continue_store_activity().
|
static |
Function called with the records for the GNUNET_GNS_EMPTY_LABEL_AT label in the zone.
Used to locate the GNUNET_GNSRECORD_TYPE_NICK record, which (if found) is then copied to cls for future use.
cls | a struct GNUNET_GNSRECORD_Data ** for storing the nick (if found) |
seq | sequence number of the record, MUST NOT BE ZERO |
private_key | the private key of the zone (unused) |
label | should be GNUNET_GNS_EMPTY_LABEL_AT |
rd_count | number of records in rd |
rd | records stored under label in the zone |
Definition at line 482 of file gnunet-service-namestore.c.
References GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_TYPE_NICK, GNUNET_malloc, GNUNET_memcpy, GNUNET_GNSRECORD_Data::record_type, and res.
Referenced by get_nick_record().
|
static |
Add entry to the cache for zone and nick.
zone | zone key to cache under |
nick | nick entry to cache |
Definition at line 524 of file gnunet-service-namestore.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_free, GNUNET_malloc, GNUNET_memcmp, GNUNET_TIME_absolute_get(), NickCache::last_used, NC_SIZE, ZoneIteration::nick, nick_cache, NickCache::rd, ZoneIteration::zone, and NickCache::zone.
Referenced by get_nick_record(), and handle_record_store().
|
static |
Return the NICK record for the zone (if it exists).
zone | private key for the zone to look for nick |
Definition at line 567 of file gnunet-service-namestore.c.
References cache_nick(), GNUNET_NAMESTORE_PluginFunctions::cls, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_get_log_call_status(), GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_z2s(), GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_LOG_CALL_STATUS, GNUNET_malloc, GNUNET_memcmp, GNUNET_OK, GNUNET_TIME_absolute_get(), NickCache::last_used, lookup_nick_it(), GNUNET_NAMESTORE_PluginFunctions::lookup_records, NC_SIZE, ZoneIteration::nick, nick_cache, NickCache::rd, res, and NickCache::zone.
Referenced by handle_record_lookup(), refresh_block(), and send_lookup_response().
|
static |
Merge the nick record nick_rd with the rest of the record set given in rd2.
Store the result in rdc_res and rd_res. The nick_rd's expiration time is set to the maximum expiration time of all of the records in rd2.
nick_rd | the nick record to integrate |
rd2_length | length of the rd2 array |
rd2 | array of records |
rdc_res[out] | length of the resulting rd_res array |
rd_res[out] | set to an array of records, including nick_rd and rd2; all of the variable-size 'data' fields in rd2 are allocated in the same chunk of memory! |
Definition at line 642 of file gnunet-service-namestore.c.
References data, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_malloc, GNUNET_memcpy, and GNUNET_TIME_absolute_get().
Referenced by lookup_it(), refresh_block(), and send_lookup_response().
|
static |
Generate a struct LookupNameResponseMessage
and send it to the given client using the given notification context.
nc | client to unicast to |
request_id | request ID to use |
zone_key | zone key of the zone |
name | name |
rd_count | number of records in rd |
rd | array of records |
Definition at line 721 of file gnunet-service-namestore.c.
References NamestoreClient::client, env, GNUNET_GNSRECORD_Data::flags, get_nick_record(), RecordResultMessage::gns_header, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), merge_with_nick_records(), NamestoreClient::mq, RecordResultMessage::name_len, ZoneIteration::nick, RecordResultMessage::private_key, GNUNET_NAMESTORE_Header::r_id, RecordResultMessage::rd_count, RecordResultMessage::rd_len, and res.
Referenced by continue_store_activity(), monitor_iterate_cb(), and zone_iterate_proc().
|
static |
Send response to the store request to the client.
client | client to talk to |
res | status of the operation |
rid | client's request ID |
Definition at line 806 of file gnunet-service-namestore.c.
References env, RecordStoreResponseMessage::gns_header, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), NamestoreClient::mq, RecordStoreResponseMessage::op_result, and GNUNET_NAMESTORE_Header::r_id.
Referenced by finish_cache_operation(), handle_record_store(), and refresh_block().
|
static |
Function called once we are done with the zone iteration and allow the zone iteration client to send us more messages.
zi | zone iteration we are processing |
Definition at line 833 of file gnunet-service-namestore.c.
References NamestoreClient::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), NamestoreClient::mq, ZoneIteration::nc, NamestoreClient::op_head, NamestoreClient::op_tail, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, and ZoneIteration::send_end.
Referenced by finish_cache_operation(), and run_zone_iteration_round().
|
static |
Cache operation complete, clean up.
cls | the struct CacheOperation |
success | success |
emsg | error messages |
Definition at line 859 of file gnunet-service-namestore.c.
References _, ZoneIteration::cache_ops, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, CacheOperation::nc, CacheOperation::rid, send_store_response(), CacheOperation::zi, and zone_iteration_done_client_continue().
Referenced by refresh_block().
|
static |
We just touched the plaintext information about a name in our zone; refresh the corresponding (encrypted) block in the namecache.
nc | client responsible for the request, can be NULL |
zi | zone iteration response for the request, can be NULL |
rid | request ID of the client |
zone_key | private key of the zone |
name | label for the records |
rd_count | number of records |
rd | records stored under the given name |
Definition at line 899 of file gnunet-service-namestore.c.
References cache_keys, ZoneIteration::cache_ops, disable_namecache, finish_cache_operation(), GNUNET_GNSRECORD_Data::flags, get_nick_record(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_block_create2(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_z2s(), GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_NAMECACHE_block_cache(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_YES, merge_with_nick_records(), ZoneIteration::nc, CacheOperation::nc, ZoneIteration::nick, CacheOperation::qe, res, CacheOperation::rid, send_store_response(), and CacheOperation::zi.
Referenced by continue_store_activity(), and zone_iterate_proc().
|
static |
Print a warning that one of our monitors is no longer reacting.
cls | a struct ZoneMonitor to warn about |
Definition at line 982 of file gnunet-service-namestore.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_absolute_time_to_string(), MONITOR_STALL_WARN_DELAY, ZoneMonitor::sa_wait_warning, ZoneMonitor::sa_waiting_start, and zm.
Referenced by continue_store_activity(), handle_monitor_next(), and monitor_unblock().
|
static |
Continue processing the sa.
sa | store activity to process |
Definition at line 1001 of file gnunet-service-namestore.c.
References NamestoreClient::client, StoreActivity::conv_name, free_store_activity(), RecordStoreMessage::gns_header, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_log, GNUNET_memcmp, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_TIME_absolute_get(), GNUNET_YES, MONITOR_STALL_WARN_DELAY, RecordStoreMessage::name_len, StoreActivity::nc, RecordStoreMessage::private_key, GNUNET_NAMESTORE_Header::r_id, RecordStoreMessage::rd_count, RecordStoreMessage::rd_len, refresh_block(), StoreActivity::rsm, send_lookup_response(), warn_monitor_slow(), zero, zm, StoreActivity::zm_pos, and GNUNET_NAMESTORE_ZoneMonitor::zone.
Referenced by client_disconnect_cb(), handle_record_store(), and monitor_unblock().
|
static |
Called whenever a client is disconnected.
Frees our resources associated with that client.
cls | closure |
client | identification of the client |
app_ctx | the struct NamestoreClient of client |
Definition at line 1080 of file gnunet-service-namestore.c.
References continue_store_activity(), free_store_activity(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), ZoneIteration::nc, CacheOperation::nc, CacheOperation::next, StoreActivity::next, NamestoreClient::op_head, NamestoreClient::op_tail, zm, and StoreActivity::zm_pos.
Referenced by run().
|
static |
Add a client to our list of active clients.
cls | NULL |
client | client to add |
mq | message queue for client |
Definition at line 1150 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, NamestoreClient::mq, and ZoneIteration::nc.
Referenced by run().
|
static |
Function called by the namestore plugin when we are trying to lookup a record as part of handle_record_lookup().
Merges all results into the context.
cls | closure with a struct RecordLookupContext |
seq | unique serial number of the record, MUST NOT BE ZERO |
zone_key | private key of the zone |
label | name that is being mapped (at most 255 characters long) |
rd_count | number of entries in rd array |
rd | array of records with data to store |
Definition at line 1215 of file gnunet-service-namestore.c.
References GNUNET_GNSRECORD_Data::flags, RecordLookupContext::found, GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_malloc, GNUNET_NO, GNUNET_YES, RecordLookupContext::label, merge_with_nick_records(), RecordLookupContext::nick, RecordLookupContext::rd_ser_len, RecordLookupContext::res_rd, and RecordLookupContext::res_rd_count.
Referenced by handle_record_lookup().
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
cls | client sending the message |
ll_msg | message of type struct LabelLookupMessage |
Definition at line 1313 of file gnunet-service-namestore.c.
References LabelLookupMessage::gns_header, GNUNET_break, GNUNET_MQ_check_zero_termination, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, LabelLookupMessage::label_len, and GNUNET_MessageHeader::size.
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
cls | client sending the message |
ll_msg | message of type struct LabelLookupMessage |
Definition at line 1338 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_NAMESTORE_PluginFunctions::cls, env, LabelLookupResponseMessage::found, RecordLookupContext::found, get_nick_record(), LabelLookupMessage::gns_header, LabelLookupResponseMessage::gns_header, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_string_to_lowercase(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, RecordLookupContext::label, LabelLookupMessage::label_len, lookup_it(), GNUNET_NAMESTORE_PluginFunctions::lookup_records, NamestoreClient::mq, LabelLookupResponseMessage::name_len, ZoneIteration::nc, RecordLookupContext::nick, LabelLookupResponseMessage::private_key, GNUNET_NAMESTORE_Header::r_id, LabelLookupResponseMessage::rd_count, LabelLookupResponseMessage::rd_len, RecordLookupContext::rd_ser_len, res, RecordLookupContext::res_rd, RecordLookupContext::res_rd_count, and LabelLookupMessage::zone.
|
static |
Checks a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
cls | client sending the message |
rp_msg | message of type struct RecordStoreMessage |
Definition at line 1407 of file gnunet-service-namestore.c.
References RecordStoreMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, MAX_NAME_LEN, RecordStoreMessage::name_len, RecordStoreMessage::rd_len, RecordLookupContext::rd_ser_len, and GNUNET_MessageHeader::size.
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
cls | client sending the message |
rp_msg | message of type struct RecordStoreMessage |
Definition at line 1447 of file gnunet-service-namestore.c.
References cache_nick(), NamestoreClient::client, GNUNET_NAMESTORE_PluginFunctions::cls, continue_store_activity(), StoreActivity::conv_name, RecordStoreMessage::gns_header, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_string_to_lowercase(), GNUNET_GNSRECORD_TYPE_NICK, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), GNUNET_YES, GNUNET_NAMESTORE_Header::header, GNUNET_NAMESTORE_PluginFunctions::lookup_records, monitor_head, RecordStoreMessage::name_len, ZoneIteration::nc, StoreActivity::nc, RecordStoreMessage::private_key, GNUNET_NAMESTORE_Header::r_id, RecordStoreMessage::rd_count, RecordStoreMessage::rd_len, GNUNET_GNSRECORD_Data::record_type, res, RecordStoreMessage::reserved, StoreActivity::rsm, send_store_response(), GNUNET_MessageHeader::size, GNUNET_NAMESTORE_PluginFunctions::store_records, and StoreActivity::zm_pos.
|
static |
Zone to name iterator.
cls | struct ZoneToNameCtx * |
seq | sequence number of the record, MUST NOT BE ZERO |
zone_key | the zone key |
name | name |
rd_count | number of records in rd |
rd | record data |
Definition at line 1606 of file gnunet-service-namestore.c.
References env, ZoneToNameResponseMessage::gns_header, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_NAMESTORE_Header::header, NamestoreClient::mq, name, ZoneToNameResponseMessage::name_len, ZoneToNameCtx::nc, GNUNET_NAMESTORE_Header::r_id, ZoneToNameResponseMessage::rd_count, ZoneToNameResponseMessage::rd_len, res, ZoneToNameResponseMessage::res, ZoneToNameCtx::rid, GNUNET_MessageHeader::size, ZoneToNameCtx::success, and ZoneToNameResponseMessage::zone.
Referenced by handle_zone_to_name().
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message.
cls | client client sending the message |
ztn_msg | message of type 'struct ZoneToNameMessage' |
Definition at line 1672 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_NAMESTORE_PluginFunctions::cls, env, ZoneToNameResponseMessage::gns_header, ZoneToNameMessage::gns_header, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, handle_zone_to_name_it(), NamestoreClient::mq, ZoneIteration::nc, ZoneToNameCtx::nc, GNUNET_NAMESTORE_Header::r_id, ZoneToNameResponseMessage::res, ZoneToNameCtx::rid, ZoneToNameCtx::success, ZoneToNameMessage::value_zone, ZoneToNameMessage::zone, and GNUNET_NAMESTORE_PluginFunctions::zone_to_name.
|
static |
Process results for zone iteration from database.
cls | struct ZoneIterationProcResult |
seq | sequence number of the record, MUST NOT BE ZERO |
zone_key | the zone key |
name | name |
rd_count | number of records for this name |
rd | record data |
Definition at line 1739 of file gnunet-service-namestore.c.
References GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_log, GNUNET_NO, GNUNET_YES, ZoneIterationProcResult::limit, ZoneIteration::nc, refresh_block(), ZoneIteration::request_id, send_lookup_response(), ZoneIteration::seq, and ZoneIterationProcResult::zi.
Referenced by run_zone_iteration_round().
|
static |
Perform the next round of the zone iteration.
zi | zone iterator to process |
limit | number of results to return in one pass |
Definition at line 1796 of file gnunet-service-namestore.c.
References ZoneIteration::cache_ops, GNUNET_NAMESTORE_PluginFunctions::cls, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_is_zero, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_divide(), GNUNET_YES, GNUNET_NAMESTORE_PluginFunctions::iterate_records, ZoneIterationProcResult::limit, ZoneIteration::send_end, ZoneIteration::seq, ZoneIterationProcResult::zi, ZoneIteration::zone, zone_iterate_proc(), and zone_iteration_done_client_continue().
Referenced by handle_iteration_next(), and handle_iteration_start().
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message.
cls | the client sending the message |
zis_msg | message from the client |
Definition at line 1842 of file gnunet-service-namestore.c.
References ZoneIterationStartMessage::gns_header, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, ZoneIteration::nc, ZoneIteration::offset, NamestoreClient::op_head, NamestoreClient::op_tail, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, run_zone_iteration_round(), ZoneIteration::zone, and ZoneIterationStartMessage::zone.
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message.
cls | the client sending the message |
zis_msg | message from the client |
Definition at line 1868 of file gnunet-service-namestore.c.
References NamestoreClient::client, ZoneIterationStopMessage::gns_header, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), ZoneIteration::nc, ZoneIteration::next, NamestoreClient::op_head, NamestoreClient::op_tail, GNUNET_NAMESTORE_Header::r_id, and ZoneIteration::request_id.
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message.
cls | the client sending the message |
message | message from the client |
Definition at line 1900 of file gnunet-service-namestore.c.
References NamestoreClient::client, ZoneIterationNextMessage::gns_header, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), ZoneIterationNextMessage::limit, ZoneIteration::nc, ZoneIteration::next, NamestoreClient::op_head, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, and run_zone_iteration_round().
|
static |
Function called when the monitor is ready for more data, and we should thus unblock PUT operations that were blocked on the monitor not being ready.
Definition at line 1935 of file gnunet-service-namestore.c.
References continue_store_activity(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_YES, ZoneMonitor::iteration_cnt, ZoneMonitor::limit, MONITOR_STALL_WARN_DELAY, StoreActivity::next, sa_head, ZoneMonitor::sa_wait_warning, ZoneMonitor::sa_waiting, ZoneMonitor::sa_waiting_start, warn_monitor_slow(), and StoreActivity::zm_pos.
Referenced by handle_monitor_next(), and monitor_sync().
|
static |
Send 'sync' message to zone monitor, we're now in sync.
zm | monitor that is now in sync |
Definition at line 1975 of file gnunet-service-namestore.c.
References env, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, ZoneMonitor::in_first_iteration, ZoneMonitor::iteration_cnt, ZoneMonitor::limit, monitor_iteration_next(), monitor_unblock(), NamestoreClient::mq, ZoneMonitor::nc, and ZoneMonitor::sa_waiting.
Referenced by handle_monitor_start(), and monitor_iteration_next().
|
static |
Obtain the next datum during the zone monitor's zone initial iteration.
cls | zone monitor that does its initial iteration |
Definition at line 2074 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_NAMESTORE_PluginFunctions::cls, GNUNET_assert, GNUNET_is_zero, GNUNET_NO, GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, GNUNET_NAMESTORE_PluginFunctions::iterate_records, ZoneMonitor::iteration_cnt, ZoneMonitor::limit, monitor_iterate_cb(), monitor_sync(), ZoneMonitor::nc, ret, ZoneMonitor::seq, ZoneMonitor::task, zm, and ZoneMonitor::zone.
Referenced by handle_monitor_next(), handle_monitor_start(), monitor_iterate_cb(), and monitor_sync().
|
static |
A GNUNET_NAMESTORE_RecordIterator for monitors.
cls | a 'struct ZoneMonitor *' with information about the monitor |
seq | sequence number of the record, MUST NOT BE ZERO |
zone_key | zone key of the zone |
name | name |
rd_count | number of records in rd |
rd | array of records |
Definition at line 2010 of file gnunet-service-namestore.c.
References GNUNET_assert, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), ZoneMonitor::iteration_cnt, ZoneMonitor::limit, monitor_iteration_next(), ZoneMonitor::nc, send_lookup_response(), ZoneIteration::seq, ZoneMonitor::seq, ZoneMonitor::task, and zm.
Referenced by monitor_iteration_next().
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message.
cls | the client sending the message |
zis_msg | message from the client |
Definition at line 2046 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_notification_context_add(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_YES, ZoneMonitor::in_first_iteration, ZoneMonitorStartMessage::iterate_first, ZoneMonitor::limit, monitor_iteration_next(), monitor_sync(), NamestoreClient::mq, ZoneIteration::nc, ZoneMonitor::nc, ZoneMonitor::task, zm, ZoneMonitor::zone, and ZoneMonitorStartMessage::zone.
|
static |
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message.
cls | the client sending the message |
nm | message from the client |
Definition at line 2114 of file gnunet-service-namestore.c.
References NamestoreClient::client, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TIME_absolute_get(), GNUNET_YES, ZoneMonitor::in_first_iteration, ZoneMonitor::iteration_cnt, ZoneMonitor::limit, ZoneMonitorNextMessage::limit, monitor_iteration_next(), MONITOR_STALL_WARN_DELAY, monitor_unblock(), ZoneIteration::nc, ZoneMonitor::nc, ZoneMonitor::next, ZoneMonitor::sa_wait_warning, ZoneMonitor::sa_waiting, ZoneMonitor::sa_waiting_start, ZoneMonitor::task, warn_monitor_slow(), and zm.
|
static |
Process namestore requests.
cls | closure |
cfg | configuration to use |
service | the initialized service |
Definition at line 2174 of file gnunet-service-namestore.c.
References cache_keys, cfg, cleanup_task(), client_connect_cb(), client_disconnect_cb(), db_lib_name, disable_namecache, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_NAMECACHE_connect(), GNUNET_notification_context_create(), GNUNET_OK, GNUNET_PLUGIN_load(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_YES, iteration_start(), and zone_to_name().
Define "main" method using service macro.
Referenced by run().
|
static |
We cache nick records to reduce DB load.
Definition at line 334 of file gnunet-service-namestore.c.
Referenced by cache_nick(), and get_nick_record().
|
static |
Public key of all zeros.
Definition at line 339 of file gnunet-service-namestore.c.
Referenced by continue_store_activity(), GNUNET_OS_init(), GNUNET_TIME_absolute_get_zero_(), and GNUNET_TIME_relative_get_zero_().
|
static |
Configuration handle.
Definition at line 344 of file gnunet-service-namestore.c.
|
static |
Handle to the statistics service.
Definition at line 349 of file gnunet-service-namestore.c.
|
static |
Namecache handle.
Definition at line 354 of file gnunet-service-namestore.c.
|
static |
Database handle.
Definition at line 359 of file gnunet-service-namestore.c.
|
static |
Name of the database plugin.
Definition at line 364 of file gnunet-service-namestore.c.
Referenced by cleanup_task(), and run().
|
static |
Head of cop DLL.
Definition at line 369 of file gnunet-service-namestore.c.
|
static |
Tail of cop DLL.
Definition at line 374 of file gnunet-service-namestore.c.
|
static |
First active zone monitor.
Definition at line 379 of file gnunet-service-namestore.c.
Referenced by handle_record_store().
|
static |
Last active zone monitor.
Definition at line 384 of file gnunet-service-namestore.c.
|
static |
Head of DLL of monitor-blocked store activities.
Definition at line 389 of file gnunet-service-namestore.c.
Referenced by monitor_unblock().
|
static |
Tail of DLL of monitor-blocked store activities.
Definition at line 394 of file gnunet-service-namestore.c.
|
static |
Notification context shared by all monitors.
Definition at line 399 of file gnunet-service-namestore.c.
|
static |
Optimize block insertion by caching map of private keys to public keys in memory?
Definition at line 405 of file gnunet-service-namestore.c.
Referenced by refresh_block(), and run().
|
static |
Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record.
Definition at line 411 of file gnunet-service-namestore.c.
Referenced by refresh_block(), and run().