diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-04-21 21:06:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-04-21 21:06:58 +0000 |
commit | f9d1691fd19c974d35f57164298dd2a580c83315 (patch) | |
tree | 4c5f5ad2020ca63a2ce5444d48275874b0d42d2e /src/include | |
parent | da683835112d7510461269a81363dcaf23af4b9b (diff) | |
download | gnunet-f9d1691fd19c974d35f57164298dd2a580c83315.tar.gz gnunet-f9d1691fd19c974d35f57164298dd2a580c83315.zip |
-evolve PSYC ideas
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/block_fs.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_mesh2_service.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_multicast_service.h | 5 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 748 |
4 files changed, 359 insertions, 402 deletions
diff --git a/src/include/block_fs.h b/src/include/block_fs.h index 4806bf7b1..a2063270e 100644 --- a/src/include/block_fs.h +++ b/src/include/block_fs.h | |||
@@ -53,7 +53,7 @@ struct UBlock | |||
53 | /** | 53 | /** |
54 | * What is being signed and why? | 54 | * What is being signed and why? |
55 | */ | 55 | */ |
56 | struct GNUNET_FS_PseudonymSignaturePurpose purpose; | 56 | struct GNUNET_FS_PseudonymSignaturePurpose purpose GNUNET_PACKED; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Public key used to sign this block. Hash of this value | 59 | * Public key used to sign this block. Hash of this value |
diff --git a/src/include/gnunet_mesh2_service.h b/src/include/gnunet_mesh2_service.h index cabd8b69b..f8bc4809c 100644 --- a/src/include/gnunet_mesh2_service.h +++ b/src/include/gnunet_mesh2_service.h | |||
@@ -19,9 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_mesh_service.h | 22 | * @file include/gnunet_mesh2_service.h |
23 | * @brief mesh service; establish tunnels to distant peers | 23 | * @brief mesh service; establish tunnels to distant peers |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - need to do sanity check that this is consistent | ||
28 | * with current ideas for the multicast layer's needs | ||
25 | */ | 29 | */ |
26 | 30 | ||
27 | #ifndef GNUNET_MESH_SERVICE_H | 31 | #ifndef GNUNET_MESH_SERVICE_H |
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index 133af9b8f..699b1df44 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -22,6 +22,11 @@ | |||
22 | * @file include/gnunet_multicast_service.h | 22 | * @file include/gnunet_multicast_service.h |
23 | * @brief multicast service; establish tunnels to distant peers | 23 | * @brief multicast service; establish tunnels to distant peers |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - need to support async message transmission, etc. | ||
28 | * - need to do sanity check that this is consistent | ||
29 | * with current ideas for the PSYC layer's needs | ||
25 | */ | 30 | */ |
26 | 31 | ||
27 | #ifndef GNUNET_MULTICAST_SERVICE_H | 32 | #ifndef GNUNET_MULTICAST_SERVICE_H |
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 790d98228..1dd831740 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -20,21 +20,57 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_psyc_service.h | 22 | * @file include/gnunet_psyc_service.h |
23 | * @brief psyc service; high-level access to the PSYC protocol | 23 | * @brief PSYC service; high-level access to the PSYC protocol |
24 | * note that clients of this API are NOT expected to | 24 | * note that clients of this API are NOT expected to |
25 | * understand the PSYC message format, only the semantics! | 25 | * understand the PSYC message format, only the semantics! |
26 | * Parsing (and serializing) the PSYC stream format is done | ||
27 | * within the implementation of the libgnunetpsyc library, | ||
28 | * and this API deliberately exposes as little as possible | ||
29 | * of the actual data stream format to the application! | ||
26 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
27 | * | 31 | * |
28 | * TODO: | 32 | * NOTE: |
29 | * - how to deal with very large channel state (i.e. channel | 33 | * - this API does not know about psyc's "root" and "places"; |
30 | * containing a movie); this might relate to the question | 34 | * there is no 'root' in GNUnet-Psyc as we're decentralized; |
31 | * of how (when/etc.) we replay method calls; is only the | 35 | * 'places' and 'persons' are combined within the same |
32 | * channel state persistent? What about a 'bounded' | 36 | * abstraction, that of a "channel". Channels are identified |
33 | * channel history, how would we enable that? | 37 | * and accessed in this API using a public/private key. |
34 | * - how to deal with seeking in large channel state (i.e. | 38 | * Higher-level applications should use NAMES within GADS |
35 | * skip to minute 45 in movie) | 39 | * to obtain public keys, and the distinction between |
36 | * - need to change send operations to 'notify_transmit_ready'-style; | 40 | * 'places' and 'persons' can then be made with the help |
37 | * deal better with 'streaming' arguments while we're at it | 41 | * of the naming system (and/or conventions). |
42 | * Channels are (as in PSYC) organized into a hierarchy; each | ||
43 | * channel owner (the one with the private key) is then | ||
44 | * the operator of the multicast group (its Origin in | ||
45 | * the terminology of the multicast API). | ||
46 | * - The API supports passing large amounts of data using | ||
47 | * 'streaming' for the argument passed to a method. State | ||
48 | * and variables must fit into memory and cannot be streamed | ||
49 | * (thus, no passing of 4 GB of data in a variable; | ||
50 | * once we implement this, we might want to create a | ||
51 | * #define for the maximum size of a variable). | ||
52 | * - PSYC defines standard variables, methods, etc. This | ||
53 | * library deliberately abstracts over all of these; a | ||
54 | * higher-level API should combine the naming system (GADS) | ||
55 | * and standard methods (message, join, leave, warn, | ||
56 | * fail, error) and variables (action, color, time, | ||
57 | * tag, etc.). However, this API does take over the | ||
58 | * routing variables, specifically 'context' (channel), | ||
59 | * and 'source'. We only kind-of support 'target', as | ||
60 | * the target is either everyone in the group or the | ||
61 | * origin, and never just a single member of the group; | ||
62 | * for such individual messages, an application needs to | ||
63 | * construct an 'inbox' channel where the owner (only) | ||
64 | * receives messages (but never forwards; private responses | ||
65 | * would be transmitted by joining the senders 'inbox' | ||
66 | * channel -- or a inbox#bob subchannel). The | ||
67 | * goal for all of this is to keep the abstractions in this | ||
68 | * API minimal: interaction with multicast, try \& slice, | ||
69 | * state/variable/channel management. Higher-level | ||
70 | * operations belong elsewhere (so maybe this API should | ||
71 | * be called 'PSYC-low', whereas a higher-level API | ||
72 | * implementing defaults for standard methods and | ||
73 | * variables might be called 'PSYC-std' or 'PSYC-high'. | ||
38 | */ | 74 | */ |
39 | 75 | ||
40 | #ifndef GNUNET_PSYC_SERVICE_H | 76 | #ifndef GNUNET_PSYC_SERVICE_H |
@@ -59,408 +95,207 @@ extern "C" | |||
59 | 95 | ||
60 | 96 | ||
61 | /** | 97 | /** |
62 | * Bits describing special properties of arguments. | ||
63 | */ | ||
64 | enum GNUNET_PSYC_ArgumentFlags | ||
65 | { | ||
66 | /** | ||
67 | * Argument is fixed size. | ||
68 | */ | ||
69 | GNUNET_PSYC_AF_FIXED_SIZE = 0, | ||
70 | |||
71 | /** | ||
72 | * Argument is variable-length | ||
73 | */ | ||
74 | GNUNET_PSYC_AF_VARIABLE_SIZE = 1, | ||
75 | |||
76 | /** | ||
77 | * Argument may be supplied incrementally to the callback | ||
78 | */ | ||
79 | GNUNET_PSYC_AF_STREAMABLE = 2, | ||
80 | |||
81 | /** | ||
82 | * Argument is variable-length, incrementally supplied | ||
83 | * data stream. | ||
84 | */ | ||
85 | GNUNET_PSYC_AF_STREAM = 3, | ||
86 | |||
87 | /** | ||
88 | * Argument is zero-terminated character array. | ||
89 | */ | ||
90 | GNUNET_PSYC_AF_ZERO_TERMINATED_CHARARRAY = 4, | ||
91 | |||
92 | /** | ||
93 | * Argument is variable-length UTF-8 encoded, zero-terminated string. | ||
94 | */ | ||
95 | GNUNET_PSYC_AF_UTF8 = 5, | ||
96 | |||
97 | /** | ||
98 | * Payload is an unsigned integer and might thus be encoded as an | ||
99 | * integer when generating PSYC stream (useful if we want to | ||
100 | * generate human-readable PSYC streams, instead of just always | ||
101 | * using length-prefixed binary encodings). Note that it | ||
102 | * is not sufficient to just test for this bit, as it is | ||
103 | * also set for 'REAL' numbers! | ||
104 | */ | ||
105 | GNUNET_PSYC_AF_UNSIGNED_INTEGER = 8, | ||
106 | |||
107 | /** | ||
108 | * Payload is an unsigned integer and might thus be encoded as an | ||
109 | * integer when generating PSYC stream (useful if we want to | ||
110 | * generate human-readable PSYC streams, instead of just always | ||
111 | * using length-prefixed binary encodings). Note that it | ||
112 | * is not sufficient to just test for this bit, as it is | ||
113 | * also set for 'REAL' numbers! | ||
114 | */ | ||
115 | GNUNET_PSYC_AF_SIGNED_INTEGER = 16, | ||
116 | |||
117 | /** | ||
118 | * Payload is a 'real' number (float or double). We save a bit here | ||
119 | * as a number cannot be both SIGNED and UNSIGNED, so setting both | ||
120 | * bits is fine to use for REALs. | ||
121 | */ | ||
122 | GNUNET_PSYC_AF_REAL_NUMBER = 24 | ||
123 | |||
124 | }; | ||
125 | |||
126 | |||
127 | /** | ||
128 | * Argument descriptors are used to describe types that can be | ||
129 | * embedded in a PSYC stream. For example, a "uint32_t" is | ||
130 | * described as 4-byte, fixed-length data, whereas a movie | ||
131 | * would be a variable-size, streaming argument. | ||
132 | */ | ||
133 | struct GNUNET_PSYC_ArgumentDescriptor | ||
134 | { | ||
135 | |||
136 | /** | ||
137 | * Required length of the argument in bytes, zero for | ||
138 | * variable-size arguments. | ||
139 | */ | ||
140 | size_t arg_len; | ||
141 | |||
142 | /** | ||
143 | * Flags describing additional properties of the argument, | ||
144 | * such as variable-size, streaming or 0-termination. This | ||
145 | * argument is a bitfield. | ||
146 | */ | ||
147 | enum GNUNET_PSYC_ArgumentFlags flags; | ||
148 | |||
149 | }; | ||
150 | |||
151 | |||
152 | /** | ||
153 | * Convenience macro to define an argument descriptor for | ||
154 | * some fixed-size C data type. | ||
155 | * | ||
156 | * @param pt C data type (i.e. 'uint32_t') | ||
157 | */ | ||
158 | #define GNUNET_PSYC_AD_C_TYPE(pt) { sizeof (pt), GNUNET_PSYC_AF_FIXED_SIZE } | ||
159 | |||
160 | /** | ||
161 | * Convenience macro to define an argument descriptor for | ||
162 | * some fixed-size unsigned integer type. | ||
163 | * | ||
164 | * @param it C integer data type (i.e. 'uint32_t') | ||
165 | */ | ||
166 | #define GNUNET_PSYC_AD_C_UINT_TYPE(it) { sizeof (it), GNUNET_PSYC_AF_FIXED_SIZE | GNUNET_PSYC_AF_UNSIGNED_INTEGER } | ||
167 | |||
168 | /** | ||
169 | * Argument descriptor for a 'uint8_t' argument. | ||
170 | */ | ||
171 | #define GNUNET_PSYC_AD_UINT8 GNUNET_PSYC_AD_C_UINT_TYPE(uint8_t) | ||
172 | |||
173 | /** | ||
174 | * Argument descriptor for a 'uint16_t' argument. | ||
175 | */ | ||
176 | #define GNUNET_PSYC_AD_UINT16 GNUNET_PSYC_AD_C_UINT_TYPE(uint16_t) | ||
177 | |||
178 | /** | ||
179 | * Argument descriptor for a 'uint32_t' argument. | ||
180 | */ | ||
181 | #define GNUNET_PSYC_AD_UINT32 GNUNET_PSYC_AD_C_UINT_TYPE(uint32_t) | ||
182 | |||
183 | /** | ||
184 | * Argument descriptor for a 'uint64_t' argument. | ||
185 | */ | ||
186 | #define GNUNET_PSYC_AD_UINT64 GNUNET_PSYC_AD_C_UINT_TYPE(uint64_t) | ||
187 | |||
188 | /** | ||
189 | * Convenience macro to define an argument descriptor for | ||
190 | * a 0-terminated, variable-length UTF-8 string. | ||
191 | */ | ||
192 | #define GNUNET_PSYC_AD_UTF8 { 0, GNUNET_PSYC_AF_UTF8 } | ||
193 | |||
194 | |||
195 | /* TODO: add more convenience macros for argument types later as needed */ | ||
196 | |||
197 | |||
198 | /** | ||
199 | * Abstract argument passed to a GNUNET_PSYC_Method. | ||
200 | */ | ||
201 | struct GNUNET_PSYC_Argument | ||
202 | { | ||
203 | |||
204 | /** | ||
205 | * Data of the argument. | ||
206 | */ | ||
207 | const void *data; | ||
208 | |||
209 | /** | ||
210 | * Number of bytes in 'data', guaranteed to be the argument | ||
211 | * descriptor 'arg_len' MINUS 'data_off' unless | ||
212 | * GNUNET_PSYC_AF_VARIABLE_SIZE was set. | ||
213 | */ | ||
214 | size_t data_size; | ||
215 | |||
216 | /** | ||
217 | * Offset of 'data' in the overall argument, | ||
218 | * always zero unless GNUNET_PSYC_AF_STREAMABLE was | ||
219 | * set for the argument. | ||
220 | */ | ||
221 | uint64_t data_off; | ||
222 | |||
223 | /** | ||
224 | * Total number of bytes to be expected in 'data', | ||
225 | * UINT64_MAX for 'unknown' (i.e. for "infinite" | ||
226 | * streams). | ||
227 | */ | ||
228 | uint64_t value_size; | ||
229 | }; | ||
230 | |||
231 | |||
232 | /** | ||
233 | * Method called from PSYC upon receiving a message indicating a call | 98 | * Method called from PSYC upon receiving a message indicating a call |
234 | * to a 'method'. The arguments given will match those of the | 99 | * to a 'method'. |
235 | * respective argument descriptor. If some arguments were marked | ||
236 | * as 'streaming', the function can return a value other than -1 | ||
237 | * to request "more" of the data for that argument. Note that all | ||
238 | * non-streaming arguments will be replayed in full for each additional | ||
239 | * invocation of the method. Using more than one streaming argument | ||
240 | * is possible, in which case PSYC will ONLY advance the stream of the | ||
241 | * argument for which the index was returned; the values of other | ||
242 | * streaming arguments will be replayed at the current offset. | ||
243 | * | ||
244 | * Returning a value other than -1 or that of a streaming argument is | ||
245 | * not allowed. Returning -1 does not indicate an error; it simply | ||
246 | * indicates that the client wants to proceed with the next method | ||
247 | * (and not see the rest of the data from any of the streaming | ||
248 | * arguments). | ||
249 | * | ||
250 | * TODO: note that this API currently doesn't allow for seeking | ||
251 | * in streaming data (very advanced feature) | ||
252 | * | 100 | * |
253 | * @param cls closure | 101 | * @param cls closure |
254 | * @param full_method_name original method name from PSYC (may be more | 102 | * @param full_method_name original method name from PSYC (may be more |
255 | * specific than the registered method name due to try&slice matching) | 103 | * specific than the registered method name due to try-and-slice matching) |
256 | * @param sender who transmitted the message (origin, except for messages | 104 | * @param sender who transmitted the message (origin, except for messages |
257 | * from one of the members to the origin) | 105 | * from one of the members to the origin) |
258 | * @param message_id unique message counter for this message | 106 | * @param message_id unique message counter for this message; |
107 | * (unique only in combination with the given sender for | ||
108 | * this channel) | ||
259 | * @param group_generation group generation counter for this message | 109 | * @param group_generation group generation counter for this message |
260 | * @param argc number of arguments in argv | 110 | * (always zero for messages from members to channel owner) |
261 | * @param argv array of argc arguments to the method | 111 | * @param data_size number of bytes in 'data' |
262 | * @return -1 if we're finished with this method, index | 112 | * @param data data stream given to the method (might not be zero-terminated |
263 | * of a streaming argument for which more data is | 113 | * if data is binary) |
264 | * requested otherwise | ||
265 | */ | 114 | */ |
266 | typedef int (*GNUNET_PSYC_Method)(void *cls, | 115 | typedef int (*GNUNET_PSYC_Method)(void *cls, |
267 | const char *full_method_name, | 116 | const char *full_method_name, |
268 | const struct GNUNET_PeerIdentity *sender, | 117 | const struct GNUNET_PeerIdentity *sender, |
269 | unsigned int argc, | 118 | uint64_t message_id, |
270 | const struct GNUNET_PSYC_Argument *argv); | 119 | uint64_t group_generation, |
120 | size_t data_size, | ||
121 | const char *data); | ||
271 | 122 | ||
272 | 123 | ||
273 | /** | 124 | /** |
274 | * Descriptor for a PSYC method and its arguments. Here is how this | 125 | * Handle for the channel of a PSYC group. |
275 | * is expected to be used. Imagine we have a method with the | ||
276 | * following signature: | ||
277 | * <pre> | ||
278 | * static void | ||
279 | * logger (void *cls, uint32_t log_level, const char *log_message); | ||
280 | * </pre> | ||
281 | * where 'cls' is supposed to be a 'FILE *'. | ||
282 | * Then for PSYC to call this method with 'stderr' for 'cls', | ||
283 | * we would provide the following method descriptor: | ||
284 | * <pre> | ||
285 | * .method_name = "log"; | ||
286 | * .method = wrap_logger; | ||
287 | * .method_cls = stderr; | ||
288 | * .argc = 2; | ||
289 | * .argv = { GNUNET_PSYC_AD_UINT32, GNUNET_PSYC_AD_UTF8 }; | ||
290 | * </pre> | ||
291 | * and define <tt>wrap_logger</tt> as follows: | ||
292 | * <pre> | ||
293 | * static void | ||
294 | * wrap_logger (void *cls, const char full_method_name, | ||
295 | * const struct GNUNET_PeerIdentity *sender, | ||
296 | * unsigned int argc, const struct GNUNET_PSYC_Argument *argv) | ||
297 | * { | ||
298 | * uint32_t *log_level = argv[0].data; | ||
299 | * const char *log_message = argv[1].data; | ||
300 | * logger (cls, *log_level, log_message); | ||
301 | * } | ||
302 | * </pre> | ||
303 | * Note that the PSYC library will take care of making sure | ||
304 | * that 'argv[0].data_size == 4' and that the log message | ||
305 | * is 0-terminated, as those requirements were specified | ||
306 | * in the method descriptor for those arguments. Finally, | ||
307 | * it is conceivable to generate the wrappers and method | ||
308 | * descriptors automatically, as they are trivial. | ||
309 | * <p> | ||
310 | * Note that due to try & slice, the given full method name | ||
311 | * might be more specific; for example, the given method | ||
312 | * might be called for a request to "log_warning" instead | ||
313 | * of just a request to "log". | ||
314 | */ | 126 | */ |
315 | struct GNUNET_PSYC_MethodDescriptor | 127 | struct GNUNET_PSYC_Channel; |
316 | { | ||
317 | |||
318 | /** | ||
319 | * Name of the method to be used in try-and-slice matching. | ||
320 | */ | ||
321 | const char *method_name; | ||
322 | |||
323 | /** | ||
324 | * Function to call. Note that if a more specific handler exists | ||
325 | * as well, the more generic handler will not be invoked. | ||
326 | */ | ||
327 | GNUNET_PSYC_Method method; | ||
328 | |||
329 | /** | ||
330 | * Closure for the method (this argument and the 'sender' argument | ||
331 | * are both not included in 'argc'). | ||
332 | */ | ||
333 | void *method_cls; | ||
334 | |||
335 | /** | ||
336 | * Number of arguments to pass to the method (length of the 'ads' | ||
337 | * array). | ||
338 | */ | ||
339 | unsigned int argc; | ||
340 | |||
341 | /** | ||
342 | * Array of 'argc' argument descriptors describing the arguments to | ||
343 | * be passed to the method. Non-matching method calls will be | ||
344 | * ignored (but logged). Note that the 'ads' of all methods with | ||
345 | * the same method name prefix should be identical. | ||
346 | */ | ||
347 | const struct GNUNET_PSYC_ArgumentDescriptor *ads; | ||
348 | |||
349 | }; | ||
350 | |||
351 | |||
352 | /** | ||
353 | * Handle for the origin of a psyc group. | ||
354 | */ | ||
355 | struct GNUNET_PSYC_Origin; | ||
356 | 128 | ||
357 | 129 | ||
358 | /** | 130 | /** |
359 | * Start a psyc group. Will create a multicast group identified by | 131 | * Start a PSYC channel. Will create a multicast group identified by |
360 | * the given public key. Messages recevied from group members will be | 132 | * the given public key. Messages recevied from group members will be |
361 | * given to the respective handler methods. If a new member wants to | 133 | * given to the respective handler methods. If a new member wants to |
362 | * join a group, the "join" method handler will be invoked; the join | 134 | * join a group, the "join" method handler will be invoked; the join |
363 | * handler must then generate a "join" message to approve the joining | 135 | * handler must then generate a "join" message to approve the joining |
364 | * of the new member. The origin can also change group membership | 136 | * of the new member. The channel can also change group membership |
365 | * without explicit requests. Note that PSYC doesn't itself "understand" | 137 | * without explicit requests. Note that PSYC doesn't itself "understand" |
366 | * join or leave messages, the respective methods must call other | 138 | * join or leave messages, the respective methods must call other |
367 | * PSYC functions to inform PSYC about the meaning of the respective | 139 | * PSYC functions to inform PSYC about the meaning of the respective |
368 | * events. | 140 | * events. |
369 | * | 141 | * |
370 | * @param cfg configuration to use (to connect to PSYC service) | 142 | * @param cfg configuration to use (to connect to PSYC service) |
143 | * @param parent parent channel, NULL for top-level channels | ||
144 | * @param name name of the channel, only important if this is a subchannel | ||
371 | * @param method_count number of methods in 'methods' array | 145 | * @param method_count number of methods in 'methods' array |
372 | * @param methods functions to invoke on messages received from members, | 146 | * @param methods functions to invoke on messages received from members, |
373 | * typcially at least contains functions for 'join' and 'leave'. | 147 | * typcially at least contains functions for 'join' and 'leave'. |
374 | * @param priv_key ECC key that will be used to sign messages for this | 148 | * @param priv_key ECC key that will be used to sign messages for this |
375 | * psyc session; public key is used to identify the | 149 | * PSYC session; public key is used to identify the |
376 | * psyc group; FIXME: we'll likely want to use | 150 | * PSYC group; FIXME: we'll likely want to use |
377 | * NOT the p521 curve here, but a cheaper one in the future | 151 | * NOT the p521 curve here, but a cheaper one in the future |
152 | * Note that end-users will usually not use the private key | ||
153 | * directly, but rather look it up in GADS for groups | ||
154 | * managed by other users, or select a file with the private | ||
155 | * key(s) when setting up their own channels | ||
378 | * @param join_policy what is the membership policy of the group? | 156 | * @param join_policy what is the membership policy of the group? |
379 | * @return handle for the origin, NULL on error | 157 | * Used to automate group management decisions. |
158 | * @return handle for the channel, NULL on error | ||
380 | */ | 159 | */ |
381 | struct GNUNET_PSYC_Origin * | 160 | struct GNUNET_PSYC_Channel * |
382 | GNUNET_PSYC_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 161 | GNUNET_PSYC_channel_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
383 | unsigned int method_count, | 162 | struct GNUNET_PSYC_Channel *parent, |
384 | const struct GNUNET_PSYC_MethodDescriptor *methods, | 163 | const char *name, |
385 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, | 164 | unsigned int method_count, |
386 | enum GNUNET_MULTICAST_JoinPolicy join_policy); | 165 | const struct GNUNET_PSYC_Method *methods, |
166 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, | ||
167 | enum GNUNET_MULTICAST_JoinPolicy join_policy); | ||
387 | 168 | ||
388 | 169 | ||
389 | /** | 170 | /** |
390 | * Update channel state. The state of a channel must fit into the | 171 | * Possible operations on PSYC state (persistent) and variables (per message). |
391 | * memory of each member (and the origin); large values that require | 172 | */ |
392 | * streaming must only be passed as streaming arguments to methods. | 173 | enum GNUNET_PSYC_Operator |
393 | * State updates might not be transmitted to group members until | 174 | { |
394 | * the next call to 'GNUNET_PSYC_origin_broadcast_call_method'. | 175 | /** |
176 | * Replace the full state with the new value ("="). | ||
177 | */ | ||
178 | GNUNET_PSYC_SOT_SET_STATE = 0, | ||
179 | |||
180 | /** | ||
181 | * Delete the complete entry from the state (given data must be | ||
182 | * empty). Equivalent to 'SET' with emtpy data, but more | ||
183 | * explicit ("="); | ||
184 | */ | ||
185 | GNUNET_PSYC_SOT_DELETE = 0, | ||
186 | |||
187 | /** | ||
188 | * Set the value of a variable to a new value (":"). | ||
189 | */ | ||
190 | GNUNET_PSYC_SOT_SET_VARIABLE, | ||
191 | |||
192 | /** | ||
193 | * Add the given value to the set of values in the state ("+"). | ||
194 | */ | ||
195 | GNUNET_PSYC_SOT_ADD_STATE, | ||
196 | |||
197 | /** | ||
198 | * Remove the given value from the set of values in the state ("-"). | ||
199 | */ | ||
200 | GNUNET_PSYC_SOT_REMOVE_STATE | ||
201 | |||
202 | }; | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Update channel state or variables. The state of a channel must fit | ||
207 | * into the memory of each member (and the channel); large values that | ||
208 | * require streaming must only be passed as the stream arguments to | ||
209 | * methods. State updates might not be transmitted to group members | ||
210 | * until the next call to 'GNUNET_PSYC_channel_broadcast_call_method'. | ||
211 | * Variable updates must be given just before the call to the | ||
212 | * respective method that needs the variables. | ||
395 | * | 213 | * |
396 | * @param origin handle to the psyc group / channel | 214 | * @param channel handle to the PSYC group / channel |
397 | * @param full_state_name name of the field in the channel state to change | 215 | * @param full_state_name name of the field in the channel state to change |
216 | * @param type kind of update operation (add, remove, replace, delete) | ||
398 | * @param data_size number of bytes in data | 217 | * @param data_size number of bytes in data |
399 | * @param data new state value | 218 | * @param data new state value |
219 | * @return GNUNET_OK on success, GNUNET_SYSERR on internal error | ||
220 | * (i.e. state too large) | ||
400 | */ | 221 | */ |
401 | void | 222 | int |
402 | GNUNET_PSYC_origin_update_state (struct GNUNET_PSYC_Origin *origin, | 223 | GNUNET_PSYC_channel_update (struct GNUNET_PSYC_Channel *channel, |
403 | const char *full_state_name, | 224 | const char *full_state_name, |
404 | size_t data_size, | 225 | enum GNUNET_PSYC_Operator type, |
405 | const void *data); | 226 | size_t data_size, |
227 | const void *data); | ||
406 | 228 | ||
407 | 229 | ||
408 | /** | 230 | /** |
409 | * Data needed to construct a PSYC message to call a method. | 231 | * Function called to provide data for a transmission via PSYC. Note |
232 | * that returning GNUNET_OK or GNUNET_SYSERR (but not GNUNET_NO) | ||
233 | * invalidates the respective transmission handle. | ||
234 | * | ||
235 | * @param cls closure | ||
236 | * @param message_id set to the unique message ID that was generated for | ||
237 | * this message | ||
238 | * @param group_generation set to the group generation used for this | ||
239 | * message | ||
240 | * @param data_size initially set to the number of bytes available in 'data', | ||
241 | * should be set to the number of bytes written to data (IN/OUT) | ||
242 | * @param data where to write the body of the message to give to the method; | ||
243 | * function must copy at most '*data_size' bytes to 'data'. | ||
244 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | ||
245 | * GNUNET_NO on success, if more data is to be transmitted later | ||
246 | * (should be used if 'data_size' was not big enough to take all the data) | ||
247 | * GNUNET_OK if this completes the transmission (all data supplied) | ||
410 | */ | 248 | */ |
411 | struct GNUNET_PSYC_CallData | 249 | typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, |
412 | { | 250 | uint64_t message_id, |
413 | 251 | uint64_t group_generation, | |
414 | /** | 252 | size_t *data_size, |
415 | * Name of the function to call. This name may be more specific | 253 | char *data); |
416 | * than the registered method name due to try&slice matching. | ||
417 | */ | ||
418 | const char *full_method_name; | ||
419 | |||
420 | /** | ||
421 | * Number of arguments to pass (other than closure and sender), | ||
422 | * length of the 'argv' array. | ||
423 | */ | ||
424 | unsigned int argc; | ||
425 | 254 | ||
426 | /** | ||
427 | * Arguments to pass to the function. | ||
428 | */ | ||
429 | const struct GNUNET_PSYC_Argument *argv; | ||
430 | 255 | ||
431 | }; | 256 | /** |
257 | * Handle for a pending PSYC transmission operation. | ||
258 | */ | ||
259 | struct GNUNET_PSYC_ChannelTransmitHandle; | ||
432 | 260 | ||
433 | 261 | ||
434 | /** | 262 | /** |
435 | * Send a message to call a method to all members in the psyc group. | 263 | * Send a message to call a method to all members in the PSYC channel |
264 | * (and all parent channels if this is a subchannel). | ||
436 | * | 265 | * |
437 | * @param origin handle to the psyc group | 266 | * @param channel handle to the PSYC multicast group |
438 | * @param increment_group_generation GNUNET_YES if we need to increment | 267 | * @param increment_group_generation GNUNET_YES if we need to increment |
439 | * the group generation counter after transmitting this message | 268 | * the group generation counter after transmitting this message |
440 | * @param call_data data needed to determine how to call which method | 269 | * @param full_method_name which method should be invoked |
441 | * @param message_id set to the unique message ID that was generated for | 270 | * @param notify function to call to obtain the arguments |
442 | * this message | 271 | * @param notify_cls closure for 'notify' |
443 | * @param group_generation set to the group generation used for this | 272 | * @return transmission handle, NULL on error (i.e. more than one request queued) |
444 | * message | 273 | */ |
445 | * FIXME: change to notify_transmit_ready-style to wait for ACKs? | 274 | struct GNUNET_PSYC_ChannelTransmitHandle * |
446 | * that'd also help with streaming arguments! | 275 | GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, |
447 | * => need to change multicast API first as well! | 276 | int increment_group_generation, |
277 | const char *full_method_name, | ||
278 | GNUNET_PSYC_ChannelReadyNotify notify, | ||
279 | void *notify_cls); | ||
280 | |||
281 | |||
282 | /** | ||
283 | * Abort transmission request to channel. | ||
284 | * | ||
285 | * @param th handle of the request that is being aborted | ||
448 | */ | 286 | */ |
449 | void | 287 | void |
450 | GNUNET_PSYC_origin_broadcast_call_method (struct GNUNET_PSYC_Origin *origin, | 288 | GNUNET_PSYC_channel_notify_transmit_ready_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); |
451 | int increment_group_generation, | ||
452 | const struct GNUNET_PSYC_CallData *call_data, | ||
453 | uint64_t *message_id, | ||
454 | uint64_t *group_generation); | ||
455 | 289 | ||
456 | 290 | ||
457 | /** | 291 | /** |
458 | * End a psyc group. | 292 | * End a PSYC channel. Note that subchannels MUST be ended before |
293 | * their parents. | ||
459 | * | 294 | * |
460 | * @param origin psyc group to terminate | 295 | * @param channel PSYC channel to terminate |
461 | */ | 296 | */ |
462 | void | 297 | void |
463 | GNUNET_PSYC_origin_end (struct GNUNET_PSYC_Origin *origin); | 298 | GNUNET_PSYC_channel_end (struct GNUNET_PSYC_Channel *channel); |
464 | 299 | ||
465 | 300 | ||
466 | /** | 301 | /** |
@@ -470,27 +305,27 @@ struct GNUNET_PSYC_Group; | |||
470 | 305 | ||
471 | 306 | ||
472 | /** | 307 | /** |
473 | * Convert 'origin' to a 'group' handle to access the 'group' APIs. | 308 | * Convert 'channel' to a 'group' handle to access the 'group' APIs. |
474 | * | 309 | * |
475 | * @param origin origin handle | 310 | * @param channel channel handle |
476 | * @return group handle, valid for as long as 'origin' is valid | 311 | * @return group handle, valid for as long as 'channel' is valid |
477 | */ | 312 | */ |
478 | struct GNUNET_PSYC_Group * | 313 | struct GNUNET_PSYC_Group * |
479 | GNUNET_PSYC_origin_get_group (struct GNUNET_PSYC_Origin *origin); | 314 | GNUNET_PSYC_channel_get_group (struct GNUNET_PSYC_Channel *channel); |
480 | 315 | ||
481 | 316 | ||
482 | /** | 317 | /** |
483 | * Add a member to the group. Note that this will NOT generate any | 318 | * Add a member to the group. Note that this will NOT generate any |
484 | * PSYC traffic, it will merely update the local data base to modify | 319 | * PSYC traffic, it will merely update the local data base to modify |
485 | * how we react to 'membership test' queries. The origin still needs to | 320 | * how we react to 'membership test' queries. The channel still needs to |
486 | * explicitly transmit a 'leave' message to notify other group members | 321 | * explicitly transmit a 'join' message to notify other group members |
487 | * and they then also must still call this function in their respective | 322 | * and they then also must still call this function in their respective |
488 | * methods handling the 'leave' message. This way, how 'join' and 'leave' | 323 | * methods handling the 'join' message. This way, how 'join' and 'leave' |
489 | * operations are exactly implemented is still up to the application; | 324 | * operations are exactly implemented is still up to the application; |
490 | * for example, there might be a 'leave_all' message to kick out everyone. | 325 | * for example, there might be a 'leave_all' method to kick out everyone. |
491 | * | 326 | * |
492 | * Note that group members are explicitly trusted to perform these | 327 | * Note that group members are explicitly trusted to execute such |
493 | * operations correctly; not doing so correctly will result in either | 328 | * methods correctly; not doing so correctly will result in either |
494 | * denying members access or offering access to group data to | 329 | * denying members access or offering access to group data to |
495 | * non-members. | 330 | * non-members. |
496 | * | 331 | * |
@@ -509,7 +344,7 @@ GNUNET_PSYC_group_member_admit (struct GNUNET_PSYC_Group *group, | |||
509 | /** | 344 | /** |
510 | * Remove a member from the group. Note that this will NOT generate any | 345 | * Remove a member from the group. Note that this will NOT generate any |
511 | * PSYC traffic, it will merely update the local data base to modify | 346 | * PSYC traffic, it will merely update the local data base to modify |
512 | * how we react to 'membership test' queries. The origin still needs to | 347 | * how we react to 'membership test' queries. The channel still needs to |
513 | * explicitly transmit a 'leave' message to notify other group members | 348 | * explicitly transmit a 'leave' message to notify other group members |
514 | * and they then also must still call this function in their respective | 349 | * and they then also must still call this function in their respective |
515 | * methods handling the 'leave' message. This way, how 'join' and 'leave' | 350 | * methods handling the 'leave' message. This way, how 'join' and 'leave' |
@@ -534,17 +369,19 @@ GNUNET_PSYC_group_member_kick (struct GNUNET_PSYC_Group *group, | |||
534 | 369 | ||
535 | 370 | ||
536 | /** | 371 | /** |
537 | * Function called to inform a member about state values for a channel. | 372 | * Function called to inform a member about state changes for a |
373 | * channel. Note that (for sets) only the delta is communicated, not | ||
374 | * the full state. | ||
538 | * | 375 | * |
539 | * @param cls closure | 376 | * @param cls closure |
540 | * @param full_state_name full name of the state | 377 | * @param full_state_name full name of the state |
541 | * @param data_size number of bytes in 'data' | 378 | * @param type how to interpret the change |
542 | * @param data raw data of the state | 379 | * @param state_value information about the new state |
543 | */ | 380 | */ |
544 | typedef void (*GNUNET_PSYC_StateCallback)(void *cls, | 381 | typedef void (*GNUNET_PSYC_StateCallback)(void *cls, |
545 | const char *full_state_name, | 382 | const char *full_state_name, |
546 | size_t data_size, | 383 | enum GNUNET_PSYC_Operator type, |
547 | const void *data); | 384 | const struct GNUNET_PSYC_Argument *state_value); |
548 | 385 | ||
549 | 386 | ||
550 | /** | 387 | /** |
@@ -571,8 +408,11 @@ struct GNUNET_PSYC_StateHandler | |||
571 | /** | 408 | /** |
572 | * Description of the kind of state that the handler expects to see. | 409 | * Description of the kind of state that the handler expects to see. |
573 | * Non-matching state updates will be ignored (but logged). Note | 410 | * Non-matching state updates will be ignored (but logged). Note |
574 | * that the state_types of all states with the same state name prefix | 411 | * that the state_types of all states with the same state name |
575 | * should be identical. | 412 | * prefix should be identical. For state types, the |
413 | * 'GNUNET_PSYC_AF_STREAMABLE' and 'GNUNET_PSYC_AF_SET_STREAMABLE' | ||
414 | * flags must never be set (as the channel state should be small | ||
415 | * enough to (easily) fit into the memory of all PSYC members). | ||
576 | */ | 416 | */ |
577 | struct GNUNET_PSYC_ArgumentDescriptor state_type; | 417 | struct GNUNET_PSYC_ArgumentDescriptor state_type; |
578 | 418 | ||
@@ -580,56 +420,137 @@ struct GNUNET_PSYC_StateHandler | |||
580 | 420 | ||
581 | 421 | ||
582 | /** | 422 | /** |
583 | * Join a psyc group. The entity joining is always the local peer. | 423 | * Join a PSYC group. The entity joining is always the local peer. |
584 | * This will send a 'join_msg' to the origin; if it succeeds, the | 424 | * This will send a 'join_msg' to the channel; if it succeeds, the |
585 | * channel state will be replayed to the joining member and the 'join' | 425 | * channel state (and 'recent' method calls) will be replayed to the |
586 | * method will be invoked to show that we joined successfully. There | 426 | * joining member and the 'join' method will be invoked to show that |
587 | * is no explicit notification on failure (as the origin may simply | 427 | * we joined successfully. There is no explicit notification on |
588 | * take days to approve, and disapproval is simply being ignored). | 428 | * failure (as the channel may simply take days to approve, and |
429 | * disapproval is simply being ignored). | ||
589 | * | 430 | * |
590 | * Note that we also specify the message to transmit to origin on | ||
591 | * 'leave' here, as a sudden crash might otherwise not permit sending | ||
592 | * a 'nice' leave message. TODO: we might want an API to change | ||
593 | * the 'leave' message later during the session. | ||
594 | * | ||
595 | * @param cfg configuration to use | 431 | * @param cfg configuration to use |
596 | * @param pub_key ECC key that identifies the group | 432 | * @param pub_key ECC key that identifies the channel we wish to join |
597 | * @param method_count number of methods in 'methods' array | 433 | * @param method_count number of methods in 'methods' array |
598 | * @param methods functions to invoke on messages received from the origin, | 434 | * @param methods functions to invoke on messages received from the channel, |
599 | * typcially at least contains functions for 'join' and 'leave'. | 435 | * typcially at least contains functions for 'join' and 'leave'. |
600 | * @param state_count number of state handlers | 436 | * @param state_count number of state handlers |
601 | * @param state_handlers array of state event handlers | 437 | * @param state_handlers array of state event handlers |
602 | * @param join_data method to invoke on origin to trigger joining; | 438 | * @param join_msg which method should we invoke on the channel controller |
603 | * use NULL to send nothing (useful for anonymous groups that permit anyone); | 439 | * to try to join the channel (i.e. "join") |
604 | arguments to give to join method, must not include streaming args | 440 | * @param join_cb method to invoke on channel to obtain arguments |
605 | * @param leave_data method to invoke on origin on leaving; | 441 | * for a join method invocation; |
606 | * use NULL to send nothing (useful for anonymous groups that permit anyone); | 442 | * use NULL to send nothing (useful for anonymous groups that permit anyone); |
607 | arguments to give to leave method, must not include streaming args | 443 | * arguments to give to join method, must not include streaming args |
444 | * @param join_cb_cls closure for 'join_cb' | ||
608 | * @return handle for the member, NULL on error | 445 | * @return handle for the member, NULL on error |
609 | */ | 446 | */ |
610 | struct GNUNET_PSYC_Member * | 447 | struct GNUNET_PSYC_Member * |
611 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 448 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
612 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, | 449 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, |
613 | unsigned int method_count, | 450 | unsigned int method_count, |
614 | const struct GNUNET_PSYC_MethodDescriptor *methods, | 451 | const struct GNUNET_PSYC_Method *methods, |
615 | unsigned int state_count, | 452 | unsigned int state_count, |
616 | struct GNUNET_PSYC_StateHandler *state_handlers, | 453 | struct GNUNET_PSYC_StateHandler *state_handlers, |
617 | const struct GNUNET_PSYC_CallData *join_data, | 454 | const char *join_method, |
618 | const struct GNUNET_PSYC_CallData *leave_data); | 455 | const struct GNUNET_PSYC_ChannelReadyNotify join_cb, |
456 | void *join_cb_cls); | ||
457 | |||
458 | |||
459 | /** | ||
460 | * Function called to provide data for a transmission to the channel | ||
461 | * owner (aka the 'host' of the channel). Note that returning | ||
462 | * GNUNET_OK or GNUNET_SYSERR (but not GNUNET_NO) invalidates the | ||
463 | * respective transmission handle. | ||
464 | * | ||
465 | * @param cls closure | ||
466 | * @param data_size initially set to the number of bytes available in 'data', | ||
467 | * should be set to the number of bytes written to data (IN/OUT) | ||
468 | * @param data where to write the body of the message to give to the method; | ||
469 | * function must copy at most '*data_size' bytes to 'data'. | ||
470 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | ||
471 | * GNUNET_NO on success, if more data is to be transmitted later | ||
472 | * GNUNET_OK if this completes the transmission (all data supplied) | ||
473 | */ | ||
474 | typedef int (*GNUNET_PSYC_HostReadyNotify)(void *cls, | ||
475 | size_t *data_size, | ||
476 | char *data); | ||
477 | |||
478 | |||
479 | /** | ||
480 | * Handle for a pending PSYC transmission operation. | ||
481 | */ | ||
482 | struct GNUNET_PSYC_HostTransmitHandle; | ||
619 | 483 | ||
620 | 484 | ||
621 | /** | 485 | /** |
622 | * Request a message to be send to the origin. | 486 | * Request a message to be send to the channel. |
623 | * | 487 | * |
624 | * @param member membership handle | 488 | * @param member membership handle |
625 | * @param request_data which method should be invoked on origin (and how) | 489 | * @param request_data which method should be invoked on channel (and how) |
490 | * @param method_name which method should be invoked | ||
491 | * @param argc number of arguments the method takes (size of 'ads' array) | ||
492 | * @param ads description of the arguments the method takes | ||
493 | * @param notify function to call to obtain the arguments | ||
494 | * @param notify_cls closure for 'notify' | ||
495 | * @return transmission handle, NULL on error (i.e. more than one request queued) | ||
496 | */ | ||
497 | struct GNUNET_PSYC_HostTransmitHandle * | ||
498 | GNUNET_PSYC_member_send_to_host (struct GNUNET_PSYC_Member *member, | ||
499 | const char *method_name, | ||
500 | GNUNET_PSYC_HostReadyNotify notify, | ||
501 | void *notify_cls); | ||
502 | |||
503 | |||
504 | /** | ||
505 | * Abort transmission request to host. | ||
506 | * | ||
507 | * @param th handle of the request that is being aborted | ||
508 | */ | ||
509 | void | ||
510 | GNUNET_PSYC_member_send_to_host_cancel (struct GNUNET_PSYC_HostTransmitHandle *th); | ||
511 | |||
512 | |||
513 | /** | ||
514 | * Handle to a story telling operation. | ||
515 | */ | ||
516 | struct GNUNET_PSYC_Story; | ||
517 | |||
518 | |||
519 | /** | ||
520 | * Request to be told the message history of the channel. Historic | ||
521 | * messages (but NOT the state at the time) will be replayed (given to | ||
522 | * the normal method handlers) if available and if access is | ||
523 | * permitted. | ||
524 | * | ||
525 | * @param member which channel should be replayed? | ||
526 | * @param start earliest interesting point in history | ||
527 | * @param end last (exclusive) interesting point in history | ||
528 | * @param finish_cb function to call when the requested story has been fully | ||
529 | * told (counting message IDs might not suffice, as some messages | ||
530 | * might be secret and thus the listener would not know the story is | ||
531 | * finished without being told explicitly); once this function | ||
532 | * has been called, the client must not call | ||
533 | * 'GNUNET_PSYC_member_story_tell_cancel' anymore | ||
534 | * @param finish_cb_cls closure to finish_cb | ||
535 | * @return handle to cancel story telling operation | ||
536 | */ | ||
537 | struct GNUNET_PSYC_Story * | ||
538 | GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, | ||
539 | uint64_t start, | ||
540 | uint64_t end, | ||
541 | void (*finish_cb)(void *), | ||
542 | void *finish_cb_cls); | ||
543 | |||
544 | |||
545 | /** | ||
546 | * Abort story telling. This function must not be called from within | ||
547 | * method handlers (as given to 'GNUNET_PSYC_member_join') of the | ||
548 | * member. | ||
626 | * | 549 | * |
627 | * FIXME: change to notify_transmit_ready-style to wait for ACKs | 550 | * @param story story telling operation to stop |
628 | * and to enable streaming arguments! | ||
629 | */ | 551 | */ |
630 | void | 552 | void |
631 | GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, | 553 | GNUNET_PSYC_member_story_tell_cancel (struct GNUNET_PSYC_Story *story); |
632 | const struct GNUNET_PSYC_CallData *request_data); | ||
633 | 554 | ||
634 | 555 | ||
635 | /** | 556 | /** |
@@ -644,8 +565,10 @@ GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, | |||
644 | * might be longer, this is only the prefix that must match) | 565 | * might be longer, this is only the prefix that must match) |
645 | * @param cb function to call on the matching state values | 566 | * @param cb function to call on the matching state values |
646 | * @param cb_cls closure for 'cb' | 567 | * @param cb_cls closure for 'cb' |
568 | * @return message ID for which the state was returned (last seen | ||
569 | * message ID) | ||
647 | */ | 570 | */ |
648 | int | 571 | uint64_t |
649 | GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, | 572 | GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, |
650 | const char *state_name, | 573 | const char *state_name, |
651 | GNUNET_PSYC_StateCallback cb, | 574 | GNUNET_PSYC_StateCallback cb, |
@@ -653,10 +576,35 @@ GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, | |||
653 | 576 | ||
654 | 577 | ||
655 | /** | 578 | /** |
656 | * Leave a mutlicast group. Will terminate the connection to the PSYC | 579 | * Obtain the current value of a variable. This function should only |
657 | * service, which will send the 'leave' method that was prepared | 580 | * be called during a GNUNET_PSYC_Method invocation (and even then |
658 | * earlier to the origin. This function must not be called on a | 581 | * only if the origin is the state owner), as variables are only valid |
659 | * 'member' that was obtained from GNUNET_PSYC_origin_get_group. | 582 | * for the duration of a method invocation. If this function is |
583 | * called outside of the scope of such a method invocation, it will | ||
584 | * return NULL. | ||
585 | * | ||
586 | * FIXME: do variables have a hierarchy as well? If so, | ||
587 | * we should document the lookup semantics. | ||
588 | * | ||
589 | * @param member membership handle | ||
590 | * @param variable_name name of the variable to query | ||
591 | * @param return_value_size set to number of bytes in variable, | ||
592 | * needed as variables might contain binary data and | ||
593 | * might also not be 0-terminated; set to 0 on errors | ||
594 | * @return NULL on error, pointer to variable state otherwise | ||
595 | */ | ||
596 | const char * | ||
597 | GNUNET_PSYC_member_variable_get (struct GNUNET_PSYC_Member *member, | ||
598 | const char *variable_name, | ||
599 | size_t *return_value_size); | ||
600 | |||
601 | |||
602 | /** | ||
603 | * Leave a multicast group. Will terminate the connection to the PSYC | ||
604 | * service. Polite clients should first explicitly send a 'leave' | ||
605 | * request (via 'GNUNET_PSYC_member_send_to_host'). This function | ||
606 | * must not be called on a 'member' that was obtained from | ||
607 | * GNUNET_PSYC_channel_get_group. | ||
660 | * | 608 | * |
661 | * @param member membership handle | 609 | * @param member membership handle |
662 | */ | 610 | */ |