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_EXTRA_LOGGING
32 #define DEBUG_DV_GOSSIP_SEND GNUNET_EXTRA_LOGGING
33 #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_EXTRA_LOGGING
34 #define DEBUG_DV_MESSAGES GNUNET_EXTRA_LOGGING
35 #define DEBUG_DV GNUNET_EXTRA_LOGGING
36 #define DEBUG_DV_PEER_NUMBERS GNUNET_EXTRA_LOGGING
37 #define DEBUG_MESSAGE_DROP GNUNET_EXTRA_LOGGING
39 typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
40 struct GNUNET_PeerIdentity *
45 size_t sender_address_len);
47 GNUNET_NETWORK_STRUCT_BEGIN
50 * DV Message, contains a message that was received
51 * via DV for this peer! Internal.
53 * Sender address is copied to the end of this struct,
54 * followed by the actual message received.
56 struct GNUNET_DV_MessageReceived
59 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
61 struct GNUNET_MessageHeader header;
64 * The sender of the message
66 struct GNUNET_PeerIdentity sender;
69 * The length of the message that was sent (appended to this end of struct)
74 * The distance to the peer that we received the message from
82 * DV Message, indicates that we have learned of a new DV level peer.
85 * Sender address is copied to the end of this struct.
87 struct GNUNET_DV_ConnectMessage
90 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
92 struct GNUNET_MessageHeader header;
95 * The sender of the message
97 struct GNUNET_PeerIdentity *sender;
100 * The message that was sent
102 struct GNUNET_MessageHeader *msg;
105 * The distance to the peer that we received the message from
110 * Length of the sender address, appended to end of this message
112 uint32_t sender_address_len;
117 * Message to return result from a send attempt.
120 struct GNUNET_DV_SendResultMessage
123 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_RESULT
125 struct GNUNET_MessageHeader header;
128 * Unique ID for attempted sent message.
133 * Result of attempted send, 0 for send okay,
134 * 1 for failure of any reason.
140 * Message to send a message over DV via a specific peer.
143 struct GNUNET_DV_SendMessage
146 * Type: GNUNET_MESSAGE_TYPE_DV_SEND
148 struct GNUNET_MessageHeader header;
151 * Intended final recipient of this message
153 struct GNUNET_PeerIdentity target;
161 * Unique ID for this message, for confirm callback.
166 * How long can we delay sending?
168 struct GNUNET_TIME_Relative timeout;
171 * Size of the address (appended to end of struct)
176 * The message(s) to be sent.
181 * Sender, appended to end of struct tells via whom
182 * to send this message.
188 * Message that gets sent between nodes updating dv infos
193 struct GNUNET_MessageHeader header;
196 * Cost from received from node to neighbor node, takes distance into account
198 uint32_t cost GNUNET_PACKED;
201 * Identity of neighbor we learned information about
203 struct GNUNET_PeerIdentity neighbor;
206 * PublicKey of neighbor.
208 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
211 * Neighbor ID to use when sending to this peer
213 uint32_t neighbor_id GNUNET_PACKED;
215 } p2p_dv_MESSAGE_NeighborInfo;
218 * Message that gets sent between nodes carrying information
222 struct GNUNET_MessageHeader header;
225 * Unique ID for this message. Will be zero unless
226 * message tracking is desired.
228 uint32_t uid GNUNET_PACKED;
231 * Identity of peer that ultimately sent the message.
232 * Should be looked up in the set of 'neighbor_id's of
233 * the referring peer.
235 uint32_t sender GNUNET_PACKED;
238 * Identity of neighbor this message is going to. Should
239 * be looked up in the set of our own identifiers for
242 uint32_t recipient GNUNET_PACKED;
244 } p2p_dv_MESSAGE_Data;
247 * Message that gets sent between nodes indicating a peer
252 struct GNUNET_MessageHeader header;
255 * Identity of neighbor that was disconnected.
257 uint32_t peer_id GNUNET_PACKED;
259 } p2p_dv_MESSAGE_Disconnect;
260 GNUNET_NETWORK_STRUCT_END
262 struct GNUNET_DV_Handle *
263 GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
264 GNUNET_DV_MessageReceivedHandler receive_handler,
265 void *receive_handler_cls);
268 * Disconnect from the DV service
270 * @param handle the current handle to the service to disconnect
273 GNUNET_DV_disconnect (struct GNUNET_DV_Handle *handle);