PSYC APIs: added missing args and functions, more consistent naming
[oweals/gnunet.git] / src / include / gnunet_psyc_service.h
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_psyc_service.h
23  * @brief PSYC service; high-level access to the PSYC protocol
24  *        note that clients of this API are NOT expected to
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!
30  * @author Christian Grothoff
31  * @author Gabor X Toth
32  *
33  * NOTE:
34  * - this API does not know about psyc's "root" and "places";
35  *   there is no 'root' in GNUnet-Psyc as we're decentralized;
36  *   'places' and 'persons' are combined within the same 
37  *   abstraction, that of a "channel".  Channels are identified
38  *   and accessed in this API using a public/private key.  
39  *   Higher-level applications should use NAMES within GADS
40  *   to obtain public keys, and the distinction between 
41  *   'places' and 'persons' can then be made with the help
42  *   of the naming system (and/or conventions).
43  *   Channels are (as in PSYC) organized into a hierarchy; each
44  *   channel owner (the one with the private key) is then
45  *   the operator of the multicast group (its Origin in 
46  *   the terminology of the multicast API).
47  * - The API supports passing large amounts of data using
48  *   'streaming' for the argument passed to a method.  State
49  *   and variables must fit into memory and cannot be streamed
50  *   (thus, no passing of 4 GB of data in a variable; 
51  *   once we implement this, we might want to create a
52  *   @c \#define for the maximum size of a variable).
53  * - PSYC defines standard variables, methods, etc.  This
54  *   library deliberately abstracts over all of these; a
55  *   higher-level API should combine the naming system (GADS)
56  *   and standard methods (message, join, part, warn,
57  *   fail, error) and variables (action, color, time,
58  *   tag, etc.).  However, this API does take over the
59  *   routing variables, specifically 'context' (channel),
60  *   and 'source'.  We only kind-of support 'target', as
61  *   the target is either everyone in the group or the
62  *   origin, and never just a single member of the group;
63  *   for such individual messages, an application needs to
64  *   construct an 'inbox' channel where the owner (only)
65  *   receives messages (but never forwards; private responses
66  *   would be transmitted by joining the senders 'inbox'
67  *   channel -- or a inbox#bob subchannel).  The
68  *   goal for all of this is to keep the abstractions in this 
69  *   API minimal: interaction with multicast, try \& slice,
70  *   state/variable/channel management.  Higher-level
71  *   operations belong elsewhere (so maybe this API should
72  *   be called 'PSYC-low', whereas a higher-level API
73  *   implementing defaults for standard methods and
74  *   variables might be called 'PSYC-std' or 'PSYC-high'.
75  *
76  * Idee (lynx): 
77  * - rename "channel" to "master"
78  * - rename "member" to "slave"
79  * - rename "group" to "channel"
80  */
81
82 #ifndef GNUNET_PSYC_SERVICE_H
83 #define GNUNET_PSYC_SERVICE_H
84
85 #ifdef __cplusplus
86 extern "C"
87 {
88 #if 0                           /* keep Emacsens' auto-indent happy */
89 }
90 #endif
91 #endif
92
93 #include "gnunet_util_lib.h"
94 #include "gnunet_psyc_lib.h"
95 #include "gnunet_multicast_service.h"
96
97
98 /** 
99  * Version number of GNUnet-PSYC API.
100  */
101 #define GNUNET_PSYC_VERSION 0x00000000
102
103
104 /** 
105  * Information flags for data fragments set via PSYC.
106  */
107 enum GNUNET_PSYC_FragmentStatus
108 {
109   /** 
110    * This is the first part of data for the given method call.
111    */
112   GNUNET_PSYC_FS_FIRST = 1,
113   
114   /** 
115    * This is the last part of data for the given method call.
116    */
117   GNUNET_PSYC_FS_LAST = 2,
118
119   /** 
120    * OR'ed flags if payload is not fragmented.
121    */
122   GNUNET_PSYC_FS_NOT_FRAGMENTED = (GNUNET_PSYC_FS_FIRST | GNUNET_PSYC_FS_LAST)
123 };
124
125
126 /** 
127  * Handle that identifies a join request.
128  *
129  * Used to match calls to #GNUNET_PSYC_JoinCallback to the
130  * corresponding calls to GNUNET_PSYC_join_decision().
131  */
132 struct GNUNET_PSYC_JoinHandle;
133
134 /** 
135  * Handle that identifies a part request.
136  *
137  * Used to match calls to #GNUNET_PSYC_PartCallback to the
138  * corresponding calls to GNUNET_PSYC_part_ack().
139  */
140 struct GNUNET_PSYC_PartHandle;
141
142
143 /** 
144  * Method called from PSYC upon receiving a message indicating a call
145  * to a @e method.  
146  *
147  * @param cls Closure.
148  * @param sender Who transmitted the message (origin, except for messages
149  *        from one of the members to the origin).
150  * @param message_id Unique message counter for this message;
151  *                   (unique only in combination with the given sender for
152  *                    this channel).
153  * @param group_generation Group generation counter for this message
154  *                   (always zero for messages from members to channel owner); FIXME: needed?
155  * @param method_name Original method name from PSYC (may be more
156  *        specific than the registered method name due to try-and-slice matching).
157  *        FIXME: no try-and-slice for methods defined here.
158  * @param data_off Byte offset of @a data in the overall data of the method.
159  * @param data_size Number of bytes in @a data.
160  * @param data Data stream given to the method (might not be zero-terminated 
161  *             if data is binary).
162  * @param frag Fragmentation status for the data.
163  */
164 typedef int (*GNUNET_PSYC_Method)(void *cls,
165                                   const struct GNUNET_PeerIdentity *sender,
166                                   uint64_t message_id,
167                                   uint64_t group_generation,
168                                   const char *method_name,
169                                   uint64_t data_off,
170                                   size_t data_size,
171                                   const void *data,
172                                   enum GNUNET_PSYC_FragmentStatus frag);
173
174
175 /** 
176  * Method called from PSYC upon receiving a join request.
177  *
178  * @param cls Closure.
179  * @param sender Who transmitted the message.
180  * @param method_name Method name in the join request.
181  * @param data_size Number of bytes in @a data.
182  * @param data Data stream given to the method (might not be zero-terminated 
183  *             if data is binary).
184  */
185 typedef int (*GNUNET_PSYC_JoinCallback)(void *cls,
186                                         const struct GNUNET_PeerIdentity *sender,
187                                         const char *method_name,
188                                         size_t data_size,
189                                         const void *data,
190                                         struct GNUNET_PSYC_JoinHandle *jh);
191
192
193 /** 
194  * Method called from PSYC upon receiving a part request.
195  *
196  * @param cls Closure.
197  * @param sender Who transmitted the message.
198  * @param method_name Method name in the part request.
199  * @param data_size Number of bytes in @a data.
200  * @param data Data stream given to the method (might not be zero-terminated 
201  *             if data is binary).
202  */
203 typedef int (*GNUNET_PSYC_PartCallback)(void *cls,
204                                         const struct GNUNET_PeerIdentity *sender,
205                                         const char *method_name,
206                                         size_t data_size,
207                                         const void *data,
208                                         struct GNUNET_PSYC_PartHandle *ph);
209
210
211 /** 
212  * Function to call with the decision made for a join request.
213  *
214  * Must be called once and only once in response to an invocation of the
215  * #GNUNET_PSYC_JoinCallback.
216  *
217  * @param jh Join request handle.
218  * @param is_admitted #GNUNET_YES if joining is approved,
219  *        #GNUNET_NO if it is disapproved
220  * @param method_name Method name for the message transmitted with the response.
221  * @param data_size Size of @a data.
222  * @param data Data of the message.
223  */
224 void
225 GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
226                            int is_admitted,
227                            const char *method_name,
228                            size_t data_size,
229                            const void *data);
230
231
232 /** 
233  * Send a part acknowledgment.
234  *
235  * @param ph Part handle.
236  */
237 void
238 GNUNET_PSYC_part_ack (struct GNUNET_PSYC_PartHandle *ph);
239
240
241 /** 
242  * Handle for the channel of a PSYC group.
243  */
244 struct GNUNET_PSYC_Channel;
245
246
247 /** 
248  * Create a PSYC channel.
249  *
250  * Will create a multicast group identified by the given ECC key.  Messages
251  * received from group members will be given to the respective handler methods.
252  * If a new member wants to join a group, the "join" method handler will be
253  * invoked; the join handler must then generate a "join" message to approve the
254  * joining of the new member.  The channel can also change group membership
255  * without explicit requests.  Note that PSYC doesn't itself "understand" join
256  * or part messages, the respective methods must call other PSYC functions to
257  * inform PSYC about the meaning of the respective events.
258  *
259  * @param cfg Configuration to use (to connect to PSYC service).
260  * @param priv_key ECC key that will be used to sign messages for this
261  *                 PSYC session; public key is used to identify the
262  *                 PSYC group; FIXME: we'll likely want to use
263  *                 NOT the p521 curve here, but a cheaper one in the future
264  *                 Note that end-users will usually not use the private key
265  *                 directly, but rather look it up in GADS for groups 
266  *                 managed by other users, or select a file with the private
267  *                 key(s) when setting up their own channels
268  * @param join_policy What is the membership policy of the group?
269  *                 Used to automate group management decisions.
270  * @param method_cb Function to invoke on messages received from members.
271  * @param join_cb Function to invoke when a peer wants to join.
272  * @param part_cb Function to invoke when a peer wants to part.
273  * @param cls Closure for the callbacks.
274  * @return Handle for the channel, NULL on error.
275  */
276 struct GNUNET_PSYC_Channel *
277 GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
278                             const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
279                             enum GNUNET_MULTICAST_JoinPolicy join_policy,
280                             GNUNET_PSYC_Method method_cb,
281                             GNUNET_PSYC_JoinCallback join_cb,
282                             GNUNET_PSYC_PartCallback part_cb,
283                             void *cls);
284
285
286 /** 
287  * Modify channel state (or set a transient variable).
288  *
289  * The state of a channel must fit into the memory of each member (and the
290  * channel); large values that require streaming must only be passed as the
291  * stream arguments to methods.  State modifications might not be transmitted to
292  * group members until the next call to GNUNET_PSYC_channel_transmit().
293  * Variable updates must be given just before the call to the respective method
294  * that needs the variables.
295  *
296  * @param channel Handle to the PSYC group / channel.
297  * @param oper Kind of update operation (add, remove, replace, delete).
298  * @param name Name of the state or transient variable to modify.
299  * @param value_size Number of bytes in @a value.
300  * @param value Value of state variable.
301  * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error
302  *        (i.e. state too large).
303  */
304 int
305 GNUNET_PSYC_channel_state_modify (struct GNUNET_PSYC_Channel *channel,
306                                   enum GNUNET_PSYC_Operator oper,
307                                   const char *name,
308                                   size_t value_size,
309                                   const void *value);
310
311
312 /** 
313  * Function called to provide data for a transmission via PSYC.
314  *
315  * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
316  * invalidates the respective transmission handle.
317  *
318  * @param cls Closure.
319  * @param message_id Set to the unique message ID that was generated for
320  *        this message.
321  * @param group_generation Set to the group generation used for this
322   *        message.
323  * @param data_size[in,out] Initially set to the number of bytes available in @a data,
324  *        should be set to the number of bytes written to data (IN/OUT).
325  * @param[out] data Where to write the body of the message to give to the method;
326  *        function must copy at most @a *data_size bytes to @a data.
327  * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
328  *         #GNUNET_NO on success, if more data is to be transmitted later 
329  *         (should be used if @a *data_size was not big enough to take all the data)
330  *         #GNUNET_YES if this completes the transmission (all data supplied)
331  */
332 typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls,
333                                               uint64_t message_id,
334                                               uint64_t group_generation,
335                                               size_t *data_size,
336                                               void *data);
337
338
339 /** 
340  * Handle for a pending PSYC transmission operation. 
341  */
342 struct GNUNET_PSYC_ChannelTransmitHandle;
343
344
345 /** 
346  * Send a message to call a method to all members in the PSYC channel.
347  *
348  * @param channel Handle to the PSYC multicast group.
349  * @param increment_group_generation #GNUNET_YES if we need to increment
350  *        the group generation counter after transmitting this message.
351  * @param method_name Which method should be invoked.
352  * @param notify Function to call to obtain the arguments.
353  * @param notify_cls Closure for @a notify.
354  * @return Transmission handle, NULL on error (i.e. more than one request queued).
355  */
356 struct GNUNET_PSYC_ChannelTransmitHandle *
357 GNUNET_PSYC_channel_transmit (struct GNUNET_PSYC_Channel *channel,
358                               int increment_group_generation,
359                               const char *method_name,
360                               GNUNET_PSYC_ChannelReadyNotify notify,
361                               void *notify_cls);
362
363
364 /** 
365  * Abort transmission request to channel.
366  *
367  * @param th Handle of the request that is being aborted.
368  */
369 void
370 GNUNET_PSYC_channel_transmit_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th);
371
372
373 /** 
374  * Destroy a PSYC channel.
375  *
376  * @param channel PSYC channel to terminate.
377  */
378 tvoid
379 GNUNET_PSYC_channel_destroy (struct GNUNET_PSYC_Channel *channel);
380
381
382 /** 
383  * Handle to access PSYC group operations for all members.
384  */
385 struct GNUNET_PSYC_Group;
386
387
388 /** 
389  * Convert @a channel to a @e group handle to access the @e group APIs.
390  * 
391  * @param channel Channel handle.
392  * @return Group handle, valid for as long as @a channel is valid.
393  */ 
394 struct GNUNET_PSYC_Group *
395 GNUNET_PSYC_channel_get_group (struct GNUNET_PSYC_Channel *channel);
396
397
398 /** 
399  * Convert @a member to a @e group handle to access the @e group APIs.
400  * 
401  * @param member Membership handle.
402  * @return Group handle, valid for as long as @a member is valid.
403  */ 
404 struct GNUNET_PSYC_Group *
405 GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member);
406
407
408 /** 
409  * Add a member to the group.
410  *
411  * Note that this will NOT generate any PSYC traffic, it will merely update the
412  * local data base to modify how we react to <em>membership test</em> queries.  The
413  * channel still needs to explicitly transmit a @e join message to notify other
414  * group members and they then also must still call this function in their
415  * respective methods handling the @e join message.  This way, how @e join and
416  * @e part operations are exactly implemented is still up to the application;
417  * for example, there might be a @e part_all method to kick out everyone.
418  *
419  * Note that group members are explicitly trusted to execute such methods
420  * correctly; not doing so correctly will result in either denying members
421  * access or offering access to group data to non-members.
422  *
423  * @param group Group handle.
424  * @param member Which peer to add.
425  * @param message_id Message ID for the message that changed the membership.
426  * @param group_generation The generation ID where the change went into effect.
427  */
428 void
429 GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group,
430                               const struct GNUNET_PeerIdentity *member,
431                               uint64_t message_id,
432                               uint64_t group_generation);
433
434
435 /** 
436  * Remove a member from the group.
437  *
438  * Note that this will NOT generate any PSYC traffic, it will merely update the
439  * local data base to modify how we react to <em>membership test</em> queries.  The
440  * channel still needs to explicitly transmit a @e part message to notify other
441  * group members and they then also must still call this function in their
442  * respective methods handling the @e part message.  This way, how @e join and
443  * @e part operations are exactly implemented is still up to the application;
444  * for example, there might be a @e part_all message to kick out everyone.
445  *
446  * Note that group members are explicitly trusted to perform these
447  * operations correctly; not doing so correctly will result in either
448  * denying members access or offering access to group data to
449  * non-members.
450  *
451  * @param group Group handle.
452  * @param member Which peer to remove.
453  * @param message_id Message ID for the message that changed the membership.
454  * @param group_generation The generation ID where the change went into effect.
455  */
456 void
457 GNUNET_PSYC_group_member_remove (struct GNUNET_PSYC_Group *group,
458                                  const struct GNUNET_PeerIdentity *member,
459                                  uint64_t message_id,
460                                  uint64_t group_generation);
461
462
463 /** 
464  * Function called to inform a member about state changes for a channel.
465  *
466  * Note that (for sets) only the delta is communicated, not the full state.
467  *
468  * @param cls Closure.
469  * @param full_state_name Full name of the state.
470  * @param type How to interpret the change.
471  * @param state_value Information about the new state.
472  * @param state_value_size Number of bytes in @a state_value.
473  */
474 typedef void (*GNUNET_PSYC_StateCallback)(void *cls,
475                                           const char *full_state_name,
476                                           enum GNUNET_PSYC_Operator type,
477                                           const void *state_value,
478                                           size_t state_value_size);
479
480
481 /** 
482  * Descriptor for an event handler handling PSYC state updates.
483  */
484 struct GNUNET_PSYC_StateHandler
485 {
486
487   /** 
488    * Name of the state variable this handler calls about, used in try-and-slice matching.
489    */
490   const char *state_name;
491
492   /** 
493    * Function to call whenever the respective state changes.
494    */
495   GNUNET_PSYC_StateCallback event_handler;
496
497   /** 
498    * Closure for the @a event_handler function.
499    */
500   void *event_handler_cls;
501
502 };
503
504 /** 
505  * Join a PSYC group.
506  *
507  * The entity joining is always the local peer.  The user must immediately use
508  * the GNUNET_PSYC_member_to_origin() (and possibly
509  * GNUNET_PSYC_member_origin_variable_set()) functions to transmit a @e join_msg to
510  * the channel; if the join request succeeds, the channel state (and @e recent
511  * method calls) will be replayed to the joining member.  There is no explicit
512  * notification on failure (as the channel may simply take days to approve, a-v/snd
513  * disapproval is simply being ignored).
514  *
515  * @param cfg Configuration to use.
516  * @param pub_key ECC key that identifies the channel we wish to join
517  * @param origin Peer identity of the origin.
518  * @param method Function to invoke on messages received from the channel,
519  *                typically at least contains functions for @e join and @e part.
520  * @param method_cls Closure for @a method.
521  * @param state_count Number of @a state_handlers.
522  * @param state_handlers Array of state event handlers.
523  * @return Handle for the member, NULL on error.
524  */
525 struct GNUNET_PSYC_Member *
526 GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 
527                          const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
528                          const struct GNUNET_PeerIdentity *origin,
529                          GNUNET_PSYC_Method method,
530                          void *method_cls,
531                          unsigned int state_count,
532                          struct GNUNET_PSYC_StateHandler *state_handlers);
533
534
535 /** 
536  * Part a PSYC group.
537  *
538  * Will terminate the connection to the PSYC service.  Polite clients should
539  * first explicitly send a @e part request (via GNUNET_PSYC_member_to_origin()).
540  *
541  * @param member membership handle
542  */
543 void
544 GNUNET_PSYC_member_part (struct GNUNET_PSYC_Member *member);
545
546
547 /** 
548  * Function called to provide data for a transmission to the channel
549  * owner (aka the @e host of the channel).
550  *
551  * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
552  * invalidates the respective transmission handle.
553  *
554  * @param cls Closure.
555  * @param data_size[in,out] Initially set to the number of bytes available in @a data,
556  *        should be set to the number of bytes written to data (IN/OUT).
557  * @param[out] data Where to write the body of the message to give to the method;
558  *        function must copy at most @a *data_size bytes to @a data.
559  * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
560  *         #GNUNET_NO on success, if more data is to be transmitted later.
561  *         #GNUNET_YES if this completes the transmission (all data supplied).
562  */
563 typedef int (*GNUNET_PSYC_MemberReadyNotify)(void *cls,
564                                              size_t *data_size,
565                                              char *data);
566
567
568 /** 
569  * Handle for a pending PSYC transmission operation.
570  */
571 struct GNUNET_PSYC_MemberTransmitHandle;
572
573
574 /** 
575  * Request a message to be sent to the channel origin.
576  *
577  * @param member Membership handle.
578  * @param method_name Which (PSYC) method should be invoked (on host).
579  * @param notify Function to call when we are allowed to transmit (to get data).
580  * @param notify_cls Closure for @a notify.
581  * @return Transmission handle, NULL on error (i.e. more than one request queued).
582  */
583 struct GNUNET_PSYC_MemberTransmitHandle *
584 GNUNET_PSYC_member_to_origin (struct GNUNET_PSYC_Member *member,
585                               const char *method_name,
586                               GNUNET_PSYC_MemberReadyNotify notify,
587                               void *notify_cls);
588
589
590 /** 
591  * Set a (temporary, ":") variable for the next message being transmitted
592  * via GNUNET_PSYC_member_to_origin().
593  *
594  * If GNUNET_PSYC_member_to_origin() is called and then cancelled, all
595  * variables that were set using this function will be unset (lost/forgotten).
596  * To clear a variable state after setting it, you can also call this function
597  * again with NULL/0 for the @a value.
598  *
599  * @param member Membership handle.
600  * @param variable_name Name of the variable to set.
601  * @param value Value to set for the given variable.
602  * @param value_size Number of bytes in @a value.
603  */
604 uint64_t
605 GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member,
606                                         const char *variable_name,
607                                         const void *value,
608                                         size_t value_size);
609
610
611 /** 
612  * Abort transmission request to origin.
613  *
614  * @param th Handle of the request that is being aborted.
615  */
616 void
617 GNUNET_PSYC_member_to_origin_cancel (struct GNUNET_PSYC_MemberTransmitHandle *th);
618
619
620 /** 
621  * Handle to a story telling operation.
622  */
623 struct GNUNET_PSYC_Story;
624
625
626 /** 
627  * Request to be told the message history of the channel.
628  *
629  * Historic messages (but NOT the state at the time) will be replayed (given to
630  * the normal method handlers) if available and if access is permitted.
631  *
632  * To get the latest message, use 0 for both the start and end message ID.
633  *
634  * @param member Which channel should be replayed?
635  * @param start_message_id Earliest interesting point in history.
636  * @param end_message_id Last (exclusive) interesting point in history.
637  * @param method Function to invoke on messages received from the story.
638  * @param method_cls Closure for @a method.
639  * @param finish_cb Function to call when the requested story has been fully 
640  *        told (counting message IDs might not suffice, as some messages
641  *        might be secret and thus the listener would not know the story is 
642  *        finished without being told explicitly); once this function
643  *        has been called, the client must not call
644  *        GNUNET_PSYC_member_story_tell_cancel() anymore.
645  * @param finish_cb_cls Closure to finish_cb.
646  * @return Handle to cancel story telling operation.
647  */
648 struct GNUNET_PSYC_Story *
649 GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member,
650                                uint64_t start_message_id,
651                                uint64_t end_message_id,
652                                GNUNET_PSYC_Method method,
653                                void *method_cls,
654                                void (*finish_cb)(void *),
655                                void *finish_cb_cls);
656
657
658 /** 
659  * Abort story telling.
660  *
661  * This function must not be called from within method handlers (as given to
662  * GNUNET_PSYC_member_join()) of the member.
663  *
664  * @param story Story telling operation to stop.
665  */
666 void
667 GNUNET_PSYC_member_story_tell_cancel (struct GNUNET_PSYC_Story *story);
668
669
670 /** 
671  * Call the given callback on all matching values (including variables) in the
672  * channel state.
673  *
674  * The callback is invoked synchronously on all matching states (as the state is
675  * fully replicated in the library in this process; channel states should be
676  * small, large data is to be passed as streaming data to methods).
677  *
678  * A name matches if it includes the @a state_name prefix, thus requesting the
679  * empty state ("") will match all values; requesting "_a_b" will also return
680  * values stored under "_a_b_c".
681  *
682  * @param member Membership handle.
683  * @param state_name Name of the state to query (full name 
684  *        might be longer, this is only the prefix that must match).
685  * @param cb Function to call on the matching state values.
686  * @param cb_cls Closure for @a cb.
687  * @return Message ID for which the state was returned (last seen
688  *         message ID).
689  */
690 uint64_t
691 GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member,
692                                   const char *state_name,
693                                   GNUNET_PSYC_StateCallback cb,
694                                   void *cb_cls);
695
696
697 /** 
698  * Obtain the current value of the best-matching value in the state
699  * (including variables).
700  *
701  * Note that variables are only valid during a #GNUNET_PSYC_Method invocation, as
702  * variables are only valid for the duration of a method invocation.
703  *
704  * If the requested variable name does not have an exact state in
705  * the state, the nearest less-specific name is matched; for example,
706  * requesting "_a_b" will match "_a" if "_a_b" does not exist.
707  *
708  * @param member Membership handle.
709  * @param variable_name Name of the variable to query.
710  * @param[out] return_value_size Set to number of bytes in variable, 
711  *        needed as variables might contain binary data and
712  *        might also not be 0-terminated; set to 0 on errors.
713  * @return NULL on error (no matching state or variable), pointer
714           to the respective value otherwise.
715  */
716 const void *
717 GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member,
718                               const char *variable_name,
719                               size_t *return_value_size);
720
721
722 #if 0                           /* keep Emacsens' auto-indent happy */
723 {
724 #endif
725 #ifdef __cplusplus
726 }
727 #endif
728
729 /* ifndef GNUNET_PSYC_SERVICE_H */
730 #endif
731 /* end of gnunet_psyc_service.h */