You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

521 lines
9.2 KiB

  1. /*
  2. * This file is part of GNUnet
  3. * Copyright (C) 2013 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. SPDX-License-Identifier: AGPL3.0-or-later
  18. */
  19. /**
  20. * @file psycstore/psycstore.h
  21. * @brief Common type definitions for the PSYCstore service and API.
  22. * @author Gabor X Toth
  23. */
  24. #ifndef GNUNET_PSYCSTORE_H
  25. #define GNUNET_PSYCSTORE_H
  26. #include "gnunet_common.h"
  27. GNUNET_NETWORK_STRUCT_BEGIN
  28. /**
  29. * Answer from service to client about last operation.
  30. */
  31. struct OperationResult
  32. {
  33. /**
  34. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
  35. */
  36. struct GNUNET_MessageHeader header;
  37. uint32_t reserved GNUNET_PACKED;
  38. /**
  39. * Operation ID.
  40. */
  41. uint64_t op_id GNUNET_PACKED;
  42. /**lowed by
  43. * Status code for the operation.
  44. */
  45. uint64_t result_code GNUNET_PACKED;
  46. /* followed by 0-terminated error message (on error) */
  47. };
  48. /**
  49. * Answer from service to client about master counters.
  50. *
  51. * @see GNUNET_PSYCSTORE_counters_get()
  52. */
  53. struct CountersResult
  54. {
  55. /**
  56. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS
  57. */
  58. struct GNUNET_MessageHeader header;
  59. /**
  60. * Status code for the operation:
  61. * #GNUNET_OK: success, counter values are returned.
  62. * #GNUNET_NO: no message has been sent to the channel yet.
  63. * #GNUNET_SYSERR: an error occurred.
  64. */
  65. uint32_t result_code GNUNET_PACKED;
  66. /**
  67. * Operation ID.
  68. */
  69. uint64_t op_id GNUNET_PACKED;
  70. uint64_t max_fragment_id GNUNET_PACKED;
  71. uint64_t max_message_id GNUNET_PACKED;
  72. uint64_t max_group_generation GNUNET_PACKED;
  73. uint64_t max_state_message_id GNUNET_PACKED;
  74. };
  75. /**
  76. * Answer from service to client containing a message fragment.
  77. */
  78. struct FragmentResult
  79. {
  80. /**
  81. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
  82. */
  83. struct GNUNET_MessageHeader header;
  84. uint32_t psycstore_flags GNUNET_PACKED;
  85. /**
  86. * Operation ID.
  87. */
  88. uint64_t op_id GNUNET_PACKED;
  89. /* Followed by GNUNET_MULTICAST_MessageHeader */
  90. };
  91. /**
  92. * Answer from service to client containing a state variable.
  93. */
  94. struct StateResult
  95. {
  96. /**
  97. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
  98. */
  99. struct GNUNET_MessageHeader header;
  100. uint16_t name_size GNUNET_PACKED;
  101. uint16_t reserved GNUNET_PACKED;
  102. /**
  103. * Operation ID.
  104. */
  105. uint64_t op_id GNUNET_PACKED;
  106. /* Followed by name and value */
  107. };
  108. /**
  109. * Generic operation request.
  110. */
  111. struct OperationRequest
  112. {
  113. struct GNUNET_MessageHeader header;
  114. uint32_t reserved GNUNET_PACKED;
  115. /**
  116. * Operation ID.
  117. */
  118. uint64_t op_id GNUNET_PACKED;
  119. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  120. };
  121. /**
  122. * @see GNUNET_PSYCSTORE_membership_store()
  123. */
  124. struct MembershipStoreRequest
  125. {
  126. /**
  127. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE
  128. */
  129. struct GNUNET_MessageHeader header;
  130. uint32_t reserved GNUNET_PACKED;
  131. /**
  132. * Operation ID.
  133. */
  134. uint64_t op_id GNUNET_PACKED;
  135. /**
  136. * Channel's public key.
  137. */
  138. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  139. /**
  140. * Slave's public key.
  141. */
  142. struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
  143. uint64_t announced_at GNUNET_PACKED;
  144. uint64_t effective_since GNUNET_PACKED;
  145. uint64_t group_generation GNUNET_PACKED;
  146. uint8_t did_join;
  147. };
  148. /**
  149. * @see GNUNET_PSYCSTORE_membership_test()
  150. */
  151. struct MembershipTestRequest
  152. {
  153. /**
  154. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST
  155. */
  156. struct GNUNET_MessageHeader header;
  157. uint32_t reserved GNUNET_PACKED;
  158. /**
  159. * Operation ID.
  160. */
  161. uint64_t op_id GNUNET_PACKED;
  162. /**
  163. * Channel's public key.
  164. */
  165. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  166. /**
  167. * Slave's public key.
  168. */
  169. struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
  170. uint64_t message_id GNUNET_PACKED;
  171. uint64_t group_generation GNUNET_PACKED;
  172. };
  173. /**
  174. * @see GNUNET_PSYCSTORE_fragment_store()
  175. */
  176. struct FragmentStoreRequest
  177. {
  178. /**
  179. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE
  180. */
  181. struct GNUNET_MessageHeader header;
  182. /**
  183. * enum GNUNET_PSYCSTORE_MessageFlags
  184. */
  185. uint32_t psycstore_flags GNUNET_PACKED;
  186. /**
  187. * Channel's public key.
  188. */
  189. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  190. /**
  191. * Operation ID.
  192. */
  193. uint64_t op_id;
  194. /* Followed by fragment */
  195. };
  196. /**
  197. * @see GNUNET_PSYCSTORE_fragment_get()
  198. */
  199. struct FragmentGetRequest
  200. {
  201. /**
  202. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET
  203. */
  204. struct GNUNET_MessageHeader header;
  205. uint32_t reserved GNUNET_PACKED;
  206. /**
  207. * Operation ID.
  208. */
  209. uint64_t op_id GNUNET_PACKED;
  210. /**
  211. * Channel's public key.
  212. */
  213. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  214. /**
  215. * Slave's public key.
  216. */
  217. struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
  218. /**
  219. * First fragment ID to request.
  220. */
  221. uint64_t first_fragment_id GNUNET_PACKED;
  222. /**
  223. * Last fragment ID to request.
  224. */
  225. uint64_t last_fragment_id GNUNET_PACKED;
  226. /**
  227. * Maximum number of fragments to retrieve.
  228. */
  229. uint64_t fragment_limit GNUNET_PACKED;
  230. /**
  231. * Do membership test with @a slave_key before returning fragment?
  232. * #GNUNET_YES or #GNUNET_NO
  233. */
  234. uint8_t do_membership_test;
  235. };
  236. /**
  237. * @see GNUNET_PSYCSTORE_message_get()
  238. */
  239. struct MessageGetRequest
  240. {
  241. /**
  242. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET
  243. */
  244. struct GNUNET_MessageHeader header;
  245. uint32_t reserved GNUNET_PACKED;
  246. /**
  247. * Operation ID.
  248. */
  249. uint64_t op_id GNUNET_PACKED;
  250. /**
  251. * Channel's public key.
  252. */
  253. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  254. /**
  255. * Slave's public key.
  256. */
  257. struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
  258. /**
  259. * First message ID to request.
  260. */
  261. uint64_t first_message_id GNUNET_PACKED;
  262. /**
  263. * Last message ID to request.
  264. */
  265. uint64_t last_message_id GNUNET_PACKED;
  266. /**
  267. * Maximum number of messages to retrieve.
  268. */
  269. uint64_t message_limit GNUNET_PACKED;
  270. /**
  271. * Maximum number of fragments to retrieve.
  272. */
  273. uint64_t fragment_limit GNUNET_PACKED;
  274. /**
  275. * Do membership test with @a slave_key before returning fragment?
  276. * #GNUNET_YES or #GNUNET_NO
  277. */
  278. uint8_t do_membership_test;
  279. /* Followed by method_prefix */
  280. };
  281. /**
  282. * @see GNUNET_PSYCSTORE_message_get_fragment()
  283. */
  284. struct MessageGetFragmentRequest
  285. {
  286. /**
  287. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_FRAGMENT_GET
  288. */
  289. struct GNUNET_MessageHeader header;
  290. uint32_t reserved GNUNET_PACKED;
  291. /**
  292. * Operation ID.
  293. */
  294. uint64_t op_id GNUNET_PACKED;
  295. /**
  296. * Channel's public key.
  297. */
  298. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  299. /**
  300. * Slave's public key.
  301. */
  302. struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
  303. /**
  304. * Requested message ID.
  305. */
  306. uint64_t message_id GNUNET_PACKED;
  307. /**
  308. * Requested fragment offset.
  309. */
  310. uint64_t fragment_offset GNUNET_PACKED;
  311. /**
  312. * Do membership test with @a slave_key before returning fragment?
  313. * #GNUNET_YES or #GNUNET_NO
  314. */
  315. uint8_t do_membership_test;
  316. };
  317. /**
  318. * @see GNUNET_PSYCSTORE_state_hash_update()
  319. */
  320. struct StateHashUpdateRequest
  321. {
  322. /**
  323. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE
  324. */
  325. struct GNUNET_MessageHeader header;
  326. uint32_t reserved GNUNET_PACKED;
  327. /**
  328. * Operation ID.
  329. */
  330. uint64_t op_id GNUNET_PACKED;
  331. /**
  332. * Channel's public key.
  333. */
  334. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  335. struct GNUNET_HashCode hash;
  336. };
  337. enum StateOpFlags
  338. {
  339. STATE_OP_FIRST = 1 << 0,
  340. STATE_OP_LAST = 1 << 1
  341. };
  342. /**
  343. * @see GNUNET_PSYCSTORE_state_modify()
  344. */
  345. struct StateModifyRequest
  346. {
  347. /**
  348. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY
  349. */
  350. struct GNUNET_MessageHeader header;
  351. /**
  352. * Operation ID.
  353. */
  354. uint64_t op_id GNUNET_PACKED;
  355. /**
  356. * ID of the message to apply the state changes in.
  357. */
  358. uint64_t message_id GNUNET_PACKED;
  359. /**
  360. * State delta of the message with ID @a message_id.
  361. */
  362. uint64_t state_delta GNUNET_PACKED;
  363. /**
  364. * Channel's public key.
  365. */
  366. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  367. };
  368. /**
  369. * @see GNUNET_PSYCSTORE_state_sync()
  370. */
  371. struct StateSyncRequest
  372. {
  373. /**
  374. * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC
  375. */
  376. struct GNUNET_MessageHeader header;
  377. /**
  378. * Size of name, including NUL terminator.
  379. */
  380. uint16_t name_size GNUNET_PACKED;
  381. /**
  382. * OR'd StateOpFlags
  383. */
  384. uint8_t flags;
  385. uint8_t reserved;
  386. /**
  387. * Operation ID.
  388. */
  389. uint64_t op_id GNUNET_PACKED;
  390. /**
  391. * ID of the message that contains the state_hash PSYC header variable.
  392. */
  393. uint64_t state_hash_message_id GNUNET_PACKED;
  394. /**
  395. * ID of the last stateful message before @a state_hash_message_id.
  396. */
  397. uint64_t max_state_message_id GNUNET_PACKED;
  398. /**
  399. * Channel's public key.
  400. */
  401. struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
  402. /* Followed by NUL-terminated name, then the value. */
  403. };
  404. GNUNET_NETWORK_STRUCT_END
  405. #endif