flat file-based namecache backend More...
#include "platform.h"
#include "gnunet_namecache_plugin.h"
#include "gnunet_namecache_service.h"
#include "gnunet_gnsrecord_lib.h"
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
struct | FlatFileEntry |
Functions | |
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 | expire_blocks (void *cls, const struct GNUNET_HashCode *key, void *value) |
static void | namecache_expire_blocks (struct Plugin *plugin) |
Removes any expired block. More... | |
static int | namecache_cache_block (void *cls, const struct GNUNET_GNSRECORD_Block *block) |
Cache a block in the datastore. More... | |
static int | namecache_lookup_block (void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls) |
Get the block for a particular zone and label in the datastore. More... | |
void * | libgnunet_plugin_namecache_flat_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_namecache_flat_done (void *cls) |
Exit point from the plugin. More... | |
flat file-based namecache backend
Definition in file plugin_namecache_flat.c.
|
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 72 of file plugin_namecache_flat.c.
References _, FlatFileEntry::block, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash_from_string, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), 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_log, GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_YES, line, plugin, FlatFileEntry::query, and size.
Referenced by libgnunet_plugin_namecache_flat_init().
|
static |
Store values in hashmap in file and free data.
plugin | the plugin context |
Definition at line 197 of file plugin_namecache_flat.c.
References FlatFileEntry::block, GNUNET_asprintf(), GNUNET_CRYPTO_hash_to_enc(), GNUNET_DISK_file_write(), GNUNET_free, GNUNET_GNSRECORD_block_get_size(), GNUNET_STRINGS_base64_encode(), GNUNET_YES, line, FlatFileEntry::query, 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 239 of file plugin_namecache_flat.c.
References _, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), 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_namecache_flat_done(), and libgnunet_plugin_namecache_flat_init().
|
static |
Definition at line 266 of file plugin_namecache_flat.c.
References FlatFileEntry::block, expiration, GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_GNSRECORD_block_get_expiration(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_YES, key, plugin, and value.
Referenced by namecache_expire_blocks().
|
static |
Removes any expired block.
plugin | the plugin |
Definition at line 293 of file plugin_namecache_flat.c.
References expire_blocks(), GNUNET_CONTAINER_multihashmap_iterate(), and plugin.
Referenced by namecache_cache_block().
|
static |
Cache a block in the datastore.
cls | closure (internal context for the plugin) |
block | block to cache |
Definition at line 309 of file plugin_namecache_flat.c.
References FlatFileEntry::block, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_query_from_block(), GNUNET_h2s_full(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, namecache_expire_blocks(), plugin, and FlatFileEntry::query.
Referenced by libgnunet_plugin_namecache_flat_init().
|
static |
Get the block for a particular zone and label in the datastore.
Will return at most one result to the iterator.
cls | closure (internal context for the plugin) |
query | hash of public key derived from the zone and the label |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 358 of file plugin_namecache_flat.c.
References GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s_full(), GNUNET_log, GNUNET_NO, GNUNET_YES, and plugin.
Referenced by libgnunet_plugin_namecache_flat_init().
void * libgnunet_plugin_namecache_flat_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the "struct GNUNET_NAMECACHE_PluginEnvironment*" |
Definition at line 385 of file plugin_namecache_flat.c.
References _, GNUNET_NAMECACHE_PluginFunctions::cache_block, cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_NAMECACHE_PluginFunctions::lookup_block, namecache_cache_block(), namecache_lookup_block(), and plugin.
void * libgnunet_plugin_namecache_flat_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | the plugin context (as returned by "init") |
Definition at line 419 of file plugin_namecache_flat.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_NAMECACHE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and plugin.