2 This file is part of GNUnet
3 (C) 2013 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_psycstore_plugin.h
23 * @brief plugin API for the PSYCstore database backend
24 * @author Gabor X Toth
26 #ifndef GNUNET_PSYCSTORE_PLUGIN_H
27 #define GNUNET_PSYCSTORE_PLUGIN_H
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_psycstore_service.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * Struct returned by the initialization function of the plugin.
45 struct GNUNET_PSYCSTORE_PluginFunctions
49 * Closure to pass to all plugin functions.
54 * Store join/leave events for a PSYC channel in order to be able to answer
55 * membership test queries later.
57 * @see GNUNET_PSYCSTORE_membership_store()
59 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
62 (*membership_store) (void *cls,
63 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
64 const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
66 uint64_t announced_at,
67 uint64_t effective_since,
68 uint64_t group_generation);
71 * Test if a member was admitted to the channel at the given message ID.
73 * @see GNUNET_PSYCSTORE_membership_test()
75 * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
76 * #GNUNET_SYSERR if there was en error.
79 (*membership_test) (void *cls,
80 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
81 const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
85 * Store a message fragment sent to a channel.
87 * @see GNUNET_PSYCSTORE_fragment_store()
89 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
92 (*fragment_store) (void *cls,
93 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
94 const struct GNUNET_MULTICAST_MessageHeader *message,
95 uint32_t psycstore_flags);
98 * Set additional flags for a given message.
100 * They are OR'd with any existing flags set.
102 * @param cls Closure.
103 * @param channel_key Public key of the channel.
104 * @param message_id ID of the message.
105 * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
107 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
110 (*message_add_flags) (void *cls,
111 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
113 uint64_t psycstore_flags);
116 * Retrieve a message fragment by fragment ID.
118 * @see GNUNET_PSYCSTORE_fragment_get()
120 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
123 (*fragment_get) (void *cls,
124 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
125 uint64_t fragment_id,
126 GNUNET_PSYCSTORE_FragmentCallback cb,
130 * Retrieve all fragments of a message.
132 * @see GNUNET_PSYCSTORE_message_get()
134 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
137 (*message_get) (void *cls,
138 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
140 uint64_t *returned_fragments,
141 GNUNET_PSYCSTORE_FragmentCallback cb,
145 * Retrieve a fragment of message specified by its message ID and fragment
148 * @see GNUNET_PSYCSTORE_message_get_fragment()
150 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
153 (*message_get_fragment) (void *cls,
154 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
156 uint64_t fragment_offset,
157 GNUNET_PSYCSTORE_FragmentCallback cb,
161 * Retrieve the max. values of message counters for a channel.
163 * @see GNUNET_PSYCSTORE_counters_get()
165 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
168 (*counters_message_get) (void *cls,
169 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
170 uint64_t *max_fragment_id,
171 uint64_t *max_message_id,
172 uint64_t *max_group_generation);
175 * Retrieve the max. values of state counters for a channel.
177 * @see GNUNET_PSYCSTORE_counters_get()
179 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
182 (*counters_state_get) (void *cls,
183 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
184 uint64_t *max_state_message_id);
188 * Begin modifying current state.
190 * @see GNUNET_PSYCSTORE_state_modify()
192 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
195 (*state_modify_begin) (void *cls,
196 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
197 uint64_t message_id, uint64_t state_delta);
200 * Set the current value of a state variable.
202 * The state modification process is started with state_modify_begin(),
203 * which is followed by one or more calls to this function,
204 * and finished with state_modify_end().
206 * @see GNUNET_PSYCSTORE_state_modify()
208 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
211 (*state_modify_set) (void *cls,
212 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
213 const char *name, const void *value, size_t value_size);
217 * End modifying current state.
219 * @see GNUNET_PSYCSTORE_state_modify()
221 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
224 (*state_modify_end) (void *cls,
225 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
226 uint64_t message_id);
230 * Begin synchronizing state.
232 * @see GNUNET_PSYCSTORE_state_sync()
234 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
237 (*state_sync_begin) (void *cls,
238 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
241 * Set the value of a state variable while synchronizing state.
243 * The state synchronization process is started with state_sync_begin(),
244 * which is followed by one or more calls to this function,
245 * and finished with state_sync_end().
247 * @see GNUNET_PSYCSTORE_state_sync()
249 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
252 (*state_sync_set) (void *cls,
253 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
254 const char *name, const void *value, size_t value_size);
258 * End synchronizing state.
260 * @see GNUNET_PSYCSTORE_state_sync()
262 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
265 (*state_sync_end) (void *cls,
266 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
267 uint64_t message_id);
271 * Reset the state of a channel.
273 * Delete all state variables stored for the given channel.
275 * @see GNUNET_PSYCSTORE_state_reset()
277 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
280 (*state_reset) (void *cls,
281 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
284 * Update signed state values from the current ones.
286 * Sets value_signed = value_current for each variable for the given channel.
289 (*state_update_signed) (void *cls,
290 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
294 * Retrieve a state variable by name (exact match).
296 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
299 (*state_get) (void *cls,
300 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
302 GNUNET_PSYCSTORE_StateCallback cb,
306 * Retrieve all state variables for a channel with the given prefix.
308 * @see GNUNET_PSYCSTORE_state_get_prefix()
310 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
313 (*state_get_prefix) (void *cls,
314 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
316 GNUNET_PSYCSTORE_StateCallback cb,
321 * Retrieve all signed state variables for a channel.
323 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
326 (*state_get_signed) (void *cls,
327 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
328 GNUNET_PSYCSTORE_StateCallback cb,
334 #if 0 /* keep Emacsens' auto-indent happy */
341 /* end of gnunet_psycstore_plugin.h */