multicast/psyc: join cb for members/slaves too
[oweals/gnunet.git] / src / include / gnunet_multicast_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_multicast_service.h
23  * @brief multicast service; establish tunnels to distant peers
24  * @author Christian Grothoff
25  * @author Gabor X Toth
26  */
27
28 #ifndef GNUNET_MULTICAST_SERVICE_H
29 #define GNUNET_MULTICAST_SERVICE_H
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #if 0                           /* keep Emacsens' auto-indent happy */
35 }
36 #endif
37 #endif
38
39 #include "gnunet_util_lib.h"
40 #include "gnunet_transport_service.h"
41
42 /** 
43  * Version number of GNUnet-multicast API.
44  */
45 #define GNUNET_MULTICAST_VERSION 0x00000000
46
47
48 /** 
49  * Opaque handle for a multicast group member.
50  */
51 struct GNUNET_MULTICAST_Member;
52
53 /** 
54  * Handle for the origin of a multicast group.
55  */
56 struct GNUNET_MULTICAST_Origin;
57
58 /** 
59  * Policy flags for the group.
60  */
61 enum GNUNET_MULTICAST_GroupFlags
62 {
63   /**
64    * Admission must be confirmed by the origin.
65    */
66   GNUNET_MULTICAST_GROUP_ADMISSION_CONTROL = 1 << 0,
67
68   /**
69    * Past messages are only available to peers who were a member at the time
70    * they were sent to the group.
71    */
72   GNUNET_MULTICAST_GROUP_RESTRICTED_HISTORY = 1 << 1,
73 };
74
75 /** 
76  * Group membership policies.
77  */
78 enum GNUNET_MULTICAST_GroupPolicy
79 {
80   /**
81    * Anyone can join the group, without announcing his presence;
82    * all messages are always public and can be distributed freely.
83    * Joins may be announced, but this is not required.
84    */
85   GNUNET_MULTICAST_GROUP_ANONYMOUS = 0,
86
87   /** 
88    * Origin must approve membership to the group, messages must only be
89    * distributed to current group members.  This includes the group
90    * state as well as transient messages.
91    */
92   GNUNET_MULTICAST_GROUP_PRIVATE
93     = GNUNET_MULTICAST_GROUP_ADMISSION_CONTROL
94     | GNUNET_MULTICAST_GROUP_RESTRICTED_HISTORY,
95
96 #if IDEAS_FOR_FUTURE
97   /** 
98    * Anyone can freely join the group (no approval required);
99    * however, messages must only be distributed to current group
100    * members, so the origin must still acknowledge that the member
101    * joined before transient messages are delivered.  As approval is
102    * guaranteed, the presistent group state can be synchronized freely
103    * immediately, prior to origin confirmation.
104    */
105   GNUNET_MULTICAST_GROUP_OPEN
106     = GNUNET_MULTICAST_GROUP_RESTRICTED_HISTORY,
107
108   /**
109    * Origin must approve membership to the group, but past messages can be
110    * freely distributed to members.
111    */
112   GNUNET_MULTICAST_GROUP_CLOSED
113     = GNUNET_MULTICAST_GROUP_ADMISSION_CONTROL,
114 ,
115 #endif
116
117 };
118
119 enum GNUNET_MULTICAST_MessageFlags
120 {
121   /**
122    * First fragment of a message.
123    */
124   GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT = 1 << 0,
125
126   /**
127    * Last fragment of a message.
128    */
129   GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT = 1 << 1,
130
131   /** 
132    * OR'ed flags if message is not fragmented.
133    */
134   GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED
135     = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT
136     | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT
137 };
138
139
140 GNUNET_NETWORK_STRUCT_BEGIN
141
142 /** 
143  * Header of a multicast message fragment.
144  *
145  * This format is public as the replay mechanism must replay message fragments using the
146  * same format.  This is needed as we want to integrity-check message fragments within
147  * the multicast layer to avoid multicasting mal-formed messages.
148  */
149 struct GNUNET_MULTICAST_MessageHeader
150 {
151
152   /** 
153    * Header for all multicast message fragments from the origin.
154    */
155   struct GNUNET_MessageHeader header;
156
157   /** 
158    * Number of hops this message fragment has taken since the origin.
159    *
160    * Helpful to determine shortest paths to the origin for responses among
161    * honest peers; updated at each hop and thus not signed and not secure.
162    */
163   uint32_t hop_counter GNUNET_PACKED;
164
165   /** 
166    * ECC signature of the message fragment.
167    *
168    * Signature must match the public key of the multicast group.
169    */
170   struct GNUNET_CRYPTO_EccSignature signature;
171
172   /** 
173    * Signature of the multicast message fragment.
174    */
175   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
176
177   /** 
178    * Number of the message fragment, monotonically increasing.
179    */
180   uint64_t fragment_id GNUNET_PACKED;
181
182   /** 
183    * Number of the message this fragment belongs to.
184    */
185   uint64_t message_id GNUNET_PACKED;
186
187   /** 
188    * Number of fragments before the current one that has the same @a message_id.
189    *
190    * 0 for the first fragment of a message.
191    * This allows replaying a message with all of its fragments.
192    */
193   uint64_t fragment_delta GNUNET_PACKED;
194
195   /** 
196    * Byte offset of this @e fragment of the @e message.
197    */
198   uint64_t fragment_offset GNUNET_PACKED;
199
200   /** 
201    * Counter that monotonically increases whenever a member parts the group.
202    *
203    * It has significance in case of replay requests: when a member has missed
204    * messages and gets a replay request: in this case if the @a group_generation
205    * is still the same before and after the missed messages, it means that no
206    * @e join or @e part operations happened during the missed messages.
207    */
208   uint64_t group_generation GNUNET_PACKED;
209
210   /** 
211    * Difference between the current @a fragment_id and the @a fragment_id of the
212    * preceeding non-transient message.
213    * 
214    * Zero for transient messages, @c UINT64_MAX for the first message, or any
215    * other message creating a full state reset by the origin.  By subtracting
216    * @a state_delta from @a fragment_id, it is possible to calculate the message
217    * ID of the preceeding non-transient message and thus quickly traverse all
218    * state changes up to the last full state reset by the origin.  This is
219    * useful as it allows joining clients to quickly reassemble the state while
220    * skipping over transient messages (and doing so without having to trust
221    * intermediaries to do it right, as the indices in the chain are signed).  If
222    * the state chain is getting too long, the origin can choose to originate a
223    * state message with a state_delta of UINT64_MAX, thereby starting a new
224    * chain.  The origin will then have to re-create the full state with state
225    * update messages following the state reset message.
226    *
227    * Open question: needed in multicast, or just have this in PSYC; still might
228    * be useful for selective fetching of messages.  Still, that again should
229    * that not be done by PSYC?
230    */
231   uint64_t state_delta GNUNET_PACKED;
232
233   /**
234    * Flags for this message fragment.
235    */
236   enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED;
237
238   /** 
239    * Header for the message body.
240    *
241    * Three message types are specifically understood by multicast, namely "peer
242    * join", "peer part", and "group terminated".  Multicast will use those
243    * messages to update its list of candidates for content distribution.  All
244    * other message types are application-specific.
245    */
246   struct GNUNET_MessageHeader body;
247
248   /* Followed by message body. */
249 };
250
251
252 /** 
253  * Header of a request from a member to the origin.
254  *
255  * FIXME: this is going to be internal.
256  */
257 struct GNUNET_MULTICAST_RequestHeader
258 {
259   /** 
260    * Header for all requests from a member to the origin.
261    */
262   struct GNUNET_MessageHeader header;
263
264   /**
265    * Public key of the group.
266    */
267   struct GNUNET_CRYPTO_ECCPublicKey pub_key;
268
269   /**
270    * Flags for this request.
271    */
272   enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED;
273
274   /** 
275    * Header for the request body.
276    *
277    * Two request types are specifically understood by multicast, namely "peer
278    * join", "peer part".  Multicast will use those messages to update its list
279    * of candidates for content distribution.  All other message types are
280    * application-specific.
281    */
282   struct GNUNET_MessageHeader body;
283
284   /* Followed by request body. */
285 };
286
287 GNUNET_NETWORK_STRUCT_END
288
289
290 /** 
291  * Handle that identifies a join request.
292  *
293  * Used to match calls to #GNUNET_MULTICAST_JoinCallback to the
294  * corresponding calls to GNUNET_MULTICAST_join_decision().
295  */
296 struct GNUNET_MULTICAST_JoinHandle;
297
298
299 /** 
300  * Function to call with the decision made for a join request.
301  *
302  * Must be called once and only once in response to an invocation of the
303  * #GNUNET_MULTICAST_JoinCallback.
304  *
305  * @param jh Join request handle.
306  * @param is_admitted #GNUNET_YES if joining is approved,
307  *        #GNUNET_NO if it is disapproved
308  * @param relay_count Number of relays given.
309  * @param relays Array of suggested peers that might be useful relays to use
310  *        when joining the multicast group (essentially a list of peers that
311  *        are already part of the multicast group and might thus be willing
312  *        to help with routing).  If empty, only this local peer (which must
313  *        be the multicast origin) is a good candidate for building the
314  *        multicast tree.  Note that it is unnecessary to specify our own
315  *        peer identity in this array.
316  * @param join_response Message to send in response to the joining peer;
317  *        can also be used to redirect the peer to a different group at the
318  *        application layer; this response is to be transmitted to the
319  *        peer that issued the request even if admission is denied.
320  */
321 void
322 GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh,
323                                 int is_admitted,
324                                 unsigned int relay_count,
325                                 const struct GNUNET_PeerIdentity *relays,
326                                 const struct GNUNET_MessageHeader *join_response);
327
328
329 /** 
330  * Method called whenever another peer wants to join the multicast group.
331  *
332  * Implementations of this function must call GNUNET_MULTICAST_join_decision()
333  * with the decision.
334  *
335  * @param cls Closure.
336  * @param peer Identity of the peer that wants to join.
337  * @param join_req Application-dependent join message from the new user
338  *        (might, for example, contain a user,
339  *        bind user identity/pseudonym to peer identity, application-level
340  *        message to origin, etc.).
341  * @param jh Join handle to pass to GNUNET_MULTICAST_join_decison().
342  */
343 typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls,
344                                               const struct GNUNET_PeerIdentity *peer,
345                                               const struct GNUNET_MessageHeader *join_req,
346                                               struct GNUNET_MULTICAST_JoinHandle *jh);
347
348
349 /** 
350  * Handle to pass back for the answer of a membership test.
351  */
352 struct GNUNET_MULTICAST_MembershipTestHandle;
353
354
355 /** 
356  * Call informing multicast about the decision taken for membership test.
357  *
358  * @param mth Handle that was given for the query.
359  * @param decision #GNUNET_YES if peer was a member, #GNUNET_NO if peer was not a member,
360  *         #GNUNET_SYSERR if we cannot answer the membership test.
361  */
362 void
363 GNUNET_MULTICAST_membership_test_answer (struct GNUNET_MULTICAST_MembershipTestHandle *mth,
364                                          int decision);
365
366
367 /** 
368  * Method called to test if a member was in the group at a particular time.
369  *
370  * It is called when a replay request is received to determine if the requested
371  * message can be replayed.
372  *
373  * @param cls Closure.
374  * @param peer Identity of the peer that we want to test.
375  * @param fragment_id Message fragment ID for which we want to do the test.
376  * @param mth Handle to give to GNUNET_MULTICAST_membership_test_answer().
377  */
378 typedef void (*GNUNET_MULTICAST_MembershipTestCallback)(void *cls,
379                                                         const struct GNUNET_PeerIdentity *peer,
380                                                         uint64_t fragment_id,
381                                                         struct GNUNET_MULTICAST_MembershipTestHandle *mth);
382
383
384 /** 
385  * Function called whenever a group member has transmitted a request
386  * to the origin (other than joining or leaving).
387  *
388  * @param cls Closure (set from GNUNET_MULTICAST_origin_start).
389  * @param sender Identity of the sender.
390  * @param req Request to the origin.
391  * @param flags Flags for the request.
392  */
393 typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls,
394                                                   const struct GNUNET_PeerIdentity *sender,
395                                                   const struct GNUNET_MessageHeader *req,
396                                                   enum GNUNET_MULTICAST_MessageFlags flags);
397
398
399 /** 
400  * Function called whenever a group member is receiving a message fragment from
401  * the origin.
402  *
403  * If admission to the group is denied, this function is called once with the
404  * response of the @e origin (as given to GNUNET_MULTICAST_join_decision()) and
405  * then a second time with NULL to indicate that the connection failed for good.
406  *
407  * @param cls Closure (set from GNUNET_MULTICAST_member_join())
408  * @param msg Message from the origin, NULL if the origin shut down
409  *        (or we were kicked out, and we should thus call
410  *        GNUNET_MULTICAST_member_part() next)
411  */
412 typedef void (*GNUNET_MULTICAST_MessageCallback) (void *cls,
413                                                   const struct GNUNET_MULTICAST_MessageHeader *msg);
414
415
416 /** 
417  * Opaque handle to a replay request from the multicast service.
418  */
419 struct GNUNET_MULTICAST_ReplayHandle;
420
421
422 /** 
423  * Functions with this signature are called whenever the multicast service needs
424  * a message to be replayed.
425  *
426  * Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE
427  * (with a message or an error); however, if the origin is destroyed or the
428  * group is left, the replay handle must no longer be used.
429  *
430  * @param cls Closure (set from GNUNET_MULTICAST_origin_start()
431  *            or GNUNET_MULTICAST_member_join()).
432  * @param fragment_id Which message fragment should be replayed.
433  * @param rh Handle to pass to message transmit function.
434  */
435 typedef void (*GNUNET_MULTICAST_ReplayCallback) (void *cls,
436                                                  uint64_t fragment_id,
437                                                  struct GNUNET_MULTICAST_ReplayHandle *rh);
438
439
440 /** 
441  * Possible error codes during replay.
442  */
443 enum GNUNET_MULTICAST_ReplayErrorCode
444 {
445
446   /** 
447    * Everything is fine.
448    */
449   GNUNET_MULTICAST_REC_OK = 0,
450
451   /** 
452    * Message fragment has been discarded (likely transient message that was too old).
453    */
454   GNUNET_MULTICAST_REC_TRANSIENT_LOST = 1,
455
456   /** 
457    * Fragment ID counter was larger than the highest counter this
458    * replay function has ever encountered; thus it is likely the
459    * origin never sent it and we're at the HEAD of the multicast
460    * stream as far as this node is concerned.
461    */
462   GNUNET_MULTICAST_REC_PAST_HEAD = 2,
463
464   /** 
465    * Internal error (i.e. database error).  Try some other peer.
466    */
467   GNUNET_MULTICAST_REC_INTERNAL_ERROR = 3
468
469 };
470
471
472 /** 
473  * Replay a message from the multicast group.
474  *
475  * @param rh Replay handle identifying which replay operation was requested.
476  * @param msg Replayed message fragment, NULL if unknown/error.
477  * @param ec Error code.
478  */
479 void
480 GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh,
481                          const struct GNUNET_MULTICAST_MessageHeader *msg,
482                          enum GNUNET_MULTICAST_ReplayErrorCode ec);
483
484
485 /** 
486  * Start a multicast group.
487  *
488  * Will advertise the origin in the P2P overlay network under the respective
489  * public key so that other peer can find this peer to join it.  Peers that
490  * issue GNUNET_MULTICAST_member_join() can then transmit a join request to
491  * either an existing group member (if the @a policy is permissive) or to
492  * the origin.  If the joining is approved, the member is cleared for @e replay
493  * and will begin to receive messages transmitted to the group.  If joining is
494  * disapproved, the failed candidate will be given a response.  Members in the
495  * group can send messages to the origin (one at a time).
496  *
497  * @param cfg Configuration to use.
498  * @param priv_key ECC key that will be used to sign messages for this
499  *        multicast session; public key is used to identify the multicast group;
500  *        FIXME: we'll likely want to use NOT the p521 curve here, but a cheaper
501  *        one in the future.
502  * @param policy Group policy specifying join and history restrictions.
503  * @param last_fragment_id Last fragment ID to continue counting fragments from
504  *        when restarting the origin.  0 for a new group.
505  * @param join_cb Function called to approve / disapprove joining of a peer.
506  * @param test_cb Function multicast can use to test group membership.
507  * @param replay_cb Function that can be called to replay a message.
508  * @param request_cb Function called with message fragments from group members.
509  * @param message_cb Function called with the message fragments sent to the
510  *        network by GNUNET_MULTICAST_origin_to_all().  These message fragments
511  *        should be stored for answering replay requests later.
512  * @param cls Closure for the various callbacks that follow.
513  * @return Handle for the origin, NULL on error.
514  */
515 struct GNUNET_MULTICAST_Origin *
516 GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
517                                const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
518                                enum GNUNET_MULTICAST_GroupPolicy policy,
519                                uint64_t last_fragment_id,
520                                GNUNET_MULTICAST_JoinCallback join_cb,
521                                GNUNET_MULITCAST_MembershipTestCallback test_cb,
522                                GNUNET_MULITCAST_ReplayCallback replay_cb,
523                                GNUNET_MULTICAST_RequestCallback request_cb,
524                                GNUNET_MULTICAST_MessageCallback message_cb,
525                                void *cls);
526
527
528 /** 
529  * Handle for a request to send a message to all multicast group members
530  * (from the origin).
531  */
532 struct GNUNET_MULTICAST_OriginMessageHandle;
533
534
535 /** 
536  * Send a message to the multicast group.
537  *
538  * @param origin Handle to the multicast group.
539  * @param message_id Application layer ID for the message.
540  * @param group_generation Group generation of the message.  See GNUNET_MULTICAST_MessageHeader.
541  * @param state_delta State delta of the message.  See GNUNET_MULTICAST_MessageHeader.
542  * @param size Number of bytes to transmit.
543  * @param cb Function to call to get the message.
544  * @param cb_cls Closure for @a cb.
545  * @return NULL on error (i.e. request already pending).
546  */
547 struct GNUNET_MULTICAST_OriginMessageHandle *
548 GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
549                                 uint64_t message_id,
550                                 uint64_t group_generation,
551                                 uint64_t state_delta,
552                                 size_t size,
553                                 GNUNET_CONNECTION_TransmitReadyNotify cb,
554                                 void *cb_cls);
555
556
557 /** 
558  * Cancel request for message transmission to multicast group.
559  *
560  * @param mh Request to cancel.
561  */
562 void
563 GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginMessageHandle *mh);
564
565
566 /** 
567  * Stop a multicast group.
568  *
569  * @param origin Multicast group to stop.
570  */
571 void
572 GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin);
573
574
575 /** 
576  * Join a multicast group.
577  *
578  * The entity joining is always the local peer.  Further information about the
579  * candidate can be provided in the @a join_request message.  If the join fails, the
580  * @a message_cb is invoked with a (failure) response and then with NULL.  If
581  * the join succeeds, outstanding (state) messages and ongoing multicast
582  * messages will be given to the @a message_cb until the member decides to part
583  * the group.  The @a test_cb and @a replay_cb functions may be called at
584  * anytime by the multicast service to support relaying messages to other
585  * members of the group.
586  *
587  * @param cfg Configuration to use.
588  * @param pub_key ECC key that identifies the group.
589  * @param origin Peer identity of the origin, to send unicast requests to.
590  * @param relay_count Number of peers in the @a relays array.
591  * @param relays Peer identities of members of the group, which serve as relays
592  *        and can be used to join the group at. and send the @a join_request to.
593  *        If empty, the @a join_request is sent directly to the @a origin.
594  * @param join_request  Application-dependent join request to be passed to the peer
595  *        @a relay (might, for example, contain a user, bind user
596  *        identity/pseudonym to peer identity, application-level message to
597  *        origin, etc.).
598  * @param max_known_fragment_id Largest known message fragment ID to the replay
599  *        service; all messages with IDs larger than this ID will be replayed if
600  *        possible (lower IDs will be considered known and thus only
601  *        be replayed upon explicit request).
602  *        FIXME: needed? can be optional or moved to a separate function.
603  * @param join_cb Function called to approve / disapprove joining of a peer.
604  * @param test_cb Function multicast can use to test group membership.
605  * @param replay_cb Function that can be called to replay messages
606  *        this peer already knows from this group; NULL if this
607  *        client is unable to support replay.
608  * @param message_cb Function to be called for all message fragments we
609  *        receive from the group, excluding those our @a replay_cb
610  *        already has.
611  * @param cls Closure for callbacks.
612  * @return Handle for the member, NULL on error.
613  */
614 struct GNUNET_MULTICAST_Member *
615 GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
616                               const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
617                               const struct GNUNET_PeerIdentity *origin,
618                               size_t member_count,
619                               const struct GNUNET_PeerIdentity *members,
620                               const struct GNUNET_MessageHeader *join_request,
621                               uint64_t max_known_fragment_id,
622                               GNUNET_MULTICAST_JoinCallback join_cb,
623                               GNUNET_MULITCAST_MembershipTestCallback test_cb,
624                               GNUNET_MULITCAST_ReplayCallback replay_cb,
625                               GNUNET_MULTICAST_MessageCallback message_cb,
626                               void *cls);
627
628
629 /** 
630  * Handle for a replay request.
631  */
632 struct GNUNET_MULTICAST_MemberReplayHandle;
633
634
635 /** 
636  * Request a message to be replayed.
637  *
638  * Useful if messages below the @e max_known_*_id's given when joining are
639  * needed and not known to the client.
640  *
641  * @param member Membership handle.
642  * @param message_id ID of a message that this client would like to see replayed.
643  * @param message_cb Function to be called for the replayed message.
644  * @param message_cb_cls Closure for @a message_cb.
645  * @return Replay request handle, NULL on error.
646  */
647 struct GNUNET_MULTICAST_MemberReplayHandle *
648 GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member,
649                                         uint64_t message_id,
650                                         GNUNET_MULTICAST_MessageCallback message_cb,
651                                         void *message_cb_cls);
652
653
654 /** 
655  * Cancel a replay request.
656  *
657  * @param rh Request to cancel.
658  */
659 void
660 GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_MemberReplayHandle *rh);
661
662
663 /** 
664  * Part a multicast group.
665  *
666  * Disconnects from all group members and invalidates the @a member handle.
667  *
668  * An application-dependent part message can be transmitted beforehand using
669  * GNUNET_MULTICAST_member_to_origin())
670  *
671  * @param member Membership handle.
672  */
673 void
674 GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member);
675
676
677 /** 
678  * Handle for a message to be delivered from a member to the origin.
679  */
680 struct GNUNET_MULTICAST_MemberRequestHandle;
681
682
683 /** 
684  * Send a message to the origin of the multicast group.
685  * 
686  * @param member Membership handle.
687  * @param size Number of bytes we want to send to origin.
688  * @param cb Callback to call to get the message.
689  * @param cb_cls Closure for @a cb.
690  * @return Handle to cancel request, NULL on error (i.e. request already pending).
691  */
692 struct GNUNET_MULTICAST_MemberRequestHandle *
693 GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
694                                    size_t size,
695                                    GNUNET_CONNECTION_TransmitReadyNotify cb,
696                                    void *cb_cls);
697
698
699 /** 
700  * Cancel request for message transmission to origin.
701  *
702  * @param rh Request to cancel.
703  */
704 void
705 GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_MemberRequestHandle *rh);
706
707
708 /** 
709  * Handle to access multicast group operations for both the origin and members.
710  */
711 struct GNUNET_MULTICAST_Group;
712
713
714 /** 
715  * Convert a group @a origin to a @e group handle to access the @e group APIs.
716  *
717  * @param origin Group origin handle.
718  * @return Group handle, valid for as long as @a origin is valid.
719  */
720 struct GNUNET_MULTICAST_Group *
721 GNUNET_MULTICAST_origin_get_group (struct GNUNET_MULTICAST_Origin *origin);
722
723
724 /** 
725  * Convert @a member to a @e group handle to access the @e group APIs.
726  *
727  * @param member Member handle.
728  * @return Group handle, valid for as long as @a member is valid.
729  */
730 struct GNUNET_MULTICAST_Group *
731 GNUNET_MULTICAST_member_get_group (struct GNUNET_MULTICAST_Member *member);
732
733
734 /**
735  * Remove a peer from the group.
736  *
737  * After a message was received notifying about a leaving member, remove the
738  * member from the multicast group.  Fragments with a greater @a message_id than
739  * the specified one won't be transmitted to the member anymore, but the
740  * transmission of lower or equal ones will still be performed.
741  */
742 void
743 GNUNET_MULTICAST_group_member_remove (struct GNUNET_MULTICAST_Group *group,
744                                       const struct GNUNET_PeerIdentity *peer,
745                                       uint64_t message_id);
746
747
748 #if 0                           /* keep Emacsens' auto-indent happy */
749 {
750 #endif
751 #ifdef __cplusplus
752 }
753 #endif
754
755 /* ifndef GNUNET_MULTICAST_SERVICE_H */
756 #endif
757 /* end of gnunet_multicast_service.h */