Data Structures | |
struct | GNUNET_PEERSTORE_Record |
Single PEERSTORE record. More... | |
Macros | |
#define | GNUNET_PEERSTORE_HELLO_KEY "peerstore-peer-hello-uri" |
Key used for storing HELLO in the peerstore. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY "transport-communicator-url" |
Key used for storing addresses in URL format in the peerstore. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY "transport-peer-hello" |
Key used for storing HELLOs in the peerstore. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME "transport-backchannel-monotonic-time" |
Key used to store sender's monotonic time from backchannel messages. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME "transport-dv-learn-monotonic-time" |
Key used to store sender's monotonic time from DV learn messages. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE "transport-tcp-communicator-handshake" |
Key used to store sender's monotonic time from handshake message. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK "transport-tcp-communicator-handshake-ack" |
Key used to store sender's monotonic time from handshake ack message. More... | |
#define | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY "transport-tcp-communicator-rekey" |
Key used to store sender's monotonic time from rekey message. More... | |
Typedefs | |
typedef void(* | GNUNET_PEERSTORE_Continuation) (void *cls, int success) |
Continuation called with a status result. More... | |
typedef void(* | GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Function called by PEERSTORE for each matching record. More... | |
typedef void(* | GNUNET_PEERSTORE_hello_notify_cb) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *hello, const char *err_msg) |
Function called by PEERSTORE when notifying a client about a changed hello. More... | |
Enumerations | |
enum | GNUNET_PEERSTORE_StoreOption { GNUNET_PEERSTORE_STOREOPTION_MULTIPLE = 0 , GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1 } |
Options for storing values in PEERSTORE. More... | |
#define GNUNET_PEERSTORE_HELLO_KEY "peerstore-peer-hello-uri" |
Key used for storing HELLO in the peerstore.
Definition at line 52 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY "transport-communicator-url" |
Key used for storing addresses in URL format in the peerstore.
Definition at line 57 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY "transport-peer-hello" |
Key used for storing HELLOs in the peerstore.
Definition at line 62 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME "transport-backchannel-monotonic-time" |
Key used to store sender's monotonic time from backchannel messages.
Definition at line 68 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME "transport-dv-learn-monotonic-time" |
Key used to store sender's monotonic time from DV learn messages.
Definition at line 75 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE "transport-tcp-communicator-handshake" |
Key used to store sender's monotonic time from handshake message.
Definition at line 81 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK "transport-tcp-communicator-handshake-ack" |
Key used to store sender's monotonic time from handshake ack message.
Definition at line 87 of file gnunet_peerstore_service.h.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY "transport-tcp-communicator-rekey" |
Key used to store sender's monotonic time from rekey message.
Definition at line 93 of file gnunet_peerstore_service.h.
typedef void(* GNUNET_PEERSTORE_Continuation) (void *cls, int success) |
Continuation called with a status result.
cls | closure |
success | GNUNET_OK or GNUNET_SYSERR |
Definition at line 174 of file gnunet_peerstore_service.h.
typedef void(* GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Function called by PEERSTORE for each matching record.
cls | closure |
seq | sequence in iteration |
record | peerstore record information |
emsg | error message, or NULL if no errors |
Definition at line 191 of file gnunet_peerstore_service.h.
typedef void(* GNUNET_PEERSTORE_hello_notify_cb) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *hello, const char *err_msg) |
Function called by PEERSTORE when notifying a client about a changed hello.
cls | closure |
hello_uri | Hello uri. |
Definition at line 202 of file gnunet_peerstore_service.h.
Options for storing values in PEERSTORE.
Definition at line 100 of file gnunet_peerstore_service.h.
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.
h | handle for peerstore. |
msg | The hello to add. |
cont | The continuation function to execute after storing. |
cont_cls | The continuation function closure. |
Definition at line 922 of file peerstore_api.c.
References GNUNET_PEERSTORE_StoreHelloContext::cont, GNUNET_PEERSTORE_StoreHelloContext::cont_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_msg(), GNUNET_HELLO_parser_get_id(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_iteration_start(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_cmp, GNUNET_TIME_absolute_get(), h, GNUNET_PEERSTORE_StoreHelloContext::h, GNUNET_PEERSTORE_StoreHelloContext::hello, hello_add_iter(), GNUNET_PEERSTORE_StoreHelloContext::ic, LOG, msg, consensus-simulation::parser, GNUNET_PEERSTORE_StoreHelloContext::pid, pid, and GNUNET_MessageHeader::size.
Referenced by callback_download(), handle_hello(), run(), and store_pi().
void GNUNET_PEERSTORE_hello_add_cancel | ( | struct GNUNET_PEERSTORE_StoreHelloContext * | huc | ) |
Cancel the request to add a hello.
huc | The context for storing a hello. |
Definition at line 967 of file peerstore_api.c.
References GNUNET_free, GNUNET_PEERSTORE_iteration_stop(), GNUNET_PEERSTORE_store_cancel(), GNUNET_PEERSTORE_StoreHelloContext::hello, GNUNET_PEERSTORE_StoreHelloContext::ic, and GNUNET_PEERSTORE_StoreHelloContext::sc.
Referenced by cleaning_task(), GNUNET_HOSTLIST_client_stop(), and shutdown_task().
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Connect to the PEERSTORE service.
cfg | configuration to use |
Definition at line 419 of file peerstore_api.c.
References cfg, GNUNET_ARM_Handle::cfg, GNUNET_free, GNUNET_new, h, GNUNET_ARM_Handle::mq, and reconnect().
Referenced by DHTU_gnunet_init(), GCH_init(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_server_start(), GNUNET_TRANSPORT_TESTING_start_peer(), GSF_connected_peer_init_(), run(), and start_peer_run().
void GNUNET_PEERSTORE_disconnect | ( | struct GNUNET_PEERSTORE_Handle * | h | ) |
Disconnect from the PEERSTORE service.
Any pending ITERATE and WATCH and STORE requests will be canceled.
h | handle to disconnect |
Any pending ITERATE and WATCH requests will be canceled. Any pending STORE requests will depend on snyc_first flag.
h | handle to disconnect |
Definition at line 443 of file peerstore_api.c.
References disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, and LOG.
Referenced by cleaning_task(), DHTU_gnunet_done(), do_shutdown(), GCH_shutdown(), GNUNET_HOSTLIST_client_stop(), GNUNET_HOSTLIST_server_stop(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_connected_peer_done_(), shutdown_task(), and stop_peer_run().
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.
Note that stored entries can be lost in some cases such as power failure.
h | Handle to the PEERSTORE service |
sub_system | name of the sub system |
peer | Peer Identity |
key | entry key |
value | entry value BLOB |
size | size of value |
expiry | absolute time after which the entry is (possibly) deleted |
options | options specific to the storage operation |
cont | Continuation function after the store request is sent |
cont_cls | Closure for cont |
Definition at line 501 of file peerstore_api.c.
References GNUNET_PEERSTORE_StoreContext::cont, GNUNET_PEERSTORE_StoreContext::cont_cls, GNUNET_PEERSTORE_StoreContext::expiry, get_op_id(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memdup, GNUNET_MESSAGE_TYPE_PEERSTORE_STORE, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, h, GNUNET_FS_SearchContext::h, key, LOG, GNUNET_ARM_Handle::mq, options, GNUNET_FS_SearchContext::options, GNUNET_PEERSTORE_StoreContext::peer, PEERSTORE_create_record_mq_envelope(), sc, size, GNUNET_PEERSTORE_StoreContext::sub_system, and value.
Referenced by flush_respect(), handle_dv_learn(), handle_validation_response(), handshake_ack_monotime_cb(), handshake_monotime_cb(), rekey_monotime_cb(), shc_cont(), and update_backtalker_monotime().
void GNUNET_PEERSTORE_store_cancel | ( | struct GNUNET_PEERSTORE_StoreContext * | sc | ) |
Cancel a store request.
sc | Store request context |
Definition at line 472 of file peerstore_api.c.
References destroy_storecontext(), GNUNET_ERROR_TYPE_DEBUG, LOG, and sc.
Referenced by free_address_list_entry(), free_backtalker(), free_neighbour(), free_validation_state(), handle_dv_learn(), and queue_destroy().
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.
The iteration can be filtered to contain only records matching peer and/or key. The sub_system to match must be provided. callback will be called with (each) matching record. GNUNET_PEERSTORE_iteration_next() must be invoked to continue processing until the end of the iteration is reached.
h | handle to the PEERSTORE service |
sub_system | name of sub system |
peer | Peer identity (can be NULL) |
key | entry key string (can be NULL) |
callback | function called with each matching record. The record will be NULL to indicate end. |
callback_cls | closure for callback |
Definition at line 741 of file peerstore_api.c.
References GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, dummy, get_op_id(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, GNUNET_YES, h, GNUNET_PEERSTORE_IterateContext::h, key, GNUNET_PEERSTORE_IterateContext::key, PeerstoreIterationStartMessage::key_size, LOG, GNUNET_ARM_Handle::mq, PeerstoreIterationStartMessage::peer, GNUNET_PEERSTORE_IterateContext::peer, PeerstoreIterationStartMessage::peer_set, PeerstoreIterationStartMessage::rid, GNUNET_PEERSTORE_IterateContext::rid, GNUNET_PEERSTORE_IterateContext::sub_system, and PeerstoreIterationStartMessage::sub_system_size.
Referenced by decrypt_and_check_tc(), do_rekey(), GNUNET_PEERSTORE_hello_add(), GNUNET_TRANSPORT_TESTING_restart_peer(), GSF_peer_connect_handler(), handle_add_queue_message(), handle_dv_box(), queue_burst(), retrieve_hello(), run(), and try_handle_plaintext().
void GNUNET_PEERSTORE_iteration_next | ( | struct GNUNET_PEERSTORE_IterateContext * | ic, |
uint64_t | limit | ||
) |
Continue an iteration.
Do NOT call after the iterate request is done.
ic | Iterate request context as returned by GNUNET_PEERSTORE_iteration_start() |
limit | how many records to return max until #GNUNET_PEERSTORE_iterate_next() needs to be called again. |
Continue an iteration.
ic | Iterate request context as returned by GNUNET_PEERSTORE_iterate() |
Definition at line 693 of file peerstore_api.c.
References GNUNET_PEERSTORE_IterateContext::env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_log, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_PEERSTORE_IterateContext::h, PeerstoreIterationNextMessage::limit, GNUNET_PEERSTORE_Handle::mq, PeerstoreIterationNextMessage::rid, and GNUNET_PEERSTORE_IterateContext::rid.
Referenced by backtalker_monotime_cb(), handshake_ack_monotime_cb(), handshake_ack_monotime_store_cb(), handshake_monotime_cb(), handshake_monotime_store_cb(), hello_add_iter(), hello_iter(), neighbour_dv_monotime_cb(), peer_respect_cb(), rekey_monotime_cb(), and rekey_monotime_store_cb().
void GNUNET_PEERSTORE_iteration_stop | ( | struct GNUNET_PEERSTORE_IterateContext * | ic | ) |
Cancel an iteration.
Do NOT call after the iterate request is done
ic | Iterate request context as returned by GNUNET_PEERSTORE_iteration_start() |
Cancel an iteration.
ic | Iterate request context as returned by GNUNET_PEERSTORE_iterate() |
Definition at line 722 of file peerstore_api.c.
References destroy_iteratecontext(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_PEERSTORE_IterateContext::h, GNUNET_PEERSTORE_Handle::mq, PeerstoreIterationStopMessage::rid, and GNUNET_PEERSTORE_IterateContext::rid.
Referenced by check_for_burst_address(), free_backtalker(), free_neighbour(), GNUNET_PEERSTORE_hello_add_cancel(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_peer_disconnect_handler(), handshake_ack_monotime_cb(), handshake_monotime_cb(), hello_add_iter(), hello_iter(), hello_iter_cb(), peer_respect_cb(), queue_destroy(), rekey_monotime_cb(), shutdown_task(), and stop_peer_run().
struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
int | iterate_first, | ||
const char * | sub_system, | ||
const struct GNUNET_PeerIdentity * | peer, | ||
const char * | key, | ||
GNUNET_SCHEDULER_TaskCallback | error_cb, | ||
void * | error_cb_cls, | ||
GNUNET_SCHEDULER_TaskCallback | sync_cb, | ||
void * | sync_cb_cls, | ||
GNUNET_PEERSTORE_Processor | callback, | ||
void * | callback_cls | ||
) |
Request watching a given key The monitoring can be filtered to contain only records matching peer and/or key.
The sub_system to match must be provided. callback will be called with (each) matching new record. GNUNET_PEERSTORE_monitor_next() must be invoked to continue processing until sync_cb is called, indicating that the caller should be up-to-date. The caller will be notified with any new values added to key through callback. If iterate_first is set to GNUNET_YES, the monitor will first iterate over all existing, matching records. In any case, after sync_cb is called the first time monitoring starts.
h | handle to the PEERSTORE service |
iterate_first | first iterated of all results if GNUNET_YES |
sub_system | name of sub system |
peer | Peer identity |
key | entry key string |
error_cb | function to call on error (i.e. disconnect); note that unlike the other error callbacks in this API, a call to this function does NOT destroy the monitor handle, it merely signals that monitoring is down. You need to still explicitly call GNUNET_PEERSTORE_monitor_stop(). |
error_cb_cls | closure for error_cb |
sync_cb | function called when we're in sync with the peerstore |
sync_cb_cls | closure for sync_cb |
callback | function called with each new value |
callback_cls | closure for callback |
Definition at line 239 of file peerstore_api_monitor.c.
References GNUNET_PEERSTORE_Monitor::callback, GNUNET_PEERSTORE_Monitor::callback_cls, cfg, error_cb(), GNUNET_PEERSTORE_Monitor::error_cb_cls, GNUNET_free, GNUNET_new, GNUNET_strdup, GNUNET_PEERSTORE_Monitor::iterate_first, key, mc, GNUNET_PEERSTORE_Monitor::peer, reconnect(), GNUNET_PEERSTORE_Monitor::sub_system, sync_cb(), and GNUNET_PEERSTORE_Monitor::sync_cb_cls.
Referenced by core_init_cb(), GCH_init(), handle_add_queue_message(), handle_suggest(), handle_validation_challenge(), process_peer(), run(), and start_notify().
void GNUNET_PEERSTORE_monitor_next | ( | struct GNUNET_PEERSTORE_Monitor * | zm, |
uint64_t | limit | ||
) |
Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).
This function is used to allow clients that merely monitor the NAMESTORE to still throttle namestore operations, so we can be sure that the monitors can keep up.
Note that GNUNET_PEERSTORE_store() only waits for this call if the previous limit set by the client was already reached. Thus, by using a limit greater than 1, monitors basically enable a queue of notifications to be processed asynchronously with some delay. Note that even with a limit of 1 the GNUNET_PEERSTORE_store() function will run asynchronously and the continuation may be invoked before the monitors completed (or even started) processing the notification. Thus, monitors will only closely track the current state of the peerstore, but not be involved in the transactions.
zm | the monitor |
limit | number of records to return to the iterator in one shot (before GNUNET_PEERSTORE_monitor_next is to be called again) |
Definition at line 295 of file peerstore_api_monitor.c.
References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), PeerstoreMonitorNextMessage::limit, GNUNET_NAMESTORE_ZoneMonitor::mq, and zm.
Referenced by check_for_global_natted(), got_hello(), handle_hello_for_client(), handle_hello_for_incoming(), peerinfo_cb(), process_notify(), process_peer(), and process_peerinfo_peers().
void GNUNET_PEERSTORE_monitor_stop | ( | struct GNUNET_PEERSTORE_Monitor * | zm | ) |
Stop monitoring.
zm | handle to the monitor activity to stop |
Definition at line 282 of file peerstore_api_monitor.c.
References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NAMESTORE_ZoneMonitor::mq, and zm.
Referenced by cleaning_task(), DHTU_gnunet_done(), free_incoming_request(), free_queue(), GCH_shutdown(), GNUNET_HOSTLIST_server_stop(), process_peer(), shutdown_task(), and stop_peer_request().