seti.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012-2014, 2020 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 set/seti.h
  18. * @brief messages used for the set intersection api
  19. * @author Florian Dold
  20. * @author Christian Grothoff
  21. */
  22. #ifndef SETI_H
  23. #define SETI_H
  24. #include "platform.h"
  25. #include "gnunet_common.h"
  26. #include "gnunet_set_service.h"
  27. GNUNET_NETWORK_STRUCT_BEGIN
  28. /**
  29. * Message sent by the client to the service to ask starting
  30. * a new set to perform operations with.
  31. */
  32. struct GNUNET_SETI_CreateMessage
  33. {
  34. /**
  35. * Type: #GNUNET_MESSAGE_TYPE_SETI_CREATE
  36. */
  37. struct GNUNET_MessageHeader header;
  38. };
  39. /**
  40. * Message sent by the client to the service to start listening for
  41. * incoming requests to perform a certain type of set operation for a
  42. * certain type of application.
  43. */
  44. struct GNUNET_SETI_ListenMessage
  45. {
  46. /**
  47. * Type: #GNUNET_MESSAGE_TYPE_SETI_LISTEN
  48. */
  49. struct GNUNET_MessageHeader header;
  50. /**
  51. * Operation type, values of `enum GNUNET_SETI_OperationType`
  52. */
  53. uint32_t operation GNUNET_PACKED;
  54. /**
  55. * application id
  56. */
  57. struct GNUNET_HashCode app_id;
  58. };
  59. /**
  60. * Message sent by a listening client to the service to accept
  61. * performing the operation with the other peer.
  62. */
  63. struct GNUNET_SETI_AcceptMessage
  64. {
  65. /**
  66. * Type: #GNUNET_MESSAGE_TYPE_SETI_ACCEPT
  67. */
  68. struct GNUNET_MessageHeader header;
  69. /**
  70. * ID of the incoming request we want to accept.
  71. */
  72. uint32_t accept_reject_id GNUNET_PACKED;
  73. /**
  74. * Request ID to identify responses.
  75. */
  76. uint32_t request_id GNUNET_PACKED;
  77. /**
  78. * Return the intersection (1), instead of the elements to
  79. * remove / the delta (0), in NBO.
  80. */
  81. uint32_t return_intersection;
  82. };
  83. /**
  84. * Message sent by a listening client to the service to reject
  85. * performing the operation with the other peer.
  86. */
  87. struct GNUNET_SETI_RejectMessage
  88. {
  89. /**
  90. * Type: #GNUNET_MESSAGE_TYPE_SETI_REJECT
  91. */
  92. struct GNUNET_MessageHeader header;
  93. /**
  94. * ID of the incoming request we want to reject.
  95. */
  96. uint32_t accept_reject_id GNUNET_PACKED;
  97. };
  98. /**
  99. * A request for an operation with another client.
  100. */
  101. struct GNUNET_SETI_RequestMessage
  102. {
  103. /**
  104. * Type: #GNUNET_MESSAGE_TYPE_SETI_REQUEST.
  105. */
  106. struct GNUNET_MessageHeader header;
  107. /**
  108. * ID of the to identify the request when accepting or
  109. * rejecting it.
  110. */
  111. uint32_t accept_id GNUNET_PACKED;
  112. /**
  113. * Identity of the requesting peer.
  114. */
  115. struct GNUNET_PeerIdentity peer_id;
  116. /* rest: context message, that is, application-specific
  117. message to convince listener to pick up */
  118. };
  119. /**
  120. * Message sent by client to service to initiate a set operation as a
  121. * client (not as listener). A set (which determines the operation
  122. * type) must already exist in association with this client.
  123. */
  124. struct GNUNET_SETI_EvaluateMessage
  125. {
  126. /**
  127. * Type: #GNUNET_MESSAGE_TYPE_SETI_EVALUATE
  128. */
  129. struct GNUNET_MessageHeader header;
  130. /**
  131. * Id of our set to evaluate, chosen implicitly by the client when it
  132. * calls #GNUNET_SETI_commit().
  133. */
  134. uint32_t request_id GNUNET_PACKED;
  135. /**
  136. * Peer to evaluate the operation with
  137. */
  138. struct GNUNET_PeerIdentity target_peer;
  139. /**
  140. * Application id
  141. */
  142. struct GNUNET_HashCode app_id;
  143. /**
  144. * Return the intersection (1), instead of the elements to
  145. * remove / the delta (0), in NBO.
  146. */
  147. uint32_t return_intersection;
  148. /* rest: context message, that is, application-specific
  149. message to convince listener to pick up */
  150. };
  151. /**
  152. * Message sent by the service to the client to indicate an
  153. * element that is removed (set intersection) or added
  154. * (set union) or part of the final result, depending on
  155. * options specified for the operation.
  156. */
  157. struct GNUNET_SETI_ResultMessage
  158. {
  159. /**
  160. * Type: #GNUNET_MESSAGE_TYPE_SETI_RESULT
  161. */
  162. struct GNUNET_MessageHeader header;
  163. /**
  164. * Current set size.
  165. */
  166. uint64_t current_size;
  167. /**
  168. * id the result belongs to
  169. */
  170. uint32_t request_id GNUNET_PACKED;
  171. /**
  172. * Was the evaluation successful? Contains
  173. * an `enum GNUNET_SETI_Status` in NBO.
  174. */
  175. uint16_t result_status GNUNET_PACKED;
  176. /**
  177. * Type of the element attachted to the message, if any.
  178. */
  179. uint16_t element_type GNUNET_PACKED;
  180. /* rest: the actual element */
  181. };
  182. /**
  183. * Message sent by client to the service to add an element to the set.
  184. */
  185. struct GNUNET_SETI_ElementMessage
  186. {
  187. /**
  188. * Type: #GNUNET_MESSAGE_TYPE_SETI_ADD.
  189. */
  190. struct GNUNET_MessageHeader header;
  191. /**
  192. * Type of the element to add or remove.
  193. */
  194. uint16_t element_type GNUNET_PACKED;
  195. /**
  196. * For alignment, always zero.
  197. */
  198. uint16_t reserved GNUNET_PACKED;
  199. /* rest: the actual element */
  200. };
  201. /**
  202. * Sent to the service by the client
  203. * in order to cancel a set operation.
  204. */
  205. struct GNUNET_SETI_CancelMessage
  206. {
  207. /**
  208. * Type: #GNUNET_MESSAGE_TYPE_SETI_CANCEL
  209. */
  210. struct GNUNET_MessageHeader header;
  211. /**
  212. * ID of the request we want to cancel.
  213. */
  214. uint32_t request_id GNUNET_PACKED;
  215. };
  216. GNUNET_NETWORK_STRUCT_END
  217. #endif