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 * What's the maximum number of sockets transport uses for validation and
53 #define DEFAULT_MAX_FDS 256
56 * Maximum frequency for re-evaluating latencies for all transport addresses.
58 #define LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
61 * Maximum frequency for re-evaluating latencies for connected addresses.
63 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
66 * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
67 * included here. These values are not required outside transport_api
70 * @param peer the peer that connected
71 * @param ats performance data
72 * @param ats_count number of entries in ats (excluding 0-termination)
73 * @param bandwidth_in inbound bandwidth in NBO
74 * @param bandwidth_out outbound bandwidth in NBO
78 typedef void (*NotifyConnect) (void *cls,
79 const struct GNUNET_PeerIdentity *peer,
80 const struct GNUNET_ATS_Information *ats,
82 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
83 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
85 GNUNET_NETWORK_STRUCT_BEGIN
88 * Message from the transport service to the library
89 * asking to check if both processes agree about this
96 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
98 struct GNUNET_MessageHeader header;
102 * 1: The 'self' field should be checked
103 * 2: this client is interested in payload traffic
108 * Identity we think we have. If it does not match, the
109 * receiver should print out an error message and disconnect.
111 struct GNUNET_PeerIdentity self;
117 * Message from the transport service to the library
118 * informing about neighbors.
120 struct ConnectInfoMessage
124 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
126 struct GNUNET_MessageHeader header;
129 * Number of ATS key-value pairs that follow this struct
130 * (excluding the 0-terminator).
132 uint32_t ats_count GNUNET_PACKED;
135 * Identity of the new neighbour.
137 struct GNUNET_PeerIdentity id;
140 * Current inbound quota for this peer
142 struct GNUNET_BANDWIDTH_Value32NBO quota_in;
145 * Current outbound quota for this peer
147 struct GNUNET_BANDWIDTH_Value32NBO quota_out;
152 * Message from the transport service to the library
153 * informing about disconnects.
155 struct DisconnectInfoMessage
159 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
161 struct GNUNET_MessageHeader header;
164 * Reserved, always zero.
166 uint32_t reserved GNUNET_PACKED;
169 * Who got disconnected?
171 struct GNUNET_PeerIdentity peer;
176 * Message type for sending a request connect message
177 * to the transport service. Must be done before transport
178 * api will allow messages to be queued/sent to transport
179 * service for transmission to a peer.
181 struct TransportRequestConnectMessage
186 struct GNUNET_MessageHeader header;
194 * Identity of the peer we would like to connect to.
196 struct GNUNET_PeerIdentity peer;
200 * Message used to set a particular bandwidth quota. Sent TO the
201 * service to set an incoming quota, sent FROM the service to update
204 struct QuotaSetMessage
208 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
210 struct GNUNET_MessageHeader header;
215 struct GNUNET_BANDWIDTH_Value32NBO quota;
218 * About which peer are we talking here?
220 struct GNUNET_PeerIdentity peer;
226 * Message used to notify the transport API about a message
227 * received from the network. The actual message follows.
229 struct InboundMessage
233 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
235 struct GNUNET_MessageHeader header;
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;
267 * Size of message sent
269 uint32_t bytes_msg GNUNET_PACKED;
272 * Size of message sent over wire
273 * Includes plugin and protocol specific overhead
275 uint32_t bytes_physical GNUNET_PACKED;
280 struct GNUNET_TIME_RelativeNBO latency;
283 * Which peer can send more now?
285 struct GNUNET_PeerIdentity peer;
291 * Message used to notify the transport service about a message
292 * to be transmitted to another peer. The actual message follows.
294 struct OutboundMessage
298 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
300 struct GNUNET_MessageHeader header;
305 uint32_t priority GNUNET_PACKED;
310 struct GNUNET_TIME_RelativeNBO timeout;
313 * Which peer should receive the message?
315 struct GNUNET_PeerIdentity peer;
321 * Message from the library to the transport service
322 * asking for converting a transport address to a
323 * human-readable UTF-8 string.
325 struct AddressLookupMessage
329 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
331 struct GNUNET_MessageHeader header;
334 * Should the conversion use numeric IP addresses (otherwise
335 * a reverse DNS lookup is OK -- if applicable).
337 int16_t numeric_only GNUNET_PACKED;
340 * Length of the (binary) address in bytes, in big-endian.
342 uint16_t addrlen GNUNET_PACKED;
345 * timeout to give up.
347 struct GNUNET_TIME_RelativeNBO timeout;
349 /* followed by 'addrlen' bytes of the actual address, then
350 * followed by the 0-terminated name of the transport */
355 * Message from the library to the transport service
356 * asking for human readable addresses known for a peer.
358 struct PeerAddressLookupMessage
361 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP
363 struct GNUNET_MessageHeader header;
371 * timeout to give up. FIXME: remove in the future.
373 struct GNUNET_TIME_RelativeNBO timeout;
376 * The identity of the peer to look up.
378 struct GNUNET_PeerIdentity peer;
383 * Message from the library to the transport service
384 * asking for binary addresses known for a peer.
386 struct AddressIterateMessage
389 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE
391 struct GNUNET_MessageHeader header;
394 * One shot call or continous replies?
399 * timeout to give up. FIXME: remove in the future
401 struct GNUNET_TIME_AbsoluteNBO timeout;
404 * The identity of the peer to look up.
406 struct GNUNET_PeerIdentity peer;
412 * Message from the library to the transport service
413 * asking for binary addresses known for a peer.
415 struct TrafficMetricMessage
418 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
420 struct GNUNET_MessageHeader header;
423 * SEND, RECEIVE or BOTH?
428 * Traffic metrics count
433 * The identity of the peer to look up.
435 struct GNUNET_PeerIdentity peer;
440 * Message from the transport service to the library
441 * containing binary addresses known for a peer.
443 * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
445 struct AddressIterateResponseMessage
448 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE
450 struct GNUNET_MessageHeader header;
460 struct GNUNET_PeerIdentity peer;
465 uint32_t addrlen GNUNET_PACKED;
468 * length of the plugin name
470 uint32_t pluginlen GNUNET_PACKED;
476 * Change in blacklisting (either request or notification,
477 * depending on which direction it is going).
479 struct BlacklistMessage
483 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
484 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
486 struct GNUNET_MessageHeader header;
489 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
492 uint32_t is_allowed GNUNET_PACKED;
495 * Which peer is being blacklisted or queried?
497 struct GNUNET_PeerIdentity peer;
500 GNUNET_NETWORK_STRUCT_END
502 /* end of transport.h */