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"
32 #include "gnunet_constants.h"
34 #define DEBUG_TRANSPORT GNUNET_EXTRA_LOGGING
38 * For how long do we allow unused bandwidth
39 * from the past to carry over into the future? (in seconds)
41 #define MAX_BANDWIDTH_CARRY_S GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S
44 * How often do we (at most) do a full quota
45 * recalculation? (in ms)
47 #define MIN_QUOTA_REFRESH_TIME 2000
50 * Maximum frequency for re-evaluating latencies for all transport addresses.
52 #define LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
55 * Maximum frequency for re-evaluating latencies for connected addresses.
57 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
60 * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
61 * included here. These values are not required outside transport_api
64 * @param peer the peer that connected
65 * @param ats performance data
66 * @param ats_count number of entries in ats (excluding 0-termination)
67 * @param bandwidth_in inbound bandwidth in NBO
68 * @param bandwidth_out outbound bandwidth in NBO
72 typedef void (*NotifyConnect) (void *cls,
73 const struct GNUNET_PeerIdentity *peer,
74 const struct GNUNET_ATS_Information *ats,
76 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
77 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
79 GNUNET_NETWORK_STRUCT_BEGIN
82 * Message from the transport service to the library
83 * asking to check if both processes agree about this
90 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
92 struct GNUNET_MessageHeader header;
96 * 1: The 'self' field should be checked
97 * 2: this client is interested in payload traffic
102 * Identity we think we have. If it does not match, the
103 * receiver should print out an error message and disconnect.
105 struct GNUNET_PeerIdentity self;
111 * Message from the transport service to the library
112 * informing about neighbors.
114 struct ConnectInfoMessage
118 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
120 struct GNUNET_MessageHeader header;
123 * Number of ATS key-value pairs that follow this struct
124 * (excluding the 0-terminator).
126 uint32_t ats_count GNUNET_PACKED;
129 * Identity of the new neighbour.
131 struct GNUNET_PeerIdentity id;
134 * Current inbound quota for this peer
136 struct GNUNET_BANDWIDTH_Value32NBO quota_in;
139 * Current outbound quota for this peer
141 struct GNUNET_BANDWIDTH_Value32NBO quota_out;
146 * Message from the transport service to the library
147 * informing about disconnects.
149 struct DisconnectInfoMessage
153 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
155 struct GNUNET_MessageHeader header;
158 * Reserved, always zero.
160 uint32_t reserved GNUNET_PACKED;
163 * Who got disconnected?
165 struct GNUNET_PeerIdentity peer;
170 * Message type for sending a request connect message
171 * to the transport service. Must be done before transport
172 * api will allow messages to be queued/sent to transport
173 * service for transmission to a peer.
175 struct TransportRequestConnectMessage
180 struct GNUNET_MessageHeader header;
188 * Identity of the peer we would like to connect to.
190 struct GNUNET_PeerIdentity peer;
194 * Message used to set a particular bandwidth quota. Sent TO the
195 * service to set an incoming quota, sent FROM the service to update
198 struct QuotaSetMessage
202 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
204 struct GNUNET_MessageHeader header;
209 struct GNUNET_BANDWIDTH_Value32NBO quota;
212 * About which peer are we talking here?
214 struct GNUNET_PeerIdentity peer;
220 * Message used to notify the transport API about a message
221 * received from the network. The actual message follows.
223 struct InboundMessage
227 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
229 struct GNUNET_MessageHeader header;
232 * Number of ATS key-value pairs that follow this struct
233 * (excluding the 0-terminator).
235 uint32_t ats_count GNUNET_PACKED;
238 * Which peer sent the message?
240 struct GNUNET_PeerIdentity peer;
246 * Message used to notify the transport API that it can
247 * send another message to the transport service.
253 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
255 struct GNUNET_MessageHeader header;
258 * GNUNET_OK if the transmission succeeded,
259 * GNUNET_SYSERR if it failed (i.e. network disconnect);
260 * in either case, it is now OK for this client to
261 * send us another message for the given peer.
263 uint32_t success GNUNET_PACKED;
268 struct GNUNET_TIME_RelativeNBO latency;
271 * Which peer can send more now?
273 struct GNUNET_PeerIdentity peer;
279 * Message used to notify the transport service about a message
280 * to be transmitted to another peer. The actual message follows.
282 struct OutboundMessage
286 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
288 struct GNUNET_MessageHeader header;
293 uint32_t priority GNUNET_PACKED;
298 struct GNUNET_TIME_RelativeNBO timeout;
301 * Which peer should receive the message?
303 struct GNUNET_PeerIdentity peer;
309 * Message from the library to the transport service
310 * asking for converting a transport address to a
311 * human-readable UTF-8 string.
313 struct AddressLookupMessage
317 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
319 struct GNUNET_MessageHeader header;
322 * Should the conversion use numeric IP addresses (otherwise
323 * a reverse DNS lookup is OK -- if applicable).
325 int16_t numeric_only GNUNET_PACKED;
328 * Length of the (binary) address in bytes, in big-endian.
330 uint16_t addrlen GNUNET_PACKED;
333 * timeout to give up.
335 struct GNUNET_TIME_RelativeNBO timeout;
337 /* followed by 'addrlen' bytes of the actual address, then
338 * followed by the 0-terminated name of the transport */
343 * Message from the library to the transport service
344 * asking for human readable addresses known for a peer.
346 struct PeerAddressLookupMessage
349 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP
351 struct GNUNET_MessageHeader header;
359 * timeout to give up. FIXME: remove in the future.
361 struct GNUNET_TIME_RelativeNBO timeout;
364 * The identity of the peer to look up.
366 struct GNUNET_PeerIdentity peer;
371 * Message from the library to the transport service
372 * asking for binary addresses known for a peer.
374 struct AddressIterateMessage
377 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE
379 struct GNUNET_MessageHeader header;
382 * One shot call or continous replies?
387 * timeout to give up. FIXME: remove in the future
389 struct GNUNET_TIME_AbsoluteNBO timeout;
392 * The identity of the peer to look up.
394 struct GNUNET_PeerIdentity peer;
400 * Message from the transport service to the library
401 * containing binary addresses known for a peer.
403 * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
405 struct AddressIterateResponseMessage
408 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE
410 struct GNUNET_MessageHeader header;
420 struct GNUNET_PeerIdentity peer;
425 uint32_t addrlen GNUNET_PACKED;
428 * length of the plugin name
430 uint32_t pluginlen GNUNET_PACKED;
436 * Change in blacklisting (either request or notification,
437 * depending on which direction it is going).
439 struct BlacklistMessage
443 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
444 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
446 struct GNUNET_MessageHeader header;
449 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
452 uint32_t is_allowed GNUNET_PACKED;
455 * Which peer is being blacklisted or queried?
457 struct GNUNET_PeerIdentity peer;
460 GNUNET_NETWORK_STRUCT_END
462 /* end of transport.h */