2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2009 Christian Grothoff (and other contributing authors)
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 2, 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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @author Christian Grothoff
23 * @author NOT Nathan Evans
29 #include "gnunet_common.h"
31 #define DEBUG_DV_GOSSIP GNUNET_NO
32 #define DEBUG_DV_GOSSIP_SEND GNUNET_NO
33 #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO
34 #define DEBUG_DV_MESSAGES GNUNET_NO
35 #define DEBUG_DV GNUNET_NO
36 #define DEBUG_DV_PEER_NUMBERS GNUNET_NO
37 #define DEBUG_MESSAGE_DROP GNUNET_NO
39 typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
40 struct GNUNET_PeerIdentity *sender,
45 size_t sender_address_len);
48 * DV Message, contains a message that was received
49 * via DV for this peer! Internal.
51 * Sender address is copied to the end of this struct,
52 * followed by the actual message received.
54 struct GNUNET_DV_MessageReceived
57 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
59 struct GNUNET_MessageHeader header;
62 * The sender of the message
64 struct GNUNET_PeerIdentity sender;
67 * The message that was sent
72 * The distance to the peer that we received the message from
77 * Length of the sender address, appended to end of this message
79 uint32_t sender_address_len;
85 * DV Message, indicates that we have learned of a new DV level peer.
88 * Sender address is copied to the end of this struct.
90 struct GNUNET_DV_ConnectMessage
93 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
95 struct GNUNET_MessageHeader header;
98 * The sender of the message
100 struct GNUNET_PeerIdentity *sender;
103 * The message that was sent
105 struct GNUNET_MessageHeader *msg;
108 * The distance to the peer that we received the message from
113 * Length of the sender address, appended to end of this message
115 uint32_t sender_address_len;
120 * Message to return result from a send attempt.
123 struct GNUNET_DV_SendResultMessage
126 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_RESULT
128 struct GNUNET_MessageHeader header;
131 * Unique ID for attempted sent message.
136 * Result of attempted send, 0 for send okay,
137 * 1 for failure of any reason.
143 * Message to send a message over DV via a specific peer.
146 struct GNUNET_DV_SendMessage
149 * Type: GNUNET_MESSAGE_TYPE_DV_SEND
151 struct GNUNET_MessageHeader header;
154 * Intended final recipient of this message
156 struct GNUNET_PeerIdentity target;
159 * The size of the msgbuf
161 uint32_t msgbuf_size;
169 * Unique ID for this message, for confirm callback.
174 * How long can we delay sending?
176 struct GNUNET_TIME_Relative timeout;
179 * Size of the address (appended to end of struct)
184 * The message(s) to be sent.
189 * Sender, appended to end of struct tells via whom
190 * to send this message.
196 * Message that gets sent between nodes updating dv infos
201 struct GNUNET_MessageHeader header;
204 * Cost from received from node to neighbor node, takes distance into account
206 uint32_t cost GNUNET_PACKED;
209 * Identity of neighbor we learned information about
211 struct GNUNET_PeerIdentity neighbor;
214 * PublicKey of neighbor.
216 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
219 * Neighbor ID to use when sending to this peer
221 uint32_t neighbor_id GNUNET_PACKED;
223 } p2p_dv_MESSAGE_NeighborInfo;
226 * Message that gets sent between nodes carrying information
230 struct GNUNET_MessageHeader header;
232 #if DEBUG_DV_MESSAGES
234 * Unique ID for this message.
236 uint32_t uid GNUNET_PACKED;
241 uint32_t reserved GNUNET_PACKED;
245 * Identity of peer that ultimately sent the message.
246 * Should be looked up in the set of 'neighbor_id's of
247 * the referring peer.
249 uint32_t sender GNUNET_PACKED;
252 * Identity of neighbor this message is going to. Should
253 * be looked up in the set of our own identifiers for
256 uint32_t recipient GNUNET_PACKED;
258 } p2p_dv_MESSAGE_Data;
261 * Message that gets sent between nodes indicating a peer
266 struct GNUNET_MessageHeader header;
269 * Identity of neighbor that was disconnected.
271 uint32_t peer_id GNUNET_PACKED;
273 } p2p_dv_MESSAGE_Disconnect;
276 struct GNUNET_DV_Handle *
277 GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
278 const struct GNUNET_CONFIGURATION_Handle *cfg,
279 GNUNET_DV_MessageReceivedHandler receive_handler,
280 void *receive_handler_cls);