2 This file is part of GNUnet
3 Copyright (C) 2013 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Gabor X Toth
25 * Plugin API for the PSYCstore database backend
27 * @defgroup psycstore-plugin PSYC Store plugin API
28 * Plugin API for the PSYC Store database backend
31 #ifndef GNUNET_PSYCSTORE_PLUGIN_H
32 #define GNUNET_PSYCSTORE_PLUGIN_H
34 #include "gnunet_util_lib.h"
35 #include "gnunet_psycstore_service.h"
40 #if 0 /* keep Emacsens' auto-indent happy */
47 * Struct returned by the initialization function of the plugin.
49 struct GNUNET_PSYCSTORE_PluginFunctions
53 * Closure to pass to all plugin functions.
58 * Store join/leave events for a PSYC channel in order to be able to answer
59 * membership test queries later.
61 * @see GNUNET_PSYCSTORE_membership_store()
63 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
66 (*membership_store) (void *cls,
67 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
68 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
70 uint64_t announced_at,
71 uint64_t effective_since,
72 uint64_t group_generation);
75 * Test if a member was admitted to the channel at the given message ID.
77 * @see GNUNET_PSYCSTORE_membership_test()
79 * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
80 * #GNUNET_SYSERR if there was en error.
83 (*membership_test) (void *cls,
84 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
85 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
89 * Store a message fragment sent to a channel.
91 * @see GNUNET_PSYCSTORE_fragment_store()
93 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
96 (*fragment_store) (void *cls,
97 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
98 const struct GNUNET_MULTICAST_MessageHeader *message,
99 uint32_t psycstore_flags);
102 * Set additional flags for a given message.
104 * They are OR'd with any existing flags set.
106 * @param cls Closure.
107 * @param channel_key Public key of the channel.
108 * @param message_id ID of the message.
109 * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
111 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
114 (*message_add_flags) (void *cls,
115 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
117 uint64_t psycstore_flags);
120 * Retrieve a message fragment range by fragment ID.
122 * @see GNUNET_PSYCSTORE_fragment_get()
124 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
127 (*fragment_get) (void *cls,
128 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
129 uint64_t first_fragment_id,
130 uint64_t last_fragment_id,
131 uint64_t *returned_fragments,
132 GNUNET_PSYCSTORE_FragmentCallback cb,
136 * Retrieve latest message fragments.
138 * @see GNUNET_PSYCSTORE_fragment_get()
140 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
143 (*fragment_get_latest) (void *cls,
144 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
145 uint64_t fragment_limit,
146 uint64_t *returned_fragments,
147 GNUNET_PSYCSTORE_FragmentCallback cb,
151 * Retrieve all fragments of a message ID range.
153 * @see GNUNET_PSYCSTORE_message_get()
155 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
158 (*message_get) (void *cls,
159 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
160 uint64_t first_fragment_id,
161 uint64_t last_fragment_id,
162 uint64_t fragment_limit,
163 uint64_t *returned_fragments,
164 GNUNET_PSYCSTORE_FragmentCallback cb,
168 * Retrieve all fragments of the latest messages.
170 * @see GNUNET_PSYCSTORE_message_get()
172 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
175 (*message_get_latest) (void *cls,
176 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
177 uint64_t fragment_limit,
178 uint64_t *returned_fragments,
179 GNUNET_PSYCSTORE_FragmentCallback cb,
183 * Retrieve a fragment of message specified by its message ID and fragment
186 * @see GNUNET_PSYCSTORE_message_get_fragment()
188 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
191 (*message_get_fragment) (void *cls,
192 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
194 uint64_t fragment_offset,
195 GNUNET_PSYCSTORE_FragmentCallback cb,
199 * Retrieve the max. values of message counters for a channel.
201 * @see GNUNET_PSYCSTORE_counters_get()
203 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
206 (*counters_message_get) (void *cls,
207 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
208 uint64_t *max_fragment_id,
209 uint64_t *max_message_id,
210 uint64_t *max_group_generation);
213 * Retrieve the max. values of state counters for a channel.
215 * @see GNUNET_PSYCSTORE_counters_get()
217 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
220 (*counters_state_get) (void *cls,
221 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
222 uint64_t *max_state_message_id);
226 * Begin modifying current state.
228 * @see GNUNET_PSYCSTORE_state_modify()
230 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
233 (*state_modify_begin) (void *cls,
234 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
235 uint64_t message_id, uint64_t state_delta);
238 * Set the current value of a state variable.
240 * The state modification process is started with state_modify_begin(),
241 * which is followed by one or more calls to this function,
242 * and finished with state_modify_end().
244 * @see GNUNET_PSYCSTORE_state_modify()
246 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
249 (*state_modify_op) (void *cls,
250 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
251 enum GNUNET_PSYC_Operator op,
252 const char *name, const void *value, size_t value_size);
256 * End modifying current state.
258 * @see GNUNET_PSYCSTORE_state_modify()
260 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
263 (*state_modify_end) (void *cls,
264 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
265 uint64_t message_id);
269 * Begin synchronizing state.
271 * @see GNUNET_PSYCSTORE_state_sync()
273 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
276 (*state_sync_begin) (void *cls,
277 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
280 * Assign value of a state variable while synchronizing state.
282 * The state synchronization process is started with state_sync_begin(),
283 * which is followed by one or more calls to this function,
284 * and finished using state_sync_end().
286 * @see GNUNET_PSYCSTORE_state_sync()
288 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
291 (*state_sync_assign) (void *cls,
292 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
293 const char *name, const void *value, size_t value_size);
297 * End synchronizing state.
299 * @see GNUNET_PSYCSTORE_state_sync()
301 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
304 (*state_sync_end) (void *cls,
305 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
306 uint64_t max_state_message_id,
307 uint64_t state_hash_message_id);
311 * Reset the state of a channel.
313 * Delete all state variables stored for the given channel.
315 * @see GNUNET_PSYCSTORE_state_reset()
317 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
320 (*state_reset) (void *cls,
321 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
324 * Update signed state values from the current ones.
326 * Sets value_signed = value_current for each variable for the given channel.
329 (*state_update_signed) (void *cls,
330 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
334 * Retrieve a state variable by name (exact match).
336 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
339 (*state_get) (void *cls,
340 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
342 GNUNET_PSYCSTORE_StateCallback cb,
346 * Retrieve all state variables for a channel with the given prefix.
348 * @see GNUNET_PSYCSTORE_state_get_prefix()
350 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
353 (*state_get_prefix) (void *cls,
354 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
356 GNUNET_PSYCSTORE_StateCallback cb,
361 * Retrieve all signed state variables for a channel.
363 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
366 (*state_get_signed) (void *cls,
367 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
368 GNUNET_PSYCSTORE_StateCallback cb,
374 #if 0 /* keep Emacsens' auto-indent happy */
383 /** @} */ /* end of group */