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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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 RPS service to request random peer(s).
67 struct GNUNET_RPS_CS_RequestMessage
70 * Header including size and type in NBO
72 struct GNUNET_MessageHeader header;
75 * Identifyer of the message.
77 uint32_t id GNUNET_PACKED;
80 * Number of random peer requested
82 uint32_t num_peers GNUNET_PACKED;
86 * Message from RPS service to client to reply with random peer(s).
88 struct GNUNET_RPS_CS_ReplyMessage
91 * Type is #GNUNET_MESSAGE_TYPE_RPS_CS_REPLY.
93 struct GNUNET_MessageHeader header;
96 * Identifyer of the message.
98 uint32_t id GNUNET_PACKED;
101 * Number of random peer replied
103 uint32_t num_peers GNUNET_PACKED;
105 /* Followed by num_peers * GNUNET_PeerIdentity */
109 * Message from client to RPS service to cancel request.
111 struct GNUNET_RPS_CS_RequestCancelMessage
114 * Header including size and type in NBO
116 struct GNUNET_MessageHeader header;
119 * Identifyer of the message.
121 uint32_t id GNUNET_PACKED;
125 * Message from client to service with seed of peers.
127 struct GNUNET_RPS_CS_SeedMessage
130 * Header including size and type in NBO
132 struct GNUNET_MessageHeader header;
137 uint32_t num_peers GNUNET_PACKED;
139 /* Followed by num_peers * GNUNET_PeerIdentity */
142 #ifdef ENABLE_MALICIOUS
144 * Message from client to service to turn service malicious.
146 struct GNUNET_RPS_CS_ActMaliciousMessage
149 * Header including size and type in NBO
151 struct GNUNET_MessageHeader header;
154 * If the type is 2 this is the attacked peer,
157 struct GNUNET_PeerIdentity attacked_peer;
160 * Type of malicious behaviour.
162 * 0 No malicious bahaviour at all
163 * 1 Try to maximise representation
164 * 2 Try to partition the network
166 uint32_t type GNUNET_PACKED;
171 uint32_t num_peers GNUNET_PACKED;
173 /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
176 #endif /* ENABLE_MALICIOUS */
179 /***********************************************************************
180 * Defines from old gnunet-service-rps_peers.h
181 ***********************************************************************/
184 * Different flags indicating the status of another peer.
189 * If we are waiting for a reply from that peer (sent a pull request).
191 Peers_PULL_REPLY_PENDING = 0x01,
193 /* IN_OTHER_GOSSIP_LIST = 0x02, unneeded? */
194 /* IN_OWN_SAMPLER_LIST = 0x04, unneeded? */
195 /* IN_OWN_GOSSIP_LIST = 0x08, unneeded? */
198 * We set this bit when we know the peer is online.
203 * We set this bit when we are going to destroy the channel to this peer.
204 * When cleanup_channel is called, we know that we wanted to destroy it.
205 * Otherwise the channel to the other peer was destroyed.
207 Peers_TO_DESTROY = 0x40,
211 * Keep track of the status of a channel.
213 * This is needed in order to know what to do with a channel when it's
216 enum Peers_ChannelFlags
219 * We destroyed the channel because the other peer established a second one.
221 Peers_CHANNEL_ESTABLISHED_TWICE = 0x1,
224 * The channel was removed because it was not needed any more. This should be
225 * the sending channel.
227 Peers_CHANNEL_CLEAN = 0x2,
230 * We destroyed the channel because the other peer established a second one.
232 Peers_CHANNEL_DESTROING = 0x4,
237 * @brief The role of a channel. Sending or receiving.
239 enum Peers_ChannelRole
242 * Channel is used for sending
244 Peers_CHANNEL_ROLE_SENDING = 0x01,
247 * Channel is used for receiving
249 Peers_CHANNEL_ROLE_RECEIVING = 0x02,
253 * @brief Functions of this type can be used to be stored at a peer for later execution.
256 * @param peer peer to execute function on
258 typedef void (* PeerOp) (void *cls, const struct GNUNET_PeerIdentity *peer);
261 * @brief Iterator over valid peers.
264 * @param peer current public peer id
265 * @return #GNUNET_YES if we should continue to
270 (*PeersIterator) (void *cls,
271 const struct GNUNET_PeerIdentity *peer);
274 GNUNET_NETWORK_STRUCT_END