2 This file is part of GNUnet
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 3, 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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Julius Bünger
25 * API to the rps service
27 * @defgroup rps RPS service
28 * Random Peer Sampling
31 #ifndef GNUNET_RPS_SERVICE_H
32 #define GNUNET_RPS_SERVICE_H
37 #if 0 /* keep Emacsens' auto-indent happy */
43 * Version of the rps API.
45 #define GNUNET_RPS_VERSION 0x00000000
48 * Handle for the random peer sampling service
50 struct GNUNET_RPS_Handle;
53 * Handle for one request to the rps service
55 struct GNUNET_RPS_Request_Handle;
58 * Callback called when requested random peers are available.
60 * @param cls the closure given with the request
61 * @param num_peers the number of peers returned
62 * @param peers array with num_peers PeerIDs
64 typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls,
66 const struct GNUNET_PeerIdentity *peers);
69 * Connect to the rps service
71 * @param cfg configuration to use
72 * @return handle to the rps service
74 struct GNUNET_RPS_Handle *
75 GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
78 * Request n random peers.
80 * This does exacly the same as GNUNET_RPS_request_peers_single_call
81 * but needs a GNUNET_RPS_Handle.
82 * This exists only for other parts of GNUnet that expect having to
83 * (dis)connect from/to a service.
85 * @param h handle to the rps service
86 * @param n number of random peers to return
87 * @param ready_cb the callback to be called when the peers are available
88 * @param cls a closure that will be given to the callback
89 * @return handle to this request
91 struct GNUNET_RPS_Request_Handle *
92 GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n,
93 GNUNET_RPS_NotifyReadyCB ready_cb,
97 * Seed rps service with peerIDs.
99 * @param h handle to the rps service
100 * @param n number of peers to seed
101 * @param ids the ids of the peers seeded
104 GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n,
105 const struct GNUNET_PeerIdentity * ids);
108 * Cancle an issued request.
110 * @param rh handle of the pending request to be canceled
113 GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh);
116 #ifdef ENABLE_MALICIOUS
118 * Turn RPS service to act malicious.
120 * @param h handle to the rps service
121 * @param type which type of malicious peer to turn to.
122 * 0 Don't act malicious at all
123 * 1 Try to maximise representation
124 * 2 Try to partition the network
125 * (isolate one peer from the rest)
126 * @param n number of @a ids
127 * @param ids the ids of the malicious peers
128 * if @type is 2 the last id is the id of the
129 * peer to be isolated from the rest
132 GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
135 const struct GNUNET_PeerIdentity *ids,
136 const struct GNUNET_PeerIdentity *target_peer);
137 #endif /* ENABLE_MALICIOUS */
141 * Disconnect from the rps service
143 * @param h the handle to the rps service
146 GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h);
149 #if 0 /* keep Emacsens' auto-indent happy */
158 /** @} */ /* end of group */