implement basic reliability ACK handling
[oweals/gnunet.git] / src / transport / transport.h
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
21 /**
22  * @file transport/transport.h
23  * @brief common internal definitions for transport service
24  * @author Christian Grothoff
25  */
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
36 /**
37  * For how long do we allow unused bandwidth
38  * from the past to carry over into the future? (in seconds)
39  */
40 #define MAX_BANDWIDTH_CARRY_S GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S
41
42 /**
43  * How often do we (at most) do a full quota
44  * recalculation? (in ms)
45  */
46 #define MIN_QUOTA_REFRESH_TIME 2000
47
48 /**
49  * What's the maximum number of sockets transport uses for validation and
50  * neighbors
51  */
52 #define DEFAULT_MAX_FDS 256
53
54 /**
55  * Maximum frequency for re-evaluating latencies for all transport addresses.
56  */
57 #define LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
58
59 /**
60  * Maximum frequency for re-evaluating latencies for connected addresses.
61  */
62 #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
63
64 /**
65  * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
66  * included here. These values are not required outside transport_api
67  *
68  * @param cls closure
69  * @param peer the peer that connected
70  * @param bandwidth_in inbound bandwidth in NBO
71  * @param bandwidth_out outbound bandwidth in NBO
72  *
73  */
74 typedef void
75 (*NotifyConnect) (void *cls,
76                   const struct GNUNET_PeerIdentity *peer,
77                   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
78                   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
79
80
81 GNUNET_NETWORK_STRUCT_BEGIN
82
83
84 /**
85  * Message from the transport service to the library
86  * asking to check if both processes agree about this
87  * peers identity.
88  */
89 struct StartMessage
90 {
91
92   /**
93    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_START
94    */
95   struct GNUNET_MessageHeader header;
96
97   /**
98    * 0: no options
99    * 1: The @e self field should be checked
100    * 2: this client is interested in payload traffic
101    */
102   uint32_t options;
103
104   /**
105    * Identity we think we have.  If it does not match, the
106    * receiver should print out an error message and disconnect.
107    */
108   struct GNUNET_PeerIdentity self;
109
110 };
111
112
113 /**
114  * Message from the transport service to the library
115  * informing about neighbors.
116  */
117 struct ConnectInfoMessage
118 {
119
120   /**
121    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
122    */
123   struct GNUNET_MessageHeader header;
124
125   /**
126    * Current outbound quota for this peer
127    */
128   struct GNUNET_BANDWIDTH_Value32NBO quota_out;
129
130   /**
131    * Identity of the new neighbour.
132    */
133   struct GNUNET_PeerIdentity id;
134 };
135
136
137 /**
138  * Message from the transport service to the library
139  * informing about disconnects.
140  */
141 struct DisconnectInfoMessage
142 {
143
144   /**
145    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
146    */
147   struct GNUNET_MessageHeader header;
148
149   /**
150    * Reserved, always zero.
151    */
152   uint32_t reserved GNUNET_PACKED;
153
154   /**
155    * Who got disconnected?
156    */
157   struct GNUNET_PeerIdentity peer;
158
159 };
160
161
162 /**
163  * Message used to set a particular bandwidth quota.  Sent TO the
164  * service to set an incoming quota, sent FROM the service to update
165  * an outgoing quota.
166  */
167 struct QuotaSetMessage
168 {
169
170   /**
171    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
172    */
173   struct GNUNET_MessageHeader header;
174
175   /**
176    * Quota.
177    */
178   struct GNUNET_BANDWIDTH_Value32NBO quota;
179
180   /**
181    * About which peer are we talking here?
182    */
183   struct GNUNET_PeerIdentity peer;
184
185 };
186
187
188 /**
189  * Message used to notify the transport API about a message
190  * received from the network.  The actual message follows.
191  */
192 struct InboundMessage
193 {
194
195   /**
196    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
197    */
198   struct GNUNET_MessageHeader header;
199
200   /**
201    * Which peer sent the message?
202    */
203   struct GNUNET_PeerIdentity peer;
204
205 };
206
207
208 /**
209  * Message used to notify the transport API that it can
210  * send another message to the transport service.
211  */
212 struct SendOkMessage
213 {
214
215   /**
216    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
217    */
218   struct GNUNET_MessageHeader header;
219
220   /**
221    * #GNUNET_OK if the transmission succeeded,
222    * #GNUNET_SYSERR if it failed (i.e. network disconnect);
223    * in either case, it is now OK for this client to
224    * send us another message for the given peer.
225    */
226   uint16_t success GNUNET_PACKED;
227
228   /**
229    * Size of message sent
230    */
231   uint16_t bytes_msg GNUNET_PACKED;
232
233   /**
234    * Size of message sent over wire
235    * Includes plugin and protocol specific overhead
236    */
237   uint32_t bytes_physical GNUNET_PACKED;
238
239   /**
240    * Which peer can send more now?
241    */
242   struct GNUNET_PeerIdentity peer;
243
244 };
245
246
247 /**
248  * Message used to notify the transport service about a message
249  * to be transmitted to another peer.  The actual message follows.
250  */
251 struct OutboundMessage
252 {
253
254   /**
255    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
256    */
257   struct GNUNET_MessageHeader header;
258
259   /**
260    * Always zero.
261    */
262   uint32_t reserved GNUNET_PACKED;
263
264   /**
265    * Allowed delay.
266    */
267   struct GNUNET_TIME_RelativeNBO timeout;
268
269   /**
270    * Which peer should receive the message?
271    */
272   struct GNUNET_PeerIdentity peer;
273
274 };
275
276
277
278
279 #if !(defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION)||defined(GNUNET_TRANSPORT_CORE_VERSION))
280
281
282 /**
283  * Message used to notify the transport API about an address to string
284  * conversion. Message is followed by the string with the humand-readable
285  * address.  For each lookup, multiple results may be returned.  The
286  * last message must have a @e res of #GNUNET_OK and an @e addr_len
287  * of zero.
288  */
289 struct AddressToStringResultMessage
290 {
291
292   /**
293    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
294    */
295   struct GNUNET_MessageHeader header;
296
297   /**
298    * #GNUNET_OK if the conversion succeeded,
299    * #GNUNET_SYSERR if it failed
300    */
301   uint32_t res GNUNET_PACKED;
302
303   /**
304    * Length of the following string, zero if @e is #GNUNET_SYSERR
305    */
306   uint32_t addr_len GNUNET_PACKED;
307 };
308
309
310 /**
311  * Message from the library to the transport service
312  * asking for converting a transport address to a
313  * human-readable UTF-8 string.
314  */
315 struct AddressLookupMessage
316 {
317
318   /**
319    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
320    */
321   struct GNUNET_MessageHeader header;
322
323   /**
324    * Should the conversion use numeric IP addresses (otherwise
325    * a reverse DNS lookup is OK -- if applicable).
326    */
327   int16_t numeric_only GNUNET_PACKED;
328
329   /**
330    * Length of the (binary) address in bytes, in big-endian.
331    */
332   uint16_t addrlen GNUNET_PACKED;
333
334   /**
335    * timeout to give up (for DNS resolution timeout mostly)
336    */
337   struct GNUNET_TIME_RelativeNBO timeout;
338
339   /* followed by @e addrlen bytes of the actual address, then
340    * followed by the 0-terminated name of the transport */
341 };
342
343
344 /**
345  * Message from the transport service to the library containing information
346  * about a peer. Information contained are:
347  * - current address used to communicate with this peer
348  * - state
349  * - state timeout
350  *
351  * Memory layout:
352  * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
353  */
354 struct ValidationIterateResponseMessage
355 {
356   /**
357    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE
358    */
359   struct GNUNET_MessageHeader header;
360
361   /**
362    * For alignment.
363    */
364   uint32_t reserved;
365
366   /**
367    * Peer identity
368    */
369   struct GNUNET_PeerIdentity peer;
370
371   /**
372    * Local info about the address
373    */
374   uint32_t local_address_info GNUNET_PACKED;
375
376   /**
377    * Address length
378    */
379   uint32_t addrlen GNUNET_PACKED;
380
381   /**
382    * Length of the plugin name
383    */
384   uint32_t pluginlen GNUNET_PACKED;
385
386   /**
387    * State
388    */
389   uint32_t state GNUNET_PACKED;
390
391   /**
392    * At what time did we successfully validate the address last.
393    * Will be NEVER if the address failed validation.
394    */
395   struct GNUNET_TIME_AbsoluteNBO last_validation;
396
397   /**
398    * Until when is the address believed to be valid.
399    * Will be ZERO if the address is not belived to be valid.
400    */
401   struct GNUNET_TIME_AbsoluteNBO valid_until;
402
403   /**
404    * When will we next try to validate the address (typically
405    * done before @e valid_until happens).
406    */
407   struct GNUNET_TIME_AbsoluteNBO next_validation;
408 };
409
410
411 /**
412  * Message from the library to the transport service
413  * asking for binary addresses known for a peer.
414  */
415 struct ValidationMonitorMessage
416 {
417   /**
418    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST
419    */
420   struct GNUNET_MessageHeader header;
421
422   /**
423    * One shot call or continous replies?
424    */
425   uint32_t one_shot GNUNET_PACKED;
426
427   /**
428    * The identity of the peer to look up.
429    */
430   struct GNUNET_PeerIdentity peer;
431
432 };
433
434
435 /**
436  * Message from the library to the transport service
437  * asking for binary addresses known for a peer.
438  */
439 struct PeerMonitorMessage
440 {
441   /**
442    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST
443    */
444   struct GNUNET_MessageHeader header;
445
446   /**
447    * One shot call or continous replies?
448    */
449   uint32_t one_shot GNUNET_PACKED;
450
451   /**
452    * The identity of the peer to look up.
453    */
454   struct GNUNET_PeerIdentity peer;
455
456 };
457
458
459 /**
460  * Message from the library to the transport service
461  * asking for binary addresses known for a peer.
462  */
463 struct TrafficMetricMessage
464 {
465   /**
466    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
467    */
468   struct GNUNET_MessageHeader header;
469
470   /**
471    * Always zero.
472    */
473   uint32_t reserved GNUNET_PACKED;
474
475   /**
476    * The identity of the peer to look up.
477    */
478   struct GNUNET_PeerIdentity peer;
479
480   /**
481    * Fake properties to generate.
482    */
483   struct GNUNET_ATS_PropertiesNBO properties;
484
485   /**
486    * Fake delay to add on inbound traffic.
487    */
488   struct GNUNET_TIME_RelativeNBO delay_in;
489
490   /**
491    * Fake delay to add on outbound traffic.
492    */
493   struct GNUNET_TIME_RelativeNBO delay_out;
494 };
495
496
497 /**
498  * Message from the transport service to the library containing information
499  * about a peer. Information contained are:
500  * - current address used to communicate with this peer
501  * - state
502  * - state timeout
503  *
504  * Memory layout:
505  * [AddressIterateResponseMessage][address[addrlen]][transportname[pluginlen]]
506  */
507 struct PeerIterateResponseMessage
508 {
509   /**
510    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
511    */
512   struct GNUNET_MessageHeader header;
513
514   /**
515    * For alignment.
516    */
517   uint32_t reserved;
518
519   /**
520    * Peer identity
521    */
522   struct GNUNET_PeerIdentity peer;
523
524   /**
525    * Timeout for the state this peer is in
526    */
527   struct GNUNET_TIME_AbsoluteNBO state_timeout;
528
529   /**
530    * Local info about the address
531    */
532   uint32_t local_address_info GNUNET_PACKED;
533
534   /**
535    * State this peer is in as an `enum GNUNET_TRANSPORT_PeerState`
536    */
537   uint32_t state GNUNET_PACKED;
538
539   /**
540    * Address length
541    */
542   uint32_t addrlen GNUNET_PACKED;
543
544   /**
545    * Length of the plugin name
546    */
547   uint32_t pluginlen GNUNET_PACKED;
548
549 };
550
551
552 /**
553  * Change in blacklisting (either request or notification,
554  * depending on which direction it is going).
555  */
556 struct BlacklistMessage
557 {
558
559   /**
560    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
561    * #GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
562    */
563   struct GNUNET_MessageHeader header;
564
565   /**
566    * 0 for the query, #GNUNET_OK (allowed) or #GNUNET_SYSERR (disallowed)
567    * for the response.
568    */
569   uint32_t is_allowed GNUNET_PACKED;
570
571   /**
572    * Which peer is being blacklisted or queried?
573    */
574   struct GNUNET_PeerIdentity peer;
575
576 };
577
578
579 /**
580  * Transport-level connection status update.
581  */
582 struct TransportPluginMonitorMessage
583 {
584
585   /**
586    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
587    */
588   struct GNUNET_MessageHeader header;
589
590   /**
591    * An `enum GNUNET_TRANSPORT_SessionState` in NBO.
592    */
593   uint16_t session_state GNUNET_PACKED;
594
595   /**
596    * #GNUNET_YES if this is an inbound connection,
597    * #GNUNET_NO if this is an outbound connection,
598    * #GNUNET_SYSERR if connections of this plugin
599    *             are so fundamentally bidirectional
600    *             that they have no 'initiator'
601    * Value given in NBO.
602    */
603   int16_t is_inbound GNUNET_PACKED;
604
605   /**
606    * Number of messages waiting transmission.
607    */
608   uint32_t msgs_pending GNUNET_PACKED;
609
610   /**
611    * Number of bytes waiting for transmission.
612    */
613   uint32_t bytes_pending GNUNET_PACKED;
614
615   /**
616    * When will this transport plugin session time out?
617    */
618   struct GNUNET_TIME_AbsoluteNBO timeout;
619
620   /**
621    * Until how long is this plugin currently blocked from reading?
622    */
623   struct GNUNET_TIME_AbsoluteNBO delay;
624
625   /**
626    * Which peer is this connection for?
627    */
628   struct GNUNET_PeerIdentity peer;
629
630   /**
631    * Unique identifier for the session.
632    */
633   uint64_t session_id;
634
635   /**
636    * Length of the plugin name in bytes, including 0-termination.
637    */
638   uint16_t plugin_name_len GNUNET_PACKED;
639
640   /**
641    * Length of the plugin address in bytes.
642    */
643   uint16_t plugin_address_len GNUNET_PACKED;
644
645   /* followed by 0-terminated plugin name and
646      @e plugin_address_len bytes of plugin address */
647
648 };
649
650 #else
651
652 /* *********************** TNG messages ***************** */
653
654 /**
655  * Communicator goes online.  Note which addresses it can
656  * work with.
657  */
658 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
659 {
660
661   /**
662    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR.
663    */
664   struct GNUNET_MessageHeader header;
665
666   /**
667    * NBO encoding of `enum GNUNET_TRANSPORT_CommunicatorCharacteristics`
668    */
669   uint32_t cc;
670
671   /* Followed by the address prefix of the communicator */
672 };
673
674
675 /**
676  * Add address to the list.
677  */
678 struct GNUNET_TRANSPORT_AddAddressMessage
679 {
680
681   /**
682    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS.
683    */
684   struct GNUNET_MessageHeader header;
685
686   /**
687    * Address identifier (used during deletion).
688    */
689   uint32_t aid GNUNET_PACKED;
690
691   /**
692    * When does the address expire?
693    */
694   struct GNUNET_TIME_RelativeNBO expiration;
695
696   /**
697    * An `enum GNUNET_NetworkType` in NBO.
698    */
699   uint32_t nt;
700
701   /* followed by UTF-8 encoded, 0-terminated human-readable address */
702 };
703
704
705 /**
706  * Remove address from the list.
707  */
708 struct GNUNET_TRANSPORT_DelAddressMessage
709 {
710
711   /**
712    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS.
713    */
714   struct GNUNET_MessageHeader header;
715
716   /**
717    * Address identifier.
718    */
719   uint32_t aid GNUNET_PACKED;
720
721 };
722
723
724 /**
725  * Inform transport about an incoming message.
726  */
727 struct GNUNET_TRANSPORT_IncomingMessage
728 {
729
730   /**
731    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG.
732    */
733   struct GNUNET_MessageHeader header;
734
735   /**
736    * Do we use flow control or not?
737    */
738   uint32_t fc_on GNUNET_PACKED;
739
740   /**
741    * 64-bit number to identify the matching ACK.
742    */
743   uint64_t fc_id GNUNET_PACKED;
744
745   /**
746    * How long does the communicator believe the address on which
747    * the message was received to remain valid?
748    */
749   struct GNUNET_TIME_RelativeNBO expected_address_validity;
750
751   /**
752    * Sender identifier.
753    */
754   struct GNUNET_PeerIdentity sender;
755
756   /* followed by the message */
757 };
758
759
760 /**
761  * Transport informs us about being done with an incoming message.
762  * (only sent if fc_on was set).
763  */
764 struct GNUNET_TRANSPORT_IncomingMessageAck
765 {
766
767   /**
768    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK.
769    */
770   struct GNUNET_MessageHeader header;
771
772   /**
773    * Reserved (0)
774    */
775   uint32_t reserved GNUNET_PACKED;
776
777   /**
778    * Which message is being ACKed?
779    */
780   uint64_t fc_id GNUNET_PACKED;
781
782   /**
783    * Sender identifier of the original message.
784    */
785   struct GNUNET_PeerIdentity sender;
786
787 };
788
789
790 /**
791  * Add queue to the transport
792  */
793 struct GNUNET_TRANSPORT_AddQueueMessage
794 {
795
796   /**
797    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
798    */
799   struct GNUNET_MessageHeader header;
800
801   /**
802    * Queue identifier (used to identify the queue).
803    */
804   uint32_t qid GNUNET_PACKED;
805
806   /**
807    * Receiver that can be addressed via the queue.
808    */
809   struct GNUNET_PeerIdentity receiver;
810
811   /**
812    * An `enum GNUNET_NetworkType` in NBO.
813    */
814   uint32_t nt;
815
816   /**
817    * Maximum transmission unit, in NBO.  UINT32_MAX for unlimited.
818    */
819   uint32_t mtu;
820
821   /**
822    * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
823    */
824   uint32_t cs;
825
826   /* followed by UTF-8 encoded, 0-terminated human-readable address */
827 };
828
829
830 /**
831  * Remove queue, it is no longer available.
832  */
833 struct GNUNET_TRANSPORT_DelQueueMessage
834 {
835
836   /**
837    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN.
838    */
839   struct GNUNET_MessageHeader header;
840
841   /**
842    * Address identifier.
843    */
844   uint32_t qid GNUNET_PACKED;
845
846   /**
847    * Receiver that can be addressed via the queue.
848    */
849   struct GNUNET_PeerIdentity receiver;
850
851 };
852
853
854 /**
855  * Transport tells communicator that it wants a new queue.
856  */
857 struct GNUNET_TRANSPORT_CreateQueue
858 {
859
860   /**
861    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE.
862    */
863   struct GNUNET_MessageHeader header;
864
865   /**
866    * Unique ID for the request.
867    */
868   uint32_t request_id GNUNET_PACKED;
869
870   /**
871    * Receiver that can be addressed via the queue.
872    */
873   struct GNUNET_PeerIdentity receiver;
874
875   /* followed by UTF-8 encoded, 0-terminated human-readable address */
876 };
877
878
879 /**
880  * Communicator tells transport how queue creation went down.
881  */
882 struct GNUNET_TRANSPORT_CreateQueueResponse
883 {
884
885   /**
886    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL.
887    */
888   struct GNUNET_MessageHeader header;
889
890   /**
891    * Unique ID for the request.
892    */
893   uint32_t request_id GNUNET_PACKED;
894 };
895
896
897 /**
898  * Inform communicator about transport's desire to send a message.
899  */
900 struct GNUNET_TRANSPORT_SendMessageTo
901 {
902
903   /**
904    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG.
905    */
906   struct GNUNET_MessageHeader header;
907
908   /**
909    * Which queue should we use?
910    */
911   uint32_t qid GNUNET_PACKED;
912
913   /**
914    * Message ID, used for flow control.
915    */
916   uint64_t mid GNUNET_PACKED;
917
918   /**
919    * Receiver identifier.
920    */
921   struct GNUNET_PeerIdentity receiver;
922
923   /* followed by the message */
924 };
925
926
927 /**
928  * Inform transport that message was sent.
929  */
930 struct GNUNET_TRANSPORT_SendMessageToAck
931 {
932
933   /**
934    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK.
935    */
936   struct GNUNET_MessageHeader header;
937
938   /**
939    * Success (#GNUNET_OK), failure (#GNUNET_SYSERR).
940    */
941   uint32_t status GNUNET_PACKED;
942
943   /**
944    * Message ID of the original message.
945    */
946   uint64_t mid GNUNET_PACKED;
947
948   /**
949    * Receiver identifier.
950    */
951   struct GNUNET_PeerIdentity receiver;
952
953 };
954
955
956 /**
957  * Message from communicator to transport service asking for
958  * transmission of a backchannel message with the given peer @e pid
959  * and communicator.
960  */
961 struct GNUNET_TRANSPORT_CommunicatorBackchannel
962 {
963   /**
964    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
965    */
966   struct GNUNET_MessageHeader header;
967
968   /**
969    * Always zero, for alignment.
970    */
971   uint32_t reserved;
972
973   /**
974    * Target peer.
975    */
976   struct GNUNET_PeerIdentity pid;
977
978   /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
979      message to the communicator */
980
981   /* Followed by the 0-terminated string specifying the desired
982      communicator at the target (@e pid) peer */
983 };
984
985
986 /**
987  * Message from transport to communicator passing along a backchannel
988  * message from the given peer @e pid.
989  */
990 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
991 {
992   /**
993    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
994    */
995   struct GNUNET_MessageHeader header;
996
997   /**
998    * Always zero, for alignment.
999    */
1000   uint32_t reserved;
1001
1002   /**
1003    * Origin peer.
1004    */
1005   struct GNUNET_PeerIdentity pid;
1006
1007   /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1008      message to the communicator */
1009
1010 };
1011
1012
1013
1014 /**
1015  * Request to start monitoring.
1016  */
1017 struct GNUNET_TRANSPORT_MonitorStart
1018 {
1019
1020   /**
1021    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START.
1022    */
1023   struct GNUNET_MessageHeader header;
1024
1025   /**
1026    * #GNUNET_YES for one-shot montoring, #GNUNET_NO for continuous monitoring.
1027    */
1028   uint32_t one_shot;
1029
1030   /**
1031    * Target identifier to monitor, all zeros for "all peers".
1032    */
1033   struct GNUNET_PeerIdentity peer;
1034
1035 };
1036
1037
1038 /**
1039  * Monitoring data.
1040  */
1041 struct GNUNET_TRANSPORT_MonitorData
1042 {
1043
1044   /**
1045    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA.
1046    */
1047   struct GNUNET_MessageHeader header;
1048
1049   /**
1050    * Network type (an `enum GNUNET_NetworkType` in NBO).
1051    */
1052   uint32_t nt GNUNET_PACKED;
1053
1054   /**
1055    * Target identifier.
1056    */
1057   struct GNUNET_PeerIdentity peer;
1058
1059   /**
1060    * @deprecated To be discussed if we keep these...
1061    */
1062   struct GNUNET_TIME_AbsoluteNBO last_validation;
1063   struct GNUNET_TIME_AbsoluteNBO valid_until;
1064   struct GNUNET_TIME_AbsoluteNBO next_validation;
1065
1066   /**
1067    * Current round-trip time estimate.
1068    */
1069   struct GNUNET_TIME_RelativeNBO rtt;
1070
1071   /**
1072    * Connection status (in NBO).
1073    */
1074   uint32_t cs GNUNET_PACKED;
1075
1076   /**
1077    * Messages pending (in NBO).
1078    */
1079   uint32_t num_msg_pending GNUNET_PACKED;
1080
1081   /**
1082    * Bytes pending (in NBO).
1083    */
1084   uint32_t num_bytes_pending GNUNET_PACKED;
1085
1086   /* Followed by 0-terminated address of the peer */
1087
1088 };
1089
1090
1091 /**
1092  * Request to verify address.
1093  */
1094 struct GNUNET_TRANSPORT_AddressToVerify
1095 {
1096
1097   /**
1098    * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY.
1099    */
1100   struct GNUNET_MessageHeader header;
1101
1102   /**
1103    * Reserved. 0.
1104    */
1105   uint32_t reserved;
1106
1107   /**
1108    * Peer the address is from.
1109    */
1110   struct GNUNET_PeerIdentity peer;
1111
1112   /* followed by variable-size raw address */
1113 };
1114
1115
1116 /**
1117  * Application client to TRANSPORT service: we would like to have
1118  * address suggestions for this peer.
1119  */
1120 struct ExpressPreferenceMessage
1121 {
1122   /**
1123    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST or
1124    * #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL to stop
1125    * suggestions.
1126    */
1127   struct GNUNET_MessageHeader header;
1128
1129   /**
1130    * What type of performance preference does the client have?
1131    * A `enum GNUNET_MQ_PreferenceKind` in NBO.
1132    */
1133   uint32_t pk GNUNET_PACKED;
1134
1135   /**
1136    * Peer to get address suggestions for.
1137    */
1138   struct GNUNET_PeerIdentity peer;
1139
1140   /**
1141    * How much bandwidth in bytes/second does the application expect?
1142    */
1143   struct GNUNET_BANDWIDTH_Value32NBO bw;
1144
1145 };
1146
1147
1148 /**
1149  * We got an address of another peer, TRANSPORT service
1150  * should validate it.  There is no response.
1151  */
1152 struct RequestHelloValidationMessage
1153 {
1154
1155   /**
1156    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION.
1157    */
1158   struct GNUNET_MessageHeader header;
1159
1160   /**
1161    * What type of network does the other peer claim this is?
1162    * A `enum GNUNET_NetworkType` in NBO.
1163    */
1164   uint32_t nt GNUNET_PACKED;
1165
1166   /**
1167    * Peer to the address is presumably for.
1168    */
1169   struct GNUNET_PeerIdentity peer;
1170
1171   /**
1172    * When does the address expire?
1173    */
1174   struct GNUNET_TIME_AbsoluteNBO expiration;
1175
1176   /* followed by 0-terminated address to validate */
1177 };
1178
1179 #endif
1180
1181 GNUNET_NETWORK_STRUCT_END
1182
1183 /* end of transport.h */
1184 #endif