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