gnunet_psycstore_plugin.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Gabor X Toth
  19. *
  20. * @file
  21. * Plugin API for the PSYCstore database backend
  22. *
  23. * @defgroup psycstore-plugin PSYC Store plugin API
  24. * Plugin API for the PSYC Store database backend
  25. * @{
  26. */
  27. #ifndef GNUNET_PSYCSTORE_PLUGIN_H
  28. #define GNUNET_PSYCSTORE_PLUGIN_H
  29. #include "gnunet_util_lib.h"
  30. #include "gnunet_psycstore_service.h"
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. /**
  39. * Struct returned by the initialization function of the plugin.
  40. */
  41. struct GNUNET_PSYCSTORE_PluginFunctions
  42. {
  43. /**
  44. * Closure to pass to all plugin functions.
  45. */
  46. void *cls;
  47. /**
  48. * Store join/leave events for a PSYC channel in order to be able to answer
  49. * membership test queries later.
  50. *
  51. * @see GNUNET_PSYCSTORE_membership_store()
  52. *
  53. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  54. */
  55. int
  56. (*membership_store) (void *cls,
  57. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  58. const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
  59. int did_join,
  60. uint64_t announced_at,
  61. uint64_t effective_since,
  62. uint64_t group_generation);
  63. /**
  64. * Test if a member was admitted to the channel at the given message ID.
  65. *
  66. * @see GNUNET_PSYCSTORE_membership_test()
  67. *
  68. * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
  69. * #GNUNET_SYSERR if there was en error.
  70. */
  71. int
  72. (*membership_test) (void *cls,
  73. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  74. const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
  75. uint64_t message_id);
  76. /**
  77. * Store a message fragment sent to a channel.
  78. *
  79. * @see GNUNET_PSYCSTORE_fragment_store()
  80. *
  81. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  82. */
  83. int
  84. (*fragment_store) (void *cls,
  85. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  86. const struct GNUNET_MULTICAST_MessageHeader *message,
  87. uint32_t psycstore_flags);
  88. /**
  89. * Set additional flags for a given message.
  90. *
  91. * They are OR'd with any existing flags set.
  92. *
  93. * @param cls Closure.
  94. * @param channel_key Public key of the channel.
  95. * @param message_id ID of the message.
  96. * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
  97. *
  98. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  99. */
  100. int
  101. (*message_add_flags) (void *cls,
  102. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  103. uint64_t message_id,
  104. uint64_t psycstore_flags);
  105. /**
  106. * Retrieve a message fragment range by fragment ID.
  107. *
  108. * @see GNUNET_PSYCSTORE_fragment_get()
  109. *
  110. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  111. */
  112. int
  113. (*fragment_get) (void *cls,
  114. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  115. uint64_t first_fragment_id,
  116. uint64_t last_fragment_id,
  117. uint64_t *returned_fragments,
  118. GNUNET_PSYCSTORE_FragmentCallback cb,
  119. void *cb_cls);
  120. /**
  121. * Retrieve latest message fragments.
  122. *
  123. * @see GNUNET_PSYCSTORE_fragment_get()
  124. *
  125. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  126. */
  127. int
  128. (*fragment_get_latest) (void *cls,
  129. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  130. uint64_t fragment_limit,
  131. uint64_t *returned_fragments,
  132. GNUNET_PSYCSTORE_FragmentCallback cb,
  133. void *cb_cls);
  134. /**
  135. * Retrieve all fragments of a message ID range.
  136. *
  137. * @see GNUNET_PSYCSTORE_message_get()
  138. *
  139. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  140. */
  141. int
  142. (*message_get) (void *cls,
  143. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  144. uint64_t first_fragment_id,
  145. uint64_t last_fragment_id,
  146. uint64_t fragment_limit,
  147. uint64_t *returned_fragments,
  148. GNUNET_PSYCSTORE_FragmentCallback cb,
  149. void *cb_cls);
  150. /**
  151. * Retrieve all fragments of the latest messages.
  152. *
  153. * @see GNUNET_PSYCSTORE_message_get()
  154. *
  155. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  156. */
  157. int
  158. (*message_get_latest) (void *cls,
  159. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  160. uint64_t fragment_limit,
  161. uint64_t *returned_fragments,
  162. GNUNET_PSYCSTORE_FragmentCallback cb,
  163. void *cb_cls);
  164. /**
  165. * Retrieve a fragment of message specified by its message ID and fragment
  166. * offset.
  167. *
  168. * @see GNUNET_PSYCSTORE_message_get_fragment()
  169. *
  170. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  171. */
  172. int
  173. (*message_get_fragment) (void *cls,
  174. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  175. uint64_t message_id,
  176. uint64_t fragment_offset,
  177. GNUNET_PSYCSTORE_FragmentCallback cb,
  178. void *cb_cls);
  179. /**
  180. * Retrieve the max. values of message counters for a channel.
  181. *
  182. * @see GNUNET_PSYCSTORE_counters_get()
  183. *
  184. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  185. */
  186. int
  187. (*counters_message_get) (void *cls,
  188. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  189. uint64_t *max_fragment_id,
  190. uint64_t *max_message_id,
  191. uint64_t *max_group_generation);
  192. /**
  193. * Retrieve the max. values of state counters for a channel.
  194. *
  195. * @see GNUNET_PSYCSTORE_counters_get()
  196. *
  197. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  198. */
  199. int
  200. (*counters_state_get) (void *cls,
  201. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  202. uint64_t *max_state_message_id);
  203. /**
  204. * Begin modifying current state.
  205. *
  206. * @see GNUNET_PSYCSTORE_state_modify()
  207. *
  208. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  209. */
  210. int
  211. (*state_modify_begin) (void *cls,
  212. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  213. uint64_t message_id, uint64_t state_delta);
  214. /**
  215. * Set the current value of a state variable.
  216. *
  217. * The state modification process is started with state_modify_begin(),
  218. * which is followed by one or more calls to this function,
  219. * and finished with state_modify_end().
  220. *
  221. * @see GNUNET_PSYCSTORE_state_modify()
  222. *
  223. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  224. */
  225. int
  226. (*state_modify_op) (void *cls,
  227. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  228. enum GNUNET_ENV_Operator op,
  229. const char *name, const void *value, size_t value_size);
  230. /**
  231. * End modifying current state.
  232. *
  233. * @see GNUNET_PSYCSTORE_state_modify()
  234. *
  235. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  236. */
  237. int
  238. (*state_modify_end) (void *cls,
  239. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  240. uint64_t message_id);
  241. /**
  242. * Begin synchronizing state.
  243. *
  244. * @see GNUNET_PSYCSTORE_state_sync()
  245. *
  246. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  247. */
  248. int
  249. (*state_sync_begin) (void *cls,
  250. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
  251. /**
  252. * Assign value of a state variable while synchronizing state.
  253. *
  254. * The state synchronization process is started with state_sync_begin(),
  255. * which is followed by one or more calls to this function,
  256. * and finished using state_sync_end().
  257. *
  258. * @see GNUNET_PSYCSTORE_state_sync()
  259. *
  260. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  261. */
  262. int
  263. (*state_sync_assign) (void *cls,
  264. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  265. const char *name, const void *value, size_t value_size);
  266. /**
  267. * End synchronizing state.
  268. *
  269. * @see GNUNET_PSYCSTORE_state_sync()
  270. *
  271. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  272. */
  273. int
  274. (*state_sync_end) (void *cls,
  275. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  276. uint64_t max_state_message_id,
  277. uint64_t state_hash_message_id);
  278. /**
  279. * Reset the state of a channel.
  280. *
  281. * Delete all state variables stored for the given channel.
  282. *
  283. * @see GNUNET_PSYCSTORE_state_reset()
  284. *
  285. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  286. */
  287. int
  288. (*state_reset) (void *cls,
  289. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
  290. /**
  291. * Update signed state values from the current ones.
  292. *
  293. * Sets value_signed = value_current for each variable for the given channel.
  294. */
  295. int
  296. (*state_update_signed) (void *cls,
  297. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
  298. /**
  299. * Retrieve a state variable by name (exact match).
  300. *
  301. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  302. */
  303. int
  304. (*state_get) (void *cls,
  305. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  306. const char *name,
  307. GNUNET_PSYCSTORE_StateCallback cb,
  308. void *cb_cls);
  309. /**
  310. * Retrieve all state variables for a channel with the given prefix.
  311. *
  312. * @see GNUNET_PSYCSTORE_state_get_prefix()
  313. *
  314. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  315. */
  316. int
  317. (*state_get_prefix) (void *cls,
  318. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  319. const char *name,
  320. GNUNET_PSYCSTORE_StateCallback cb,
  321. void *cb_cls);
  322. /**
  323. * Retrieve all signed state variables for a channel.
  324. *
  325. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  326. */
  327. int
  328. (*state_get_signed) (void *cls,
  329. const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
  330. GNUNET_PSYCSTORE_StateCallback cb,
  331. void *cb_cls);
  332. };
  333. #if 0 /* keep Emacsens' auto-indent happy */
  334. {
  335. #endif
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339. #endif
  340. /** @} */ /* end of group */