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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_rps_service.h
23 * @brief API to the rps service
24 * @author Julius Bünger
26 #ifndef GNUNET_RPS_SERVICE_H
27 #define GNUNET_RPS_SERVICE_H
32 #if 0 /* keep Emacsens' auto-indent happy */
38 * Version of the rps API.
40 #define GNUNET_RPS_VERSION 0x00000000
43 * Handle for the random peer sampling service
45 struct GNUNET_RPS_Handle;
48 * Handle for one request to the rps service
50 struct GNUNET_RPS_Request_Handle;
53 * Callback called when requested random peers are available.
55 * @param cls the closure given with the request
56 * @param num_peers the number of peers returned
57 * @param peers array with num_peers PeerIDs
59 typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers);
62 * Connect to the rps service
64 * @param cfg configuration to use
65 * @return handle to the rps service
67 struct GNUNET_RPS_Handle *
68 GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
71 * Request n random peers.
73 * This does exacly the same as GNUNET_RPS_request_peers_single_call
74 * but needs a GNUNET_RPS_Handle.
75 * This exists only for other parts of GNUnet that expect having to
76 * (dis)connect from/to a service.
78 * @param h handle to the rps service
79 * @param n number of random peers to return
80 * @param ready_cb the callback to be called when the peers are available
81 * @param cls a closure that will be given to the callback
82 * @return handle to this request
84 struct GNUNET_RPS_Request_Handle *
85 GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n,
86 GNUNET_RPS_NotifyReadyCB ready_cb,
90 * Seed rps service with peerIDs.
92 * @param h handle to the rps service
93 * @param n number of peers to seed
94 * @param ids the ids of the peers seeded
97 GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n,
98 const struct GNUNET_PeerIdentity * ids);
101 * Cancle an issued request.
103 * @param rh handle of the pending request to be canceled
106 GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh);
111 * Turn RPS service to act malicious.
113 * @param h handle to the rps service
114 * @param type which type of malicious peer to turn to.
115 * 0 Don't act malicious at all
116 * 1 Try to maximise representation
117 * 2 Try to partition the network
118 * (isolate one peer from the rest)
119 * @param n number of @a ids
120 * @param ids the ids of the malicious peers
121 * if @type is 2 the last id is the id of the
122 * peer to be isolated from the rest
125 GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
128 const struct GNUNET_PeerIdentity *ids);
133 * Disconnect from the rps service
135 * @param h the handle to the rps service
138 GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h);
140 #if 0 /* keep Emacsens' auto-indent happy */