aboutsummaryrefslogtreecommitdiff
path: root/src/service/transport/transport.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/transport/transport.h')
-rw-r--r--src/service/transport/transport.h828
1 files changed, 828 insertions, 0 deletions
diff --git a/src/service/transport/transport.h b/src/service/transport/transport.h
new file mode 100644
index 000000000..66f17ee5b
--- /dev/null
+++ b/src/service/transport/transport.h
@@ -0,0 +1,828 @@
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_util_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 * Similar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
38 * included here. These values are not required outside transport_api
39 *
40 * @param cls closure
41 * @param peer the peer that connected
42 * @param bandwidth_in inbound bandwidth in NBO
43 * @param bandwidth_out outbound bandwidth in NBO
44 *
45 */
46typedef void (*NotifyConnect) (
47 void *cls,
48 const struct GNUNET_PeerIdentity *peer,
49 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
50 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
51
52
53GNUNET_NETWORK_STRUCT_BEGIN
54
55
56/**
57 * Message from the transport service to the library
58 * asking to check if both processes agree about this
59 * peers identity.
60 */
61struct StartMessage
62{
63 /**
64 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_START
65 */
66 struct GNUNET_MessageHeader header;
67
68 /**
69 * 0: no options
70 * 1: The @e self field should be checked
71 * 2: this client is interested in payload traffic
72 */
73 uint32_t options;
74
75 /**
76 * Identity we think we have. If it does not match, the
77 * receiver should print out an error message and disconnect.
78 */
79 struct GNUNET_PeerIdentity self;
80};
81
82
83/**
84 * Message from the transport service to the library
85 * informing about neighbors.
86 */
87struct ConnectInfoMessage
88{
89 /**
90 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
91 */
92 struct GNUNET_MessageHeader header;
93
94#if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
95 defined(GNUNET_TRANSPORT_CORE_VERSION))
96
97 /**
98 * Always zero, for alignment.
99 */
100 uint32_t reserved GNUNET_PACKED;
101#else
102 /**
103 * Current outbound quota for this peer
104 */
105 struct GNUNET_BANDWIDTH_Value32NBO quota_out;
106#endif
107
108 /**
109 * Identity of the new neighbour.
110 */
111 struct GNUNET_PeerIdentity id;
112};
113
114
115/**
116 * Message from the transport service to the library
117 * informing about disconnects.
118 */
119struct DisconnectInfoMessage
120{
121 /**
122 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
123 */
124 struct GNUNET_MessageHeader header;
125
126 /**
127 * Reserved, always zero.
128 */
129 uint32_t reserved GNUNET_PACKED;
130
131 /**
132 * Who got disconnected?
133 */
134 struct GNUNET_PeerIdentity peer;
135};
136
137
138/**
139 * Message used to notify the transport API about a message
140 * received from the network. The actual message follows.
141 */
142struct InboundMessage
143{
144 /**
145 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
146 */
147 struct GNUNET_MessageHeader header;
148
149 /**
150 * Which peer sent the message?
151 */
152 struct GNUNET_PeerIdentity peer;
153};
154
155
156/**
157 * Message used to notify the transport API that it can
158 * send another message to the transport service.
159 */
160struct SendOkMessage
161{
162 /**
163 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
164 */
165 struct GNUNET_MessageHeader header;
166
167#if (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
168 defined(GNUNET_TRANSPORT_CORE_VERSION))
169
170 uint32_t reserved GNUNET_PACKED;
171#else
172 /**
173 * #GNUNET_OK if the transmission succeeded,
174 * #GNUNET_SYSERR if it failed (i.e. network disconnect);
175 * in either case, it is now OK for this client to
176 * send us another message for the given peer.
177 */
178 uint16_t success GNUNET_PACKED;
179
180 /**
181 * Size of message sent
182 */
183 uint16_t bytes_msg GNUNET_PACKED;
184
185 /**
186 * Size of message sent over wire.
187 * Includes plugin and protocol specific overheads.
188 */
189 uint32_t bytes_physical GNUNET_PACKED;
190#endif
191
192 /**
193 * Which peer can send more now?
194 */
195 struct GNUNET_PeerIdentity peer;
196};
197
198
199/**
200 * Message used to notify the transport API that it can
201 * send another message to the transport service.
202 * (Used to implement flow control.)
203 */
204struct RecvOkMessage
205{
206 /**
207 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK
208 */
209 struct GNUNET_MessageHeader header;
210
211 /**
212 * Number of messages by which to increase the window, greater or
213 * equal to one.
214 */
215 uint32_t increase_window_delta GNUNET_PACKED;
216
217 /**
218 * Which peer can CORE handle more from now?
219 */
220 struct GNUNET_PeerIdentity peer;
221};
222
223
224/**
225 * Message used to notify the transport service about a message
226 * to be transmitted to another peer. The actual message follows.
227 */
228struct OutboundMessage
229{
230 /**
231 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
232 */
233 struct GNUNET_MessageHeader header;
234
235 /**
236 * An `enum GNUNET_MQ_PriorityPreferences` in NBO.
237 */
238 uint32_t priority GNUNET_PACKED;
239
240#if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \
241 defined(GNUNET_TRANSPORT_CORE_VERSION))
242
243 /**
244 * Allowed delay.
245 */
246 struct GNUNET_TIME_RelativeNBO timeout;
247#endif
248
249 /**
250 * Which peer should receive the message?
251 */
252 struct GNUNET_PeerIdentity peer;
253};
254
255
256/* *********************** TNG messages ***************** */
257
258/**
259 * Communicator goes online. Note which addresses it can
260 * work with.
261 */
262struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
263{
264 /**
265 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR.
266 */
267 struct GNUNET_MessageHeader header;
268
269 /**
270 * NBO encoding of `enum GNUNET_TRANSPORT_CommunicatorCharacteristics`
271 */
272 uint32_t cc;
273
274 /* Followed by the address prefix of the communicator */
275};
276
277
278/**
279 * Add address to the list.
280 */
281struct GNUNET_TRANSPORT_AddAddressMessage
282{
283 /**
284 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS.
285 */
286 struct GNUNET_MessageHeader header;
287
288 /**
289 * Address identifier (used during deletion).
290 */
291 uint32_t aid GNUNET_PACKED;
292
293 /**
294 * When does the address expire?
295 */
296 struct GNUNET_TIME_RelativeNBO expiration;
297
298 /**
299 * An `enum GNUNET_NetworkType` in NBO.
300 */
301 uint32_t nt;
302
303 /* followed by UTF-8 encoded, 0-terminated human-readable address */
304};
305
306
307/**
308 * Remove address from the list.
309 */
310struct GNUNET_TRANSPORT_DelAddressMessage
311{
312 /**
313 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS.
314 */
315 struct GNUNET_MessageHeader header;
316
317 /**
318 * Address identifier.
319 */
320 uint32_t aid GNUNET_PACKED;
321};
322
323
324/**
325 * Inform transport about an incoming message.
326 */
327struct GNUNET_TRANSPORT_IncomingMessage
328{
329 /**
330 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG.
331 */
332 struct GNUNET_MessageHeader header;
333
334 /**
335 * Do we use flow control or not?
336 */
337 uint32_t fc_on GNUNET_PACKED;
338
339 /**
340 * 64-bit number to identify the matching ACK.
341 */
342 uint64_t fc_id GNUNET_PACKED;
343
344 /**
345 * How long does the communicator believe the address on which
346 * the message was received to remain valid?
347 */
348 struct GNUNET_TIME_RelativeNBO expected_address_validity;
349
350 /**
351 * Sender identifier.
352 */
353 struct GNUNET_PeerIdentity sender;
354
355 /**
356 * Direct neighbour sender identifier.
357 */
358 struct GNUNET_PeerIdentity neighbour_sender;
359
360 /* followed by the message */
361};
362
363
364/**
365 * Transport informs us about being done with an incoming message.
366 * (only sent if fc_on was set).
367 */
368struct GNUNET_TRANSPORT_IncomingMessageAck
369{
370 /**
371 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK.
372 */
373 struct GNUNET_MessageHeader header;
374
375 /**
376 * Reserved (0)
377 */
378 uint32_t reserved GNUNET_PACKED;
379
380 /**
381 * Which message is being ACKed?
382 */
383 uint64_t fc_id GNUNET_PACKED;
384
385 /**
386 * Sender identifier of the original message.
387 */
388 struct GNUNET_PeerIdentity sender;
389};
390
391
392/**
393 * Add queue to the transport
394 */
395struct GNUNET_TRANSPORT_AddQueueMessage
396{
397 /**
398 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
399 */
400 struct GNUNET_MessageHeader header;
401
402 /**
403 * Queue identifier (used to identify the queue).
404 */
405 uint32_t qid GNUNET_PACKED;
406
407 /**
408 * Receiver that can be addressed via the queue.
409 */
410 struct GNUNET_PeerIdentity receiver;
411
412 /**
413 * An `enum GNUNET_NetworkType` in NBO.
414 */
415 uint32_t nt;
416
417 /**
418 * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
419 */
420 uint32_t mtu;
421
422 /**
423 * Queue length, in NBO. Defines how many messages may be
424 * send through this queue. UINT64_MAX for unlimited.
425 */
426 uint64_t q_len;
427
428 /**
429 * Priority of the queue in relation to other queues.
430 */
431 uint32_t priority;
432
433 /**
434 * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
435 */
436 uint32_t cs;
437
438 /* followed by UTF-8 encoded, 0-terminated human-readable address */
439};
440
441
442/**
443 * Update queue
444 */
445struct GNUNET_TRANSPORT_UpdateQueueMessage
446{
447 /**
448 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
449 */
450 struct GNUNET_MessageHeader header;
451
452 /**
453 * Queue identifier (used to identify the queue).
454 */
455 uint32_t qid GNUNET_PACKED;
456
457 /**
458 * Receiver that can be addressed via the queue.
459 */
460 struct GNUNET_PeerIdentity receiver;
461
462 /**
463 * An `enum GNUNET_NetworkType` in NBO.
464 */
465 uint32_t nt;
466
467 /**
468 * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
469 */
470 uint32_t mtu;
471
472 /**
473 * Queue length, in NBO. Defines how many messages may be
474 * send through this queue. UINT64_MAX for unlimited.
475 */
476 uint64_t q_len;
477
478 /**
479 * Priority of the queue in relation to other queues.
480 */
481 uint32_t priority;
482
483 /**
484 * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
485 */
486 uint32_t cs;
487};
488
489
490/**
491 * Remove queue, it is no longer available.
492 */
493struct GNUNET_TRANSPORT_DelQueueMessage
494{
495 /**
496 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN.
497 */
498 struct GNUNET_MessageHeader header;
499
500 /**
501 * Address identifier.
502 */
503 uint32_t qid GNUNET_PACKED;
504
505 /**
506 * Receiver that can be addressed via the queue.
507 */
508 struct GNUNET_PeerIdentity receiver;
509};
510
511
512/**
513 * Transport tells communicator that it wants a new queue.
514 */
515struct GNUNET_TRANSPORT_CreateQueue
516{
517 /**
518 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE.
519 */
520 struct GNUNET_MessageHeader header;
521
522 /**
523 * Unique ID for the request.
524 */
525 uint32_t request_id GNUNET_PACKED;
526
527 /**
528 * Receiver that can be addressed via the queue.
529 */
530 struct GNUNET_PeerIdentity receiver;
531
532 /* followed by UTF-8 encoded, 0-terminated human-readable address */
533};
534
535
536/**
537 * Communicator tells transport how queue creation went down.
538 */
539struct GNUNET_TRANSPORT_CreateQueueResponse
540{
541 /**
542 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or
543 * #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL.
544 */
545 struct GNUNET_MessageHeader header;
546
547 /**
548 * Unique ID for the request.
549 */
550 uint32_t request_id GNUNET_PACKED;
551};
552
553
554/**
555 * Inform communicator about transport's desire to send a message.
556 */
557struct GNUNET_TRANSPORT_SendMessageTo
558{
559 /**
560 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG.
561 */
562 struct GNUNET_MessageHeader header;
563
564 /**
565 * Which queue should we use?
566 */
567 uint32_t qid GNUNET_PACKED;
568
569 /**
570 * Message ID, used for flow control.
571 */
572 uint64_t mid GNUNET_PACKED;
573
574 /**
575 * Receiver identifier.
576 */
577 struct GNUNET_PeerIdentity receiver;
578
579 /* followed by the message */
580};
581
582
583/**
584 * Inform transport that message was sent.
585 */
586struct GNUNET_TRANSPORT_SendMessageToAck
587{
588 /**
589 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK.
590 */
591 struct GNUNET_MessageHeader header;
592
593 /**
594 * Success (#GNUNET_OK), failure (#GNUNET_SYSERR).
595 */
596 uint32_t status GNUNET_PACKED;
597
598 /**
599 * Message ID of the original message.
600 */
601 uint64_t mid GNUNET_PACKED;
602
603 /**
604 * Queue ID for the queue which was used to send the message.
605 */
606 uint32_t qid GNUNET_PACKED;
607
608 /**
609 * Receiver identifier.
610 */
611 struct GNUNET_PeerIdentity receiver;
612};
613
614
615/**
616 * Message from communicator to transport service asking for
617 * transmission of a backchannel message with the given peer @e pid
618 * and communicator.
619 */
620struct GNUNET_TRANSPORT_CommunicatorBackchannel
621{
622 /**
623 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
624 */
625 struct GNUNET_MessageHeader header;
626
627 /**
628 * Always zero, for alignment.
629 */
630 uint32_t reserved;
631
632 /**
633 * Target peer.
634 */
635 struct GNUNET_PeerIdentity pid;
636
637 /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
638 message to the communicator */
639
640 /* Followed by the 0-terminated string specifying the desired
641 communicator at the target (@e pid) peer */
642};
643
644
645/**
646 * Message from transport to communicator passing along a backchannel
647 * message from the given peer @e pid.
648 */
649struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
650{
651 /**
652 * Type will be
653 * #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
654 */
655 struct GNUNET_MessageHeader header;
656
657 /**
658 * Always zero, for alignment.
659 */
660 uint32_t reserved;
661
662 /**
663 * Origin peer.
664 */
665 struct GNUNET_PeerIdentity pid;
666
667 /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
668 message to the communicator */
669};
670
671
672/**
673 * Request to start monitoring.
674 */
675struct GNUNET_TRANSPORT_MonitorStart
676{
677 /**
678 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START.
679 */
680 struct GNUNET_MessageHeader header;
681
682 /**
683 * #GNUNET_YES for one-shot montoring, #GNUNET_NO for continuous monitoring.
684 */
685 uint32_t one_shot;
686
687 /**
688 * Target identifier to monitor, all zeros for "all peers".
689 */
690 struct GNUNET_PeerIdentity peer;
691};
692
693
694/**
695 * Monitoring data.
696 */
697struct GNUNET_TRANSPORT_MonitorData
698{
699 /**
700 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA.
701 */
702 struct GNUNET_MessageHeader header;
703
704 /**
705 * Network type (an `enum GNUNET_NetworkType` in NBO).
706 */
707 uint32_t nt GNUNET_PACKED;
708
709 /**
710 * Target identifier.
711 */
712 struct GNUNET_PeerIdentity peer;
713
714 /**
715 * @deprecated To be discussed if we keep these...
716 */
717 struct GNUNET_TIME_AbsoluteNBO last_validation;
718 struct GNUNET_TIME_AbsoluteNBO valid_until;
719 struct GNUNET_TIME_AbsoluteNBO next_validation;
720
721 /**
722 * Current round-trip time estimate.
723 */
724 struct GNUNET_TIME_RelativeNBO rtt;
725
726 /**
727 * Connection status (in NBO).
728 */
729 uint32_t cs GNUNET_PACKED;
730
731 /**
732 * Messages pending (in NBO).
733 */
734 uint32_t num_msg_pending GNUNET_PACKED;
735
736 /**
737 * Bytes pending (in NBO).
738 */
739 uint32_t num_bytes_pending GNUNET_PACKED;
740
741 /* Followed by 0-terminated address of the peer */
742};
743
744
745/**
746 * Request to verify address.
747 */
748struct GNUNET_TRANSPORT_AddressToVerify
749{
750 /**
751 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY.
752 */
753 struct GNUNET_MessageHeader header;
754
755 /**
756 * Reserved. 0.
757 */
758 uint32_t reserved;
759
760 /**
761 * Peer the address is from.
762 */
763 struct GNUNET_PeerIdentity peer;
764
765 /* followed by variable-size raw address */
766};
767
768
769/**
770 * Application client to TRANSPORT service: we would like to have
771 * address suggestions for this peer.
772 */
773struct ExpressPreferenceMessage
774{
775 /**
776 * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST or
777 * #GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL to stop
778 * suggestions.
779 */
780 struct GNUNET_MessageHeader header;
781
782 /**
783 * What type of performance preference does the client have?
784 * A `enum GNUNET_MQ_PreferenceKind` in NBO.
785 */
786 uint32_t pk GNUNET_PACKED;
787
788 /**
789 * Peer to get address suggestions for.
790 */
791 struct GNUNET_PeerIdentity peer;
792
793 /**
794 * How much bandwidth in bytes/second does the application expect?
795 */
796 struct GNUNET_BANDWIDTH_Value32NBO bw;
797};
798
799
800/**
801 * We got an address of another peer, TRANSPORT service
802 * should validate it. There is no response.
803 */
804struct RequestHelloValidationMessage
805{
806 /**
807 * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION.
808 */
809 struct GNUNET_MessageHeader header;
810
811 /**
812 * What type of network does the other peer claim this is?
813 * A `enum GNUNET_NetworkType` in NBO.
814 */
815 uint32_t nt GNUNET_PACKED;
816
817 /**
818 * Peer to the address is presumably for.
819 */
820 struct GNUNET_PeerIdentity peer;
821
822 /* followed by 0-terminated address to validate */
823};
824
825GNUNET_NETWORK_STRUCT_END
826
827/* end of transport.h */
828#endif