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