Maintain the list of currently known hosts. More...
Typedefs | |
typedef void(* | GNUNET_PEERINFO_Processor) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
Type of an iterator over the hosts. More... | |
Maintain the list of currently known hosts.
Holds an in-memory structure of data/hosts.
typedef void(* GNUNET_PEERINFO_Processor) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
Type of an iterator over the hosts.
Note that each host will be called with each available protocol.
cls | closure |
peer | id of the peer, NULL for last call |
hello | hello message for the peer (can be NULL) |
error | message |
Definition at line 120 of file gnunet_peerinfo_service.h.
struct GNUNET_PEERINFO_Handle* GNUNET_PEERINFO_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Connect to the peerinfo service.
cfg | configuration to use |
Definition at line 123 of file peerinfo_api.c.
References cfg, GNUNET_ARM_Handle::cfg, GNUNET_free, GNUNET_new, h, GNUNET_ARM_Handle::mq, and reconnect().
Referenced by GCH_init(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_server_start(), libgnunet_plugin_rest_peerinfo_init(), and run().
void GNUNET_PEERINFO_disconnect | ( | struct GNUNET_PEERINFO_Handle * | h | ) |
Disconnect from the peerinfo service.
Note that all iterators must have completed or have been cancelled by the time this function is called (otherwise, calling this function is a serious error). Furthermore, if GNUNET_PEERINFO_add_peer() operations are still pending, they will be cancelled silently on disconnect.
h | handle to disconnect |
Definition at line 149 of file peerinfo_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), h, and GNUNET_ARM_Handle::mq.
Referenced by cleaning_task(), cleanup_handle(), GCH_shutdown(), GNUNET_HOSTLIST_client_stop(), GNUNET_HOSTLIST_server_stop(), libgnunet_plugin_rest_peerinfo_done(), and shutdown_task().
struct GNUNET_MQ_Envelope* GNUNET_PEERINFO_add_peer | ( | struct GNUNET_PEERINFO_Handle * | h, |
const struct GNUNET_HELLO_Message * | hello, | ||
GNUNET_SCHEDULER_TaskCallback | cont, | ||
void * | cont_cls | ||
) |
Add a host to the persistent list.
This method operates in semi-reliable mode: if the transmission is not completed by the time GNUNET_PEERINFO_disconnect() is called, it will be aborted. Furthermore, if a second HELLO is added for the same peer before the first one was transmitted, PEERINFO may merge the two HELLOs prior to transmission to the service.
h | handle to the peerinfo service |
hello | the verified (!) HELLO message |
cont | continuation to call when done, NULL is allowed |
cont_cls | closure for cont |
This method operates in semi-reliable mode: if the transmission is not completed by the time GNUNET_PEERINFO_disconnect() is called, it will be aborted. Furthermore, if a second HELLO is added for the same peer before the first one was transmitted, PEERINFO may merge the two HELLOs prior to transmission to the service.
h | handle to the peerinfo service |
hello | the verified (!) HELLO message |
cont | continuation to call when done, NULL is allowed |
cont_cls | closure for cont |
Definition at line 530 of file peerinfo_api.c.
References env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_id(), GNUNET_i2s(), GNUNET_MQ_msg_copy(), GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, h, LOG, GNUNET_ARM_Handle::mq, and peer.
Referenced by callback_download(), GST_validation_handle_pong(), handle_hello(), parse_hello_uri(), and refresh_hello_task().
struct GNUNET_PEERINFO_IteratorContext* GNUNET_PEERINFO_iterate | ( | struct GNUNET_PEERINFO_Handle * | h, |
int | include_friend_only, | ||
const struct GNUNET_PeerIdentity * | peer, | ||
GNUNET_PEERINFO_Processor | callback, | ||
void * | callback_cls | ||
) |
Call a method for each known matching host.
The callback method will be invoked once for each matching host and then finally once with a NULL pointer. After that final invocation, the iterator context must no longer be used.
Instead of calling this function with peer == NULL
it is often better to use GNUNET_PEERINFO_notify().
h | handle to the peerinfo service |
include_friend_only | include HELLO messages for friends only |
peer | restrict iteration to this peer only (can be NULL) |
callback | the method to call for each peer |
callback_cls | closure for callback |
Definition at line 464 of file peerinfo_api.c.
References GNUNET_PEERINFO_IteratorContext::callback, GNUNET_PEERINFO_IteratorContext::callback_cls, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_YES, h, GNUNET_PEERINFO_IteratorContext::h, GNUNET_PEERINFO_IteratorContext::have_peer, include_friend_only, GNUNET_PEERINFO_IteratorContext::include_friend_only, GNUNET_PEERINFO_IteratorContext::peer, peer, and send_ic_request().
Referenced by peerinfo_get(), process_notify(), and state_machine().
void GNUNET_PEERINFO_iterate_cancel | ( | struct GNUNET_PEERINFO_IteratorContext * | ic | ) |
Cancel an iteration over peer information.
ic | context of the iterator to cancel |
Definition at line 497 of file peerinfo_api.c.
References GNUNET_PEERINFO_IteratorContext::callback, GNUNET_CONTAINER_DLL_remove, GNUNET_free, h, and GNUNET_PEERINFO_IteratorContext::h.
Referenced by cleanup_handle(), GNUNET_HOSTLIST_server_stop(), process_notify(), and shutdown_task().
struct GNUNET_PEERINFO_NotifyContext* GNUNET_PEERINFO_notify | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
int | include_friend_only, | ||
GNUNET_PEERINFO_Processor | callback, | ||
void * | callback_cls | ||
) |
Call a method whenever our known information about peers changes.
Initially calls the given function for all known peers and then only signals changes.
If include_friend_only is set to GNUNET_YES peerinfo will include HELLO messages which are intended for friend to friend mode and which do not have to be gossiped. Otherwise these messages are skipped.
cfg | configuration to use |
include_friend_only | include HELLO messages for friends only |
callback | the method to call for each peer |
callback_cls | closure for callback |
Definition at line 245 of file peerinfo_api_notify.c.
References GNUNET_PEERINFO_NotifyContext::callback, GNUNET_PEERINFO_NotifyContext::callback_cls, cfg, GNUNET_PEERINFO_NotifyContext::cfg, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new, include_friend_only, GNUNET_PEERINFO_NotifyContext::include_friend_only, LOG, GNUNET_PEERINFO_NotifyContext::mq, nc, and reconnect().
Referenced by core_init(), core_init_cb(), GCH_init(), GNUNET_HOSTLIST_server_start(), GST_validation_start(), process_peer(), and run().
void GNUNET_PEERINFO_notify_cancel | ( | struct GNUNET_PEERINFO_NotifyContext * | nc | ) |
Stop notifying about changes.
nc | context to stop notifying |
Definition at line 275 of file peerinfo_api_notify.c.
References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_PEERINFO_NotifyContext::mq, nc, and GNUNET_PEERINFO_NotifyContext::task.
Referenced by cleaning_task(), GCH_shutdown(), GNUNET_HOSTLIST_server_stop(), GST_validation_stop(), libgnunet_plugin_dhtu_gnunet_done(), process_peer(), and shutdown_task().