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