gnunet-service-setu_protocol.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2013, 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. * @author Florian Dold
  18. * @author Christian Grothoff
  19. * @file set/gnunet-service-set_protocol.h
  20. * @brief Peer-to-Peer messages for gnunet set
  21. */
  22. #ifndef SET_PROTOCOL_H
  23. #define SET_PROTOCOL_H
  24. #include "platform.h"
  25. #include "gnunet_common.h"
  26. GNUNET_NETWORK_STRUCT_BEGIN
  27. struct OperationRequestMessage
  28. {
  29. /**
  30. * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
  31. */
  32. struct GNUNET_MessageHeader header;
  33. /**
  34. * Operation to request, values from `enum GNUNET_SET_OperationType`
  35. */
  36. uint32_t operation GNUNET_PACKED;
  37. /**
  38. * For Intersection: my element count
  39. */
  40. uint32_t element_count GNUNET_PACKED;
  41. /**
  42. * Application-specific identifier of the request.
  43. */
  44. struct GNUNET_HashCode app_idX;
  45. /* rest: optional message */
  46. };
  47. /**
  48. * Message containing buckets of an invertible bloom filter.
  49. *
  50. * If an IBF has too many buckets for an IBF message,
  51. * it is split into multiple messages.
  52. */
  53. struct IBFMessage
  54. {
  55. /**
  56. * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF
  57. */
  58. struct GNUNET_MessageHeader header;
  59. /**
  60. * Order of the whole ibf, where
  61. * num_buckets = 2^order
  62. */
  63. uint8_t order;
  64. /**
  65. * Padding, must be 0.
  66. */
  67. uint8_t reserved1;
  68. /**
  69. * Padding, must be 0.
  70. */
  71. uint16_t reserved2 GNUNET_PACKED;
  72. /**
  73. * Offset of the strata in the rest of the message
  74. */
  75. uint32_t offset GNUNET_PACKED;
  76. /**
  77. * Salt used when hashing elements for this IBF.
  78. */
  79. uint32_t salt GNUNET_PACKED;
  80. /* rest: buckets */
  81. };
  82. struct InquiryMessage
  83. {
  84. /**
  85. * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF
  86. */
  87. struct GNUNET_MessageHeader header;
  88. /**
  89. * Salt used when hashing elements for this inquiry.
  90. */
  91. uint32_t salt GNUNET_PACKED;
  92. /**
  93. * Reserved, set to 0.
  94. */
  95. uint32_t reserved GNUNET_PACKED;
  96. /* rest: inquiry IBF keys */
  97. };
  98. /**
  99. * During intersection, the first (and possibly second) message
  100. * send it the number of elements in the set, to allow the peers
  101. * to decide who should start with the Bloom filter.
  102. */
  103. struct IntersectionElementInfoMessage
  104. {
  105. /**
  106. * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO
  107. */
  108. struct GNUNET_MessageHeader header;
  109. /**
  110. * mutator used with this bloomfilter.
  111. */
  112. uint32_t sender_element_count GNUNET_PACKED;
  113. };
  114. /**
  115. * Bloom filter messages exchanged for set intersection calculation.
  116. */
  117. struct BFMessage
  118. {
  119. /**
  120. * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF
  121. */
  122. struct GNUNET_MessageHeader header;
  123. /**
  124. * Number of elements the sender still has in the set.
  125. */
  126. uint32_t sender_element_count GNUNET_PACKED;
  127. /**
  128. * XOR of all hashes over all elements remaining in the set.
  129. * Used to determine termination.
  130. */
  131. struct GNUNET_HashCode element_xor_hash;
  132. /**
  133. * Mutator used with this bloomfilter.
  134. */
  135. uint32_t sender_mutator GNUNET_PACKED;
  136. /**
  137. * Total length of the bloomfilter data.
  138. */
  139. uint32_t bloomfilter_total_length GNUNET_PACKED;
  140. /**
  141. * Number of bits (k-value) used in encoding the bloomfilter.
  142. */
  143. uint32_t bits_per_element GNUNET_PACKED;
  144. /**
  145. * rest: the sender's bloomfilter
  146. */
  147. };
  148. /**
  149. * Last message, send to confirm the final set. Contains the element
  150. * count as it is possible that the peer determined that we were done
  151. * by getting the empty set, which in that case also needs to be
  152. * communicated.
  153. */
  154. struct IntersectionDoneMessage
  155. {
  156. /**
  157. * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE
  158. */
  159. struct GNUNET_MessageHeader header;
  160. /**
  161. * Final number of elements in intersection.
  162. */
  163. uint32_t final_element_count GNUNET_PACKED;
  164. /**
  165. * XOR of all hashes over all elements remaining in the set.
  166. */
  167. struct GNUNET_HashCode element_xor_hash;
  168. };
  169. /**
  170. * Strata estimator together with the peer's overall set size.
  171. */
  172. struct StrataEstimatorMessage
  173. {
  174. /**
  175. * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE(C)
  176. */
  177. struct GNUNET_MessageHeader header;
  178. uint64_t set_size;
  179. };
  180. GNUNET_NETWORK_STRUCT_END
  181. #endif