2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2007, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file peerinfo/peerinfo_api.c
23 * @brief API to access peerinfo service
24 * @author Christian Grothoff
27 #include "gnunet_client_lib.h"
28 #include "gnunet_container_lib.h"
29 #include "gnunet_peerinfo_service.h"
30 #include "gnunet_protocols.h"
31 #include "gnunet_time_lib.h"
35 * Function to call after transmission has succeeded.
38 * @param success GNUNET_OK if transmission worked, GNUNET_SYSERR on error
40 typedef void (*TransmissionContinuation)(void *cls,
45 * Entry in the transmission queue to PEERINFO service.
47 struct TransmissionQueueEntry
50 * This is a linked list.
52 struct TransmissionQueueEntry *next;
55 * This is a linked list.
57 struct TransmissionQueueEntry *prev;
60 * Function to call after request has been transmitted, or NULL (in which
61 * case we must consider sending the next entry immediately).
63 TransmissionContinuation cont;
71 * Timeout for the operation.
73 struct GNUNET_TIME_Absolute timeout;
76 * Number of bytes of the request message (follows after this struct).
84 * Handle to the peerinfo service.
86 struct GNUNET_PEERINFO_Handle
91 const struct GNUNET_CONFIGURATION_Handle *cfg;
96 struct GNUNET_SCHEDULER_Handle *sched;
99 * Connection to the service.
101 struct GNUNET_CLIENT_Connection *client;
104 * Head of transmission queue.
106 struct TransmissionQueueEntry *tq_head;
109 * Tail of transmission queue.
111 struct TransmissionQueueEntry *tq_tail;
114 * Handle for the current transmission request, or NULL if none is pending.
116 struct GNUNET_CLIENT_TransmitHandle *th;
119 * Set to GNUNET_YES if we are currently receiving replies from the
128 * Connect to the peerinfo service.
130 * @param cfg configuration to use
131 * @param sched scheduler to use
132 * @return NULL on error (configuration related, actual connection
133 * etablishment may happen asynchronously).
135 struct GNUNET_PEERINFO_Handle *
136 GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
137 struct GNUNET_SCHEDULER_Handle *sched)
139 struct GNUNET_CLIENT_Connection *client;
140 struct GNUNET_PEERINFO_Handle *ret;
142 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
145 ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle));
146 ret->client = client;
154 * Disconnect from the peerinfo service. Note that all iterators must
155 * have completed or have been cancelled by the time this function is
156 * called (otherwise, calling this function is a serious error).
157 * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still
158 * pending, they will be cancelled silently on disconnect.
160 * @param h handle to disconnect
163 GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h)
165 struct TransmissionQueueEntry *tqe;
167 while (NULL != (tqe = h->tq_head))
169 GNUNET_CONTAINER_DLL_remove (h->tq_head,
172 if (tqe->cont != NULL)
173 tqe->cont (tqe->cont_cls, GNUNET_SYSERR);
176 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
182 * Check if we have a request pending in the transmission queue and are
183 * able to transmit it right now. If so, schedule transmission.
185 * @param h handle to the service
188 trigger_transmit (struct GNUNET_PEERINFO_Handle *h);
192 * Close the existing connection to PEERINFO and reconnect.
194 * @param h handle to the service
197 reconnect (struct GNUNET_PEERINFO_Handle *h)
199 GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR);
200 h->client = GNUNET_CLIENT_connect (h->sched, "client", h->cfg);
201 GNUNET_assert (h->client != NULL);
206 * Transmit the request at the head of the transmission queue
207 * and trigger continuation (if any).
209 * @param cls the 'struct GNUNET_PEERINFO_Handle' (with the queue)
210 * @param size size of the buffer (0 on error)
211 * @param buf where to copy the message
212 * @return number of bytes copied to buf
215 do_transmit (void *cls, size_t size, void *buf)
217 struct GNUNET_PEERINFO_Handle *h = cls;
218 struct TransmissionQueueEntry *tqe = h->tq_head;
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
227 ("Failed to transmit message of type %u to `%s' service.\n"),
228 ntohs (msg->type), "peerinfo");
230 GNUNET_CONTAINER_DLL_remove (h->tq_head,
234 trigger_transmit (h);
235 if (tqe->cont != NULL)
236 tqe->cont (tqe->cont_cls, GNUNET_SYSERR);
241 GNUNET_assert (size >= ret);
242 memcpy (buf, &tqe[1], ret);
243 GNUNET_CONTAINER_DLL_remove (h->tq_head,
246 if (tqe->cont != NULL)
247 tqe->cont (tqe->cont_cls, GNUNET_OK);
249 trigger_transmit (h);
256 * Check if we have a request pending in the transmission queue and are
257 * able to transmit it right now. If so, schedule transmission.
259 * @param h handle to the service
262 trigger_transmit (struct GNUNET_PEERINFO_Handle *h)
264 struct TransmissionQueueEntry *tqe;
266 /* FIXME: need to handle case where we are still *receiving* (and then
267 do nothing here as well!) */
268 if (NULL == (tqe = h->tq_head))
272 if (h->in_receive == GNUNET_YES)
274 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
276 GNUNET_TIME_absolute_get_remaining (tqe->timeout),
283 * Add a host to the persistent list. This method operates in
284 * semi-reliable mode: if the transmission is not completed by
285 * the time 'GNUNET_PEERINFO_disconnect' is called, it will be
286 * aborted. Furthermore, if a second HELLO is added for the
287 * same peer before the first one was transmitted, PEERINFO may
288 * merge the two HELLOs prior to transmission to the service.
290 * @param h handle to the peerinfo service
291 * @param hello the verified (!) HELLO message
294 GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h,
295 const struct GNUNET_HELLO_Message *hello)
297 uint16_t hs = GNUNET_HELLO_size (hello);
298 struct TransmissionQueueEntry *tqe;
301 struct GNUNET_PeerIdentity peer;
302 GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer));
303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
304 "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
309 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + hs);
311 tqe->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
312 memcpy (&tqe[1], hello, hs);
313 GNUNET_CONTAINER_DLL_insert_after (h->tq_head,
317 trigger_transmit (h);
322 * Context for an iteration request.
324 struct GNUNET_PEERINFO_NewIteratorContext
327 * Handle to the PEERINFO service.
329 struct GNUNET_PEERINFO_Handle *h;
332 * Function to call with the results.
334 GNUNET_PEERINFO_Processor callback;
337 * Closure for 'callback'.
342 * Our entry in the transmission queue.
344 struct TransmissionQueueEntry *tqe;
347 * Task responsible for timeout.
349 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
352 * Timeout for the operation.
354 struct GNUNET_TIME_Absolute timeout;
357 * Are we now receiving?
364 * Type of a function to call when we receive a message
368 * @param msg message received, NULL on timeout or fatal error
371 peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
373 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls;
374 const struct InfoMessage *im;
375 const struct GNUNET_HELLO_Message *hello;
378 ic->h->in_receive = GNUNET_NO;
381 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
382 _("Failed to receive response from `%s' service.\n"),
385 trigger_transmit (ic->h);
386 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
387 GNUNET_SCHEDULER_cancel (ic->h->sched,
389 if (ic->callback != NULL)
390 ic->callback (ic->callback_cls, NULL, NULL, 1);
394 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END)
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
398 "Received end of list of peers from peerinfo database\n");
400 trigger_transmit (ic->h);
401 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
402 GNUNET_SCHEDULER_cancel (ic->h->sched,
404 if (ic->callback != NULL)
405 ic->callback (ic->callback_cls, NULL, NULL, 0);
409 ms = ntohs (msg->size);
410 if ((ms < sizeof (struct InfoMessage)) ||
411 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_PEERINFO_INFO))
415 trigger_transmit (ic->h);
416 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
417 GNUNET_SCHEDULER_cancel (ic->h->sched,
419 if (ic->callback != NULL)
420 ic->callback (ic->callback_cls, NULL, NULL, 2);
424 im = (const struct InfoMessage *) msg;
426 if (ms > sizeof (struct InfoMessage) + sizeof (struct GNUNET_MessageHeader))
428 hello = (const struct GNUNET_HELLO_Message *) &im[1];
429 if (ms != sizeof (struct InfoMessage) + GNUNET_HELLO_size (hello))
433 trigger_transmit (ic->h);
434 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
435 GNUNET_SCHEDULER_cancel (ic->h->sched,
437 if (ic->callback != NULL)
438 ic->callback (ic->callback_cls, NULL, NULL, 2);
444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
445 "Received %u bytes of `%s' information about peer `%s' from PEERINFO database\n",
446 (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello),
448 GNUNET_i2s (&im->peer));
450 ic->h->in_receive = GNUNET_YES;
451 if (ic->callback != NULL)
452 ic->callback (ic->callback_cls, &im->peer, hello, ntohl (im->trust));
453 GNUNET_CLIENT_receive (ic->h->client,
456 GNUNET_TIME_absolute_get_remaining (ic->timeout));
461 * We've transmitted the iteration request. Now get ready to process
462 * the results (or handle transmission error).
464 * @param cls the 'struct GNUNET_PEERINFO_NewIteratorContext'
465 * @param transmit_success GNUNET_OK if transmission worked
468 iterator_start_receive (void *cls,
469 int transmit_success)
471 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls;
473 if (GNUNET_OK != transmit_success)
475 ic->callback (ic->callback_cls, NULL, NULL, 2);
477 trigger_transmit (ic->h);
481 ic->h->in_receive = GNUNET_YES;
482 ic->in_receive = GNUNET_YES;
484 GNUNET_CLIENT_receive (ic->h->client,
487 GNUNET_TIME_absolute_get_remaining (ic->timeout));
492 * Peerinfo iteration request has timed out.
494 * @param cls the 'struct GNUNET_PEERINFO_NewIteratorContext*'
495 * @param tc scheduler context
498 signal_timeout (void *cls,
499 const struct GNUNET_SCHEDULER_TaskContext *tc)
501 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls;
503 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
504 ic->callback (ic->callback_cls, NULL, NULL, 1);
507 return; /* need to finish processing */
508 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head,
511 GNUNET_free (ic->tqe);
517 * Call a method for each known matching host and change its trust
518 * value. The callback method will be invoked once for each matching
519 * host and then finally once with a NULL pointer. After that final
520 * invocation, the iterator context must no longer be used.
522 * Note that the last call can be triggered by timeout or by simply
523 * being done; however, the trust argument will be set to zero if we
524 * are done, 1 if we timed out and 2 for fatal error.
526 * Instead of calling this function with 'peer == NULL' and 'trust ==
527 * 0', it is often better to use 'GNUNET_PEERINFO_notify'.
529 * @param h handle to the peerinfo service
530 * @param peer restrict iteration to this peer only (can be NULL)
531 * @param trust_delta how much to change the trust in all matching peers
532 * @param timeout how long to wait until timing out
533 * @param callback the method to call for each peer
534 * @param callback_cls closure for callback
535 * @return NULL on error (in this case, 'callback' is never called!),
536 * otherwise an iterator context
538 struct GNUNET_PEERINFO_NewIteratorContext *
539 GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
540 const struct GNUNET_PeerIdentity *peer,
542 struct GNUNET_TIME_Relative timeout,
543 GNUNET_PEERINFO_Processor callback,
546 struct ListAllPeersMessage *lapm;
547 struct ListPeerMessage *lpm;
548 struct GNUNET_PEERINFO_NewIteratorContext *ic;
549 struct TransmissionQueueEntry *tqe;
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Requesting list of peers from peerinfo database\n");
557 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
558 sizeof (struct ListAllPeersMessage));
559 tqe->size = sizeof (struct ListAllPeersMessage);
560 lapm = (struct ListAllPeersMessage *) &tqe[1];
561 lapm->header.size = htons (sizeof (struct ListAllPeersMessage));
562 lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
563 lapm->trust_change = htonl (trust_delta);
567 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
568 sizeof (struct ListPeerMessage));
569 tqe->size = sizeof (struct ListPeerMessage);
570 lpm = (struct ListPeerMessage *) &tqe[1];
571 lpm->header.size = htons (sizeof (struct ListPeerMessage));
572 lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
573 lpm->trust_change = htonl (trust_delta);
574 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
576 ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NewIteratorContext));
579 ic->callback = callback;
580 ic->callback_cls = callback_cls;
581 ic->timeout = GNUNET_TIME_relative_to_absolute (timeout);
582 ic->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched,
586 tqe->timeout = ic->timeout;
587 tqe->cont = &iterator_start_receive;
589 tqe->timeout = ic->timeout;
590 GNUNET_CONTAINER_DLL_insert_after (h->tq_head,
594 trigger_transmit (h);
601 * Cancel an iteration over peer information.
603 * @param ic context of the iterator to cancel
606 GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *ic)
608 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
610 GNUNET_SCHEDULER_cancel (ic->h->sched,
612 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
616 return; /* need to finish processing */
617 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head,
620 GNUNET_free (ic->tqe);
626 /* ***************************** OLD API ****************************** */
631 #define ADD_PEER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
636 struct GNUNET_CLIENT_Connection *client;
637 struct GNUNET_MessageHeader *msg;
642 copy_and_free (void *cls, size_t size, void *buf)
644 struct CAFContext *cc = cls;
645 struct GNUNET_MessageHeader *msg = cc->msg;
651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
653 ("Failed to transmit message of type %u to `%s' service.\n"),
654 ntohs (msg->type), "peerinfo");
657 GNUNET_CLIENT_disconnect (cc->client, GNUNET_NO);
661 msize = ntohs (msg->size);
662 GNUNET_assert (size >= msize);
663 memcpy (buf, msg, msize);
665 GNUNET_CLIENT_disconnect (cc->client, GNUNET_YES);
673 * Add a host to the persistent list.
675 * @param cfg configuration to use
676 * @param sched scheduler to use
677 * @param peer identity of the peer
678 * @param hello the verified (!) HELLO message
681 GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
682 struct GNUNET_SCHEDULER_Handle *sched,
683 const struct GNUNET_PeerIdentity *peer,
684 const struct GNUNET_HELLO_Message *hello)
686 struct GNUNET_CLIENT_Connection *client;
687 struct PeerAddMessage *pam;
689 struct CAFContext *cc;
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
693 "Adding peer `%s' to peerinfo database\n",
696 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
699 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
700 _("Could not connect to `%s' service.\n"), "peerinfo");
703 hs = GNUNET_HELLO_size (hello);
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
706 "Size of `%s' is %u bytes\n",
708 (unsigned int) GNUNET_HELLO_size (hello));
710 pam = GNUNET_malloc (sizeof (struct PeerAddMessage) + hs);
711 pam->header.size = htons (hs + sizeof (struct PeerAddMessage));
712 pam->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_ADD);
713 memcpy (&pam->peer, peer, sizeof (struct GNUNET_PeerIdentity));
714 memcpy (&pam[1], hello, hs);
715 cc = GNUNET_malloc (sizeof (struct CAFContext));
717 cc->msg = &pam->header;
718 GNUNET_CLIENT_notify_transmit_ready (client,
719 ntohs (pam->header.size),
727 * Context for the info handler.
729 struct GNUNET_PEERINFO_IteratorContext
733 * Our connection to the PEERINFO service.
735 struct GNUNET_CLIENT_Connection *client;
738 * Function to call with information.
740 GNUNET_PEERINFO_Processor callback;
743 * Closure for callback.
748 * When should we time out?
750 struct GNUNET_TIME_Absolute timeout;
756 * Type of a function to call when we receive a message
760 * @param msg message received, NULL on timeout or fatal error
763 info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
765 struct GNUNET_PEERINFO_IteratorContext *ic = cls;
766 const struct InfoMessage *im;
767 const struct GNUNET_HELLO_Message *hello;
772 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
773 _("Failed to receive response from `%s' service.\n"),
775 ic->callback (ic->callback_cls, NULL, NULL, 1);
776 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
780 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END)
783 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
784 "Received end of list of peers from peerinfo database\n");
786 ic->callback (ic->callback_cls, NULL, NULL, 0);
787 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
791 ms = ntohs (msg->size);
792 if ((ms < sizeof (struct InfoMessage)) ||
793 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_PEERINFO_INFO))
796 ic->callback (ic->callback_cls, NULL, NULL, 2);
797 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
801 im = (const struct InfoMessage *) msg;
803 if (ms > sizeof (struct InfoMessage) + sizeof (struct GNUNET_MessageHeader))
805 hello = (const struct GNUNET_HELLO_Message *) &im[1];
806 if (ms != sizeof (struct InfoMessage) + GNUNET_HELLO_size (hello))
809 ic->callback (ic->callback_cls, NULL, NULL, 2);
810 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Received %u bytes of `%s' information about peer `%s' from PEERINFO database\n",
818 (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello),
820 GNUNET_i2s (&im->peer));
822 ic->callback (ic->callback_cls, &im->peer, hello, ntohl (im->trust));
823 GNUNET_CLIENT_receive (ic->client,
826 GNUNET_TIME_absolute_get_remaining (ic->timeout));
831 * Call a method for each known matching host and change
832 * its trust value. The method will be invoked once for
833 * each host and then finally once with a NULL pointer.
834 * Note that the last call can be triggered by timeout or
835 * by simply being done; however, the trust argument will
836 * be set to zero if we are done and to 1 if we timed out.
838 * @param cfg configuration to use
839 * @param sched scheduler to use
840 * @param peer restrict iteration to this peer only (can be NULL)
841 * @param trust_delta how much to change the trust in all matching peers
842 * @param timeout how long to wait until timing out
843 * @param callback the method to call for each peer
844 * @param callback_cls closure for callback
845 * @return NULL on error, otherwise an iterator context
847 struct GNUNET_PEERINFO_IteratorContext *
848 GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
849 struct GNUNET_SCHEDULER_Handle *sched,
850 const struct GNUNET_PeerIdentity *peer,
852 struct GNUNET_TIME_Relative timeout,
853 GNUNET_PEERINFO_Processor callback,
856 struct GNUNET_CLIENT_Connection *client;
857 struct ListAllPeersMessage *lapm;
858 struct ListPeerMessage *lpm;
859 struct GNUNET_PEERINFO_IteratorContext *ihc;
861 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
864 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
865 _("Could not connect to `%s' service.\n"), "peerinfo");
869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870 "Requesting list of peers from peerinfo database\n");
874 ihc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext) +
875 sizeof (struct ListAllPeersMessage));
876 lapm = (struct ListAllPeersMessage *) &ihc[1];
877 lapm->header.size = htons (sizeof (struct ListAllPeersMessage));
878 lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
879 lapm->trust_change = htonl (trust_delta);
883 ihc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext) +
884 sizeof (struct ListPeerMessage));
885 lpm = (struct ListPeerMessage *) &ihc[1];
886 lpm->header.size = htons (sizeof (struct ListPeerMessage));
887 lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
888 lpm->trust_change = htonl (trust_delta);
889 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
891 ihc->client = client;
892 ihc->callback = callback;
893 ihc->callback_cls = callback_cls;
894 ihc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
896 GNUNET_CLIENT_transmit_and_get_response (client,
897 (const struct GNUNET_MessageHeader*) &ihc[1],
904 GNUNET_CLIENT_disconnect (ihc->client, GNUNET_NO);
913 * Cancel an iteration over peer information.
915 * @param ic context of the iterator to cancel
918 GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
920 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
925 /* end of peerinfo_api.c */