2 This file is part of GNUnet
3 (C) 2012, 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_EccPublicKey *channel_key,
64 const struct GNUNET_CRYPTO_EccPublicKey *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_EccPublicKey *channel_key,
81 const struct GNUNET_CRYPTO_EccPublicKey *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_EccPublicKey *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 message_id ID of the message.
103 * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
105 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
108 (*message_add_flags) (void *cls,
109 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
111 uint64_t psycstore_flags);
114 * Retrieve a message fragment by fragment ID.
116 * @see GNUNET_PSYCSTORE_fragment_get()
118 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
121 (*fragment_get) (void *cls,
122 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
123 uint64_t fragment_id,
124 GNUNET_PSYCSTORE_FragmentCallback cb,
128 * Retrieve all fragments of a message.
130 * @see GNUNET_PSYCSTORE_message_get()
132 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
135 (*message_get) (void *cls,
136 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
138 GNUNET_PSYCSTORE_FragmentCallback cb,
142 * Retrieve a fragment of message specified by its message ID and fragment
145 * @see GNUNET_PSYCSTORE_message_get_fragment()
147 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
150 (*message_get_fragment) (void *cls,
151 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
153 uint64_t fragment_offset,
154 GNUNET_PSYCSTORE_FragmentCallback cb,
158 * Retrieve latest values of counters for a channel master.
160 * @see GNUNET_PSYCSTORE_counters_get_master()
162 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
165 (*counters_get_master) (void *cls,
166 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
167 uint64_t *fragment_id,
168 uint64_t *message_id,
169 uint64_t *group_generation);
172 * Retrieve latest values of counters for a channel slave.
174 * @see GNUNET_PSYCSTORE_counters_get_slave()
176 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
179 (*counters_get_slave) (void *cls,
180 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
181 uint64_t *max_state_msg_id);
184 * Set a state variable to the given value.
186 * @see GNUNET_PSYCSTORE_state_modify()
188 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
191 (*state_set) (void *cls,
192 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
199 * Reset the state of a channel.
201 * Delete all state variables stored for the given channel.
203 * @see GNUNET_PSYCSTORE_state_reset()
205 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
208 (*state_reset) (void *cls,
209 const struct GNUNET_CRYPTO_EccPublicKey *channel_key);
212 * Update signed state values from the current ones.
214 * Sets value_signed = value_current for each variable for the given channel.
217 (*state_update_signed) (void *cls,
218 const struct GNUNET_CRYPTO_EccPublicKey *channel_key);
221 * Update signed values of state variables in the state store.
223 * @param h Handle for the PSYCstore.
224 * @param channel_key The channel we are interested in.
225 * @param message_id Message ID that contained the state @a hash.
226 * @param hash Hash of the serialized full state.
227 * @param rcb Callback to call with the result of the operation.
228 * @param rcb_cls Closure for the callback.
230 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
233 (*state_hash_update) (void *cls,
234 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
236 const struct GNUNET_HashCode *hash,
237 GNUNET_PSYCSTORE_ResultCallback rcb,
241 * Retrieve a state variable by name (exact match).
243 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
246 (*state_get) (void *cls,
247 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
249 GNUNET_PSYCSTORE_StateCallback cb,
253 * Retrieve all state variables for a channel with the given prefix.
255 * @see GNUNET_PSYCSTORE_state_get_all()
257 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
260 (*state_get_all) (void *cls,
261 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
263 GNUNET_PSYCSTORE_StateCallback cb,
268 * Retrieve all signed state variables for a channel.
270 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
273 (*state_get_signed) (void *cls,
274 const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
275 GNUNET_PSYCSTORE_StateCallback cb,
281 #if 0 /* keep Emacsens' auto-indent happy */
288 /* end of gnunet_psycstore_plugin.h */