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