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 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., 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 length of the message that was sent (appended to this end of struct)
72 * The distance to the peer that we received the message from
80 * DV Message, indicates that we have learned of a new DV level peer.
83 * Sender address is copied to the end of this struct.
85 struct GNUNET_DV_ConnectMessage
88 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
90 struct GNUNET_MessageHeader header;
93 * The sender of the message
95 struct GNUNET_PeerIdentity *sender;
98 * The message that was sent
100 struct GNUNET_MessageHeader *msg;
103 * The distance to the peer that we received the message from
108 * Length of the sender address, appended to end of this message
110 uint32_t sender_address_len;
115 * Message to return result from a send attempt.
118 struct GNUNET_DV_SendResultMessage
121 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_RESULT
123 struct GNUNET_MessageHeader header;
126 * Unique ID for attempted sent message.
131 * Result of attempted send, 0 for send okay,
132 * 1 for failure of any reason.
138 * Message to send a message over DV via a specific peer.
141 struct GNUNET_DV_SendMessage
144 * Type: GNUNET_MESSAGE_TYPE_DV_SEND
146 struct GNUNET_MessageHeader header;
149 * Intended final recipient of this message
151 struct GNUNET_PeerIdentity target;
159 * Unique ID for this message, for confirm callback.
164 * How long can we delay sending?
166 struct GNUNET_TIME_Relative timeout;
169 * Size of the address (appended to end of struct)
174 * The message(s) to be sent.
179 * Sender, appended to end of struct tells via whom
180 * to send this message.
186 * Message that gets sent between nodes updating dv infos
191 struct GNUNET_MessageHeader header;
194 * Cost from received from node to neighbor node, takes distance into account
196 uint32_t cost GNUNET_PACKED;
199 * Identity of neighbor we learned information about
201 struct GNUNET_PeerIdentity neighbor;
204 * PublicKey of neighbor.
206 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
209 * Neighbor ID to use when sending to this peer
211 uint32_t neighbor_id GNUNET_PACKED;
213 } p2p_dv_MESSAGE_NeighborInfo;
216 * Message that gets sent between nodes carrying information
220 struct GNUNET_MessageHeader header;
223 * Unique ID for this message. Will be zero unless
224 * message tracking is desired.
226 uint32_t uid GNUNET_PACKED;
229 * Identity of peer that ultimately sent the message.
230 * Should be looked up in the set of 'neighbor_id's of
231 * the referring peer.
233 uint32_t sender GNUNET_PACKED;
236 * Identity of neighbor this message is going to. Should
237 * be looked up in the set of our own identifiers for
240 uint32_t recipient GNUNET_PACKED;
242 } p2p_dv_MESSAGE_Data;
245 * Message that gets sent between nodes indicating a peer
250 struct GNUNET_MessageHeader header;
253 * Identity of neighbor that was disconnected.
255 uint32_t peer_id GNUNET_PACKED;
257 } p2p_dv_MESSAGE_Disconnect;
260 struct GNUNET_DV_Handle *
261 GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
262 GNUNET_DV_MessageReceivedHandler receive_handler,
263 void *receive_handler_cls);
266 * Disconnect from the DV service
268 * @param handle the current handle to the service to disconnect
270 void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);