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_YES
33 #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_YES
34 #define DEBUG_DV GNUNET_YES
35 #define DEBUG_DV_API GNUNET_YES
37 typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
38 struct GNUNET_PeerIdentity *sender,
43 size_t sender_address_len);
46 * DV Message, contains a message that was received
47 * via DV for this peer!
49 * Sender address is copied to the end of this struct,
50 * followed by the actual message received.
52 struct GNUNET_DV_MessageReceived
55 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
57 struct GNUNET_MessageHeader header;
60 * The sender of the message
62 struct GNUNET_PeerIdentity sender;
65 * The message that was sent
70 * The distance to the peer that we received the message from
75 * Length of the sender address, appended to end of this message
77 uint32_t sender_address_len;
83 * 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
119 struct GNUNET_DV_SendResultMessage
122 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_RESULT
124 struct GNUNET_MessageHeader header;
127 * Unique ID for attempted sent message.
132 * Result of attempted send, 0 for send okay,
133 * 1 for failure of any reason.
139 * 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;
154 * The size of the msgbuf
156 uint32_t msgbuf_size;
164 * Unique ID for this message, for confirm callback.
169 * How long can we delay sending?
171 struct GNUNET_TIME_Relative timeout;
174 * Size of the address (appended to end of struct)
179 * The message(s) to be sent.
184 * Sender, appended to end of struct tells via whom
185 * to send this message.
191 * Message that gets sent between nodes updating dv infos
196 struct GNUNET_MessageHeader header;
199 * Cost from received from node to neighbor node, takes distance into account
201 unsigned int cost GNUNET_PACKED;
204 * Identity of neighbor we learned information about
206 struct GNUNET_PeerIdentity neighbor;
209 * PublicKey of neighbor.
211 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
214 * Neighbor ID to use when sending to this peer
216 uint32_t neighbor_id GNUNET_PACKED;
218 } p2p_dv_MESSAGE_NeighborInfo;
221 * Message that gets sent between nodes carrying information
225 struct GNUNET_MessageHeader header;
228 * Identity of peer that ultimately sent the message.
229 * Should be looked up in the set of 'neighbor_id's of
230 * the referring peer.
232 unsigned int sender GNUNET_PACKED;
235 * Identity of neighbor this message is going to. Should
236 * be looked up in the set of our own identifiers for
239 unsigned int recipient GNUNET_PACKED;
241 } p2p_dv_MESSAGE_Data;
244 * Message that gets sent between nodes indicating a peer
249 struct GNUNET_MessageHeader header;
252 * Identity of neighbor that was disconnected.
254 uint32_t peer_id GNUNET_PACKED;
256 } p2p_dv_MESSAGE_Disconnect;
259 struct GNUNET_DV_Handle *
260 GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
261 const struct GNUNET_CONFIGURATION_Handle *cfg,
262 GNUNET_DV_MessageReceivedHandler receive_handler,
263 void *receive_handler_cls);