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_util_lib.h"
30 #include "gnunet_psycstore_service.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
42 * Struct returned by the initialization function of the plugin.
44 struct GNUNET_PSYCSTORE_PluginFunctions
48 * Closure to pass to all plugin functions.
53 * Store join/leave events for a PSYC channel in order to be able to answer
54 * membership test queries later.
56 * @see GNUNET_PSYCSTORE_membership_store()
58 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
61 (*membership_store) (void *cls,
62 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
63 const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
65 uint64_t announced_at,
66 uint64_t effective_since,
67 uint64_t group_generation);
70 * Test if a member was admitted to the channel at the given message ID.
72 * @see GNUNET_PSYCSTORE_membership_test()
74 * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
75 * #GNUNET_SYSERR if there was en error.
78 (*membership_test) (void *cls,
79 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
80 const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
84 * Store a message fragment sent to a channel.
86 * @see GNUNET_PSYCSTORE_fragment_store()
88 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
91 (*fragment_store) (void *cls,
92 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
93 const struct GNUNET_MULTICAST_MessageHeader *message,
94 uint32_t psycstore_flags);
97 * Set additional flags for a given message.
99 * They are OR'd with any existing flags set.
101 * @param cls Closure.
102 * @param channel_key Public key of the channel.
103 * @param message_id ID of the message.
104 * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
106 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
109 (*message_add_flags) (void *cls,
110 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
112 uint64_t psycstore_flags);
115 * Retrieve a message fragment by fragment ID.
117 * @see GNUNET_PSYCSTORE_fragment_get()
119 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
122 (*fragment_get) (void *cls,
123 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
124 uint64_t fragment_id,
125 GNUNET_PSYCSTORE_FragmentCallback cb,
129 * Retrieve all fragments of a message.
131 * @see GNUNET_PSYCSTORE_message_get()
133 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
136 (*message_get) (void *cls,
137 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
139 uint64_t *returned_fragments,
140 GNUNET_PSYCSTORE_FragmentCallback cb,
144 * Retrieve a fragment of message specified by its message ID and fragment
147 * @see GNUNET_PSYCSTORE_message_get_fragment()
149 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
152 (*message_get_fragment) (void *cls,
153 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
155 uint64_t fragment_offset,
156 GNUNET_PSYCSTORE_FragmentCallback cb,
160 * Retrieve the max. values of message counters for a channel.
162 * @see GNUNET_PSYCSTORE_counters_get()
164 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
167 (*counters_message_get) (void *cls,
168 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
169 uint64_t *max_fragment_id,
170 uint64_t *max_message_id,
171 uint64_t *max_group_generation);
174 * Retrieve the max. values of state counters for a channel.
176 * @see GNUNET_PSYCSTORE_counters_get()
178 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
181 (*counters_state_get) (void *cls,
182 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
183 uint64_t *max_state_message_id);
187 * Begin modifying current state.
189 * @see GNUNET_PSYCSTORE_state_modify()
191 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
194 (*state_modify_begin) (void *cls,
195 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
196 uint64_t message_id, uint64_t state_delta);
199 * Set the current value of a state variable.
201 * The state modification process is started with state_modify_begin(),
202 * which is followed by one or more calls to this function,
203 * and finished with state_modify_end().
205 * @see GNUNET_PSYCSTORE_state_modify()
207 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
210 (*state_modify_set) (void *cls,
211 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
212 const char *name, const void *value, size_t value_size);
216 * End modifying current state.
218 * @see GNUNET_PSYCSTORE_state_modify()
220 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
223 (*state_modify_end) (void *cls,
224 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
225 uint64_t message_id);
229 * Begin synchronizing state.
231 * @see GNUNET_PSYCSTORE_state_sync()
233 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
236 (*state_sync_begin) (void *cls,
237 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
240 * Set the value of a state variable while synchronizing state.
242 * The state synchronization process is started with state_sync_begin(),
243 * which is followed by one or more calls to this function,
244 * and finished with state_sync_end().
246 * @see GNUNET_PSYCSTORE_state_sync()
248 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
251 (*state_sync_set) (void *cls,
252 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
253 const char *name, const void *value, size_t value_size);
257 * End synchronizing state.
259 * @see GNUNET_PSYCSTORE_state_sync()
261 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
264 (*state_sync_end) (void *cls,
265 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
266 uint64_t message_id);
270 * Reset the state of a channel.
272 * Delete all state variables stored for the given channel.
274 * @see GNUNET_PSYCSTORE_state_reset()
276 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
279 (*state_reset) (void *cls,
280 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
283 * Update signed state values from the current ones.
285 * Sets value_signed = value_current for each variable for the given channel.
288 (*state_update_signed) (void *cls,
289 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
293 * Retrieve a state variable by name (exact match).
295 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
298 (*state_get) (void *cls,
299 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
301 GNUNET_PSYCSTORE_StateCallback cb,
305 * Retrieve all state variables for a channel with the given prefix.
307 * @see GNUNET_PSYCSTORE_state_get_prefix()
309 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
312 (*state_get_prefix) (void *cls,
313 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
315 GNUNET_PSYCSTORE_StateCallback cb,
320 * Retrieve all signed state variables for a channel.
322 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
325 (*state_get_signed) (void *cls,
326 const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
327 GNUNET_PSYCSTORE_StateCallback cb,
333 #if 0 /* keep Emacsens' auto-indent happy */
340 /* end of gnunet_psycstore_plugin.h */