31 #define LOG(kind, ...) GNUNET_log_from (kind, "peerinfo-api", __VA_ARGS__)
153 while (NULL != (ic =
h->ic_head))
165 if (NULL !=
h->r_task)
210 _ (
"Failed to receive response from `PEERINFO' service."));
249 uint16_t ms = ntohs (im->
header.
size) -
sizeof(*im);
268 "Received HELLO for peer `%s', expected peer `%s'\n",
364 "Requesting list of peers from PEERINFO service\n");
372 "Requesting information on peer `%s' from PEERINFO service\n",
408 "Received end of list of peers from PEERINFO service\n");
412 if (NULL !=
h->ic_head)
443 if (NULL !=
h->r_task)
458 if (NULL !=
h->ic_head)
485 if (
h->ic_head == ic)
502 if (ic ==
h->ic_head)
544 "Adding peer `%s' to PEERINFO database\n",
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static int include_friend_only
Option '-f'.
Constants for network protocols.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
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.
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.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
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.
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
#define GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END
End of information about other peers.
#define GNUNET_MESSAGE_TYPE_PEERINFO_GET
Request update and listing of a peer.
#define GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL
Request update and listing of all peers.
#define GNUNET_MESSAGE_TYPE_PEERINFO_INFO
Information about one of the peers.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
common internal definitions for peerinfo service
static void handle_info(void *cls, const struct InfoMessage *im)
Handle info message.
static void send_ic_request(struct GNUNET_PEERINFO_Handle *h)
Send the next IC request at the head of the queue.
static void reconnect(struct GNUNET_PEERINFO_Handle *h)
Close the existing connection to PEERINFO and reconnect.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We got a disconnect after asking regex to do the announcement.
static int check_info(void *cls, const struct InfoMessage *im)
Function called when we receive an info message.
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.
static void do_reconnect(struct GNUNET_PEERINFO_Handle *h)
We encountered an error, reconnect to the PEERINFO service.
static void reconnect_task(void *cls)
Task scheduled to re-try connecting to the peerinfo service.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
A HELLO message is used to exchange information about transports with other peers.
Handle to a message queue.
Message handler for a specific message type.
Handle to the peerinfo service.
struct GNUNET_MQ_Handle * mq
Connection to the service.
struct GNUNET_PEERINFO_IteratorContext * ic_tail
Tail of iterator DLL.
struct GNUNET_SCHEDULER_Task * r_task
ID for a reconnect task.
struct GNUNET_PEERINFO_IteratorContext * ic_head
Head of iterator DLL.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Context for an iteration request.
struct GNUNET_PEERINFO_IteratorContext * next
Kept in a DLL.
struct GNUNET_PEERINFO_IteratorContext * prev
Kept in a DLL.
void * callback_cls
Closure for callback.
struct GNUNET_PeerIdentity peer
Peer we are interested in (only valid if iteration was restricted to one peer).
int have_peer
Is peer set?
GNUNET_PEERINFO_Processor callback
Function to call with the results.
int include_friend_only
Only include friends in reply?
struct GNUNET_PEERINFO_Handle * h
Handle to the PEERINFO service.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Message used to inform the client about a particular peer; this message is optionally followed by a H...
uint32_t reserved
Always zero.
struct GNUNET_PeerIdentity peer
About which peer are we talking here?
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_PEERINFO_INFO.
Message requesting a listing of all peers, restricted to the specified peer identity.
uint32_t include_friend_only
Include friend only HELLOs and peers in callbacks.
Message requesting a listing of peers, restricted to the specified peer identity.
struct GNUNET_PeerIdentity peer
Restrict to peers with this identity (optional field, check header.size!).
uint32_t include_friend_only
Include friend only HELLOs and peers in callbacks.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.