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 #define DEBUG_TRANSPORT GNUNET_EXTRA_LOGGING
35 #define DEBUG_TRANSPORT_TIMEOUT GNUNET_EXTRA_LOGGING
37 #define DEBUG_TRANSPORT_DISCONNECT GNUNET_EXTRA_LOGGING
39 #define DEBUG_TRANSPORT_API GNUNET_EXTRA_LOGGING
42 * For how long do we allow unused bandwidth
43 * from the past to carry over into the future? (in seconds)
45 #define MAX_BANDWIDTH_CARRY_S 5
48 * How often do we (at most) do a full quota
49 * recalculation? (in ms)
51 #define MIN_QUOTA_REFRESH_TIME 2000
54 * Maximum frequency for re-evaluating latencies for all transport addresses.
56 #define LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
59 * Maximum frequency for re-evaluating latencies for connected addresses.
61 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
64 * Message from the transport service to the library
65 * asking to check if both processes agree about this
72 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
74 struct GNUNET_MessageHeader header;
77 * Should the 'self' field be checked?
82 * Identity we think we have. If it does not match, the
83 * receiver should print out an error message and disconnect.
85 struct GNUNET_PeerIdentity self;
91 * Message from the transport service to the library
92 * informing about neighbors.
94 struct ConnectInfoMessage
98 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
100 struct GNUNET_MessageHeader header;
103 * Number of ATS key-value pairs that follow this struct
104 * (excluding the 0-terminator).
106 uint32_t ats_count GNUNET_PACKED;
109 * Identity of the new neighbour.
111 struct GNUNET_PeerIdentity id;
114 * First of the ATS information blocks (we must have at least
115 * one due to the 0-termination requirement).
117 struct GNUNET_ATS_Information ats;
122 * Message from the transport service to the library
123 * informing about disconnects.
125 struct DisconnectInfoMessage
129 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
131 struct GNUNET_MessageHeader header;
134 * Reserved, always zero.
136 uint32_t reserved GNUNET_PACKED;
139 * Who got disconnected?
141 struct GNUNET_PeerIdentity peer;
146 * Message type for sending a request connect message
147 * to the transport service. Must be done before transport
148 * api will allow messages to be queued/sent to transport
149 * service for transmission to a peer.
151 struct TransportRequestConnectMessage
156 struct GNUNET_MessageHeader header;
164 * Identity of the peer we would like to connect to.
166 struct GNUNET_PeerIdentity peer;
170 * Message used to set a particular bandwidth quota. Sent TO the
171 * service to set an incoming quota, sent FROM the service to update
174 struct QuotaSetMessage
178 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO
180 struct GNUNET_MessageHeader header;
185 struct GNUNET_BANDWIDTH_Value32NBO quota;
188 * About which peer are we talking here?
190 struct GNUNET_PeerIdentity peer;
196 * Message used to notify the transport API about a message
197 * received from the network. The actual message follows.
199 struct InboundMessage
203 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
205 struct GNUNET_MessageHeader header;
208 * Number of ATS key-value pairs that follow this struct
209 * (excluding the 0-terminator).
211 uint32_t ats_count GNUNET_PACKED;
214 * Which peer sent the message?
216 struct GNUNET_PeerIdentity peer;
219 * First of the ATS information blocks (we must have at least
220 * one due to the 0-termination requirement).
222 struct GNUNET_ATS_Information ats;
227 * Message used to notify the transport API that it can
228 * send another message to the transport service.
234 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
236 struct GNUNET_MessageHeader header;
239 * GNUNET_OK if the transmission succeeded,
240 * GNUNET_SYSERR if it failed (i.e. network disconnect);
241 * in either case, it is now OK for this client to
242 * send us another message for the given peer.
244 uint32_t success GNUNET_PACKED;
249 struct GNUNET_TIME_RelativeNBO latency;
252 * Which peer can send more now?
254 struct GNUNET_PeerIdentity peer;
260 * Message used to notify the transport service about a message
261 * to be transmitted to another peer. The actual message follows.
263 struct OutboundMessage
267 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
269 struct GNUNET_MessageHeader header;
274 uint32_t priority GNUNET_PACKED;
279 struct GNUNET_TIME_RelativeNBO timeout;
282 * Which peer should receive the message?
284 struct GNUNET_PeerIdentity peer;
290 * Message from the library to the transport service
291 * asking for converting a transport address to a
292 * human-readable UTF-8 string.
294 struct AddressLookupMessage
298 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP
300 struct GNUNET_MessageHeader header;
303 * Should the conversion use numeric IP addresses (otherwise
304 * a reverse DNS lookup is OK -- if applicable).
306 int32_t numeric_only GNUNET_PACKED;
309 * timeout to give up.
311 struct GNUNET_TIME_RelativeNBO timeout;
314 * Length of the (binary) address in bytes, in big-endian.
316 uint32_t addrlen GNUNET_PACKED;
318 /* followed by 'addrlen' bytes of the actual address, then
319 * followed by the 0-terminated name of the transport */
324 * Message from the library to the transport service
325 * asking for human readable addresses known for a peer.
327 struct PeerAddressLookupMessage
330 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP
332 struct GNUNET_MessageHeader header;
340 * timeout to give up. FIXME: remove in the future.
342 struct GNUNET_TIME_RelativeNBO timeout;
345 * The identity of the peer to look up.
347 struct GNUNET_PeerIdentity peer;
352 * Message from the library to the transport service
353 * asking for binary addresses known for a peer.
355 struct AddressIterateMessage
358 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE
360 struct GNUNET_MessageHeader header;
368 * timeout to give up. FIXME: remove in the future
370 struct GNUNET_TIME_AbsoluteNBO timeout;
374 * Message from the library to the transport service
375 * asking for human readable addresses known for a peer.
377 struct AddressIterateResponseMessage
380 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY
382 struct GNUNET_MessageHeader header;
392 struct GNUNET_PeerIdentity peer;
397 uint32_t addrlen GNUNET_PACKED;
400 * length of the plugin name
402 uint32_t pluginlen GNUNET_PACKED;
407 * Change in blacklisting (either request or notification,
408 * depending on which direction it is going).
410 struct BlacklistMessage
414 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
415 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
417 struct GNUNET_MessageHeader header;
420 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
423 uint32_t is_allowed GNUNET_PACKED;
426 * Which peer is being blacklisted or queried?
428 struct GNUNET_PeerIdentity peer;
433 /* end of transport.h */