multicast, psyc, psycstore, client_manager fixes
[oweals/gnunet.git] / src / include / gnunet_rps_service.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 
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 3, 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., 51 Franklin Street, Fifth Floor,
18       Boston, MA 02110-1301, USA.
19  */
20
21 /**
22  * @file include/gnunet_rps_service.h
23  * @brief API to the rps service
24  * @author Julius Bünger
25  */
26 #ifndef GNUNET_RPS_SERVICE_H
27 #define GNUNET_RPS_SERVICE_H
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0                           /* keep Emacsens' auto-indent happy */
33 }
34 #endif
35 #endif
36
37 /**
38  * Version of the rps API.
39  */
40 #define GNUNET_RPS_VERSION 0x00000000
41
42 /**
43  * Handle for the random peer sampling service
44  */
45 struct GNUNET_RPS_Handle;
46
47 /**
48  * Handle for one request to the rps service
49  */
50 struct GNUNET_RPS_Request_Handle;
51
52 /**
53  * Callback called when requested random peers are available.
54  *
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
58  */
59 typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls,
60     uint64_t num_peers,
61     const struct GNUNET_PeerIdentity *peers);
62
63 /**
64  * Connect to the rps service
65  *
66  * @param cfg configuration to use
67  * @return handle to the rps service
68  */
69   struct GNUNET_RPS_Handle *
70 GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
71
72 /**
73  * Request n random peers.
74  *
75  * This does exacly the same as GNUNET_RPS_request_peers_single_call
76  * but needs a GNUNET_RPS_Handle.
77  * This exists only for other parts of GNUnet that expect having to
78  * (dis)connect from/to a service.
79  *
80  * @param h handle to the rps service
81  * @param n number of random peers to return
82  * @param ready_cb the callback to be called when the peers are available
83  * @param cls a closure that will be given to the callback
84  * @return handle to this request
85  */
86   struct GNUNET_RPS_Request_Handle *
87 GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n,
88                           GNUNET_RPS_NotifyReadyCB ready_cb,
89                           void *cls);
90
91 /**
92  * Seed rps service with peerIDs.
93  *
94  * @param h handle to the rps service
95  * @param n number of peers to seed
96  * @param ids the ids of the peers seeded
97  */
98   void
99 GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n,
100                      const struct GNUNET_PeerIdentity * ids);
101
102 /**
103  * Cancle an issued request.
104  *
105  * @param rh handle of the pending request to be canceled
106  */
107   void
108 GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh);
109
110
111 #ifdef ENABLE_MALICIOUS
112 /**
113  * Turn RPS service to act malicious.
114  *
115  * @param h handle to the rps service
116  * @param type which type of malicious peer to turn to.
117  *             0 Don't act malicious at all
118  *             1 Try to maximise representation
119  *             2 Try to partition the network
120  *               (isolate one peer from the rest)
121  * @param n number of @a ids
122  * @param ids the ids of the malicious peers
123  *            if @type is 2 the last id is the id of the
124  *            peer to be isolated from the rest
125  */
126   void
127 GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
128                           uint32_t type,
129                           uint32_t num_peers,
130                           const struct GNUNET_PeerIdentity *ids,
131                           const struct GNUNET_PeerIdentity *target_peer);
132 #endif /* ENABLE_MALICIOUS */
133
134
135 /**
136  * Disconnect from the rps service
137  *
138  * @param h the handle to the rps service
139  */
140   void
141 GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h);
142
143 #if 0                           /* keep Emacsens' auto-indent happy */
144 {
145 #endif
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif