set.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012-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 set/set.h
  18. * @brief messages used for the set api
  19. * @author Florian Dold
  20. * @author Christian Grothoff
  21. */
  22. #ifndef SET_H
  23. #define SET_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. Includes the desired
  31. * set operation type.
  32. */
  33. struct GNUNET_SET_CreateMessage
  34. {
  35. /**
  36. * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE
  37. */
  38. struct GNUNET_MessageHeader header;
  39. /**
  40. * Operation type, values of `enum GNUNET_SET_OperationType`
  41. */
  42. uint32_t operation GNUNET_PACKED;
  43. };
  44. /**
  45. * Message sent by the client to the service to start listening for
  46. * incoming requests to perform a certain type of set operation for a
  47. * certain type of application.
  48. */
  49. struct GNUNET_SET_ListenMessage
  50. {
  51. /**
  52. * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN
  53. */
  54. struct GNUNET_MessageHeader header;
  55. /**
  56. * Operation type, values of `enum GNUNET_SET_OperationType`
  57. */
  58. uint32_t operation GNUNET_PACKED;
  59. /**
  60. * application id
  61. */
  62. struct GNUNET_HashCode app_id;
  63. };
  64. /**
  65. * Message sent by a listening client to the service to accept
  66. * performing the operation with the other peer.
  67. */
  68. struct GNUNET_SET_AcceptMessage
  69. {
  70. /**
  71. * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT
  72. */
  73. struct GNUNET_MessageHeader header;
  74. /**
  75. * ID of the incoming request we want to accept.
  76. */
  77. uint32_t accept_reject_id GNUNET_PACKED;
  78. /**
  79. * Request ID to identify responses.
  80. */
  81. uint32_t request_id GNUNET_PACKED;
  82. /**
  83. * How should results be sent to us?
  84. * See `enum GNUNET_SET_ResultMode`.
  85. */
  86. uint32_t result_mode GNUNET_PACKED;
  87. /**
  88. * Always use delta operation instead of sending full sets,
  89. * even it it's less efficient.
  90. */
  91. uint8_t force_delta;
  92. /**
  93. * Always send full sets, even if delta operations would
  94. * be more efficient.
  95. */
  96. uint8_t force_full;
  97. /**
  98. * #GNUNET_YES to fail operations where Byzantine faults
  99. * are suspected
  100. */
  101. uint8_t byzantine;
  102. /**
  103. * Lower bound for the set size, used only when
  104. * byzantine mode is enabled.
  105. */
  106. uint8_t byzantine_lower_bound;
  107. };
  108. /**
  109. * Message sent by a listening client to the service to reject
  110. * performing the operation with the other peer.
  111. */
  112. struct GNUNET_SET_RejectMessage
  113. {
  114. /**
  115. * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT
  116. */
  117. struct GNUNET_MessageHeader header;
  118. /**
  119. * ID of the incoming request we want to reject.
  120. */
  121. uint32_t accept_reject_id GNUNET_PACKED;
  122. };
  123. /**
  124. * A request for an operation with another client.
  125. */
  126. struct GNUNET_SET_RequestMessage
  127. {
  128. /**
  129. * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST.
  130. */
  131. struct GNUNET_MessageHeader header;
  132. /**
  133. * ID of the to identify the request when accepting or
  134. * rejecting it.
  135. */
  136. uint32_t accept_id GNUNET_PACKED;
  137. /**
  138. * Identity of the requesting peer.
  139. */
  140. struct GNUNET_PeerIdentity peer_id;
  141. /* rest: context message, that is, application-specific
  142. message to convince listener to pick up */
  143. };
  144. /**
  145. * Message sent by client to service to initiate a set operation as a
  146. * client (not as listener). A set (which determines the operation
  147. * type) must already exist in association with this client.
  148. */
  149. struct GNUNET_SET_EvaluateMessage
  150. {
  151. /**
  152. * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
  153. */
  154. struct GNUNET_MessageHeader header;
  155. /**
  156. * How should results be sent to us?
  157. * See `enum GNUNET_SET_ResultMode`.
  158. */
  159. uint32_t result_mode GNUNET_PACKED;
  160. /**
  161. * Peer to evaluate the operation with
  162. */
  163. struct GNUNET_PeerIdentity target_peer;
  164. /**
  165. * Application id
  166. */
  167. struct GNUNET_HashCode app_id;
  168. /**
  169. * Id of our set to evaluate, chosen implicitly by the client when it
  170. * calls #GNUNET_SET_commit().
  171. */
  172. uint32_t request_id GNUNET_PACKED;
  173. /**
  174. * Always use delta operation instead of sending full sets,
  175. * even it it's less efficient.
  176. */
  177. uint8_t force_delta;
  178. /**
  179. * Always send full sets, even if delta operations would
  180. * be more efficient.
  181. */
  182. uint8_t force_full;
  183. /**
  184. * #GNUNET_YES to fail operations where Byzantine faults
  185. * are suspected
  186. */
  187. uint8_t byzantine;
  188. /**
  189. * Lower bound for the set size, used only when
  190. * byzantine mode is enabled.
  191. */
  192. uint8_t byzantine_lower_bound;
  193. /* rest: context message, that is, application-specific
  194. message to convince listener to pick up */
  195. };
  196. /**
  197. * Message sent by the service to the client to indicate an
  198. * element that is removed (set intersection) or added
  199. * (set union) or part of the final result, depending on
  200. * options specified for the operation.
  201. */
  202. struct GNUNET_SET_ResultMessage
  203. {
  204. /**
  205. * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT
  206. */
  207. struct GNUNET_MessageHeader header;
  208. /**
  209. * Current set size.
  210. */
  211. uint64_t current_size;
  212. /**
  213. * id the result belongs to
  214. */
  215. uint32_t request_id GNUNET_PACKED;
  216. /**
  217. * Was the evaluation successful? Contains
  218. * an `enum GNUNET_SET_Status` in NBO.
  219. */
  220. uint16_t result_status GNUNET_PACKED;
  221. /**
  222. * Type of the element attachted to the message, if any.
  223. */
  224. uint16_t element_type GNUNET_PACKED;
  225. /* rest: the actual element */
  226. };
  227. /**
  228. * Message sent by client to the service to add or remove
  229. * an element to/from the set.
  230. */
  231. struct GNUNET_SET_ElementMessage
  232. {
  233. /**
  234. * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
  235. * #GNUNET_MESSAGE_TYPE_SET_REMOVE
  236. */
  237. struct GNUNET_MessageHeader header;
  238. /**
  239. * Type of the element to add or remove.
  240. */
  241. uint16_t element_type GNUNET_PACKED;
  242. /**
  243. * For alignment, always zero.
  244. */
  245. uint16_t reserved GNUNET_PACKED;
  246. /* rest: the actual element */
  247. };
  248. /**
  249. * Sent to the service by the client
  250. * in order to cancel a set operation.
  251. */
  252. struct GNUNET_SET_CancelMessage
  253. {
  254. /**
  255. * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
  256. */
  257. struct GNUNET_MessageHeader header;
  258. /**
  259. * ID of the request we want to cancel.
  260. */
  261. uint32_t request_id GNUNET_PACKED;
  262. };
  263. /**
  264. * Set element transmitted by service to client in response to a set
  265. * iteration request.
  266. */
  267. struct GNUNET_SET_IterResponseMessage
  268. {
  269. /**
  270. * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT
  271. */
  272. struct GNUNET_MessageHeader header;
  273. /**
  274. * To which set iteration does this reponse belong to? First
  275. * iteration (per client) has counter zero. Wraps around.
  276. */
  277. uint16_t iteration_id GNUNET_PACKED;
  278. /**
  279. * Type of the element attachted to the message,
  280. * if any.
  281. */
  282. uint16_t element_type GNUNET_PACKED;
  283. /* rest: element */
  284. };
  285. /**
  286. * Client acknowledges receiving element in iteration.
  287. */
  288. struct GNUNET_SET_IterAckMessage
  289. {
  290. /**
  291. * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
  292. */
  293. struct GNUNET_MessageHeader header;
  294. /**
  295. * Non-zero if the service should continue sending elements.
  296. */
  297. uint32_t send_more;
  298. };
  299. /**
  300. * Server responds to a lazy copy request.
  301. */
  302. struct GNUNET_SET_CopyLazyResponseMessage
  303. {
  304. /**
  305. * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE
  306. */
  307. struct GNUNET_MessageHeader header;
  308. /**
  309. * Temporary name for the copied set.
  310. */
  311. uint32_t cookie;
  312. };
  313. /**
  314. * Client connects to a lazily copied set.
  315. */
  316. struct GNUNET_SET_CopyLazyConnectMessage
  317. {
  318. /**
  319. * Type: #GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT
  320. */
  321. struct GNUNET_MessageHeader header;
  322. /**
  323. * Temporary name for the copied set.
  324. */
  325. uint32_t cookie;
  326. };
  327. GNUNET_NETWORK_STRUCT_END
  328. #endif