diff options
Diffstat (limited to 'src/include/gnunet_peerinfo_service.h')
-rw-r--r-- | src/include/gnunet_peerinfo_service.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h new file mode 100644 index 000000000..45c52c447 --- /dev/null +++ b/src/include/gnunet_peerinfo_service.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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. | ||
19 | */ | ||
20 | /** | ||
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 | ||
26 | */ | ||
27 | |||
28 | #ifndef GNUNET_PEERINFO_SERVICE_H | ||
29 | #define GNUNET_PEERINFO_SERVICE_H | ||
30 | |||
31 | #include "gnunet_common.h" | ||
32 | #include "gnunet_configuration_lib.h" | ||
33 | #include "gnunet_crypto_lib.h" | ||
34 | #include "gnunet_hello_lib.h" | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Add a host to the persistent list. | ||
47 | * | ||
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 | ||
52 | */ | ||
53 | void | ||
54 | GNUNET_PEERINFO_add_peer (struct GNUNET_CONFIGURATION_Handle *cfg, | ||
55 | struct GNUNET_SCHEDULER_Handle *sched, | ||
56 | const struct GNUNET_PeerIdentity *peer, | ||
57 | const struct GNUNET_HELLO_Message *hello); | ||
58 | |||
59 | /** | ||
60 | * Type of an iterator over the hosts. Note that each | ||
61 | * host will be called with each available protocol. | ||
62 | * | ||
63 | * @param cls closure | ||
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 | ||
67 | */ | ||
68 | typedef void | ||
69 | (*GNUNET_PEERINFO_Processor) (void *cls, | ||
70 | const struct GNUNET_PeerIdentity * peer, | ||
71 | const struct GNUNET_HELLO_Message * hello, | ||
72 | uint32_t trust); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Call a method for each known matching host and change | ||
77 | * its trust value. The method will be invoked once for | ||
78 | * each host and then finally once with a NULL pointer. | ||
79 | * Note that the last call can be triggered by timeout or | ||
80 | * by simply being done; however, the trust argument will | ||
81 | * be set to zero if we are done, 1 if we timed out and | ||
82 | * 2 for fatal error. | ||
83 | * | ||
84 | * @param cfg configuration to use | ||
85 | * @param sched scheduler to use | ||
86 | * @param peer restrict iteration to this peer only (can be NULL) | ||
87 | * @param trust_delta how much to change the trust in all matching peers | ||
88 | * @param timeout how long to wait until timing out | ||
89 | * @param callback the method to call for each peer | ||
90 | * @param callback_cls closure for callback | ||
91 | */ | ||
92 | void | ||
93 | GNUNET_PEERINFO_for_all (struct GNUNET_CONFIGURATION_Handle *cfg, | ||
94 | struct GNUNET_SCHEDULER_Handle *sched, | ||
95 | const struct GNUNET_PeerIdentity *peer, | ||
96 | int trust_delta, | ||
97 | struct GNUNET_TIME_Relative timeout, | ||
98 | GNUNET_PEERINFO_Processor callback, | ||
99 | void *callback_cls); | ||
100 | |||
101 | |||
102 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
103 | { | ||
104 | #endif | ||
105 | #ifdef __cplusplus | ||
106 | } | ||
107 | #endif | ||
108 | |||
109 | |||
110 | /* end of gnunet_peerinfo_service.h */ | ||
111 | #endif | ||