API to access peerinfo service. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "peerinfo.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_PEERINFO_IteratorContext |
Context for an iteration request. More... | |
struct | GNUNET_PEERINFO_Handle |
Handle to the peerinfo service. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "peerinfo-api", __VA_ARGS__) |
Functions | |
static void | reconnect (struct GNUNET_PEERINFO_Handle *h) |
Close the existing connection to PEERINFO and reconnect. More... | |
struct GNUNET_PEERINFO_Handle * | GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect to the peerinfo service. More... | |
void | GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h) |
Disconnect from the peerinfo service. More... | |
static void | reconnect_task (void *cls) |
Task scheduled to re-try connecting to the peerinfo service. More... | |
static void | do_reconnect (struct GNUNET_PEERINFO_Handle *h) |
We encountered an error, reconnect to the PEERINFO service. More... | |
static void | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
We got a disconnect after asking regex to do the announcement. More... | |
static int | check_info (void *cls, const struct InfoMessage *im) |
Function called when we receive an info message. More... | |
static void | handle_info (void *cls, const struct InfoMessage *im) |
Handle info message. More... | |
static void | send_ic_request (struct GNUNET_PEERINFO_Handle *h) |
Send the next IC request at the head of the queue. More... | |
static void | handle_end_iteration (void *cls, const struct GNUNET_MessageHeader *msg) |
Type of a function to call when we receive a message from the service. More... | |
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. More... | |
void | GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic) |
Cancel an iteration over peer information. More... | |
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. More... | |
API to access peerinfo service.
Definition in file peerinfo_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "peerinfo-api", __VA_ARGS__) |
Definition at line 31 of file peerinfo_api.c.
|
static |
Close the existing connection to PEERINFO and reconnect.
h | handle to the service |
Definition at line 429 of file peerinfo_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_PEERINFO_INFO, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END, GNUNET_MQ_destroy(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_SCHEDULER_cancel(), h, handlers, info, GNUNET_ARM_Handle::mq, mq_error_handler(), and send_ic_request().
Referenced by GNUNET_PEERINFO_connect(), handle_end_iteration(), and reconnect_task().
|
static |
Task scheduled to re-try connecting to the peerinfo service.
cls | the struct GNUNET_PEERINFO_Handle * |
Definition at line 180 of file peerinfo_api.c.
References h, and reconnect().
Referenced by do_reconnect().
|
static |
We encountered an error, reconnect to the PEERINFO service.
h | handle to reconnect |
Definition at line 195 of file peerinfo_api.c.
References _, GNUNET_PEERINFO_IteratorContext::callback, GNUNET_PEERINFO_IteratorContext::callback_cls, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_now(), h, GNUNET_ARM_Handle::mq, and reconnect_task().
Referenced by mq_error_handler().
|
static |
We got a disconnect after asking regex to do the announcement.
Retry.
cls | the struct GNUNET_PEERINFO_Handle to retry |
error | error code |
Definition at line 226 of file peerinfo_api.c.
References do_reconnect(), and h.
Referenced by reconnect().
|
static |
Function called when we receive an info message.
Check it is well-formed.
cls | closure |
im | message received |
Definition at line 244 of file peerinfo_api.c.
References GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_HELLO_get_id(), GNUNET_HELLO_size(), GNUNET_i2s(), GNUNET_memcmp, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, h, GNUNET_PEERINFO_IteratorContext::have_peer, InfoMessage::header, id, LOG, InfoMessage::peer, GNUNET_PEERINFO_IteratorContext::peer, InfoMessage::reserved, and GNUNET_MessageHeader::size.
|
static |
Handle info message.
cls | closure |
im | message received |
Definition at line 319 of file peerinfo_api.c.
References GNUNET_PEERINFO_IteratorContext::callback, GNUNET_PEERINFO_IteratorContext::callback_cls, h, InfoMessage::header, InfoMessage::peer, and GNUNET_MessageHeader::size.
|
static |
Send the next IC request at the head of the queue.
h | handle |
Definition at line 344 of file peerinfo_api.c.
References env, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_PEERINFO_GET, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, h, GNUNET_PEERINFO_IteratorContext::have_peer, ListPeerMessage::include_friend_only, ListAllPeersMessage::include_friend_only, GNUNET_PEERINFO_IteratorContext::include_friend_only, LOG, GNUNET_ARM_Handle::mq, ListPeerMessage::peer, and GNUNET_PEERINFO_IteratorContext::peer.
Referenced by GNUNET_PEERINFO_iterate(), handle_end_iteration(), and reconnect().
|
static |
Type of a function to call when we receive a message from the service.
Call the iterator with the result and (if applicable) continue to receive more messages or trigger processing the next event (if applicable).
cls | closure |
msg | message received, NULL on timeout or fatal error |
Definition at line 394 of file peerinfo_api.c.
References GNUNET_PEERINFO_IteratorContext::callback, GNUNET_PEERINFO_IteratorContext::callback_cls, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, LOG, reconnect(), and send_ic_request().