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