diff options
author | Gabor X Toth <*@tg-x.net> | 2013-08-29 15:14:17 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-08-29 15:14:17 +0000 |
commit | 81eaa5a9d5ebe1e61790069a2777178abd1b6a2c (patch) | |
tree | 2b24561b930dca7ede2d27590e1c434fe19ed365 /src/include/gnunet_psycstore_plugin.h | |
parent | b1ed5b9a472bd56796646a70068eb48da0db3e2f (diff) | |
download | gnunet-81eaa5a9d5ebe1e61790069a2777178abd1b6a2c.tar.gz gnunet-81eaa5a9d5ebe1e61790069a2777178abd1b6a2c.zip |
psycstore: sqlite plugin
Diffstat (limited to 'src/include/gnunet_psycstore_plugin.h')
-rw-r--r-- | src/include/gnunet_psycstore_plugin.h | 237 |
1 files changed, 237 insertions, 0 deletions
diff --git a/src/include/gnunet_psycstore_plugin.h b/src/include/gnunet_psycstore_plugin.h new file mode 100644 index 000000000..e567de278 --- /dev/null +++ b/src/include/gnunet_psycstore_plugin.h | |||
@@ -0,0 +1,237 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_psycstore_plugin.h | ||
23 | * @brief plugin API for the PSYCstore database backend | ||
24 | * @author Gabor X Toth | ||
25 | */ | ||
26 | #ifndef GNUNET_PSYCSTORE_PLUGIN_H | ||
27 | #define GNUNET_PSYCSTORE_PLUGIN_H | ||
28 | |||
29 | #include "gnunet_common.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_psycstore_service.h" | ||
32 | |||
33 | #ifdef __cplusplus | ||
34 | extern "C" | ||
35 | { | ||
36 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
37 | } | ||
38 | #endif | ||
39 | #endif | ||
40 | |||
41 | |||
42 | /** | ||
43 | * @brief struct returned by the initialization function of the plugin | ||
44 | */ | ||
45 | struct GNUNET_PSYCSTORE_PluginFunctions | ||
46 | { | ||
47 | |||
48 | /** | ||
49 | * Closure to pass to all plugin functions. | ||
50 | */ | ||
51 | void *cls; | ||
52 | |||
53 | /** | ||
54 | * Store join/leave events for a PSYC channel in order to be able to answer | ||
55 | * membership test queries later. | ||
56 | * | ||
57 | * @see GNUNET_PSYCSTORE_membership_store() | ||
58 | * | ||
59 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
60 | */ | ||
61 | int | ||
62 | (*membership_store) (void *cls, | ||
63 | const struct GNUNET_HashCode *channel_key, | ||
64 | const struct GNUNET_HashCode *slave_key, | ||
65 | int did_join, | ||
66 | uint64_t announced_at, | ||
67 | uint64_t effective_since, | ||
68 | uint64_t group_generation); | ||
69 | |||
70 | /** | ||
71 | * Test if a member was admitted to the channel at the given message ID. | ||
72 | * | ||
73 | * @see GNUNET_PSYCSTORE_membership_test() | ||
74 | * | ||
75 | * @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not, | ||
76 | * #GNUNET_SYSERR if there was en error. | ||
77 | */ | ||
78 | int | ||
79 | (*membership_test) (void *cls, | ||
80 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
81 | const struct GNUNET_CRYPTO_EccPublicKey *slave_key, | ||
82 | uint64_t message_id, | ||
83 | uint64_t group_generation); | ||
84 | |||
85 | /** | ||
86 | * Store a message fragment sent to a channel. | ||
87 | * | ||
88 | * @see GNUNET_PSYCSTORE_fragment_store() | ||
89 | * | ||
90 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
91 | */ | ||
92 | int | ||
93 | (*fragment_store) (void *cls, | ||
94 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
95 | const struct GNUNET_MULTICAST_MessageHeader *message); | ||
96 | |||
97 | /** | ||
98 | * Set additional flags for a given message. | ||
99 | * | ||
100 | * @param message_id ID of the message. | ||
101 | * @param flags Flags to add. | ||
102 | * | ||
103 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
104 | */ | ||
105 | int | ||
106 | (*fragment_add_flags) (void *cls, | ||
107 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
108 | uint64_t message_id, | ||
109 | uint64_t multicast_flags, | ||
110 | uint64_t psyc_flags); | ||
111 | |||
112 | /** | ||
113 | * Retrieve a message fragment by fragment ID. | ||
114 | * | ||
115 | * @see GNUNET_PSYCSTORE_fragment_get() | ||
116 | * | ||
117 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
118 | */ | ||
119 | int | ||
120 | (*fragment_get) (void *cls, | ||
121 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
122 | uint64_t fragment_id, | ||
123 | GNUNET_PSYCSTORE_FragmentCallback cb, | ||
124 | void *cb_cls); | ||
125 | |||
126 | /** | ||
127 | * Retrieve all fragments of a message. | ||
128 | * | ||
129 | * @see GNUNET_PSYCSTORE_message_get() | ||
130 | * | ||
131 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
132 | */ | ||
133 | int | ||
134 | (*message_get) (void *cls, | ||
135 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
136 | uint64_t message_id, | ||
137 | GNUNET_PSYCSTORE_FragmentCallback cb, | ||
138 | void *cb_cls); | ||
139 | |||
140 | /** | ||
141 | * Retrieve a fragment of message specified by its message ID and fragment | ||
142 | * offset. | ||
143 | * | ||
144 | * @see GNUNET_PSYCSTORE_message_get_fragment() | ||
145 | * | ||
146 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
147 | */ | ||
148 | int | ||
149 | (*message_get_fragment) (void *cls, | ||
150 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
151 | uint64_t message_id, | ||
152 | uint64_t fragment_offset, | ||
153 | GNUNET_PSYCSTORE_FragmentCallback cb, | ||
154 | void *cb_cls); | ||
155 | |||
156 | /** | ||
157 | * Retrieve latest values of counters for a channel master. | ||
158 | * | ||
159 | * @see GNUNET_PSYCSTORE_counters_get_master() | ||
160 | * | ||
161 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
162 | */ | ||
163 | int | ||
164 | (*counters_get_master) (void *cls, | ||
165 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
166 | uint64_t *fragment_id, | ||
167 | uint64_t *message_id, | ||
168 | uint64_t *group_generation); | ||
169 | |||
170 | /** | ||
171 | * Retrieve latest values of counters for a channel slave. | ||
172 | * | ||
173 | * @see GNUNET_PSYCSTORE_counters_get_slave() | ||
174 | * | ||
175 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
176 | */ | ||
177 | int | ||
178 | (*counters_get_slave) (void *cls, | ||
179 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
180 | uint64_t *max_state_msg_id); | ||
181 | |||
182 | /** | ||
183 | * Set a state variable to the given value. | ||
184 | * | ||
185 | * @see GNUNET_PSYCSTORE_state_modify() | ||
186 | * | ||
187 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
188 | */ | ||
189 | int | ||
190 | (*state_set) (struct GNUNET_PSYCSTORE_Handle *h, | ||
191 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
192 | const char *name, | ||
193 | size_t value_size, | ||
194 | const void *value); | ||
195 | |||
196 | /** | ||
197 | * Retrieve a state variable by name. | ||
198 | * | ||
199 | * @param name Name of the variable to retrieve. | ||
200 | * @param[out] value_size Size of value. | ||
201 | * @param[out] value Returned value. | ||
202 | * | ||
203 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
204 | */ | ||
205 | int | ||
206 | (*state_get) (struct GNUNET_PSYCSTORE_Handle *h, | ||
207 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
208 | const char *name, | ||
209 | GNUNET_PSYCSTORE_StateCallback cb, | ||
210 | void *cb_cls); | ||
211 | |||
212 | /** | ||
213 | * Retrieve all state variables for a channel with the given prefix. | ||
214 | * | ||
215 | * @see GNUNET_PSYCSTORE_state_get_all() | ||
216 | * | ||
217 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
218 | */ | ||
219 | int | ||
220 | (*state_get_all) (struct GNUNET_PSYCSTORE_Handle *h, | ||
221 | const struct GNUNET_CRYPTO_EccPublicKey *channel_key, | ||
222 | const char *name, | ||
223 | GNUNET_PSYCSTORE_StateCallback cb, | ||
224 | void *cb_cls); | ||
225 | |||
226 | }; | ||
227 | |||
228 | |||
229 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
230 | { | ||
231 | #endif | ||
232 | #ifdef __cplusplus | ||
233 | } | ||
234 | #endif | ||
235 | |||
236 | /* end of gnunet_psycstore_plugin.h */ | ||
237 | #endif | ||