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,
36 struct GNUNET_MessageHeader *msg,
37 unsigned int distance,
39 size_t sender_address_len);
42 * DV Message, contains a message that was received
43 * via DV for this peer!
45 * Sender address is copied to the end of this struct.
47 struct GNUNET_DV_MessageReceived
50 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
52 struct GNUNET_MessageHeader header;
55 * The sender of the message
57 struct GNUNET_PeerIdentity sender;
60 * The message that was sent
62 struct GNUNET_MessageHeader *msg;
65 * The distance to the peer that we received the message from
70 * Length of the sender address, appended to end of this message
72 size_t sender_address_len;
78 * DV Message, indicates that we have learned of a new DV level peer.
80 * Sender address is copied to the end of this struct.
82 struct GNUNET_DV_ConnectMessage
85 * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE
87 struct GNUNET_MessageHeader header;
90 * The sender of the message
92 struct GNUNET_PeerIdentity *sender;
95 * The message that was sent
97 struct GNUNET_MessageHeader *msg;
100 * The distance to the peer that we received the message from
105 * Length of the sender address, appended to end of this message
107 size_t sender_address_len;
113 * Message to send a message over DV via a specific peer
115 struct GNUNET_DV_SendMessage
118 * Type: GNUNET_MESSAGE_TYPE_DV_SEND
120 struct GNUNET_MessageHeader header;
123 * Intended final recipient of this message
125 struct GNUNET_PeerIdentity target;
128 * The message(s) to be sent.
133 * The size of the msgbuf
143 * How long can we delay sending?
145 struct GNUNET_TIME_Relative timeout;
148 * Size of the address (appended to end of struct)
153 * Sender, appended to end of struct tells via whom
154 * to send this message.
160 * Message that gets sent between nodes updating dv infos
164 struct GNUNET_MessageHeader header;
167 * Cost from received from node to neighbor node, takes distance into account
169 unsigned int cost GNUNET_PACKED;
172 * Identity of neighbor we learned information about
174 struct GNUNET_PeerIdentity neighbor;
177 * Neighbor ID to use when sending to this peer
179 unsigned int neighbor_id GNUNET_PACKED;
181 } p2p_dv_MESSAGE_NeighborInfo;
184 * Message that gets sent between nodes carrying information
188 struct GNUNET_MessageHeader header;
191 * Identity of peer that ultimately sent the message.
192 * Should be looked up in the set of 'neighbor_id's of
193 * the referring peer.
195 unsigned int sender GNUNET_PACKED;
198 * Identity of neighbor this message is going to. Should
199 * be looked up in the set of our own identifiers for
202 unsigned int recipient GNUNET_PACKED;
204 } p2p_dv_MESSAGE_Data;
207 struct GNUNET_DV_Handle *
208 GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
209 const struct GNUNET_CONFIGURATION_Handle *cfg,
210 GNUNET_DV_MessageReceivedHandler receive_handler,
211 void *receive_handler_cls);