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 */
120 * Message from client to service indicating that
121 * clients wants to get updates of the view
123 struct GNUNET_RPS_CS_DEBUG_ViewRequest
126 * Header including size and type in NBO
128 struct GNUNET_MessageHeader header;
132 * 0 for sending updates until cancellation
134 uint32_t num_updates GNUNET_PACKED;
138 * Message from service to client containing current update of view
140 struct GNUNET_RPS_CS_DEBUG_ViewReply
143 * Header including size and type in NBO
145 struct GNUNET_MessageHeader header;
148 * Identifyer of the message.
150 uint32_t id GNUNET_PACKED;
153 * Number of peers in the view
155 uint64_t num_peers GNUNET_PACKED;
157 /* Followed by num_peers * GNUNET_PeerIdentity */
160 * Message from client to service indicating that
161 * clients wants to get stream of biased peers
163 struct GNUNET_RPS_CS_DEBUG_StreamRequest
166 * Header including size and type in NBO
168 struct GNUNET_MessageHeader header;
172 * Message from service to client containing peer from biased stream
174 struct GNUNET_RPS_CS_DEBUG_StreamReply
177 * Header including size and type in NBO
179 struct GNUNET_MessageHeader header;
184 uint64_t num_peers GNUNET_PACKED;
186 // TODO maybe source of peer (pull/push list, peerinfo, ...)
188 /* Followed by num_peers * GNUNET_PeerIdentity */
191 GNUNET_NETWORK_STRUCT_END
193 /***********************************************************************
194 * Defines from old gnunet-service-rps_peers.h
195 ***********************************************************************/
198 * Different flags indicating the status of another peer.
203 * If we are waiting for a reply from that peer (sent a pull request).
205 Peers_PULL_REPLY_PENDING = 0x01,
207 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
208 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
209 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
212 * We set this bit when we know the peer is online.
217 * We set this bit when we are going to destroy the channel to this peer.
218 * When cleanup_channel is called, we know that we wanted to destroy it.
219 * Otherwise the channel to the other peer was destroyed.
221 Peers_TO_DESTROY = 0x40,
225 * Keep track of the status of a channel.
227 * This is needed in order to know what to do with a channel when it's
230 enum Peers_ChannelFlags
233 * We destroyed the channel because the other peer established a second one.
235 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
238 * The channel was removed because it was not needed any more. This should be
239 * the sending channel.
241 Peers_CHANNEL_CLEAN = 0x2,
244 * We destroyed the channel because the other peer established a second one.
246 Peers_CHANNEL_DESTROING = 0x4,
251 * @brief The role of a channel. Sending or receiving.
253 enum Peers_ChannelRole
256 * Channel is used for sending
258 Peers_CHANNEL_ROLE_SENDING = 0x01,
261 * Channel is used for receiving
263 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
267 * @brief Functions of this type can be used to be stored at a peer for later execution.
270 * @param peer peer to execute function on
272 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
275 * @brief Iterator over valid peers.
278 * @param peer current public peer id
279 * @return #GNUNET_YES if we should continue to
284 (*PeersIterator) (void *cls,
285 const struct GNUNET_PeerIdentity *peer);
289 * Handle to the statistics service.
291 extern struct GNUNET_STATISTICS_Handle *stats;