2 This file is part of GNUnet
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Julius Bünger
23 * API to the rps service
25 * @defgroup rps RPS service
26 * Random Peer Sampling
29 #ifndef GNUNET_RPS_SERVICE_H
30 #define GNUNET_RPS_SERVICE_H
35 #if 0 /* keep Emacsens' auto-indent happy */
41 * Version of the rps API.
43 #define GNUNET_RPS_VERSION 0x00000000
46 * Handle for the random peer sampling service
48 struct GNUNET_RPS_Handle;
51 * Handle for one request to the rps service
53 struct GNUNET_RPS_Request_Handle;
56 * Callback called when requested random peers are available.
58 * @param cls the closure given with the request
59 * @param num_peers the number of peers returned
60 * @param peers array with num_peers PeerIDs
62 typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls,
64 const struct GNUNET_PeerIdentity *peers);
68 * Connect to the rps service
70 * @param cfg configuration to use
71 * @return handle to the rps service
73 struct GNUNET_RPS_Handle *
74 GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
77 * Request n random peers.
79 * This does exacly the same as GNUNET_RPS_request_peers_single_call
80 * but needs a GNUNET_RPS_Handle.
81 * This exists only for other parts of GNUnet that expect having to
82 * (dis)connect from/to a service.
84 * @param h handle to the rps service
85 * @param n number of random peers to return
86 * @param ready_cb the callback to be called when the peers are available
87 * @param cls a closure that will be given to the callback
88 * @return handle to this request
90 struct GNUNET_RPS_Request_Handle *
91 GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n,
92 GNUNET_RPS_NotifyReadyCB ready_cb,
96 * Seed rps service with peerIDs.
98 * @param h handle to the rps service
99 * @param n number of peers to seed
100 * @param ids the ids of the peers seeded
103 GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n,
104 const struct GNUNET_PeerIdentity * ids);
107 * Cancle an issued request.
109 * @param rh handle of the pending request to be canceled
112 GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh);
115 #ifdef ENABLE_MALICIOUS
117 * Turn RPS service to act malicious.
119 * @param h handle to the rps service
120 * @param type which type of malicious peer to turn to.
121 * 0 Don't act malicious at all
122 * 1 Try to maximise representation
123 * 2 Try to partition the network
124 * (isolate one peer from the rest)
125 * @param n number of @a ids
126 * @param ids the ids of the malicious peers
127 * if @type is 2 the last id is the id of the
128 * peer to be isolated from the rest
131 GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
134 const struct GNUNET_PeerIdentity *ids,
135 const struct GNUNET_PeerIdentity *target_peer);
136 #endif /* ENABLE_MALICIOUS */
138 /* Get internals for debugging/profiling purposes */
141 * Request updates of view
143 * @param rps_handle handle to the rps service
144 * @param num_req_peers number of peers we want to receive
145 * (0 for infinite updates)
146 * @param cls a closure that will be given to the callback
147 * @param ready_cb the callback called when the peers are available
150 GNUNET_RPS_view_request (struct GNUNET_RPS_Handle *rps_handle,
151 uint32_t num_updates,
152 GNUNET_RPS_NotifyReadyCB view_update_cb,
157 * Request biased stream of peers that are being put into the sampler
159 * @param rps_handle handle to the rps service
160 * @param num_req_peers number of peers we want to receive
161 * (0 for infinite updates)
162 * @param cls a closure that will be given to the callback
163 * @param ready_cb the callback called when the peers are available
166 GNUNET_RPS_stream_request (struct GNUNET_RPS_Handle *rps_handle,
167 uint32_t num_updates,
168 GNUNET_RPS_NotifyReadyCB stream_input_cb,
173 * Disconnect from the rps service
175 * @param h the handle to the rps service
178 GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h);
181 #if 0 /* keep Emacsens' auto-indent happy */
190 /** @} */ /* end of group */