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 RPS service to request random peer(s).
65 struct GNUNET_RPS_CS_RequestMessage
68 * Header including size and type in NBO
70 struct GNUNET_MessageHeader header;
73 * Identifyer of the message.
75 uint32_t id GNUNET_PACKED;
78 * Number of random peer requested
80 uint32_t num_peers GNUNET_PACKED;
84 * Message from RPS service to client to reply with random peer(s).
86 struct GNUNET_RPS_CS_ReplyMessage
89 * Type is #GNUNET_MESSAGE_TYPE_RPS_CS_REPLY.
91 struct GNUNET_MessageHeader header;
94 * Identifyer of the message.
96 uint32_t id GNUNET_PACKED;
99 * Number of random peer replied
101 uint32_t num_peers GNUNET_PACKED;
103 /* Followed by num_peers * GNUNET_PeerIdentity */
107 * Message from client to RPS service to cancel request.
109 struct GNUNET_RPS_CS_RequestCancelMessage
112 * Header including size and type in NBO
114 struct GNUNET_MessageHeader header;
117 * Identifyer of the message.
119 uint32_t id GNUNET_PACKED;
123 * Message from client to service with seed of peers.
125 struct GNUNET_RPS_CS_SeedMessage
128 * Header including size and type in NBO
130 struct GNUNET_MessageHeader header;
135 uint32_t num_peers GNUNET_PACKED;
137 /* Followed by num_peers * GNUNET_PeerIdentity */
140 #ifdef ENABLE_MALICIOUS
142 * Message from client to service to turn service malicious.
144 struct GNUNET_RPS_CS_ActMaliciousMessage
147 * Header including size and type in NBO
149 struct GNUNET_MessageHeader header;
152 * If the type is 2 this is the attacked peer,
155 struct GNUNET_PeerIdentity attacked_peer;
158 * Type of malicious behaviour.
160 * 0 No malicious bahaviour at all
161 * 1 Try to maximise representation
162 * 2 Try to partition the network
164 uint32_t type GNUNET_PACKED;
169 uint32_t num_peers GNUNET_PACKED;
171 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
174 #endif /* ENABLE_MALICIOUS */
180 * Message from client to service indicating that
181 * clients wants to get updates of the view
183 struct GNUNET_RPS_CS_DEBUG_ViewRequest
186 * Header including size and type in NBO
188 struct GNUNET_MessageHeader header;
192 * 0 for sending updates until cancellation
194 uint32_t num_updates GNUNET_PACKED;
198 * Message from service to client containing current update of view
200 struct GNUNET_RPS_CS_DEBUG_ViewReply
203 * Header including size and type in NBO
205 struct GNUNET_MessageHeader header;
208 * Identifyer of the message.
210 uint32_t id GNUNET_PACKED;
213 * Number of peers in the view
215 uint64_t num_peers GNUNET_PACKED;
217 /* Followed by num_peers * GNUNET_PeerIdentity */
220 /***********************************************************************
221 * Defines from old gnunet-service-rps_peers.h
222 ***********************************************************************/
225 * Different flags indicating the status of another peer.
230 * If we are waiting for a reply from that peer (sent a pull request).
232 Peers_PULL_REPLY_PENDING = 0x01,
234 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
235 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
236 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
239 * We set this bit when we know the peer is online.
244 * We set this bit when we are going to destroy the channel to this peer.
245 * When cleanup_channel is called, we know that we wanted to destroy it.
246 * Otherwise the channel to the other peer was destroyed.
248 Peers_TO_DESTROY = 0x40,
252 * Keep track of the status of a channel.
254 * This is needed in order to know what to do with a channel when it's
257 enum Peers_ChannelFlags
260 * We destroyed the channel because the other peer established a second one.
262 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
265 * The channel was removed because it was not needed any more. This should be
266 * the sending channel.
268 Peers_CHANNEL_CLEAN = 0x2,
271 * We destroyed the channel because the other peer established a second one.
273 Peers_CHANNEL_DESTROING = 0x4,
278 * @brief The role of a channel. Sending or receiving.
280 enum Peers_ChannelRole
283 * Channel is used for sending
285 Peers_CHANNEL_ROLE_SENDING = 0x01,
288 * Channel is used for receiving
290 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
294 * @brief Functions of this type can be used to be stored at a peer for later execution.
297 * @param peer peer to execute function on
299 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
302 * @brief Iterator over valid peers.
305 * @param peer current public peer id
306 * @return #GNUNET_YES if we should continue to
311 (*PeersIterator) (void *cls,
312 const struct GNUNET_PeerIdentity *peer);
315 GNUNET_NETWORK_STRUCT_END