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