file-based namestore backend More...
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
struct | FlatFileEntry |
struct | IterateContext |
Closure for iterate_zones. More... | |
struct | ZoneToNameContext |
Closure for zone_to_name. More... | |
Functions | |
static void | hash_pkey_and_label (const struct GNUNET_CRYPTO_PrivateKey *pkey, const char *label, struct GNUNET_HashCode *h) |
Hash contactenation of pkey and label into h. More... | |
static int | database_setup (struct Plugin *plugin) |
Initialize the database connections and associated data structures (create tables and indices as needed as well). More... | |
static int | store_and_free_entries (void *cls, const struct GNUNET_HashCode *key, void *value) |
Store values in hashmap in file and free data. More... | |
static void | database_shutdown (struct Plugin *plugin) |
Shutdown database connection and associate data structures. More... | |
static int | namestore_flat_store_records (void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Store a record in the datastore. More... | |
static int | namestore_flat_lookup_records (void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
Lookup records in the datastore for which we are the authority. More... | |
static int | iterate_zones (void *cls, const struct GNUNET_HashCode *key, void *value) |
Helper function for namestore_flat_iterate_records(). More... | |
static int | namestore_flat_iterate_records (void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, uint64_t serial, uint64_t limit, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
Iterate over the results for a particular key and zone in the datastore. More... | |
static int | zone_to_name (void *cls, const struct GNUNET_HashCode *key, void *value) |
static int | namestore_flat_zone_to_name (void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const struct GNUNET_CRYPTO_PublicKey *value_zone, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) |
Look for an existing PKEY delegation record for a given public key. More... | |
void * | libgnunet_plugin_namestore_flat_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_namestore_flat_done (void *cls) |
Exit point from the plugin. More... | |
file-based namestore backend
Definition in file plugin_namestore_flat.c.
|
static |
Hash contactenation of pkey and label into h.
pkey | a key | |
label | a label | |
[out] | h | initialized hash |
Definition at line 87 of file plugin_namestore_flat.c.
References GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, h, key, and pkey.
Referenced by database_setup(), namestore_flat_lookup_records(), and namestore_flat_store_records().
|
static |
Initialize the database connections and associated data structures (create tables and indices as needed as well).
plugin | the plugin context (state for this module) |
Definition at line 120 of file plugin_namestore_flat.c.
References _, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_map(), GNUNET_DISK_file_open(), GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_file_unmap(), GNUNET_DISK_MAP_TYPE_READ, GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_records_deserialize(), GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_strerror, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_YES, hash_pkey_and_label(), FlatFileEntry::label, line, mh, plugin, FlatFileEntry::private_key, record_count, FlatFileEntry::record_count, FlatFileEntry::record_data, FlatFileEntry::rvalue, size, and SIZE_MAX.
Referenced by libgnunet_plugin_namestore_flat_init().
|
static |
Store values in hashmap in file and free data.
plugin | the plugin context |
key | key in the map |
value | a struct FlatFileEntry |
Definition at line 333 of file plugin_namestore_flat.c.
References data, data_size, GNUNET_asprintf(), GNUNET_break, GNUNET_DISK_file_write(), GNUNET_free, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_STRINGS_base64_encode(), GNUNET_SYSERR, GNUNET_YES, key, FlatFileEntry::label, line, FlatFileEntry::private_key, FlatFileEntry::record_count, FlatFileEntry::record_data, ret, FlatFileEntry::rvalue, and value.
Referenced by database_shutdown().
|
static |
Shutdown database connection and associate data structures.
plugin | the plugin context (state for this module) |
Definition at line 409 of file plugin_namestore_flat.c.
References _, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, plugin, and store_and_free_entries().
Referenced by libgnunet_plugin_namestore_flat_done(), and libgnunet_plugin_namestore_flat_init().
|
static |
Store a record in the datastore.
Removes any existing record in the same zone with the same name.
cls | closure (internal context for the plugin) |
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 451 of file plugin_namestore_flat.c.
References GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_asprintf(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log_from, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_OK, hash_pkey_and_label(), FlatFileEntry::label, plugin, FlatFileEntry::private_key, rd, rd_count, FlatFileEntry::record_count, FlatFileEntry::record_data, GNUNET_GNSRECORD_Data::record_type, and FlatFileEntry::rvalue.
Referenced by libgnunet_plugin_namestore_flat_init().
|
static |
Lookup records in the datastore for which we are the authority.
cls | closure (internal context for the plugin) |
zone | private key of the zone |
label | name of the record in the zone |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 517 of file plugin_namestore_flat.c.
References GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, hash_pkey_and_label(), FlatFileEntry::label, plugin, FlatFileEntry::private_key, FlatFileEntry::record_count, and FlatFileEntry::record_data.
Referenced by libgnunet_plugin_namestore_flat_init().
|
static |
Helper function for namestore_flat_iterate_records().
cls | a struct IterateContext |
key | unused |
value | a struct FlatFileEntry |
Definition at line 598 of file plugin_namestore_flat.c.
References GNUNET_memcmp, GNUNET_NO, GNUNET_YES, IterateContext::iter, IterateContext::iter_cls, key, FlatFileEntry::label, IterateContext::limit, IterateContext::offset, IterateContext::pos, FlatFileEntry::private_key, FlatFileEntry::record_count, FlatFileEntry::record_data, value, and IterateContext::zone.
Referenced by namestore_flat_iterate_records().
|
static |
Iterate over the results for a particular key and zone in the datastore.
Will return at most one result to the iterator.
cls | closure (internal context for the plugin) |
zone | hash of public key of the zone, NULL to iterate over all zones |
serial | serial number to exclude in the list of all matching records |
limit | maximum number of results to return to iter |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 646 of file plugin_namestore_flat.c.
References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_NO, GNUNET_OK, IterateContext::iter, IterateContext::iter_cls, iterate_zones(), IterateContext::limit, IterateContext::offset, plugin, IterateContext::pos, and IterateContext::zone.
Referenced by libgnunet_plugin_namestore_flat_init().
|
static |
Definition at line 685 of file plugin_namestore_flat.c.
References GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_is_zonekey_type(), GNUNET_memcmp, GNUNET_NO, GNUNET_YES, ZoneToNameContext::iter, ZoneToNameContext::iter_cls, key, FlatFileEntry::label, FlatFileEntry::private_key, FlatFileEntry::record_count, FlatFileEntry::record_data, GNUNET_GNSRECORD_Data::record_type, ZoneToNameContext::result_found, GNUNET_CRYPTO_PublicKey::type, value, ZoneToNameContext::value_zone, and ZoneToNameContext::zone.
Referenced by namestore_flat_zone_to_name().
|
static |
Look for an existing PKEY delegation record for a given public key.
Returns at most one result to the iterator.
cls | closure (internal context for the plugin) |
zone | private key of the zone to look up in, never NULL |
value_zone | public key of the target zone (value), never NULL |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 733 of file plugin_namestore_flat.c.
References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_z2s(), GNUNET_log, GNUNET_NO, ZoneToNameContext::iter, ZoneToNameContext::iter_cls, plugin, ZoneToNameContext::result_found, ZoneToNameContext::value_zone, ZoneToNameContext::zone, and zone_to_name().
Referenced by libgnunet_plugin_namestore_flat_init().
void * libgnunet_plugin_namestore_flat_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the "struct GNUNET_NAMESTORE_PluginEnvironment*" |
Definition at line 766 of file plugin_namestore_flat.c.
References _, cfg, GNUNET_NAMESTORE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_NAMESTORE_PluginFunctions::iterate_records, GNUNET_NAMESTORE_PluginFunctions::lookup_records, namestore_flat_iterate_records(), namestore_flat_lookup_records(), namestore_flat_store_records(), namestore_flat_zone_to_name(), plugin, GNUNET_NAMESTORE_PluginFunctions::store_records, and GNUNET_NAMESTORE_PluginFunctions::zone_to_name.
void * libgnunet_plugin_namestore_flat_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | the plugin context (as returned by "init") |
Definition at line 802 of file plugin_namestore_flat.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_NAMESTORE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and plugin.