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/>.
20 * @brief example IPC messages between RPS API and GNS service
21 * @author Julius Bünger
24 #include "gnunet_rps_service.h"
27 * Mesh port used by RPS.
29 #define GNUNET_RPS_CADET_PORT 31337
32 GNUNET_NETWORK_STRUCT_BEGIN
34 /***********************************************************************
36 ***********************************************************************/
39 * P2P Message to send PeerIDs to other peer.
41 struct GNUNET_RPS_P2P_PullReplyMessage
44 * Header including size and type in NBO
46 struct GNUNET_MessageHeader header;
49 * Number of PeerIDs sent
51 uint32_t num_peers GNUNET_PACKED;
53 /* Followed by num_peers * GNUNET_PeerIdentity */
58 /***********************************************************************
59 * Client-Service Messages
60 ***********************************************************************/
63 * Message from client to service with seed of peers.
65 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 */
80 #ifdef ENABLE_MALICIOUS
82 * Message from client to service to turn service malicious.
84 struct GNUNET_RPS_CS_ActMaliciousMessage
87 * Header including size and type in NBO
89 struct GNUNET_MessageHeader header;
92 * If the type is 2 this is the attacked peer,
95 struct GNUNET_PeerIdentity attacked_peer;
98 * Type of malicious behaviour.
100 * 0 No malicious bahaviour at all
101 * 1 Try to maximise representation
102 * 2 Try to partition the network
104 uint32_t type GNUNET_PACKED;
109 uint32_t num_peers GNUNET_PACKED;
111 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
114 #endif /* ENABLE_MALICIOUS */
118 * Message from client to service telling it to start a new sub
120 struct GNUNET_RPS_CS_SubStartMessage
123 * Header including size and type in NBO
125 struct GNUNET_MessageHeader header;
130 uint32_t reserved GNUNET_PACKED;
133 * Mean interval between two rounds
135 struct GNUNET_TIME_RelativeNBO round_interval;
138 * Length of the shared value represented as string.
140 struct GNUNET_HashCode hash GNUNET_PACKED;
145 * Message from client to service telling it to stop a new sub
147 struct GNUNET_RPS_CS_SubStopMessage
150 * Header including size and type in NBO
152 struct GNUNET_MessageHeader header;
155 * Length of the shared value represented as string.
157 struct GNUNET_HashCode hash GNUNET_PACKED;
164 * Message from client to service indicating that
165 * clients wants to get updates of the view
167 struct GNUNET_RPS_CS_DEBUG_ViewRequest
170 * Header including size and type in NBO
172 struct GNUNET_MessageHeader header;
176 * 0 for sending updates until cancellation
178 uint32_t num_updates GNUNET_PACKED;
182 * Message from service to client containing current update of view
184 struct GNUNET_RPS_CS_DEBUG_ViewReply
187 * Header including size and type in NBO
189 struct GNUNET_MessageHeader header;
192 * Identifyer of the message.
194 uint32_t id GNUNET_PACKED;
197 * Number of peers in the view
199 uint64_t num_peers GNUNET_PACKED;
201 /* Followed by num_peers * GNUNET_PeerIdentity */
204 * Message from client to service indicating that
205 * clients wants to get stream of biased peers
207 struct GNUNET_RPS_CS_DEBUG_StreamRequest
210 * Header including size and type in NBO
212 struct GNUNET_MessageHeader header;
216 * Message from service to client containing peer from biased stream
218 struct GNUNET_RPS_CS_DEBUG_StreamReply
221 * Header including size and type in NBO
223 struct GNUNET_MessageHeader header;
228 uint64_t num_peers GNUNET_PACKED;
230 // TODO maybe source of peer (pull/push list, peerinfo, ...)
232 /* Followed by num_peers * GNUNET_PeerIdentity */
235 GNUNET_NETWORK_STRUCT_END
237 /***********************************************************************
238 * Defines from old gnunet-service-rps_peers.h
239 ***********************************************************************/
242 * Different flags indicating the status of another peer.
247 * If we are waiting for a reply from that peer (sent a pull request).
249 Peers_PULL_REPLY_PENDING = 0x01,
251 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
252 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
253 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
256 * We set this bit when we know the peer is online.
261 * We set this bit when we are going to destroy the channel to this peer.
262 * When cleanup_channel is called, we know that we wanted to destroy it.
263 * Otherwise the channel to the other peer was destroyed.
265 Peers_TO_DESTROY = 0x40,
269 * Keep track of the status of a channel.
271 * This is needed in order to know what to do with a channel when it's
274 enum Peers_ChannelFlags
277 * We destroyed the channel because the other peer established a second one.
279 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
282 * The channel was removed because it was not needed any more. This should be
283 * the sending channel.
285 Peers_CHANNEL_CLEAN = 0x2,
288 * We destroyed the channel because the other peer established a second one.
290 Peers_CHANNEL_DESTROING = 0x4,
295 * @brief The role of a channel. Sending or receiving.
297 enum Peers_ChannelRole
300 * Channel is used for sending
302 Peers_CHANNEL_ROLE_SENDING = 0x01,
305 * Channel is used for receiving
307 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
311 * @brief Functions of this type can be used to be stored at a peer for later execution.
314 * @param peer peer to execute function on
316 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
319 * @brief Iterator over valid peers.
322 * @param peer current public peer id
323 * @return #GNUNET_YES if we should continue to
328 (*PeersIterator) (void *cls,
329 const struct GNUNET_PeerIdentity *peer);
333 * Handle to the statistics service.
335 extern struct GNUNET_STATISTICS_Handle *stats;