2 This file is part of GNUnet.
3 (C) 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 * @file transport/transport.h
23 * @brief common internal definitions for transport service
24 * @author Christian Grothoff
29 #include "gnunet_crypto_lib.h"
30 #include "gnunet_time_lib.h"
31 #include "gnunet_transport_service.h"
33 /* Minimum time between to calculations*/
34 #define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15)
35 #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
36 #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
37 #define ATS_MAX_ITERATIONS INT_MAX
39 #define DEBUG_TRANSPORT GNUNET_NO
41 #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO
43 #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO
46 * For how long do we allow unused bandwidth
47 * from the past to carry over into the future? (in seconds)
49 #define MAX_BANDWIDTH_CARRY_S 5
52 * How often do we (at most) do a full quota
53 * recalculation? (in ms)
55 #define MIN_QUOTA_REFRESH_TIME 2000
58 * Message from the transport service to the library
59 * asking to check if both processes agree about this
66 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
68 struct GNUNET_MessageHeader header;
71 * Should the 'self' field be checked?
76 * Identity we think we have. If it does not match, the
77 * receiver should print out an error message and disconnect.
79 struct GNUNET_PeerIdentity self;
85 * Message from the transport service to the library
86 * informing about neighbors.
88 struct ConnectInfoMessage
92 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
94 struct GNUNET_MessageHeader header;
97 * Number of ATS key-value pairs that follow this struct
98 * (excluding the 0-terminator).
100 uint32_t ats_count GNUNET_PACKED;
103 * Identity of the new neighbour.
105 struct GNUNET_PeerIdentity id;
108 * First of the ATS information blocks (we must have at least
109 * one due to the 0-termination requirement).
111 struct GNUNET_TRANSPORT_ATS_Information ats;
116 * Message from the transport service to the library
117 * informing about disconnects.
119 struct DisconnectInfoMessage
123 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
125 struct GNUNET_MessageHeader header;
128 * Reserved, always zero.
130 uint32_t reserved GNUNET_PACKED;
133 * Who got disconnected?
135 struct GNUNET_PeerIdentity peer;
140 * Message type for sending a request connect message
141 * to the transport service. Must be done before transport
142 * api will allow messages to be queued/sent to transport
143 * service for transmission to a peer.
145 struct TransportRequestConnectMessage
150 struct GNUNET_MessageHeader header;
153 * Identity of the peer we would like to connect to.
155 struct GNUNET_PeerIdentity peer;
159 * Message used to set a particular bandwidth quota. Send TO the
160 * service to set an incoming quota, send FROM the service to update
163 struct QuotaSetMessage
167 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO
169 struct GNUNET_MessageHeader header;
174 struct GNUNET_BANDWIDTH_Value32NBO quota;
177 * About which peer are we talking here?
179 struct GNUNET_PeerIdentity peer;
185 * Message used to ask the transport service to create a connection.
187 struct TryConnectMessage
191 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_TRY_CONNECT
193 struct GNUNET_MessageHeader header;
201 * About which peer are we talking here?
203 struct GNUNET_PeerIdentity peer;
209 * Message used to notify the transport API about a message
210 * received from the network. The actual message follows.
212 struct InboundMessage
216 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
218 struct GNUNET_MessageHeader header;
223 uint32_t reserved GNUNET_PACKED;
226 * Number of ATS key-value pairs that follow this struct
227 * (excluding the 0-terminator).
229 uint32_t ats_count GNUNET_PACKED;
232 * Which peer sent the message?
234 struct GNUNET_PeerIdentity peer;
237 * First of the ATS information blocks (we must have at least
238 * one due to the 0-termination requirement).
240 struct GNUNET_TRANSPORT_ATS_Information ats;
245 * Message used to notify the transport API that it can
246 * send another message to the transport service.
252 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
254 struct GNUNET_MessageHeader header;
257 * GNUNET_OK if the transmission succeeded,
258 * GNUNET_SYSERR if it failed (i.e. network disconnect);
259 * in either case, it is now OK for this client to
260 * send us another message for the given peer.
262 uint32_t success GNUNET_PACKED;
267 struct GNUNET_TIME_RelativeNBO latency;
270 * Which peer can send more now?
272 struct GNUNET_PeerIdentity peer;
278 * Message used to notify the transport service about a message
279 * to be transmitted to another peer. The actual message follows.
281 struct OutboundMessage
285 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
287 struct GNUNET_MessageHeader header;
292 uint32_t priority GNUNET_PACKED;
297 struct GNUNET_TIME_RelativeNBO timeout;
300 * Which peer should receive the message?
302 struct GNUNET_PeerIdentity peer;
308 * Message from the library to the transport service
309 * asking for converting a transport address to a
310 * human-readable UTF-8 string.
312 struct AddressLookupMessage
316 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP
318 struct GNUNET_MessageHeader header;
321 * Should the conversion use numeric IP addresses (otherwise
322 * a reverse DNS lookup is OK -- if applicable).
324 int32_t numeric_only GNUNET_PACKED;
327 * timeout to give up.
329 struct GNUNET_TIME_AbsoluteNBO timeout;
332 * Length of the (binary) address in bytes, in big-endian.
334 uint32_t addrlen GNUNET_PACKED;
336 /* followed by 'addrlen' bytes of the actual address, then
337 followed by the 0-terminated name of the transport */
343 * Change in blacklisting (either request or notification,
344 * depending on which direction it is going).
346 struct BlacklistMessage
350 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
351 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
353 struct GNUNET_MessageHeader header;
356 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
359 uint32_t is_allowed GNUNET_PACKED;
362 * Which peer is being blacklisted or queried?
364 struct GNUNET_PeerIdentity peer;
369 /* end of transport.h */