API for peerstore. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_hello_uri_lib.h"
#include "peerstore.h"
#include "peerstore_common.h"
#include "gnunet_peerstore_service.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_PEERSTORE_Handle |
Handle to the PEERSTORE service. More... | |
struct | GNUNET_PEERSTORE_StoreHelloContext |
Context for a add hello uri request. More... | |
struct | GNUNET_PEERSTORE_StoreContext |
Context for a store request. More... | |
struct | StoreHelloCls |
Closure for store callback when storing hello uris. More... | |
struct | GNUNET_PEERSTORE_IterateContext |
Context for a iterate request. More... | |
struct | GNUNET_PEERSTORE_NotifyContext |
Context for the info handler. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__) |
Functions | |
static void | reconnect (void *cls) |
Close the existing connection to PEERSTORE and reconnect. More... | |
static uint32_t | get_op_id (struct GNUNET_PEERSTORE_Handle *h) |
Get a fresh operation id to distinguish between namestore requests. More... | |
static void | disconnect (struct GNUNET_PEERSTORE_Handle *h) |
Disconnect from the peerstore service. More... | |
static void | disconnect_and_schedule_reconnect (struct GNUNET_PEERSTORE_Handle *h) |
Function that will schedule the job that will try to connect us again to the client. More... | |
static void | handle_client_error (void *cls, enum GNUNET_MQ_Error error) |
Function called when we had trouble talking to the service. More... | |
struct GNUNET_PEERSTORE_Handle * | GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect to the PEERSTORE service. More... | |
void | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h) |
Disconnect from the PEERSTORE service. More... | |
static void | destroy_storecontext (struct GNUNET_PEERSTORE_StoreContext *sc) |
void | GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc) |
Cancel a store request. More... | |
struct GNUNET_PEERSTORE_StoreContext * | GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, GNUNET_PEERSTORE_Continuation cont, void *cont_cls) |
Store a new entry in the PEERSTORE. More... | |
static void | handle_store_result (void *cls, const struct PeerstoreResultMessage *msg) |
When a response for store request is received. More... | |
static void | destroy_iteratecontext (struct GNUNET_PEERSTORE_IterateContext *ic) |
static void | handle_iterate_end (void *cls, const struct PeerstoreResultMessage *msg) |
When a response for iterate request is received. More... | |
static int | check_iterate_result (void *cls, const struct PeerstoreRecordMessage *msg) |
When a response for iterate request is received, check the message is well-formed. More... | |
static void | handle_iterate_result (void *cls, const struct PeerstoreRecordMessage *msg) |
When a response for iterate request is received. More... | |
void | GNUNET_PEERSTORE_iteration_next (struct GNUNET_PEERSTORE_IterateContext *ic, uint64_t limit) |
Cancel an iterate request Please do not call after the iterate request is done. More... | |
void | GNUNET_PEERSTORE_iteration_stop (struct GNUNET_PEERSTORE_IterateContext *ic) |
Cancel an iterate request Please do not call after the iterate request is done. More... | |
struct GNUNET_PEERSTORE_IterateContext * | GNUNET_PEERSTORE_iteration_start (struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls) |
Iterate over peerstore entries. More... | |
static void | hello_store_success (void *cls, int success) |
static void | hello_add_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
struct GNUNET_PEERSTORE_StoreHelloContext * | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, const struct GNUNET_MessageHeader *msg, GNUNET_PEERSTORE_Continuation cont, void *cont_cls) |
Add hello to peerstore. More... | |
void | GNUNET_PEERSTORE_hello_add_cancel (struct GNUNET_PEERSTORE_StoreHelloContext *huc) |
Cancel the request to add a hello. More... | |
API for peerstore.
Definition in file peerstore_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__) |
Definition at line 34 of file peerstore_api.c.
|
static |
Close the existing connection to PEERSTORE and reconnect.
cls | a struct GNUNET_PEERSTORE_Handle *h |
cls | a struct GNUNET_PEERSTORE_Handle * |
Definition at line 802 of file peerstore_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END, GNUNET_MESSAGE_TYPE_PEERSTORE_RECORD, GNUNET_MESSAGE_TYPE_PEERSTORE_STORE_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_send(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, handle_client_error(), LOG, GNUNET_ARM_Handle::mq, reconnect(), GNUNET_ARM_Handle::reconnect_task, and sc.
Referenced by disconnect_and_schedule_reconnect(), GNUNET_PEERSTORE_connect(), and reconnect().
|
static |
Get a fresh operation id to distinguish between namestore requests.
h | the namestore handle |
Definition at line 343 of file peerstore_api.c.
References h.
Referenced by GNUNET_PEERSTORE_iteration_start(), and GNUNET_PEERSTORE_store().
|
static |
Disconnect from the peerstore service.
h | peerstore handle to disconnect |
Definition at line 355 of file peerstore_api.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_MQ_destroy(), h, and GNUNET_ARM_Handle::mq.
Referenced by disconnect_and_schedule_reconnect(), and GNUNET_PEERSTORE_disconnect().
|
static |
Function that will schedule the job that will try to connect us again to the client.
h | peerstore to reconnect |
Definition at line 379 of file peerstore_api.c.
References disconnect(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, h, LOG, reconnect(), and GNUNET_ARM_Handle::reconnect_task.
Referenced by handle_client_error().
|
static |
Function called when we had trouble talking to the service.
Definition at line 401 of file peerstore_api.c.
References disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_ERROR, h, and LOG.
Referenced by reconnect().
|
static |
Definition at line 456 of file peerstore_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_SearchContext::h, and sc.
Referenced by GNUNET_PEERSTORE_store_cancel(), and handle_store_result().
|
static |
When a response for store request is received.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 565 of file peerstore_api.c.
References _, destroy_storecontext(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, h, LOG, msg, and sc.
|
static |
Definition at line 593 of file peerstore_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PEERSTORE_IterateContext::h, GNUNET_PEERSTORE_Handle::iterate_head, GNUNET_PEERSTORE_Handle::iterate_tail, GNUNET_PEERSTORE_IterateContext::key, and GNUNET_PEERSTORE_IterateContext::sub_system.
Referenced by GNUNET_PEERSTORE_iteration_stop(), and handle_iterate_end().
|
static |
When a response for iterate request is received.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 609 of file peerstore_api.c.
References _, GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, destroy_iteratecontext(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, h, LOG, msg, GNUNET_PEERSTORE_IterateContext::next, and GNUNET_PEERSTORE_IterateContext::rid.
|
static |
When a response for iterate request is received, check the message is well-formed.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 638 of file peerstore_api.c.
References GNUNET_OK.
|
static |
When a response for iterate request is received.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 652 of file peerstore_api.c.
References _, GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, h, LOG, msg, GNUNET_PEERSTORE_IterateContext::next, PEERSTORE_destroy_record(), PEERSTORE_parse_record_message(), record(), and GNUNET_PEERSTORE_IterateContext::rid.
|
static |
Definition at line 851 of file peerstore_api.c.
References GNUNET_PEERSTORE_StoreHelloContext::cont, GNUNET_PEERSTORE_StoreHelloContext::cont_cls, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_OK, GNUNET_PEERSTORE_StoreHelloContext::hello, LOG, and GNUNET_PEERSTORE_StoreHelloContext::sc.
Referenced by hello_add_iter().
|
static |
If we ever get here, we are newer than the existing record or the only/first record.
Definition at line 872 of file peerstore_api.c.
References GNUNET_PEERSTORE_StoreHelloContext::cont, GNUNET_PEERSTORE_StoreHelloContext::cont_cls, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_i2s(), GNUNET_OK, GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_iteration_next(), GNUNET_PEERSTORE_iteration_stop(), GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_cmp, GNUNET_PEERSTORE_StoreHelloContext::h, GNUNET_PEERSTORE_StoreHelloContext::hello, hello_store_success(), GNUNET_PEERSTORE_StoreHelloContext::ic, LOG, GNUNET_PEERSTORE_StoreHelloContext::pid, record(), GNUNET_PEERSTORE_StoreHelloContext::sc, and GNUNET_MessageHeader::size.
Referenced by GNUNET_PEERSTORE_hello_add().