communicator.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2014 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file transport/communicator.h
  18. * @brief common internal definitions for communicator services
  19. * @author Christian Grothoff
  20. */
  21. #ifndef COMMUNICATOR_H
  22. #define COMMUNICAOTR_H
  23. #include "gnunet_util_lib.h"
  24. #include "gnunet_protocols.h"
  25. GNUNET_NETWORK_STRUCT_BEGIN
  26. /**
  27. * Message used to tell a communicator about a successful
  28. * key exchange.
  29. *
  30. * Note that this style of KX acknowledgement typically only applies
  31. * for communicators where the underlying network protocol is
  32. * unidirectional and/or lacks cryptography. Furthermore, this is
  33. * just the recommended "generic" style, communicators are always free
  34. * to implement original designs that better fit their requirements.
  35. */
  36. struct GNUNET_TRANSPORT_CommunicatorGenericKXConfirmation
  37. {
  38. /**
  39. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_KX_CONFIRMATION
  40. */
  41. struct GNUNET_MessageHeader header;
  42. /**
  43. * Timestamp from the original sender which identifies the original KX.
  44. */
  45. struct GNUNET_TIME_AbsoluteNBO monotonic_time;
  46. /**
  47. * How long does the receiver of the KX believe that the address
  48. * on which the KX was received will continue to be valid.
  49. */
  50. struct GNUNET_TIME_RelativeNBO validity;
  51. /**
  52. * Hash of the shared secret. Specific hash function may depend on
  53. * the communicator's protocol details.
  54. */
  55. struct GNUNET_HashCode token;
  56. };
  57. /**
  58. * Message used to tell a communicator about the receiver's
  59. * flow control limits and to acknowledge receipt of certain
  60. * messages.
  61. *
  62. * Note that a sender MAY choose to violate the flow-control
  63. * limits provided in this message by a receiver, which may
  64. * result in messages being lost (after all, transport is an
  65. * unreliable channel). So if the sender violates these
  66. * constraints, it should expect that the receive will simply
  67. * discard the (partially) received "old" messages.
  68. *
  69. * This way, if a sender or receiver crashes, there is no protocol
  70. * violation.
  71. *
  72. * Note that this style of flow control typically only applies
  73. * for communicators where the underlying network protocol does
  74. * not already implement flow control. Furthermore, this is
  75. * just the recommended "generic" style, communicators are always
  76. * free to implement original designs that better fit their
  77. * requirements.
  78. */
  79. struct GNUNET_TRANSPORT_CommunicatorGenericFCLimits
  80. {
  81. /**
  82. * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_FC_LIMITS
  83. */
  84. struct GNUNET_MessageHeader header;
  85. /**
  86. * Maximum number of messages beyond the acknowledged message
  87. * number that can still be transmitted concurrently without
  88. * further acknowledgements.
  89. */
  90. uint32_t msg_window_size;
  91. /**
  92. * Up to which message number were all messages received.
  93. */
  94. uint64_t msg_cummulative_ack;
  95. /**
  96. * Maximum number of payload bytes beyond the acknowledged
  97. * number of bytes can still be transmitted without further
  98. * acknowledgements.
  99. */
  100. uint64_t bytes_window_size;
  101. /**
  102. * Cumulative acknowledgement for number of bytes received.
  103. */
  104. uint64_t bytes_cummulative_ack;
  105. /**
  106. * Followed by a variable-size bitfield for messages received
  107. * beyond @e msg_cummulative_ack. Index at offset 0 must thus
  108. * be zero, otherwise @e msg_cummulative_ack should be
  109. * increased. Note that this field can be overall of 0 bytes.
  110. * The variable-size bitfield must be a multiple of 64 bits
  111. * long.
  112. */
  113. /* uint64_t msg_selective_ack_field[]; */
  114. };
  115. GNUNET_NETWORK_STRUCT_END
  116. /* end of communicator.h */
  117. #endif