aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/peerinfo_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo/peerinfo_api.c')
-rw-r--r--src/peerinfo/peerinfo_api.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index a1eeeb220..1f382f096 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2007, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2001, 2002, 2004, 2005, 2007, 2009, 2010 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -397,7 +397,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
397 GNUNET_SCHEDULER_cancel (ic->h->sched, 397 GNUNET_SCHEDULER_cancel (ic->h->sched,
398 ic->timeout_task); 398 ic->timeout_task);
399 if (ic->callback != NULL) 399 if (ic->callback != NULL)
400 ic->callback (ic->callback_cls, NULL, NULL, 1); 400 ic->callback (ic->callback_cls, NULL, NULL);
401 GNUNET_free (ic); 401 GNUNET_free (ic);
402 return; 402 return;
403 } 403 }
@@ -413,7 +413,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
413 GNUNET_SCHEDULER_cancel (ic->h->sched, 413 GNUNET_SCHEDULER_cancel (ic->h->sched,
414 ic->timeout_task); 414 ic->timeout_task);
415 if (ic->callback != NULL) 415 if (ic->callback != NULL)
416 ic->callback (ic->callback_cls, NULL, NULL, 0); 416 ic->callback (ic->callback_cls, NULL, NULL);
417 GNUNET_free (ic); 417 GNUNET_free (ic);
418 return; 418 return;
419 } 419 }
@@ -428,7 +428,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
428 GNUNET_SCHEDULER_cancel (ic->h->sched, 428 GNUNET_SCHEDULER_cancel (ic->h->sched,
429 ic->timeout_task); 429 ic->timeout_task);
430 if (ic->callback != NULL) 430 if (ic->callback != NULL)
431 ic->callback (ic->callback_cls, NULL, NULL, 2); 431 ic->callback (ic->callback_cls, NULL, NULL);
432 GNUNET_free (ic); 432 GNUNET_free (ic);
433 return; 433 return;
434 } 434 }
@@ -446,7 +446,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
446 GNUNET_SCHEDULER_cancel (ic->h->sched, 446 GNUNET_SCHEDULER_cancel (ic->h->sched,
447 ic->timeout_task); 447 ic->timeout_task);
448 if (ic->callback != NULL) 448 if (ic->callback != NULL)
449 ic->callback (ic->callback_cls, NULL, NULL, 2); 449 ic->callback (ic->callback_cls, NULL, NULL);
450 GNUNET_free (ic); 450 GNUNET_free (ic);
451 return; 451 return;
452 } 452 }
@@ -461,7 +461,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
461#endif 461#endif
462 ic->h->in_receive = GNUNET_YES; 462 ic->h->in_receive = GNUNET_YES;
463 if (ic->callback != NULL) 463 if (ic->callback != NULL)
464 ic->callback (ic->callback_cls, &im->peer, hello, ntohl (im->trust)); 464 ic->callback (ic->callback_cls, &im->peer, hello);
465 GNUNET_CLIENT_receive (ic->h->client, 465 GNUNET_CLIENT_receive (ic->h->client,
466 &peerinfo_handler, 466 &peerinfo_handler,
467 ic, 467 ic,
@@ -497,7 +497,7 @@ iterator_start_receive (void *cls,
497 reconnect (ic->h); 497 reconnect (ic->h);
498 trigger_transmit (ic->h); 498 trigger_transmit (ic->h);
499 if (ic->callback != NULL) 499 if (ic->callback != NULL)
500 ic->callback (ic->callback_cls, NULL, NULL, 1); 500 ic->callback (ic->callback_cls, NULL, NULL);
501 GNUNET_free (ic); 501 GNUNET_free (ic);
502 return; 502 return;
503 } 503 }
@@ -536,7 +536,7 @@ signal_timeout (void *cls,
536 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, 536 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head,
537 ic->h->tq_tail, 537 ic->h->tq_tail,
538 ic->tqe); 538 ic->tqe);
539 ic->callback (ic->callback_cls, NULL, NULL, 1); 539 ic->callback (ic->callback_cls, NULL, NULL);
540 ic->callback = NULL; 540 ic->callback = NULL;
541 if (ic->in_receive) 541 if (ic->in_receive)
542 return; 542 return;
@@ -551,16 +551,11 @@ signal_timeout (void *cls,
551 * host and then finally once with a NULL pointer. After that final 551 * host and then finally once with a NULL pointer. After that final
552 * invocation, the iterator context must no longer be used. 552 * invocation, the iterator context must no longer be used.
553 * 553 *
554 * Note that the last call can be triggered by timeout or by simply 554 * Instead of calling this function with 'peer == NULL' it is often
555 * being done; however, the trust argument will be set to zero if we 555 * better to use 'GNUNET_PEERINFO_notify'.
556 * are done, 1 if we timed out and 2 for fatal error.
557 *
558 * Instead of calling this function with 'peer == NULL' and 'trust ==
559 * 0', it is often better to use 'GNUNET_PEERINFO_notify'.
560 * 556 *
561 * @param h handle to the peerinfo service 557 * @param h handle to the peerinfo service
562 * @param peer restrict iteration to this peer only (can be NULL) 558 * @param peer restrict iteration to this peer only (can be NULL)
563 * @param trust_delta how much to change the trust in all matching peers
564 * @param timeout how long to wait until timing out 559 * @param timeout how long to wait until timing out
565 * @param callback the method to call for each peer 560 * @param callback the method to call for each peer
566 * @param callback_cls closure for callback 561 * @param callback_cls closure for callback
@@ -570,12 +565,11 @@ signal_timeout (void *cls,
570struct GNUNET_PEERINFO_IteratorContext * 565struct GNUNET_PEERINFO_IteratorContext *
571GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, 566GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
572 const struct GNUNET_PeerIdentity *peer, 567 const struct GNUNET_PeerIdentity *peer,
573 int trust_delta,
574 struct GNUNET_TIME_Relative timeout, 568 struct GNUNET_TIME_Relative timeout,
575 GNUNET_PEERINFO_Processor callback, 569 GNUNET_PEERINFO_Processor callback,
576 void *callback_cls) 570 void *callback_cls)
577{ 571{
578 struct ListAllPeersMessage *lapm; 572 struct GNUNET_MessageHeader *lapm;
579 struct ListPeerMessage *lpm; 573 struct ListPeerMessage *lpm;
580 struct GNUNET_PEERINFO_IteratorContext *ic; 574 struct GNUNET_PEERINFO_IteratorContext *ic;
581 struct TransmissionQueueEntry *tqe; 575 struct TransmissionQueueEntry *tqe;
@@ -587,12 +581,11 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
587 "Requesting list of peers from PEERINFO service\n"); 581 "Requesting list of peers from PEERINFO service\n");
588#endif 582#endif
589 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + 583 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
590 sizeof (struct ListAllPeersMessage)); 584 sizeof (struct GNUNET_MessageHeader));
591 tqe->size = sizeof (struct ListAllPeersMessage); 585 tqe->size = sizeof (struct GNUNET_MessageHeader);
592 lapm = (struct ListAllPeersMessage *) &tqe[1]; 586 lapm = (struct GNUNET_MessageHeader *) &tqe[1];
593 lapm->header.size = htons (sizeof (struct ListAllPeersMessage)); 587 lapm->size = htons (sizeof (struct GNUNET_MessageHeader));
594 lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL); 588 lapm->type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
595 lapm->trust_change = htonl (trust_delta);
596 } 589 }
597 else 590 else
598 { 591 {
@@ -607,7 +600,6 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
607 lpm = (struct ListPeerMessage *) &tqe[1]; 600 lpm = (struct ListPeerMessage *) &tqe[1];
608 lpm->header.size = htons (sizeof (struct ListPeerMessage)); 601 lpm->header.size = htons (sizeof (struct ListPeerMessage));
609 lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET); 602 lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
610 lpm->trust_change = htonl (trust_delta);
611 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 603 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
612 } 604 }
613 ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext)); 605 ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext));