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 GNUNET_YES
32 #define DEBUG_DV_API GNUNET_YES
34 typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
35 struct GNUNET_PeerIdentity *sender,
38 unsigned int distance,
40 size_t sender_address_len);
43 * DV Message, contains a message that was received
44 * via DV for this peer!
46 * Sender address is copied to the end of this struct,
47 * followed by the actual message received.
49 struct GNUNET_DV_MessageReceived
52 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
54 struct GNUNET_MessageHeader header;
57 * The sender of the message
59 struct GNUNET_PeerIdentity sender;
62 * The message that was sent
67 * The distance to the peer that we received the message from
72 * Length of the sender address, appended to end of this message
74 size_t sender_address_len;
80 * DV Message, indicates that we have learned of a new DV level peer.
82 * Sender address is copied to the end of this struct.
84 struct GNUNET_DV_ConnectMessage
87 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
89 struct GNUNET_MessageHeader header;
92 * The sender of the message
94 struct GNUNET_PeerIdentity *sender;
97 * The message that was sent
99 struct GNUNET_MessageHeader *msg;
102 * The distance to the peer that we received the message from
107 * Length of the sender address, appended to end of this message
109 size_t sender_address_len;
115 * Message to send a message over DV via a specific peer
117 struct GNUNET_DV_SendMessage
120 * Type: GNUNET_MESSAGE_TYPE_DV_SEND
122 struct GNUNET_MessageHeader header;
125 * Intended final recipient of this message
127 struct GNUNET_PeerIdentity target;
130 * The message(s) to be sent.
135 * The size of the msgbuf
145 * How long can we delay sending?
147 struct GNUNET_TIME_Relative timeout;
150 * Size of the address (appended to end of struct)
155 * Sender, appended to end of struct tells via whom
156 * to send this message.
162 * Message that gets sent between nodes updating dv infos
167 struct GNUNET_MessageHeader header;
170 * Cost from received from node to neighbor node, takes distance into account
172 unsigned int cost GNUNET_PACKED;
175 * Identity of neighbor we learned information about
177 struct GNUNET_PeerIdentity neighbor;
180 * PublicKey of neighbor.
182 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
185 * Neighbor ID to use when sending to this peer
187 unsigned int neighbor_id GNUNET_PACKED;
189 } p2p_dv_MESSAGE_NeighborInfo;
192 * Message that gets sent between nodes carrying information
196 struct GNUNET_MessageHeader header;
199 * Identity of peer that ultimately sent the message.
200 * Should be looked up in the set of 'neighbor_id's of
201 * the referring peer.
203 unsigned int sender GNUNET_PACKED;
206 * Identity of neighbor this message is going to. Should
207 * be looked up in the set of our own identifiers for
210 unsigned int recipient GNUNET_PACKED;
212 } p2p_dv_MESSAGE_Data;
215 struct GNUNET_DV_Handle *
216 GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
217 const struct GNUNET_CONFIGURATION_Handle *cfg,
218 GNUNET_DV_MessageReceivedHandler receive_handler,
219 void *receive_handler_cls);