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 bandwidth_in inbound bandwidth in NBO
72 * @param bandwidth_out outbound bandwidth in NBO
76 typedef void (*NotifyConnect) (void *cls,
77 const struct GNUNET_PeerIdentity *peer,
78 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
79 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
81 GNUNET_NETWORK_STRUCT_BEGIN
84 * Message from the transport service to the library
85 * asking to check if both processes agree about this
92 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
94 struct GNUNET_MessageHeader header;
98 * 1: The 'self' field should be checked
99 * 2: this client is interested in payload traffic
104 * Identity we think we have. If it does not match, the
105 * receiver should print out an error message and disconnect.
107 struct GNUNET_PeerIdentity self;
113 * Message from the transport service to the library
114 * informing about neighbors.
116 struct ConnectInfoMessage
120 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
122 struct GNUNET_MessageHeader header;
125 * Identity of the new neighbour.
127 struct GNUNET_PeerIdentity id;
130 * Current inbound quota for this peer
132 struct GNUNET_BANDWIDTH_Value32NBO quota_in;
135 * Current outbound quota for this peer
137 struct GNUNET_BANDWIDTH_Value32NBO quota_out;
142 * Message from the transport service to the library
143 * informing about disconnects.
145 struct DisconnectInfoMessage
149 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
151 struct GNUNET_MessageHeader header;
154 * Reserved, always zero.
156 uint32_t reserved GNUNET_PACKED;
159 * Who got disconnected?
161 struct GNUNET_PeerIdentity peer;
166 * Message type for sending a request connect message
167 * to the transport service. Must be done before transport
168 * api will allow messages to be queued/sent to transport
169 * service for transmission to a peer.
171 struct TransportRequestConnectMessage
176 struct GNUNET_MessageHeader header;
179 * Connect (GNUNET_YES) or connect (GNUNET_NO).
184 * Identity of the peer we would like to connect to.
186 struct GNUNET_PeerIdentity peer;
190 * Message used to set a particular bandwidth quota. Sent TO the
191 * service to set an incoming quota, sent FROM the service to update
194 struct QuotaSetMessage
198 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
200 struct GNUNET_MessageHeader header;
205 struct GNUNET_BANDWIDTH_Value32NBO quota;
208 * About which peer are we talking here?
210 struct GNUNET_PeerIdentity peer;
216 * Message used to notify the transport API about a message
217 * received from the network. The actual message follows.
219 struct InboundMessage
223 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
225 struct GNUNET_MessageHeader header;
228 * Which peer sent the message?
230 struct GNUNET_PeerIdentity peer;
236 * Message used to notify the transport API that it can
237 * send another message to the transport service.
243 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
245 struct GNUNET_MessageHeader header;
248 * GNUNET_OK if the transmission succeeded,
249 * GNUNET_SYSERR if it failed (i.e. network disconnect);
250 * in either case, it is now OK for this client to
251 * send us another message for the given peer.
253 uint32_t success GNUNET_PACKED;
257 * Size of message sent
259 uint32_t bytes_msg GNUNET_PACKED;
262 * Size of message sent over wire
263 * Includes plugin and protocol specific overhead
265 uint32_t bytes_physical GNUNET_PACKED;
270 struct GNUNET_TIME_RelativeNBO latency;
273 * Which peer can send more now?
275 struct GNUNET_PeerIdentity peer;
280 * Message used to notify the transport API about an address to string
281 * conversion. Message is followed by the string with length strlen
283 struct AddressToStringResultMessage
287 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
289 struct GNUNET_MessageHeader header;
292 * GNUNET_OK if the conversion succeeded,
293 * GNUNET_SYSERR if it failed
295 uint32_t res GNUNET_PACKED;
298 * Length of the following string
300 uint32_t addr_len GNUNET_PACKED;
307 * Message used to notify the transport service about a message
308 * to be transmitted to another peer. The actual message follows.
310 struct OutboundMessage
314 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
316 struct GNUNET_MessageHeader header;
321 uint32_t reserved GNUNET_PACKED;
326 struct GNUNET_TIME_RelativeNBO timeout;
329 * Which peer should receive the message?
331 struct GNUNET_PeerIdentity peer;
337 * Message from the library to the transport service
338 * asking for converting a transport address to a
339 * human-readable UTF-8 string.
341 struct AddressLookupMessage
345 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
347 struct GNUNET_MessageHeader header;
350 * Should the conversion use numeric IP addresses (otherwise
351 * a reverse DNS lookup is OK -- if applicable).
353 int16_t numeric_only GNUNET_PACKED;
356 * Length of the (binary) address in bytes, in big-endian.
358 uint16_t addrlen GNUNET_PACKED;
361 * timeout to give up.
363 struct GNUNET_TIME_RelativeNBO timeout;
365 /* followed by 'addrlen' bytes of the actual address, then
366 * followed by the 0-terminated name of the transport */
371 * Message from the transport service to the library containing information
372 * about a peer. Information contained are:
373 * - current address used to communicate with this peer
378 * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
380 struct ValidationIterateResponseMessage
383 * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE
385 struct GNUNET_MessageHeader header;
395 struct GNUNET_PeerIdentity peer;
398 * Local info about the address
400 uint32_t local_address_info GNUNET_PACKED;
405 uint32_t addrlen GNUNET_PACKED;
408 * Length of the plugin name
410 uint32_t pluginlen GNUNET_PACKED;
415 uint32_t state GNUNET_PACKED;
417 struct GNUNET_TIME_AbsoluteNBO last_validation;
419 struct GNUNET_TIME_AbsoluteNBO valid_until;
421 struct GNUNET_TIME_AbsoluteNBO next_validation;
425 * Message from the library to the transport service
426 * asking for binary addresses known for a peer.
428 struct ValidationMonitorMessage
431 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST
433 struct GNUNET_MessageHeader header;
436 * One shot call or continous replies?
441 * The identity of the peer to look up.
443 struct GNUNET_PeerIdentity peer;
449 * Message from the library to the transport service
450 * asking for binary addresses known for a peer.
452 struct PeerMonitorMessage
455 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST
457 struct GNUNET_MessageHeader header;
460 * One shot call or continous replies?
465 * The identity of the peer to look up.
467 struct GNUNET_PeerIdentity peer;
473 * Message from the library to the transport service
474 * asking for binary addresses known for a peer.
476 struct TrafficMetricMessage
479 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
481 struct GNUNET_MessageHeader header;
484 * SEND, RECEIVE or BOTH?
489 * Traffic metrics count
494 * The identity of the peer to look up.
496 struct GNUNET_PeerIdentity peer;
501 * Message from the transport service to the library containing information
502 * about a peer. Information contained are:
503 * - current address used to communicate with this peer
508 * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
510 struct PeerIterateResponseMessage
513 * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
515 struct GNUNET_MessageHeader header;
525 struct GNUNET_PeerIdentity peer;
528 * Timeout for the state this peer is in
530 struct GNUNET_TIME_AbsoluteNBO state_timeout;
533 * Local info about the address
535 uint32_t local_address_info GNUNET_PACKED;
538 * State this peer is in as #GNUNET_TRANSPORT_PeerState enumeration element
540 uint32_t state GNUNET_PACKED;
545 uint32_t addrlen GNUNET_PACKED;
548 * Length of the plugin name
550 uint32_t pluginlen GNUNET_PACKED;
556 * Change in blacklisting (either request or notification,
557 * depending on which direction it is going).
559 struct BlacklistMessage
563 * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
564 * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
566 struct GNUNET_MessageHeader header;
569 * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
572 uint32_t is_allowed GNUNET_PACKED;
575 * Which peer is being blacklisted or queried?
577 struct GNUNET_PeerIdentity peer;
580 GNUNET_NETWORK_STRUCT_END
582 /* end of transport.h */