GNUnet  0.19.5
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_util_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 
779  struct GNUNET_PeerIdentity neighbour_sender;
780 
781  /* followed by the message */
782 };
783 
784 
789 struct GNUNET_TRANSPORT_IncomingMessageAck
790 {
794  struct GNUNET_MessageHeader header;
795 
799  uint32_t reserved GNUNET_PACKED;
800 
804  uint64_t fc_id GNUNET_PACKED;
805 
809  struct GNUNET_PeerIdentity sender;
810 };
811 
812 
816 struct GNUNET_TRANSPORT_AddQueueMessage
817 {
821  struct GNUNET_MessageHeader header;
822 
826  uint32_t qid GNUNET_PACKED;
827 
832 
836  uint32_t nt;
837 
841  uint32_t mtu;
842 
847  uint64_t q_len;
848 
852  uint32_t priority;
853 
857  uint32_t cs;
858 
859  /* followed by UTF-8 encoded, 0-terminated human-readable address */
860 };
861 
862 
866 struct GNUNET_TRANSPORT_UpdateQueueMessage
867 {
871  struct GNUNET_MessageHeader header;
872 
876  uint32_t qid GNUNET_PACKED;
877 
882 
886  uint32_t nt;
887 
891  uint32_t mtu;
892 
897  uint64_t q_len;
898 
902  uint32_t priority;
903 
907  uint32_t cs;
908 };
909 
910 
914 struct GNUNET_TRANSPORT_DelQueueMessage
915 {
919  struct GNUNET_MessageHeader header;
920 
924  uint32_t qid GNUNET_PACKED;
925 
930 };
931 
932 
936 struct GNUNET_TRANSPORT_CreateQueue
937 {
941  struct GNUNET_MessageHeader header;
942 
946  uint32_t request_id GNUNET_PACKED;
947 
952 
953  /* followed by UTF-8 encoded, 0-terminated human-readable address */
954 };
955 
956 
960 struct GNUNET_TRANSPORT_CreateQueueResponse
961 {
966  struct GNUNET_MessageHeader header;
967 
971  uint32_t request_id GNUNET_PACKED;
972 };
973 
974 
978 struct GNUNET_TRANSPORT_SendMessageTo
979 {
983  struct GNUNET_MessageHeader header;
984 
988  uint32_t qid GNUNET_PACKED;
989 
993  uint64_t mid GNUNET_PACKED;
994 
999 
1000  /* followed by the message */
1001 };
1002 
1003 
1007 struct GNUNET_TRANSPORT_SendMessageToAck
1008 {
1012  struct GNUNET_MessageHeader header;
1013 
1017  uint32_t status GNUNET_PACKED;
1018 
1022  uint64_t mid GNUNET_PACKED;
1023 
1027  uint32_t qid GNUNET_PACKED;
1028 
1033 };
1034 
1035 
1041 struct GNUNET_TRANSPORT_CommunicatorBackchannel
1042 {
1046  struct GNUNET_MessageHeader header;
1047 
1051  uint32_t reserved;
1052 
1056  struct GNUNET_PeerIdentity pid;
1057 
1058  /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1059  message to the communicator */
1060 
1061  /* Followed by the 0-terminated string specifying the desired
1062  communicator at the target (@e pid) peer */
1063 };
1064 
1065 
1070 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
1071 {
1076  struct GNUNET_MessageHeader header;
1077 
1081  uint32_t reserved;
1082 
1086  struct GNUNET_PeerIdentity pid;
1087 
1088  /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1089  message to the communicator */
1090 };
1091 
1092 
1096 struct GNUNET_TRANSPORT_MonitorStart
1097 {
1101  struct GNUNET_MessageHeader header;
1102 
1106  uint32_t one_shot;
1107 
1111  struct GNUNET_PeerIdentity peer;
1112 };
1113 
1114 
1118 struct GNUNET_TRANSPORT_MonitorData
1119 {
1123  struct GNUNET_MessageHeader header;
1124 
1128  uint32_t nt GNUNET_PACKED;
1129 
1133  struct GNUNET_PeerIdentity peer;
1134 
1138  struct GNUNET_TIME_AbsoluteNBO last_validation;
1139  struct GNUNET_TIME_AbsoluteNBO valid_until;
1140  struct GNUNET_TIME_AbsoluteNBO next_validation;
1141 
1145  struct GNUNET_TIME_RelativeNBO rtt;
1146 
1150  uint32_t cs GNUNET_PACKED;
1151 
1155  uint32_t num_msg_pending GNUNET_PACKED;
1156 
1160  uint32_t num_bytes_pending GNUNET_PACKED;
1161 
1162  /* Followed by 0-terminated address of the peer */
1163 };
1164 
1165 
1169 struct GNUNET_TRANSPORT_AddressToVerify
1170 {
1174  struct GNUNET_MessageHeader header;
1175 
1179  uint32_t reserved;
1180 
1184  struct GNUNET_PeerIdentity peer;
1185 
1186  /* followed by variable-size raw address */
1187 };
1188 
1189 
1194 struct ExpressPreferenceMessage
1195 {
1201  struct GNUNET_MessageHeader header;
1202 
1207  uint32_t pk GNUNET_PACKED;
1208 
1212  struct GNUNET_PeerIdentity peer;
1213 
1218 };
1219 
1220 
1225 struct RequestHelloValidationMessage
1226 {
1230  struct GNUNET_MessageHeader header;
1231 
1236  uint32_t nt GNUNET_PACKED;
1237 
1241  struct GNUNET_PeerIdentity peer;
1242 
1243  /* followed by 0-terminated address to validate */
1244 };
1245 
1246 #endif
1247 
1249 
1250 /* end of transport.h */
1251 #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.
Functions related to time.
#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.
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:330
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