diff options
author | Gabor X Toth <*@tg-x.net> | 2013-07-28 19:30:06 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-07-28 19:30:06 +0000 |
commit | b9b10bb434ec1f611be916a402d15440ccc8ec6d (patch) | |
tree | f7556169d75d1e2064e92ff914d09f621dc6c80c /src/include/gnunet_multicast_service.h | |
parent | b7b5c0ffeda46dee307c5f46347bffd649459681 (diff) | |
download | gnunet-b9b10bb434ec1f611be916a402d15440ccc8ec6d.tar.gz gnunet-b9b10bb434ec1f611be916a402d15440ccc8ec6d.zip |
multicast: additional args for member_start, origin_start, origin_to_all; social: use private key struct instead of file
Diffstat (limited to 'src/include/gnunet_multicast_service.h')
-rw-r--r-- | src/include/gnunet_multicast_service.h | 119 |
1 files changed, 74 insertions, 45 deletions
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index a5d7411c3..46e6f824b 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -56,40 +56,62 @@ struct GNUNET_MULTICAST_Member; | |||
56 | struct GNUNET_MULTICAST_Origin; | 56 | struct GNUNET_MULTICAST_Origin; |
57 | 57 | ||
58 | /** | 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 | /** | ||
59 | * Group membership policies. | 76 | * Group membership policies. |
60 | */ | 77 | */ |
61 | enum GNUNET_MULTICAST_JoinPolicy | 78 | enum GNUNET_MULTICAST_GroupPolicy |
62 | { | 79 | { |
63 | /** | 80 | /** |
64 | * Anyone can join the group, without announcing his presence; | 81 | * Anyone can join the group, without announcing his presence; |
65 | * all messages are always public and can be distributed freely. | 82 | * all messages are always public and can be distributed freely. |
66 | * Joins may be announced, but this is not required. | 83 | * Joins may be announced, but this is not required. |
67 | */ | 84 | */ |
68 | GNUNET_MULTICAST_JP_ANONYMOUS = 0, | 85 | GNUNET_MULTICAST_GROUP_ANONYMOUS = 0, |
69 | 86 | ||
70 | /** | 87 | /** |
71 | * Origin must approve membership to the group, messages must only be | 88 | * Origin must approve membership to the group, messages must only be |
72 | * distributed to current group members. This includes the group | 89 | * distributed to current group members. This includes the group |
73 | * state as well as transient messages. | 90 | * state as well as transient messages. |
74 | */ | 91 | */ |
75 | GNUNET_MULTICAST_JP_PRIVATE = 1, | 92 | GNUNET_MULTICAST_GROUP_PRIVATE |
93 | = GNUNET_MULTICAST_GROUP_ADMISSION_CONTROL | ||
94 | | GNUNET_MULTICAST_GROUP_RESTRICTED_HISTORY, | ||
76 | 95 | ||
77 | #if IDEAS_FOR_FUTURE | 96 | #if IDEAS_FOR_FUTURE |
78 | /** | 97 | /** |
79 | * Anyone can freely join the group (no approval required); however, | 98 | * Anyone can freely join the group (no approval required); |
80 | * transient messages must only be distributed to current group | 99 | * however, messages must only be distributed to current group |
81 | * members, so the origin must still acknowledge that the member | 100 | * members, so the origin must still acknowledge that the member |
82 | * joined before transient messages are delivered. As approval is | 101 | * joined before transient messages are delivered. As approval is |
83 | * guaranteed, the presistent group state can be synchronized freely | 102 | * guaranteed, the presistent group state can be synchronized freely |
84 | * immediately, prior to origin confirmation. | 103 | * immediately, prior to origin confirmation. |
85 | */ | 104 | */ |
86 | GNUNET_MULTICAST_JP_OPEN = 2, | 105 | GNUNET_MULTICAST_GROUP_OPEN |
106 | = GNUNET_MULTICAST_GROUP_RESTRICTED_HISTORY, | ||
87 | 107 | ||
88 | /** | 108 | /** |
89 | * Origin must approve membership to the group, but past messages can be | 109 | * Origin must approve membership to the group, but past messages can be |
90 | * freely distributed to members. | 110 | * freely distributed to members. |
91 | */ | 111 | */ |
92 | GNUNET_MULTICAST_JP_CLOSED = 3, | 112 | GNUNET_MULTICAST_GROUP_CLOSED |
113 | = GNUNET_MULTICAST_GROUP_ADMISSION_CONTROL, | ||
114 | , | ||
93 | #endif | 115 | #endif |
94 | 116 | ||
95 | }; | 117 | }; |
@@ -281,10 +303,6 @@ struct GNUNET_MULTICAST_JoinHandle; | |||
281 | * #GNUNET_MULTICAST_JoinCallback. | 303 | * #GNUNET_MULTICAST_JoinCallback. |
282 | * | 304 | * |
283 | * @param jh Join request handle. | 305 | * @param jh Join request handle. |
284 | * @param join_response Message to send in response to the joining peer; | ||
285 | * can also be used to redirect the peer to a different group at the | ||
286 | * application layer; this response is to be transmitted to the | ||
287 | * peer that issued the request even if admission is denied. | ||
288 | * @param is_admitted #GNUNET_YES if joining is approved, | 306 | * @param is_admitted #GNUNET_YES if joining is approved, |
289 | * #GNUNET_NO if it is disapproved | 307 | * #GNUNET_NO if it is disapproved |
290 | * @param relay_count Number of relays given. | 308 | * @param relay_count Number of relays given. |
@@ -295,13 +313,17 @@ struct GNUNET_MULTICAST_JoinHandle; | |||
295 | * be the multicast origin) is a good candidate for building the | 313 | * be the multicast origin) is a good candidate for building the |
296 | * multicast tree. Note that it is unnecessary to specify our own | 314 | * multicast tree. Note that it is unnecessary to specify our own |
297 | * peer identity in this array. | 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. | ||
298 | */ | 320 | */ |
299 | void | 321 | void |
300 | GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, | 322 | GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, |
301 | const struct GNUNET_MessageHeader *join_response, | ||
302 | int is_admitted, | 323 | int is_admitted, |
303 | unsigned int relay_count, | 324 | unsigned int relay_count, |
304 | const struct GNUNET_PeerIdentity *relays); | 325 | const struct GNUNET_PeerIdentity *relays, |
326 | const struct GNUNET_MessageHeader *join_response); | ||
305 | 327 | ||
306 | 328 | ||
307 | /** | 329 | /** |
@@ -312,7 +334,7 @@ GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, | |||
312 | * | 334 | * |
313 | * @param cls Closure. | 335 | * @param cls Closure. |
314 | * @param peer Identity of the peer that wants to join. | 336 | * @param peer Identity of the peer that wants to join. |
315 | * @param msg Application-dependent join message from the new user | 337 | * @param join_req Application-dependent join message from the new user |
316 | * (might, for example, contain a user, | 338 | * (might, for example, contain a user, |
317 | * bind user identity/pseudonym to peer identity, application-level | 339 | * bind user identity/pseudonym to peer identity, application-level |
318 | * message to origin, etc.). | 340 | * message to origin, etc.). |
@@ -320,7 +342,7 @@ GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, | |||
320 | */ | 342 | */ |
321 | typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls, | 343 | typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls, |
322 | const struct GNUNET_PeerIdentity *peer, | 344 | const struct GNUNET_PeerIdentity *peer, |
323 | const struct GNUNET_MessageHeader *msg, | 345 | const struct GNUNET_MessageHeader *join_req, |
324 | struct GNUNET_MULTICAST_JoinHandle *jh); | 346 | struct GNUNET_MULTICAST_JoinHandle *jh); |
325 | 347 | ||
326 | 348 | ||
@@ -466,41 +488,41 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh, | |||
466 | * Will advertise the origin in the P2P overlay network under the respective | 488 | * Will advertise the origin in the P2P overlay network under the respective |
467 | * public key so that other peer can find this peer to join it. Peers that | 489 | * public key so that other peer can find this peer to join it. Peers that |
468 | * issue GNUNET_MULTICAST_member_join() can then transmit a join request to | 490 | * issue GNUNET_MULTICAST_member_join() can then transmit a join request to |
469 | * either an existing group member (if the @a join_policy is permissive) or to | 491 | * either an existing group member (if the @a policy is permissive) or to |
470 | * the origin. If the joining is approved, the member is cleared for @e replay | 492 | * the origin. If the joining is approved, the member is cleared for @e replay |
471 | * and will begin to receive messages transmitted to the group. If joining is | 493 | * and will begin to receive messages transmitted to the group. If joining is |
472 | * disapproved, the failed candidate will be given a response. Members in the | 494 | * disapproved, the failed candidate will be given a response. Members in the |
473 | * group can send messages to the origin (one at a time). | 495 | * group can send messages to the origin (one at a time). |
474 | * | 496 | * |
475 | * @param cfg Configuration to use. | 497 | * @param cfg Configuration to use. |
476 | * @param cls Closure for the various callbacks that follow. | ||
477 | * @param priv_key ECC key that will be used to sign messages for this | 498 | * @param priv_key ECC key that will be used to sign messages for this |
478 | * multicast session; public key is used to identify the | 499 | * multicast session; public key is used to identify the multicast group; |
479 | * multicast group; FIXME: we'll likely want to use | 500 | * FIXME: we'll likely want to use NOT the p521 curve here, but a cheaper |
480 | * NOT the p521 curve here, but a cheaper one in the future. | 501 | * one in the future. |
481 | * @param join_policy What is the membership policy of the group? | 502 | * @param policy Group policy specifying join and history restrictions. |
482 | * @param last_fragment_id Last fragment ID to continue counting fragments from | 503 | * @param last_fragment_id Last fragment ID to continue counting fragments from |
483 | * when restarting the origin. 0 for a new group. | 504 | * when restarting the origin. 0 for a new group. |
484 | * @param replay_cb Function that can be called to replay a message. | ||
485 | * @param test_cb Function multicast can use to test group membership. | ||
486 | * @param join_cb Function called to approve / disapprove joining of a peer. | 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. | ||
487 | * @param request_cb Function called with message fragments from group members. | 508 | * @param request_cb Function called with message fragments from group members. |
488 | * @param message_cb Function called with the message fragments sent to the | 509 | * @param message_cb Function called with the message fragments sent to the |
489 | * network by GNUNET_MULTICAST_origin_to_all(). These message | 510 | * network by GNUNET_MULTICAST_origin_to_all(). These message fragments |
490 | * fragments should be stored for answering replay requests later. | 511 | * should be stored for answering replay requests later. |
512 | * @param cls Closure for the various callbacks that follow. | ||
491 | * @return Handle for the origin, NULL on error. | 513 | * @return Handle for the origin, NULL on error. |
492 | */ | 514 | */ |
493 | struct GNUNET_MULTICAST_Origin * | 515 | struct GNUNET_MULTICAST_Origin * |
494 | GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 516 | GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
495 | void *cls, | ||
496 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, | 517 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, |
497 | enum GNUNET_MULTICAST_JoinPolicy join_policy, | 518 | enum GNUNET_MULTICAST_GroupPolicy policy, |
498 | uint64_t last_fragment_id, | 519 | uint64_t last_fragment_id, |
499 | GNUNET_MULITCAST_ReplayCallback replay_cb, | ||
500 | GNUNET_MULITCAST_MembershipTestCallback test_cb, | ||
501 | GNUNET_MULTICAST_JoinCallback join_cb, | 520 | GNUNET_MULTICAST_JoinCallback join_cb, |
521 | GNUNET_MULITCAST_MembershipTestCallback test_cb, | ||
522 | GNUNET_MULITCAST_ReplayCallback replay_cb, | ||
502 | GNUNET_MULTICAST_RequestCallback request_cb, | 523 | GNUNET_MULTICAST_RequestCallback request_cb, |
503 | GNUNET_MULTICAST_MessageCallback message_cb); | 524 | GNUNET_MULTICAST_MessageCallback message_cb, |
525 | void *cls); | ||
504 | 526 | ||
505 | 527 | ||
506 | /** | 528 | /** |
@@ -514,6 +536,9 @@ struct GNUNET_MULTICAST_OriginMessageHandle; | |||
514 | * Send a message to the multicast group. | 536 | * Send a message to the multicast group. |
515 | * | 537 | * |
516 | * @param origin Handle to the multicast group. | 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. | ||
517 | * @param size Number of bytes to transmit. | 542 | * @param size Number of bytes to transmit. |
518 | * @param cb Function to call to get the message. | 543 | * @param cb Function to call to get the message. |
519 | * @param cb_cls Closure for @a cb. | 544 | * @param cb_cls Closure for @a cb. |
@@ -521,6 +546,9 @@ struct GNUNET_MULTICAST_OriginMessageHandle; | |||
521 | */ | 546 | */ |
522 | struct GNUNET_MULTICAST_OriginMessageHandle * | 547 | struct GNUNET_MULTICAST_OriginMessageHandle * |
523 | GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, | 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, | ||
524 | size_t size, | 552 | size_t size, |
525 | GNUNET_CONNECTION_TransmitReadyNotify cb, | 553 | GNUNET_CONNECTION_TransmitReadyNotify cb, |
526 | void *cb_cls); | 554 | void *cb_cls); |
@@ -548,7 +576,7 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin); | |||
548 | * Join a multicast group. | 576 | * Join a multicast group. |
549 | * | 577 | * |
550 | * The entity joining is always the local peer. Further information about the | 578 | * The entity joining is always the local peer. Further information about the |
551 | * candidate can be provided in the @a join_req message. If the join fails, the | 579 | * candidate can be provided in the @a join_request message. If the join fails, the |
552 | * @a message_cb is invoked with a (failure) response and then with NULL. If | 580 | * @a message_cb is invoked with a (failure) response and then with NULL. If |
553 | * the join succeeds, outstanding (state) messages and ongoing multicast | 581 | * the join succeeds, outstanding (state) messages and ongoing multicast |
554 | * messages will be given to the @a message_cb until the member decides to part | 582 | * messages will be given to the @a message_cb until the member decides to part |
@@ -558,16 +586,20 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin); | |||
558 | * | 586 | * |
559 | * @param cfg Configuration to use. | 587 | * @param cfg Configuration to use. |
560 | * @param pub_key ECC key that identifies the group. | 588 | * @param pub_key ECC key that identifies the group. |
561 | * @param origin Peer identity of the origin. | 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.). | ||
562 | * @param max_known_fragment_id Largest known message fragment ID to the replay | 598 | * @param max_known_fragment_id Largest known message fragment ID to the replay |
563 | * service; all messages with IDs larger than this ID will be replayed if | 599 | * service; all messages with IDs larger than this ID will be replayed if |
564 | * possible (lower IDs will be considered known and thus only | 600 | * possible (lower IDs will be considered known and thus only |
565 | * be replayed upon explicit request). | 601 | * be replayed upon explicit request). |
566 | * @param max_known_state_fragment_id Largest known message fragment ID with a | 602 | * FIXME: needed? can be optional or moved to a separate function. |
567 | * non-zero value for the @e state_delta; state messages with | ||
568 | * larger IDs than this value will be replayed with high priority | ||
569 | * (lower IDs will be considered known and thus only | ||
570 | * be replayed upon explicit request). | ||
571 | * @param replay_cb Function that can be called to replay messages | 603 | * @param replay_cb Function that can be called to replay messages |
572 | * this peer already knows from this group; NULL if this | 604 | * this peer already knows from this group; NULL if this |
573 | * client is unable to support replay. | 605 | * client is unable to support replay. |
@@ -576,23 +608,20 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin); | |||
576 | * receive from the group, excluding those our @a replay_cb | 608 | * receive from the group, excluding those our @a replay_cb |
577 | * already has. | 609 | * already has. |
578 | * @param cls Closure for callbacks. | 610 | * @param cls Closure for callbacks. |
579 | * @param join_req Application-dependent join message to be passed to origin | ||
580 | * (might, for example, contain a user | ||
581 | * bind user identity/pseudonym to peer identity, application-level | ||
582 | * message to origin, etc.). | ||
583 | * @return Handle for the member, NULL on error. | 611 | * @return Handle for the member, NULL on error. |
584 | */ | 612 | */ |
585 | struct GNUNET_MULTICAST_Member * | 613 | struct GNUNET_MULTICAST_Member * |
586 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 614 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
587 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, | 615 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, |
588 | const struct GNUNET_PeerIdentity *origin, | 616 | const struct GNUNET_PeerIdentity *origin, |
617 | size_t member_count, | ||
618 | const struct GNUNET_PeerIdentity *members, | ||
619 | const struct GNUNET_MessageHeader *join_request, | ||
589 | uint64_t max_known_fragment_id, | 620 | uint64_t max_known_fragment_id, |
590 | uint64_t max_known_state_fragment_id, | ||
591 | GNUNET_MULTICAST_ReplayCallback replay_cb, | 621 | GNUNET_MULTICAST_ReplayCallback replay_cb, |
592 | GNUNET_MULITCAST_MembershipTestCallback test_cb, | 622 | GNUNET_MULITCAST_MembershipTestCallback test_cb, |
593 | GNUNET_MULTICAST_MessageCallback message_cb, | 623 | GNUNET_MULTICAST_MessageCallback message_cb, |
594 | void *cls, | 624 | void *cls); |
595 | const struct GNUNET_MessageHeader *join_req); | ||
596 | 625 | ||
597 | 626 | ||
598 | /** | 627 | /** |