2 This file is part of GNUnet
3 (C) 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.
21 * @file include/gnunet_peerinfo_service.h
22 * @brief Code to maintain the list of currently known hosts
23 * (in memory structure of data/hosts) and their trust ratings
24 * (in memory structure of data/trust)
25 * @author Christian Grothoff
28 #ifndef GNUNET_PEERINFO_SERVICE_H
29 #define GNUNET_PEERINFO_SERVICE_H
31 #include "gnunet_common.h"
32 #include "gnunet_configuration_lib.h"
33 #include "gnunet_crypto_lib.h"
34 #include "gnunet_hello_lib.h"
39 #if 0 /* keep Emacsens' auto-indent happy */
46 * Add a host to the persistent list.
48 * @param cfg configuration to use
49 * @param sched scheduler to use
50 * @param peer identity of the peer
51 * @param hello the verified (!) HELLO message
54 GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
55 struct GNUNET_SCHEDULER_Handle *sched,
56 const struct GNUNET_PeerIdentity *peer,
57 const struct GNUNET_HELLO_Message *hello);
60 * Type of an iterator over the hosts. Note that each
61 * host will be called with each available protocol.
64 * @param peer id of the peer, NULL for last call
65 * @param hello hello message for the peer (can be NULL)
66 * @param trust amount of trust we have in the peer
69 (*GNUNET_PEERINFO_Processor) (void *cls,
70 const struct GNUNET_PeerIdentity * peer,
71 const struct GNUNET_HELLO_Message * hello,
76 * Handle for cancellation of iteration over peers.
78 struct GNUNET_PEERINFO_IteratorContext;
82 * Call a method for each known matching host and change
83 * its trust value. The method will be invoked once for
84 * each host and then finally once with a NULL pointer. After
85 * that final invocation, the iterator context must no longer
88 * Note that the last call can be triggered by timeout or by simply
89 * being done; however, the trust argument will be set to zero if we
90 * are done, 1 if we timed out and 2 for fatal error.
92 * @param cfg configuration to use
93 * @param sched scheduler to use
94 * @param peer restrict iteration to this peer only (can be NULL)
95 * @param trust_delta how much to change the trust in all matching peers
96 * @param timeout how long to wait until timing out
97 * @param callback the method to call for each peer
98 * @param callback_cls closure for callback
99 * @return NULL on error (in this case, 'callback' is never called!),
100 * otherwise an iterator context
102 struct GNUNET_PEERINFO_IteratorContext *
103 GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
104 struct GNUNET_SCHEDULER_Handle *sched,
105 const struct GNUNET_PeerIdentity *peer,
107 struct GNUNET_TIME_Relative timeout,
108 GNUNET_PEERINFO_Processor callback,
113 * Cancel an iteration over peer information.
115 * @param ic context of the iterator to cancel
118 GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic);
122 * Handle for notifications about changes to the set of known peers.
124 struct GNUNET_PEERINFO_NotifyContext;
128 * Call a method whenever our known information about peers
129 * changes. Initially calls the given function for all known
130 * peers and then only signals changes. Note that it is
131 * possible (i.e. on disconnects) that the callback is called
132 * twice with the same peer information.
134 * @param cfg configuration to use
135 * @param sched scheduler to use
136 * @param callback the method to call for each peer
137 * @param callback_cls closure for callback
138 * @return NULL on error
140 struct GNUNET_PEERINFO_NotifyContext *
141 GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
142 struct GNUNET_SCHEDULER_Handle *sched,
143 GNUNET_PEERINFO_Processor callback,
148 * Stop notifying about changes.
150 * @param nc context to stop notifying
153 GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc);
156 #if 0 /* keep Emacsens' auto-indent happy */
164 /* end of gnunet_peerinfo_service.h */