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
46 * Header including size and type in NBO
48 struct GNUNET_MessageHeader header;
51 * Number of PeerIDs sent
53 uint32_t num_peers GNUNET_PACKED;
55 /* 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
69 * Header including size and type in NBO
71 struct GNUNET_MessageHeader header;
76 uint32_t num_peers GNUNET_PACKED;
78 /* Followed by num_peers * GNUNET_PeerIdentity */
83 * Message from client to service to turn service malicious.
85 struct GNUNET_RPS_CS_ActMaliciousMessage
88 * Header including size and type in NBO
90 struct GNUNET_MessageHeader header;
93 * If the type is 2 this is the attacked peer,
96 struct GNUNET_PeerIdentity attacked_peer;
99 * Type of malicious behaviour.
101 * 0 No malicious bahaviour at all
102 * 1 Try to maximise representation
103 * 2 Try to partition the network
105 uint32_t type GNUNET_PACKED;
110 uint32_t num_peers GNUNET_PACKED;
112 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
115 #endif /* ENABLE_MALICIOUS */
119 * Message from client to service telling it to start a new sub
121 struct GNUNET_RPS_CS_SubStartMessage
124 * Header including size and type in NBO
126 struct GNUNET_MessageHeader header;
131 uint32_t reserved GNUNET_PACKED;
134 * Mean interval between two rounds
136 struct GNUNET_TIME_RelativeNBO round_interval;
139 * Length of the shared value represented as string.
141 struct GNUNET_HashCode hash GNUNET_PACKED;
146 * Message from client to service telling it to stop a new sub
148 struct GNUNET_RPS_CS_SubStopMessage
151 * Header including size and type in NBO
153 struct GNUNET_MessageHeader header;
156 * Length of the shared value represented as string.
158 struct GNUNET_HashCode hash GNUNET_PACKED;
165 * Message from client to service indicating that
166 * clients wants to get updates of the view
168 struct GNUNET_RPS_CS_DEBUG_ViewRequest
171 * Header including size and type in NBO
173 struct GNUNET_MessageHeader header;
177 * 0 for sending updates until cancellation
179 uint32_t num_updates GNUNET_PACKED;
183 * Message from service to client containing current update of view
185 struct GNUNET_RPS_CS_DEBUG_ViewReply
188 * Header including size and type in NBO
190 struct GNUNET_MessageHeader header;
193 * Identifyer of the message.
195 uint32_t id GNUNET_PACKED;
198 * Number of peers in the view
200 uint64_t num_peers GNUNET_PACKED;
202 /* Followed by num_peers * GNUNET_PeerIdentity */
205 * Message from client to service indicating that
206 * clients wants to get stream of biased peers
208 struct GNUNET_RPS_CS_DEBUG_StreamRequest
211 * Header including size and type in NBO
213 struct GNUNET_MessageHeader header;
217 * Message from service to client containing peer from biased stream
219 struct GNUNET_RPS_CS_DEBUG_StreamReply
222 * Header including size and type in NBO
224 struct GNUNET_MessageHeader header;
229 uint64_t num_peers GNUNET_PACKED;
231 // TODO maybe source of peer (pull/push list, peerinfo, ...)
233 /* Followed by num_peers * GNUNET_PeerIdentity */
236 GNUNET_NETWORK_STRUCT_END
238 /***********************************************************************
239 * Defines from old gnunet-service-rps_peers.h
240 ***********************************************************************/
243 * Different flags indicating the status of another peer.
248 * If we are waiting for a reply from that peer (sent a pull request).
250 Peers_PULL_REPLY_PENDING = 0x01,
252 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
253 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
254 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
257 * We set this bit when we know the peer is online.
262 * We set this bit when we are going to destroy the channel to this peer.
263 * When cleanup_channel is called, we know that we wanted to destroy it.
264 * Otherwise the channel to the other peer was destroyed.
266 Peers_TO_DESTROY = 0x40,
270 * Keep track of the status of a channel.
272 * This is needed in order to know what to do with a channel when it's
275 enum Peers_ChannelFlags
278 * We destroyed the channel because the other peer established a second one.
280 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
283 * The channel was removed because it was not needed any more. This should be
284 * the sending channel.
286 Peers_CHANNEL_CLEAN = 0x2,
289 * We destroyed the channel because the other peer established a second one.
291 Peers_CHANNEL_DESTROING = 0x4,
296 * @brief The role of a channel. Sending or receiving.
298 enum Peers_ChannelRole
301 * Channel is used for sending
303 Peers_CHANNEL_ROLE_SENDING = 0x01,
306 * Channel is used for receiving
308 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
312 * @brief Functions of this type can be used to be stored at a peer for later execution.
315 * @param peer peer to execute function on
317 typedef void (*PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
320 * @brief Iterator over valid peers.
323 * @param peer current public peer id
324 * @return #GNUNET_YES if we should continue to
329 (*PeersIterator) (void *cls,
330 const struct GNUNET_PeerIdentity *peer);
334 * Handle to the statistics service.
336 extern struct GNUNET_STATISTICS_Handle *stats;