2 This file is part of GNUnet
3 Copyright (C) 2012-2013 GNUnet e.V.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @brief example IPC messages between RPS API and GNS service
23 * @author Julius Bünger
26 #include "gnunet_rps_service.h"
29 * Mesh port used by RPS.
31 #define GNUNET_RPS_CADET_PORT 31337
34 GNUNET_NETWORK_STRUCT_BEGIN
36 /***********************************************************************
38 ***********************************************************************/
41 * P2P Message to send PeerIDs to other peer.
43 struct GNUNET_RPS_P2P_PullReplyMessage {
45 * Header including size and type in NBO
47 struct GNUNET_MessageHeader header;
50 * Number of PeerIDs sent
52 uint32_t num_peers GNUNET_PACKED;
54 /* Followed by num_peers * GNUNET_PeerIdentity */
59 /***********************************************************************
60 * Client-Service Messages
61 ***********************************************************************/
64 * Message from client to service with seed of peers.
66 struct GNUNET_RPS_CS_SeedMessage {
68 * Header including size and type in NBO
70 struct GNUNET_MessageHeader header;
75 uint32_t num_peers GNUNET_PACKED;
77 /* Followed by num_peers * GNUNET_PeerIdentity */
82 * Message from client to service to turn service malicious.
84 struct GNUNET_RPS_CS_ActMaliciousMessage {
86 * Header including size and type in NBO
88 struct GNUNET_MessageHeader header;
91 * If the type is 2 this is the attacked peer,
94 struct GNUNET_PeerIdentity attacked_peer;
97 * Type of malicious behaviour.
99 * 0 No malicious bahaviour at all
100 * 1 Try to maximise representation
101 * 2 Try to partition the network
103 uint32_t type GNUNET_PACKED;
108 uint32_t num_peers GNUNET_PACKED;
110 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
113 #endif /* ENABLE_MALICIOUS */
117 * Message from client to service telling it to start a new sub
119 struct GNUNET_RPS_CS_SubStartMessage {
121 * Header including size and type in NBO
123 struct GNUNET_MessageHeader header;
128 uint32_t reserved GNUNET_PACKED;
131 * Mean interval between two rounds
133 struct GNUNET_TIME_RelativeNBO round_interval;
136 * Length of the shared value represented as string.
138 struct GNUNET_HashCode hash GNUNET_PACKED;
143 * Message from client to service telling it to stop a new sub
145 struct GNUNET_RPS_CS_SubStopMessage {
147 * Header including size and type in NBO
149 struct GNUNET_MessageHeader header;
152 * Length of the shared value represented as string.
154 struct GNUNET_HashCode hash GNUNET_PACKED;
161 * Message from client to service indicating that
162 * clients wants to get updates of the view
164 struct GNUNET_RPS_CS_DEBUG_ViewRequest {
166 * Header including size and type in NBO
168 struct GNUNET_MessageHeader header;
172 * 0 for sending updates until cancellation
174 uint32_t num_updates GNUNET_PACKED;
178 * Message from service to client containing current update of view
180 struct GNUNET_RPS_CS_DEBUG_ViewReply {
182 * Header including size and type in NBO
184 struct GNUNET_MessageHeader header;
187 * Identifyer of the message.
189 uint32_t id GNUNET_PACKED;
192 * Number of peers in the view
194 uint64_t num_peers GNUNET_PACKED;
196 /* Followed by num_peers * GNUNET_PeerIdentity */
199 * Message from client to service indicating that
200 * clients wants to get stream of biased peers
202 struct GNUNET_RPS_CS_DEBUG_StreamRequest {
204 * Header including size and type in NBO
206 struct GNUNET_MessageHeader header;
210 * Message from service to client containing peer from biased stream
212 struct GNUNET_RPS_CS_DEBUG_StreamReply {
214 * Header including size and type in NBO
216 struct GNUNET_MessageHeader header;
221 uint64_t num_peers GNUNET_PACKED;
223 // TODO maybe source of peer (pull/push list, peerinfo, ...)
225 /* Followed by num_peers * GNUNET_PeerIdentity */
228 GNUNET_NETWORK_STRUCT_END
230 /***********************************************************************
231 * Defines from old gnunet-service-rps_peers.h
232 ***********************************************************************/
235 * Different flags indicating the status of another peer.
237 enum Peers_PeerFlags {
239 * If we are waiting for a reply from that peer (sent a pull request).
241 Peers_PULL_REPLY_PENDING = 0x01,
243 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
244 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
245 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
248 * We set this bit when we know the peer is online.
253 * We set this bit when we are going to destroy the channel to this peer.
254 * When cleanup_channel is called, we know that we wanted to destroy it.
255 * Otherwise the channel to the other peer was destroyed.
257 Peers_TO_DESTROY = 0x40,
261 * Keep track of the status of a channel.
263 * This is needed in order to know what to do with a channel when it's
266 enum Peers_ChannelFlags {
268 * We destroyed the channel because the other peer established a second one.
270 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
273 * The channel was removed because it was not needed any more. This should be
274 * the sending channel.
276 Peers_CHANNEL_CLEAN = 0x2,
279 * We destroyed the channel because the other peer established a second one.
281 Peers_CHANNEL_DESTROING = 0x4,
286 * @brief The role of a channel. Sending or receiving.
288 enum Peers_ChannelRole {
290 * Channel is used for sending
292 Peers_CHANNEL_ROLE_SENDING = 0x01,
295 * Channel is used for receiving
297 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
301 * @brief Functions of this type can be used to be stored at a peer for later execution.
304 * @param peer peer to execute function on
306 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
309 * @brief Iterator over valid peers.
312 * @param peer current public peer id
313 * @return #GNUNET_YES if we should continue to
318 (*PeersIterator) (void *cls,
319 const struct GNUNET_PeerIdentity *peer);
323 * Handle to the statistics service.
325 extern struct GNUNET_STATISTICS_Handle *stats;