GNUnet  0.11.x
transport.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009-2014 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #ifndef TRANSPORT_H
27 #define TRANSPORT_H
28 
29 #include "gnunet_crypto_lib.h"
30 #include "gnunet_time_lib.h"
31 #include "gnunet_constants.h"
32 
33 #define DEBUG_TRANSPORT GNUNET_EXTRA_LOGGING
34 
35 
40 #define MAX_BANDWIDTH_CARRY_S GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S
41 
46 #define MIN_QUOTA_REFRESH_TIME 2000
47 
52 #define DEFAULT_MAX_FDS 256
53 
57 #define LATENCY_EVALUATION_MAX_DELAY \
58  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
59 
63 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY \
64  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
65 
76 typedef void (*NotifyConnect) (
77  void *cls,
78  const struct GNUNET_PeerIdentity *peer,
79  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
80  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
81 
82 
84 
85 
92 {
97 
103  uint32_t options;
104 
109  struct GNUNET_PeerIdentity self;
110 };
111 
112 
118 {
123 
124 #if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
125  defined(GNUNET_TRANSPORT_CORE_VERSION))
126 
130  uint32_t reserved GNUNET_PACKED;
131 #else
136 #endif
137 
141  struct GNUNET_PeerIdentity id;
142 };
143 
144 
150 {
155 
160 
164  struct GNUNET_PeerIdentity peer;
165 };
166 
167 
176 {
181 
186 
190  struct GNUNET_PeerIdentity peer;
191 };
192 
193 
199 {
204 
208  struct GNUNET_PeerIdentity peer;
209 };
210 
211 
217 {
222 
223 #if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
224  defined(GNUNET_TRANSPORT_CORE_VERSION))
225 
226  uint32_t reserved GNUNET_PACKED;
227 #else
235 
240 
246 #endif
247 
251  struct GNUNET_PeerIdentity peer;
252 };
253 
254 
261 {
266 
272 
276  struct GNUNET_PeerIdentity peer;
277 };
278 
279 
285 {
290 
295 
296 #if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
297  defined(GNUNET_TRANSPORT_CORE_VERSION))
298 
303 #endif
304 
308  struct GNUNET_PeerIdentity peer;
309 };
310 
311 
312 #if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
313  defined(GNUNET_TRANSPORT_CORE_VERSION))
314 
315 
324 {
329 
334  uint32_t res GNUNET_PACKED;
335 
340 };
341 
342 
349 {
354 
360 
365 
370 
371  /* followed by @e addrlen bytes of the actual address, then
372  * followed by the 0-terminated name of the transport */
373 };
374 
375 
387 {
392 
396  uint32_t reserved;
397 
401  struct GNUNET_PeerIdentity peer;
402 
407 
412 
417 
422 
428 
434 
440 };
441 
442 
448 {
453 
458 
462  struct GNUNET_PeerIdentity peer;
463 };
464 
465 
471 {
476 
481 
485  struct GNUNET_PeerIdentity peer;
486 };
487 
488 
494 {
499 
504 
508  struct GNUNET_PeerIdentity peer;
509 
514 
519 
524 };
525 
526 
538 {
543 
547  uint32_t reserved;
548 
552  struct GNUNET_PeerIdentity peer;
553 
558 
563 
568 
573 
578 };
579 
580 
586 {
592 
598 
602  struct GNUNET_PeerIdentity peer;
603 };
604 
605 
610 {
615 
620 
630 
635 
640 
645 
650 
654  struct GNUNET_PeerIdentity peer;
655 
659  uint64_t session_id;
660 
665 
670 
671  /* followed by 0-terminated plugin name and
672  @e plugin_address_len bytes of plugin address */
673 };
674 
675 #else
676 
677 /* *********************** TNG messages ***************** */
678 
683 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
684 {
688  struct GNUNET_MessageHeader header;
689 
693  uint32_t cc;
694 
695  /* Followed by the address prefix of the communicator */
696 };
697 
698 
702 struct GNUNET_TRANSPORT_AddAddressMessage
703 {
707  struct GNUNET_MessageHeader header;
708 
712  uint32_t aid GNUNET_PACKED;
713 
718 
722  uint32_t nt;
723 
724  /* followed by UTF-8 encoded, 0-terminated human-readable address */
725 };
726 
727 
731 struct GNUNET_TRANSPORT_DelAddressMessage
732 {
736  struct GNUNET_MessageHeader header;
737 
741  uint32_t aid GNUNET_PACKED;
742 };
743 
744 
748 struct GNUNET_TRANSPORT_IncomingMessage
749 {
753  struct GNUNET_MessageHeader header;
754 
758  uint32_t fc_on GNUNET_PACKED;
759 
763  uint64_t fc_id GNUNET_PACKED;
764 
769  struct GNUNET_TIME_RelativeNBO expected_address_validity;
770 
774  struct GNUNET_PeerIdentity sender;
775 
776  /* followed by the message */
777 };
778 
779 
784 struct GNUNET_TRANSPORT_IncomingMessageAck
785 {
789  struct GNUNET_MessageHeader header;
790 
794  uint32_t reserved GNUNET_PACKED;
795 
799  uint64_t fc_id GNUNET_PACKED;
800 
804  struct GNUNET_PeerIdentity sender;
805 };
806 
807 
811 struct GNUNET_TRANSPORT_AddQueueMessage
812 {
816  struct GNUNET_MessageHeader header;
817 
821  uint32_t qid GNUNET_PACKED;
822 
827 
831  uint32_t nt;
832 
836  uint32_t mtu;
837 
842  uint64_t q_len;
843 
847  uint32_t priority;
848 
852  uint32_t cs;
853 
854  /* followed by UTF-8 encoded, 0-terminated human-readable address */
855 };
856 
857 
861 struct GNUNET_TRANSPORT_UpdateQueueMessage
862 {
866  struct GNUNET_MessageHeader header;
867 
871  uint32_t qid GNUNET_PACKED;
872 
877 
881  uint32_t nt;
882 
886  uint32_t mtu;
887 
892  uint64_t q_len;
893 
897  uint32_t priority;
898 
902  uint32_t cs;
903 };
904 
905 
909 struct GNUNET_TRANSPORT_DelQueueMessage
910 {
914  struct GNUNET_MessageHeader header;
915 
919  uint32_t qid GNUNET_PACKED;
920 
925 };
926 
927 
931 struct GNUNET_TRANSPORT_CreateQueue
932 {
936  struct GNUNET_MessageHeader header;
937 
941  uint32_t request_id GNUNET_PACKED;
942 
947 
948  /* followed by UTF-8 encoded, 0-terminated human-readable address */
949 };
950 
951 
955 struct GNUNET_TRANSPORT_CreateQueueResponse
956 {
961  struct GNUNET_MessageHeader header;
962 
966  uint32_t request_id GNUNET_PACKED;
967 };
968 
969 
973 struct GNUNET_TRANSPORT_SendMessageTo
974 {
978  struct GNUNET_MessageHeader header;
979 
983  uint32_t qid GNUNET_PACKED;
984 
988  uint64_t mid GNUNET_PACKED;
989 
994 
995  /* followed by the message */
996 };
997 
998 
1002 struct GNUNET_TRANSPORT_SendMessageToAck
1003 {
1007  struct GNUNET_MessageHeader header;
1008 
1012  uint32_t status GNUNET_PACKED;
1013 
1017  uint64_t mid GNUNET_PACKED;
1018 
1023 };
1024 
1025 
1031 struct GNUNET_TRANSPORT_CommunicatorBackchannel
1032 {
1036  struct GNUNET_MessageHeader header;
1037 
1041  uint32_t reserved;
1042 
1046  struct GNUNET_PeerIdentity pid;
1047 
1048  /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1049  message to the communicator */
1050 
1051  /* Followed by the 0-terminated string specifying the desired
1052  communicator at the target (@e pid) peer */
1053 };
1054 
1055 
1060 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
1061 {
1066  struct GNUNET_MessageHeader header;
1067 
1071  uint32_t reserved;
1072 
1076  struct GNUNET_PeerIdentity pid;
1077 
1078  /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1079  message to the communicator */
1080 };
1081 
1082 
1086 struct GNUNET_TRANSPORT_MonitorStart
1087 {
1091  struct GNUNET_MessageHeader header;
1092 
1096  uint32_t one_shot;
1097 
1101  struct GNUNET_PeerIdentity peer;
1102 };
1103 
1104 
1108 struct GNUNET_TRANSPORT_MonitorData
1109 {
1113  struct GNUNET_MessageHeader header;
1114 
1118  uint32_t nt GNUNET_PACKED;
1119 
1123  struct GNUNET_PeerIdentity peer;
1124 
1128  struct GNUNET_TIME_AbsoluteNBO last_validation;
1129  struct GNUNET_TIME_AbsoluteNBO valid_until;
1130  struct GNUNET_TIME_AbsoluteNBO next_validation;
1131 
1135  struct GNUNET_TIME_RelativeNBO rtt;
1136 
1140  uint32_t cs GNUNET_PACKED;
1141 
1145  uint32_t num_msg_pending GNUNET_PACKED;
1146 
1150  uint32_t num_bytes_pending GNUNET_PACKED;
1151 
1152  /* Followed by 0-terminated address of the peer */
1153 };
1154 
1155 
1159 struct GNUNET_TRANSPORT_AddressToVerify
1160 {
1164  struct GNUNET_MessageHeader header;
1165 
1169  uint32_t reserved;
1170 
1174  struct GNUNET_PeerIdentity peer;
1175 
1176  /* followed by variable-size raw address */
1177 };
1178 
1179 
1184 struct ExpressPreferenceMessage
1185 {
1191  struct GNUNET_MessageHeader header;
1192 
1197  uint32_t pk GNUNET_PACKED;
1198 
1202  struct GNUNET_PeerIdentity peer;
1203 
1208 };
1209 
1210 
1215 struct RequestHelloValidationMessage
1216 {
1220  struct GNUNET_MessageHeader header;
1221 
1226  uint32_t nt GNUNET_PACKED;
1227 
1231  struct GNUNET_PeerIdentity peer;
1232 
1233  /* followed by 0-terminated address to validate */
1234 };
1235 
1236 #endif
1237 
1239 
1240 /* end of transport.h */
1241 #endif
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static unsigned long long reserved
How much space have we currently reserved?
struct GNUNET_BIO_WriteHandle * bw
handle to the file to write the load statistics to
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
cryptographic primitives for GNUnet
void receiver(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback to read from the SOCKS5 proxy.
Definition: socks.c:329
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:349
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable)...
Definition: transport.h:359
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:369
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING.
Definition: transport.h:353
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:324
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:339
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY.
Definition: transport.h:328
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:334
Change in blacklisting (either request or notification, depending on which direction it is going).
Definition: transport.h:586
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST...
Definition: transport.h:591
Message from the transport service to the library informing about neighbors.
Definition: transport.h:118
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:122
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:141
struct GNUNET_BANDWIDTH_Value32NBO quota_out
Current outbound quota for this peer.
Definition: transport.h:135
Message from the transport service to the library informing about disconnects.
Definition: transport.h:150
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT.
Definition: transport.h:154
uint32_t reserved
Reserved, always zero.
Definition: transport.h:159
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:164
ATS performance characteristics for an address in network byte order (for IPC).
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds and in network byte order.
Message used to notify the transport API about a message received from the network.
Definition: transport.h:199
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:203
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:208
Message used to notify the transport service about a message to be transmitted to another peer.
Definition: transport.h:285
uint32_t priority
An enum GNUNET_MQ_PriorityPreferences in NBO.
Definition: transport.h:294
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:308
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:302
Message from the transport service to the library containing information about a peer.
Definition: transport.h:538
uint32_t pluginlen
Length of the plugin name.
Definition: transport.h:577
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:557
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE.
Definition: transport.h:542
struct GNUNET_PeerIdentity peer
Peer identity.
Definition: transport.h:552
uint32_t local_address_info
Local info about the address.
Definition: transport.h:562
uint32_t reserved
For alignment.
Definition: transport.h:547
uint32_t state
State this peer is in as an enum GNUNET_TRANSPORT_PeerState
Definition: transport.h:567
uint32_t addrlen
Address length.
Definition: transport.h:572
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:471
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:485
uint32_t one_shot
One shot call or continuous replies?
Definition: transport.h:480
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST.
Definition: transport.h:475
Message used to set a particular bandwidth quota.
Definition: transport.h:176
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA.
Definition: transport.h:180
struct GNUNET_BANDWIDTH_Value32NBO quota
Quota.
Definition: transport.h:185
struct GNUNET_PeerIdentity peer
About which peer are we talking here?
Definition: transport.h:190
Message used to notify the transport API that it can send another message to the transport service.
Definition: transport.h:261
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition: transport.h:276
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK.
Definition: transport.h:265
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition: transport.h:271
Message used to notify the transport API that it can send another message to the transport service.
Definition: transport.h:217
uint16_t success
GNUNET_OK if the transmission succeeded, GNUNET_SYSERR if it failed (i.e.
Definition: transport.h:234
uint16_t bytes_msg
Size of message sent.
Definition: transport.h:239
uint32_t bytes_physical
Size of message sent over wire.
Definition: transport.h:245
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:251
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK.
Definition: transport.h:221
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:92
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START.
Definition: transport.h:96
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic
Definition: transport.h:103
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition: transport.h:109
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:494
struct GNUNET_TIME_RelativeNBO delay_in
Fake delay to add on inbound traffic.
Definition: transport.h:518
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC.
Definition: transport.h:498
struct GNUNET_TIME_RelativeNBO delay_out
Fake delay to add on outbound traffic.
Definition: transport.h:523
struct GNUNET_ATS_PropertiesNBO properties
Fake properties to generate.
Definition: transport.h:513
uint32_t reserved
Always zero.
Definition: transport.h:503
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:508
Transport-level connection status update.
Definition: transport.h:610
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
Definition: transport.h:614
struct GNUNET_TIME_AbsoluteNBO timeout
When will this transport plugin session time out?
Definition: transport.h:644
uint16_t plugin_address_len
Length of the plugin address in bytes.
Definition: transport.h:669
uint16_t plugin_name_len
Length of the plugin name in bytes, including 0-termination.
Definition: transport.h:664
uint16_t session_state
An enum GNUNET_TRANSPORT_SessionState in NBO.
Definition: transport.h:619
struct GNUNET_TIME_AbsoluteNBO delay
Until how long is this plugin currently blocked from reading?
Definition: transport.h:649
uint32_t bytes_pending
Number of bytes waiting for transmission.
Definition: transport.h:639
uint32_t msgs_pending
Number of messages waiting transmission.
Definition: transport.h:634
uint64_t session_id
Unique identifier for the session.
Definition: transport.h:659
struct GNUNET_PeerIdentity peer
Which peer is this connection for?
Definition: transport.h:654
int16_t is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection,...
Definition: transport.h:629
Message from the transport service to the library containing information about a peer.
Definition: transport.h:387
uint32_t pluginlen
Length of the plugin name.
Definition: transport.h:416
struct GNUNET_TIME_AbsoluteNBO last_validation
At what time did we successfully validate the address last.
Definition: transport.h:427
struct GNUNET_MessageHeader header
Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE.
Definition: transport.h:391
uint32_t addrlen
Address length.
Definition: transport.h:411
uint32_t reserved
For alignment.
Definition: transport.h:396
struct GNUNET_PeerIdentity peer
Peer identity.
Definition: transport.h:401
struct GNUNET_TIME_AbsoluteNBO valid_until
Until when is the address believed to be valid.
Definition: transport.h:433
uint32_t local_address_info
Local info about the address.
Definition: transport.h:406
struct GNUNET_TIME_AbsoluteNBO next_validation
When will we next try to validate the address (typically done before valid_until happens).
Definition: transport.h:439
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:448
struct GNUNET_MessageHeader header
Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST.
Definition: transport.h:452
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:462
uint32_t one_shot
One shot call or continuous replies?
Definition: transport.h:457
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void(* NotifyConnect)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
Similar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are included here.
Definition: transport.h:76