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