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, 1)
35 #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
36 #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 500)
37 #define ATS_MAX_ITERATIONS INT_MAX
41 struct GNUNET_CONTAINER_MultiHashMap * peers;
43 * Time of last execution
45 struct GNUNET_TIME_Absolute last;
47 * Minimum intervall between two executions
49 struct GNUNET_TIME_Relative min_delta;
51 * Regular intervall when execution is triggered
53 struct GNUNET_TIME_Relative exec_intervall;
55 * Maximum execution time per calculation
57 struct GNUNET_TIME_Relative max_exec_duration;
59 * Maximum number of LP iterations per calculation
63 GNUNET_SCHEDULER_TaskIdentifier ats_task;
66 #define DEBUG_TRANSPORT GNUNET_NO
67 #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO
68 #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO
71 * For how long do we allow unused bandwidth
72 * from the past to carry over into the future? (in seconds)
74 #define MAX_BANDWIDTH_CARRY_S 5
77 * How often do we (at most) do a full quota
78 * recalculation? (in ms)
80 #define MIN_QUOTA_REFRESH_TIME 2000
83 * Message from the transport service to the library
84 * asking to check if both processes agree about this
91 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
93 struct GNUNET_MessageHeader header;
96 * Should the 'self' field be checked?
101 * Identity we think we have. If it does not match, the
102 * receiver should print out an error message and disconnect.
104 struct GNUNET_PeerIdentity self;
110 * Message from the transport service to the library
111 * informing about neighbors.
113 struct ConnectInfoMessage
117 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
119 struct GNUNET_MessageHeader header;
122 * Number of ATS key-value pairs that follow this struct
123 * (excluding the 0-terminator).
125 uint32_t ats_count GNUNET_PACKED;
128 * Identity of the new neighbour.
130 struct GNUNET_PeerIdentity id;
133 * First of the ATS information blocks (we must have at least
134 * one due to the 0-termination requirement).
136 struct GNUNET_TRANSPORT_ATS_Information ats;
141 * Message from the transport service to the library
142 * informing about disconnects.
144 struct DisconnectInfoMessage
148 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
150 struct GNUNET_MessageHeader header;
153 * Reserved, always zero.
155 uint32_t reserved GNUNET_PACKED;
158 * Who got disconnected?
160 struct GNUNET_PeerIdentity peer;
165 * Message type for sending a request connect message
166 * to the transport service. Must be done before transport
167 * api will allow messages to be queued/sent to transport
168 * service for transmission to a peer.
170 struct TransportRequestConnectMessage
175 struct GNUNET_MessageHeader header;
178 * Identity of the peer we would like to connect to.
180 struct GNUNET_PeerIdentity peer;
184 * Message used to set a particular bandwidth quota. Send TO the
185 * service to set an incoming quota, send FROM the service to update
188 struct QuotaSetMessage
192 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO
194 struct GNUNET_MessageHeader header;
199 struct GNUNET_BANDWIDTH_Value32NBO quota;
202 * About which peer are we talking here?
204 struct GNUNET_PeerIdentity peer;
210 * Message used to notify the transport API about a message
211 * received from the network. The actual message follows.
213 struct InboundMessage
217 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
219 struct GNUNET_MessageHeader header;
224 uint32_t reserved GNUNET_PACKED;
227 * Number of ATS key-value pairs that follow this struct
228 * (excluding the 0-terminator).
230 uint32_t ats_count GNUNET_PACKED;
233 * Which peer sent the message?
235 struct GNUNET_PeerIdentity peer;
238 * First of the ATS information blocks (we must have at least
239 * one due to the 0-termination requirement).
241 struct GNUNET_TRANSPORT_ATS_Information ats;
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_LOOKUP
319 struct GNUNET_MessageHeader header;
322 * Should the conversion use numeric IP addresses (otherwise
323 * a reverse DNS lookup is OK -- if applicable).
325 int32_t numeric_only GNUNET_PACKED;
328 * timeout to give up.
330 struct GNUNET_TIME_AbsoluteNBO timeout;
333 * Length of the (binary) address in bytes, in big-endian.
335 uint32_t addrlen GNUNET_PACKED;
337 /* followed by 'addrlen' bytes of the actual address, then
338 followed by the 0-terminated name of the transport */
344 * Change in blacklisting (either request or notification,
345 * depending on which direction it is going).
347 struct BlacklistMessage
351 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
352 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
354 struct GNUNET_MessageHeader header;
357 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
360 uint32_t is_allowed GNUNET_PACKED;
363 * Which peer is being blacklisted or queried?
365 struct GNUNET_PeerIdentity peer;
370 /* end of transport.h */