aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_multicast_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2013-07-12 08:47:10 +0000
committerGabor X Toth <*@tg-x.net>2013-07-12 08:47:10 +0000
commit15b4d21a45db18ce0384d1c42c83459ba2ed24f8 (patch)
treea70ebcbc24dca219f1a7df943dc52c0fd706c555 /src/include/gnunet_multicast_service.h
parent57be99113715a6023164633556ea1de50ceae6e1 (diff)
downloadgnunet-15b4d21a45db18ce0384d1c42c83459ba2ed24f8.tar.gz
gnunet-15b4d21a45db18ce0384d1c42c83459ba2ed24f8.zip
PSYC APIs: added missing args and functions, more consistent naming
- multicast: origin arg for join; s/leave/part/g - psyc: origin arg for join; join/part callbacks - social: enter2, home_advertise, away - psycstore/social: get latest historic message using ID 0 - added PSYC lib
Diffstat (limited to 'src/include/gnunet_multicast_service.h')
-rw-r--r--src/include/gnunet_multicast_service.h156
1 files changed, 67 insertions, 89 deletions
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h
index 76a6bcf32..df677784a 100644
--- a/src/include/gnunet_multicast_service.h
+++ b/src/include/gnunet_multicast_service.h
@@ -22,7 +22,7 @@
22 * @file include/gnunet_multicast_service.h 22 * @file include/gnunet_multicast_service.h
23 * @brief multicast service; establish tunnels to distant peers 23 * @brief multicast service; establish tunnels to distant peers
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author tg(x) 25 * @author Gabor X Toth
26 */ 26 */
27 27
28#ifndef GNUNET_MULTICAST_SERVICE_H 28#ifndef GNUNET_MULTICAST_SERVICE_H
@@ -138,12 +138,12 @@ struct GNUNET_MULTICAST_MessageHeader
138 uint64_t message_id GNUNET_PACKED; 138 uint64_t message_id GNUNET_PACKED;
139 139
140 /** 140 /**
141 * Counter that monotonically increases whenever a member leaves the group. 141 * Counter that monotonically increases whenever a member parts the group.
142 * 142 *
143 * It has significance in case of replay requests: when a member has missed 143 * It has significance in case of replay requests: when a member has missed
144 * messages and gets a replay request: in this case if the @a group_generation 144 * messages and gets a replay request: in this case if the @a group_generation
145 * is still the same before and after the missed messages, it means that no 145 * is still the same before and after the missed messages, it means that no
146 * @e join or @a leave operations happened during the missed messages. 146 * @e join or @e part operations happened during the missed messages.
147 */ 147 */
148 uint64_t group_generation GNUNET_PACKED; 148 uint64_t group_generation GNUNET_PACKED;
149 149
@@ -174,7 +174,7 @@ struct GNUNET_MULTICAST_MessageHeader
174 * Header for the message body. 174 * Header for the message body.
175 * 175 *
176 * Three message types are specifically understood by multicast, namely "peer 176 * Three message types are specifically understood by multicast, namely "peer
177 * join", "peer leave", and "group terminated". Multicast will use those 177 * join", "peer part", and "group terminated". Multicast will use those
178 * messages to update its list of candidates for content distribution. All 178 * messages to update its list of candidates for content distribution. All
179 * other message types are application-specific. 179 * other message types are application-specific.
180 */ 180 */
@@ -194,9 +194,17 @@ GNUNET_NETWORK_STRUCT_END
194 */ 194 */
195struct GNUNET_MULTICAST_JoinHandle; 195struct GNUNET_MULTICAST_JoinHandle;
196 196
197/**
198 * Handle that identifies a part request.
199 *
200 * Used to match calls to #GNUNET_MULTICAST_PartCallback to the
201 * corresponding calls to GNUNET_MULTICAST_part_ack().
202 */
203struct GNUNET_MULTICAST_PartHandle;
204
197 205
198/** 206/**
199 * Function to call with the decision made for a membership change request. 207 * Function to call with the decision made for a join request.
200 * 208 *
201 * Must be called once and only once in response to an invocation of the 209 * Must be called once and only once in response to an invocation of the
202 * #GNUNET_MULTICAST_JoinCallback. 210 * #GNUNET_MULTICAST_JoinCallback.
@@ -206,9 +214,8 @@ struct GNUNET_MULTICAST_JoinHandle;
206 * can also be used to redirect the peer to a different group at the 214 * can also be used to redirect the peer to a different group at the
207 * application layer; this response is to be transmitted to the 215 * application layer; this response is to be transmitted to the
208 * peer that issued the request even if admission is denied. 216 * peer that issued the request even if admission is denied.
209 * @param is_admitted #GNUNET_OK if joining is approved, 217 * @param is_admitted #GNUNET_YES if joining is approved,
210 * #GNUNET_SYSERR if it is disapproved; 218 * #GNUNET_NO if it is disapproved
211 * #GNUNET_NO for peers leaving.
212 * @param relay_count Number of relays given. 219 * @param relay_count Number of relays given.
213 * @param relays Array of suggested peers that might be useful relays to use 220 * @param relays Array of suggested peers that might be useful relays to use
214 * when joining the multicast group (essentially a list of peers that 221 * when joining the multicast group (essentially a list of peers that
@@ -220,10 +227,19 @@ struct GNUNET_MULTICAST_JoinHandle;
220 */ 227 */
221void 228void
222GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, 229GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh,
223 const struct GNUNET_MessageHeader *join_response, 230 const struct GNUNET_MessageHeader *join_response,
224 int is_admitted, 231 int is_admitted,
225 unsigned int relay_count, 232 unsigned int relay_count,
226 const struct GNUNET_PeerIdentity *relays); 233 const struct GNUNET_PeerIdentity *relays);
234
235
236/**
237 * Part acknowledgment.
238 *
239 * @param ph Part handle.
240 */
241void
242GNUNET_MULTICAST_part_ack (struct GNUNET_MULTICAST_PartHandle *ph);
227 243
228 244
229/** 245/**
@@ -249,17 +265,17 @@ typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls,
249/** 265/**
250 * Method called whenever another peer wants to part the multicast group. 266 * Method called whenever another peer wants to part the multicast group.
251 * 267 *
252 * A leave request must be always be honoured. 268 * A part request must always be honoured, and answered with GNUNET_MULTICAST_part_ack();
253 * 269 *
254 * @param cls Closure. 270 * @param cls Closure.
255 * @param peer Identity of the peer that wants to leave. 271 * @param peer Identity of the peer that wants to part.
256 * @param msg Application-dependent leave message from the leaving user. 272 * @param msg Application-dependent part message from the leaving user.
257 * @param jh Join handle to pass to GNUNET_MULTICAST_join_decison(). 273 * @param ph Part handle.
258 */ 274 */
259typedef void (*GNUNET_MULTICAST_PartCallback)(void *cls, 275typedef void (*GNUNET_MULTICAST_PartCallback)(void *cls,
260 const struct GNUNET_PeerIdentity *peer, 276 const struct GNUNET_PeerIdentity *peer,
261 const struct GNUNET_MessageHeader *msg, 277 const struct GNUNET_MessageHeader *msg,
262 struct GNUNET_MULTICAST_JoinHandle *jh); 278 struct GNUNET_MULTICAST_PartHandle *ph);
263 279
264 280
265/** 281/**
@@ -283,6 +299,9 @@ GNUNET_MULTICAST_membership_test_answer (struct GNUNET_MULTICAST_MembershipTestH
283/** 299/**
284 * Method called to test if a member was in the group at a particular time. 300 * Method called to test if a member was in the group at a particular time.
285 * 301 *
302 * It is called when a replay request is received to determine if the requested
303 * message can be replayed.
304 *
286 * @param cls Closure. 305 * @param cls Closure.
287 * @param peer Identity of the peer that we want to test. 306 * @param peer Identity of the peer that we want to test.
288 * @param message_id Message ID for which we want to do the test. 307 * @param message_id Message ID for which we want to do the test.
@@ -300,7 +319,7 @@ typedef void (*GNUNET_MULTICAST_MembershipTestCallback)(void *cls,
300 * 319 *
301 * @param cls Closure (set from GNUNET_MULTICAST_origin_start). 320 * @param cls Closure (set from GNUNET_MULTICAST_origin_start).
302 * @param sender Identity of the sender. 321 * @param sender Identity of the sender.
303 * @param request_id Unique counter for the request from this sender to this origin. 322 * @param request_id Unique counter for the request from this sender to this origin. FIXME: needed?
304 * @param msg Message to the origin. 323 * @param msg Message to the origin.
305 */ 324 */
306typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls, 325typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls,
@@ -322,11 +341,11 @@ typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls,
322 * normal message IDs in either direction start at 1. 341 * normal message IDs in either direction start at 1.
323 * @param msg Message from the origin, NULL if the origin shut down 342 * @param msg Message from the origin, NULL if the origin shut down
324 * (or we were kicked out, and we should thus call 343 * (or we were kicked out, and we should thus call
325 * GNUNET_MULTICAST_member_leave() next) 344 * GNUNET_MULTICAST_member_part() next)
326 */ 345 */
327typedef void (*GNUNET_MULTICAST_MulticastMessageCallback) (void *cls, 346typedef void (*GNUNET_MULTICAST_MessageCallback) (void *cls,
328 uint64_t message_id, 347 uint64_t message_id,
329 const struct GNUNET_MULTICAST_MessageHeader *msg); 348 const struct GNUNET_MULTICAST_MessageHeader *msg);
330 349
331 350
332/** 351/**
@@ -336,11 +355,12 @@ struct GNUNET_MULTICAST_ReplayHandle;
336 355
337 356
338/** 357/**
339 * Functions with this signature are called whenever the multicast 358 * Functions with this signature are called whenever the multicast service needs
340 * service needs a message to be replayed. Implementations of this 359 * a message to be replayed.
341 * function MUST call GNUNET_MULTICAST_replay() ONCE (with a message 360 *
342 * or an error); however, if the origin is destroyed or the group is 361 * Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE
343 * left, the replay handle must no longer be used. 362 * (with a message or an error); however, if the origin is destroyed or the
363 * group is left, the replay handle must no longer be used.
344 * 364 *
345 * @param cls Closure (set from GNUNET_MULTICAST_origin_start() 365 * @param cls Closure (set from GNUNET_MULTICAST_origin_start()
346 * or GNUNET_MULTICAST_member_join()). 366 * or GNUNET_MULTICAST_member_join()).
@@ -398,48 +418,6 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh,
398 418
399 419
400/** 420/**
401 * Handle to pass back for the answer of a ping.
402 */
403struct GNUNET_MULTICAST_PingHandle;
404
405
406/**
407 * A response to a @e ping.
408 *
409 * @param rh Handle that was given for the ping.
410 * @param message_id Latest message ID seen by this peer for this group.
411 *
412 * @deprecated needed???
413 */
414void
415GNUNET_MULTICAST_pong (struct GNUNET_MULTICAST_ReplayHandle *rh,
416 uint64_t message_id);
417
418
419/**
420 * Method called whenever a @e ping is received from another member.
421 *
422 * A @e ping is sent after a period of inactivity to check if the member has not
423 * missed any messages. A ping contains the latest message ID a member has
424 * seen, and must be answered with GNUNET_MULTICAST_pong() containing the latest
425 * message ID seen by this peer. If the latest message ID on this peer is higher, the
426 * missing messages must be replayed to the requesting member using
427 * GNUNET_MULTICAST_replay().
428 *
429 * @param cls Closure.
430 * @param peer Identity of the peer who sent the ping.
431 * @param latest_message_id Latest message ID seen by the requesting member.
432 * @param rh Handle to pass back to GNUNET_MULTICAST_pong() or GNUNET_MULTICAST_replay().
433 *
434 * @deprecated needed???
435 */
436typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls,
437 const struct GNUNET_PeerIdentity *peer,
438 uint64_t latest_messaged_id
439 struct GNUNET_MULTICAST_ReplayHandle *rh);
440
441
442/**
443 * Start a multicast group. 421 * Start a multicast group.
444 * 422 *
445 * Will advertise the origin in the P2P overlay network under the respective 423 * Will advertise the origin in the P2P overlay network under the respective
@@ -460,7 +438,6 @@ typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls,
460 * @param join_policy What is the membership policy of the group? 438 * @param join_policy What is the membership policy of the group?
461 * @param replay_cb Function that can be called to replay a message. 439 * @param replay_cb Function that can be called to replay a message.
462 * @param test_cb Function multicast can use to test group membership. 440 * @param test_cb Function multicast can use to test group membership.
463 * @param ping_cb Function called to answer a ping. -- Gabor: remove this one!? deprecated?
464 * @param join_cb Function called to approve / disapprove joining of a peer. 441 * @param join_cb Function called to approve / disapprove joining of a peer.
465 * @param part_cb Function called when a member wants to part the group. 442 * @param part_cb Function called when a member wants to part the group.
466 * @param request_cb Function called with messages from group members. 443 * @param request_cb Function called with messages from group members.
@@ -473,7 +450,6 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
473 enum GNUNET_MULTICAST_JoinPolicy join_policy, 450 enum GNUNET_MULTICAST_JoinPolicy join_policy,
474 GNUNET_MULITCAST_ReplayCallback replay_cb, 451 GNUNET_MULITCAST_ReplayCallback replay_cb,
475 GNUNET_MULITCAST_MembershipTestCallback test_cb, 452 GNUNET_MULITCAST_MembershipTestCallback test_cb,
476 GNUNET_MULITCAST_PingCallback ping_cb,
477 GNUNET_MULTICAST_JoinCallback join_cb, 453 GNUNET_MULTICAST_JoinCallback join_cb,
478 GNUNET_MULTICAST_PartCallback part_cb, 454 GNUNET_MULTICAST_PartCallback part_cb,
479 GNUNET_MULTICAST_RequestCallback request_cb); 455 GNUNET_MULTICAST_RequestCallback request_cb);
@@ -483,7 +459,7 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
483 * Handle for a request to send a message to all multicast group members 459 * Handle for a request to send a message to all multicast group members
484 * (from the origin). 460 * (from the origin).
485 */ 461 */
486struct GNUNET_MULTICAST_MulticastRequest; 462struct GNUNET_MULTICAST_OriginMessageHandle;
487 463
488 464
489/** 465/**
@@ -495,7 +471,7 @@ struct GNUNET_MULTICAST_MulticastRequest;
495 * @param cb_cls Closure for @a cb. 471 * @param cb_cls Closure for @a cb.
496 * @return NULL on error (i.e. request already pending). 472 * @return NULL on error (i.e. request already pending).
497 */ 473 */
498struct GNUNET_MULTICAST_MulticastRequest * 474struct GNUNET_MULTICAST_OriginMessageHandle *
499GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, 475GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
500 size_t size, 476 size_t size,
501 GNUNET_CONNECTION_TransmitReadyNotify cb, 477 GNUNET_CONNECTION_TransmitReadyNotify cb,
@@ -505,10 +481,10 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
505/** 481/**
506 * Cancel request for message transmission to multicast group. 482 * Cancel request for message transmission to multicast group.
507 * 483 *
508 * @param mr Request to cancel. 484 * @param mh Request to cancel.
509 */ 485 */
510void 486void
511GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_MulticastRequest *mr); 487GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginMessageHandle *mh);
512 488
513 489
514/** 490/**
@@ -527,7 +503,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin);
527 * candidate can be provided in the @a join_req message. If the join fails, the 503 * candidate can be provided in the @a join_req message. If the join fails, the
528 * @a message_cb is invoked with a (failure) response and then with NULL. If 504 * @a message_cb is invoked with a (failure) response and then with NULL. If
529 * the join succeeds, outstanding (state) messages and ongoing multicast 505 * the join succeeds, outstanding (state) messages and ongoing multicast
530 * messages will be given to the @a message_cb until the member decides to leave 506 * messages will be given to the @a message_cb until the member decides to part
531 * the group. The @a test_cb and @a replay_cb functions may be called at 507 * the group. The @a test_cb and @a replay_cb functions may be called at
532 * anytime by the multicast service to support relaying messages to other 508 * anytime by the multicast service to support relaying messages to other
533 * members of the group. 509 * members of the group.
@@ -535,6 +511,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin);
535 * @param cfg Configuration to use. 511 * @param cfg Configuration to use.
536 * @param cls Closure for callbacks. 512 * @param cls Closure for callbacks.
537 * @param pub_key ECC key that identifies the group. 513 * @param pub_key ECC key that identifies the group.
514 * @param origin Peer identity of the origin.
538 * @param max_known_message_id Largest known message ID to the replay service; 515 * @param max_known_message_id Largest known message ID to the replay service;
539 * all messages with IDs larger than this ID will be replayed if 516 * all messages with IDs larger than this ID will be replayed if
540 * possible (lower IDs will be considered known and thus only 517 * possible (lower IDs will be considered known and thus only
@@ -561,18 +538,19 @@ struct GNUNET_MULTICAST_Member *
561GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 538GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
562 void *cls, 539 void *cls,
563 const struct GNUNET_CRYPTO_EccPublicKey *pub_key, 540 const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
541 const struct GNUNET_PeerIdentity *origin,
564 uint64_t max_known_message_id, 542 uint64_t max_known_message_id,
565 uint64_t max_known_state_message_id, 543 uint64_t max_known_state_message_id,
566 GNUNET_MULTICAST_ReplayCallback replay_cb, 544 GNUNET_MULTICAST_ReplayCallback replay_cb,
567 GNUNET_MULITCAST_MembershipTestCallback test_cb, 545 GNUNET_MULITCAST_MembershipTestCallback test_cb,
568 GNUNET_MULTICAST_MulticastMessageCallback message_cb, 546 GNUNET_MULTICAST_MessageCallback message_cb,
569 const struct GNUNET_MessageHeader *join_req); 547 const struct GNUNET_MessageHeader *join_req);
570 548
571 549
572/** 550/**
573 * Handle for a replay request. 551 * Handle for a replay request.
574 */ 552 */
575struct GNUNET_MULTICAST_ReplayRequest; 553struct GNUNET_MULTICAST_MemberReplayHandle;
576 554
577 555
578/** 556/**
@@ -587,20 +565,20 @@ struct GNUNET_MULTICAST_ReplayRequest;
587 * @param message_cb_cls Closure for @a message_cb. 565 * @param message_cb_cls Closure for @a message_cb.
588 * @return Replay request handle, NULL on error. 566 * @return Replay request handle, NULL on error.
589 */ 567 */
590struct GNUNET_MULTICAST_ReplayRequest * 568struct GNUNET_MULTICAST_MemberReplayHandle *
591GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member, 569GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member,
592 uint64_t message_id, 570 uint64_t message_id,
593 GNUNET_MULTICAST_MulticastMessageCallback message_cb, 571 GNUNET_MULTICAST_MessageCallback message_cb,
594 void *message_cb_cls); 572 void *message_cb_cls);
595 573
596 574
597/** 575/**
598 * Cancel a replay request. 576 * Cancel a replay request.
599 * 577 *
600 * @param rr Request to cancel. 578 * @param rh Request to cancel.
601 */ 579 */
602void 580void
603GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_ReplayRequest *rr); 581GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_MemberReplayHandle *rh);
604 582
605 583
606/** 584/**
@@ -613,9 +591,9 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member);
613 591
614 592
615/** 593/**
616 * Handle for a message to be delivered to the origin. 594 * Handle for a message to be delivered from a member to the origin.
617 */ 595 */
618struct GNUNET_MULTICAST_ResponseRequest; 596struct GNUNET_MULTICAST_MemberRequestHandle;
619 597
620 598
621/** 599/**
@@ -627,7 +605,7 @@ struct GNUNET_MULTICAST_ResponseRequest;
627 * @param cb_cls Closure for @a cb. 605 * @param cb_cls Closure for @a cb.
628 * @return Handle to cancel request, NULL on error (i.e. request already pending). 606 * @return Handle to cancel request, NULL on error (i.e. request already pending).
629 */ 607 */
630struct GNUNET_MULTICAST_ResponseRequest * 608struct GNUNET_MULTICAST_MemberRequestHandle *
631GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, 609GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
632 size_t size, 610 size_t size,
633 GNUNET_CONNECTION_TransmitReadyNotify cb, 611 GNUNET_CONNECTION_TransmitReadyNotify cb,
@@ -637,10 +615,10 @@ GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
637/** 615/**
638 * Cancel request for message transmission to origin. 616 * Cancel request for message transmission to origin.
639 * 617 *
640 * @param rr Request to cancel. 618 * @param rh Request to cancel.
641 */ 619 */
642void 620void
643GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_ResponseRequest *rr); 621GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_MemberRequestHandle *rh);
644 622
645 623
646 624