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