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 */
60 /***********************************************************************
61 * Client-Service Messages
62 ***********************************************************************/
65 * Message from client to service with seed of peers.
67 struct GNUNET_RPS_CS_SeedMessage
70 * Header including size and type in NBO
72 struct GNUNET_MessageHeader header;
77 uint32_t num_peers GNUNET_PACKED;
79 /* Followed by num_peers * GNUNET_PeerIdentity */
84 * Message from client to service to turn service malicious.
86 struct GNUNET_RPS_CS_ActMaliciousMessage
89 * Header including size and type in NBO
91 struct GNUNET_MessageHeader header;
94 * If the type is 2 this is the attacked peer,
97 struct GNUNET_PeerIdentity attacked_peer;
100 * Type of malicious behaviour.
102 * 0 No malicious bahaviour at all
103 * 1 Try to maximise representation
104 * 2 Try to partition the network
106 uint32_t type GNUNET_PACKED;
111 uint32_t num_peers GNUNET_PACKED;
113 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
116 #endif /* ENABLE_MALICIOUS */
120 * Message from client to service telling it to start a new sub
122 struct GNUNET_RPS_CS_SubStartMessage
125 * Header including size and type in NBO
127 struct GNUNET_MessageHeader header;
132 uint32_t reserved GNUNET_PACKED;
135 * Mean interval between two rounds
137 struct GNUNET_TIME_RelativeNBO round_interval;
140 * Length of the shared value represented as string.
142 struct GNUNET_HashCode hash GNUNET_PACKED;
147 * Message from client to service telling it to stop a new sub
149 struct GNUNET_RPS_CS_SubStopMessage
152 * Header including size and type in NBO
154 struct GNUNET_MessageHeader header;
157 * Length of the shared value represented as string.
159 struct GNUNET_HashCode hash GNUNET_PACKED;
166 * Message from client to service indicating that
167 * clients wants to get updates of the view
169 struct GNUNET_RPS_CS_DEBUG_ViewRequest
172 * Header including size and type in NBO
174 struct GNUNET_MessageHeader header;
178 * 0 for sending updates until cancellation
180 uint32_t num_updates GNUNET_PACKED;
184 * Message from service to client containing current update of view
186 struct GNUNET_RPS_CS_DEBUG_ViewReply
189 * Header including size and type in NBO
191 struct GNUNET_MessageHeader header;
194 * Identifyer of the message.
196 uint32_t id GNUNET_PACKED;
199 * Number of peers in the view
201 uint64_t num_peers GNUNET_PACKED;
203 /* Followed by num_peers * GNUNET_PeerIdentity */
206 * Message from client to service indicating that
207 * clients wants to get stream of biased peers
209 struct GNUNET_RPS_CS_DEBUG_StreamRequest
212 * Header including size and type in NBO
214 struct GNUNET_MessageHeader header;
218 * Message from service to client containing peer from biased stream
220 struct GNUNET_RPS_CS_DEBUG_StreamReply
223 * Header including size and type in NBO
225 struct GNUNET_MessageHeader header;
230 uint64_t num_peers GNUNET_PACKED;
232 // TODO maybe source of peer (pull/push list, peerinfo, ...)
234 /* Followed by num_peers * GNUNET_PeerIdentity */
237 GNUNET_NETWORK_STRUCT_END
239 /***********************************************************************
240 * Defines from old gnunet-service-rps_peers.h
241 ***********************************************************************/
244 * Different flags indicating the status of another peer.
249 * If we are waiting for a reply from that peer (sent a pull request).
251 Peers_PULL_REPLY_PENDING = 0x01,
253 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
254 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
255 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
258 * We set this bit when we know the peer is online.
263 * We set this bit when we are going to destroy the channel to this peer.
264 * When cleanup_channel is called, we know that we wanted to destroy it.
265 * Otherwise the channel to the other peer was destroyed.
267 Peers_TO_DESTROY = 0x40,
271 * Keep track of the status of a channel.
273 * This is needed in order to know what to do with a channel when it's
276 enum Peers_ChannelFlags
279 * We destroyed the channel because the other peer established a second one.
281 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
284 * The channel was removed because it was not needed any more. This should be
285 * the sending channel.
287 Peers_CHANNEL_CLEAN = 0x2,
290 * We destroyed the channel because the other peer established a second one.
292 Peers_CHANNEL_DESTROING = 0x4,
297 * @brief The role of a channel. Sending or receiving.
299 enum Peers_ChannelRole
302 * Channel is used for sending
304 Peers_CHANNEL_ROLE_SENDING = 0x01,
307 * Channel is used for receiving
309 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
313 * @brief Functions of this type can be used to be stored at a peer for later execution.
316 * @param peer peer to execute function on
318 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
321 * @brief Iterator over valid peers.
324 * @param peer current public peer id
325 * @return #GNUNET_YES if we should continue to
330 (*PeersIterator) (void *cls,
331 const struct GNUNET_PeerIdentity *peer);
335 * Handle to the statistics service.
337 extern struct GNUNET_STATISTICS_Handle *stats;