diff options
author | Gabor X Toth <*@tg-x.net> | 2014-07-23 16:19:49 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-07-23 16:19:49 +0000 |
commit | 3cf8ba0b60f8495892fa76635e9c23555d0a304c (patch) | |
tree | 5f27648bdb3cf3409628e4e5edc26f811cbd03a5 /src/multicast | |
parent | 252b5599987b7ba03b879a8c2d1c455ad4c9834a (diff) | |
download | gnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.tar.gz gnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.zip |
social: implement enter/leave/messaging; psyc: improvements and fixes
- social: implement enter/leave, send/receive messages, slicer
- psyc, social: add struct GNUNET_PSYC_Message for single-fragment join messages
- psyc: add message callback in addition to message part callback
- client_manager, social, psyc, multicast: add disconnect callback
Diffstat (limited to 'src/multicast')
-rw-r--r-- | src/multicast/gnunet-service-multicast.c | 7 | ||||
-rw-r--r-- | src/multicast/multicast_api.c | 76 |
2 files changed, 72 insertions, 11 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 1bb27f96e..1b8e5c8b6 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -423,6 +423,7 @@ client_origin_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
423 | { | 423 | { |
424 | orig = GNUNET_new (struct Origin); | 424 | orig = GNUNET_new (struct Origin); |
425 | orig->priv_key = msg->group_key; | 425 | orig->priv_key = msg->group_key; |
426 | orig->max_fragment_id = GNUNET_ntohll (msg->max_fragment_id); | ||
426 | grp = &orig->grp; | 427 | grp = &orig->grp; |
427 | grp->is_origin = GNUNET_YES; | 428 | grp->is_origin = GNUNET_YES; |
428 | grp->pub_key = pub_key; | 429 | grp->pub_key = pub_key; |
@@ -482,6 +483,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
482 | mem->priv_key = msg->member_key; | 483 | mem->priv_key = msg->member_key; |
483 | mem->pub_key = mem_pub_key; | 484 | mem->pub_key = mem_pub_key; |
484 | mem->pub_key_hash = mem_pub_key_hash; | 485 | mem->pub_key_hash = mem_pub_key_hash; |
486 | mem->max_fragment_id = 0; // FIXME | ||
485 | 487 | ||
486 | grp = &mem->grp; | 488 | grp = &mem->grp; |
487 | grp->is_origin = GNUNET_NO; | 489 | grp->is_origin = GNUNET_NO; |
@@ -663,7 +665,7 @@ client_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
663 | struct GNUNET_MULTICAST_MessageHeader * | 665 | struct GNUNET_MULTICAST_MessageHeader * |
664 | msg = (struct GNUNET_MULTICAST_MessageHeader *) m; | 666 | msg = (struct GNUNET_MULTICAST_MessageHeader *) m; |
665 | 667 | ||
666 | msg->fragment_id = GNUNET_htonll (orig->max_fragment_id++); | 668 | msg->fragment_id = GNUNET_htonll (++orig->max_fragment_id); |
667 | msg->purpose.size = htonl (sizeof (*msg) + ntohs (m->size) | 669 | msg->purpose.size = htonl (sizeof (*msg) + ntohs (m->size) |
668 | - sizeof (msg->header) | 670 | - sizeof (msg->header) |
669 | - sizeof (msg->hop_counter) | 671 | - sizeof (msg->hop_counter) |
@@ -699,8 +701,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
699 | struct GNUNET_MULTICAST_RequestHeader * | 701 | struct GNUNET_MULTICAST_RequestHeader * |
700 | req = (struct GNUNET_MULTICAST_RequestHeader *) m; | 702 | req = (struct GNUNET_MULTICAST_RequestHeader *) m; |
701 | 703 | ||
702 | req->fragment_id = GNUNET_ntohll (mem->max_fragment_id++); | 704 | req->fragment_id = GNUNET_ntohll (++mem->max_fragment_id); |
703 | |||
704 | req->purpose.size = htonl (sizeof (*req) + ntohs (m->size) | 705 | req->purpose.size = htonl (sizeof (*req) + ntohs (m->size) |
705 | - sizeof (req->header) | 706 | - sizeof (req->header) |
706 | - sizeof (req->member_key) | 707 | - sizeof (req->member_key) |
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index d2a0412bb..fb2630081 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -88,6 +88,16 @@ struct GNUNET_MULTICAST_Group | |||
88 | void *cb_cls; | 88 | void *cb_cls; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Function called after disconnected from the service. | ||
92 | */ | ||
93 | GNUNET_ContinuationCallback disconnect_cb; | ||
94 | |||
95 | /** | ||
96 | * Closure for @a disconnect_cb. | ||
97 | */ | ||
98 | void *disconnect_cls; | ||
99 | |||
100 | /** | ||
91 | * Are we currently transmitting a message? | 101 | * Are we currently transmitting a message? |
92 | */ | 102 | */ |
93 | uint8_t in_transmit; | 103 | uint8_t in_transmit; |
@@ -96,6 +106,12 @@ struct GNUNET_MULTICAST_Group | |||
96 | * Is this the origin or a member? | 106 | * Is this the origin or a member? |
97 | */ | 107 | */ |
98 | uint8_t is_origin; | 108 | uint8_t is_origin; |
109 | |||
110 | /** | ||
111 | * Is this channel in the process of disconnecting from the service? | ||
112 | * #GNUNET_YES or #GNUNET_NO | ||
113 | */ | ||
114 | uint8_t is_disconnecting; | ||
99 | }; | 115 | }; |
100 | 116 | ||
101 | 117 | ||
@@ -320,8 +336,9 @@ member_recv_join_decision (void *cls, | |||
320 | mem->join_dcsn_cb (grp->cb_cls, is_admitted, &hdcsn->peer, | 336 | mem->join_dcsn_cb (grp->cb_cls, is_admitted, &hdcsn->peer, |
321 | relay_count, relays, join_resp); | 337 | relay_count, relays, join_resp); |
322 | 338 | ||
323 | if (GNUNET_YES != is_admitted) | 339 | // FIXME: |
324 | GNUNET_MULTICAST_member_part (mem); | 340 | //if (GNUNET_YES != is_admitted) |
341 | // GNUNET_MULTICAST_member_part (mem); | ||
325 | } | 342 | } |
326 | 343 | ||
327 | 344 | ||
@@ -371,6 +388,33 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler member_handlers[] = | |||
371 | }; | 388 | }; |
372 | 389 | ||
373 | 390 | ||
391 | static void | ||
392 | group_cleanup (struct GNUNET_MULTICAST_Group *grp) | ||
393 | { | ||
394 | GNUNET_free (grp->connect_msg); | ||
395 | if (NULL != grp->disconnect_cb) | ||
396 | grp->disconnect_cb (grp->disconnect_cls); | ||
397 | } | ||
398 | |||
399 | |||
400 | static void | ||
401 | origin_cleanup (void *cls) | ||
402 | { | ||
403 | struct GNUNET_MULTICAST_Origin *orig = cls; | ||
404 | group_cleanup (&orig->grp); | ||
405 | GNUNET_free (orig); | ||
406 | } | ||
407 | |||
408 | |||
409 | static void | ||
410 | member_cleanup (void *cls) | ||
411 | { | ||
412 | struct GNUNET_MULTICAST_Member *mem = cls; | ||
413 | group_cleanup (&mem->grp); | ||
414 | GNUNET_free (mem); | ||
415 | } | ||
416 | |||
417 | |||
374 | /** | 418 | /** |
375 | * Function to call with the decision made for a join request. | 419 | * Function to call with the decision made for a join request. |
376 | * | 420 | * |
@@ -565,10 +609,18 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
565 | * @param origin Multicast group to stop. | 609 | * @param origin Multicast group to stop. |
566 | */ | 610 | */ |
567 | void | 611 | void |
568 | GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig) | 612 | GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig, |
613 | GNUNET_ContinuationCallback stop_cb, | ||
614 | void *stop_cls) | ||
569 | { | 615 | { |
570 | GNUNET_CLIENT_MANAGER_disconnect (orig->grp.client, GNUNET_YES); | 616 | struct GNUNET_MULTICAST_Group *grp = &orig->grp; |
571 | GNUNET_free (orig); | 617 | |
618 | grp->is_disconnecting = GNUNET_YES; | ||
619 | grp->disconnect_cb = stop_cb; | ||
620 | grp->disconnect_cls = stop_cls; | ||
621 | |||
622 | GNUNET_CLIENT_MANAGER_disconnect (orig->grp.client, GNUNET_YES, | ||
623 | &origin_cleanup, orig); | ||
572 | } | 624 | } |
573 | 625 | ||
574 | 626 | ||
@@ -774,10 +826,18 @@ GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
774 | * @param member Membership handle. | 826 | * @param member Membership handle. |
775 | */ | 827 | */ |
776 | void | 828 | void |
777 | GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem) | 829 | GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem, |
830 | GNUNET_ContinuationCallback part_cb, | ||
831 | void *part_cls) | ||
778 | { | 832 | { |
779 | GNUNET_CLIENT_MANAGER_disconnect (mem->grp.client, GNUNET_YES); | 833 | struct GNUNET_MULTICAST_Group *grp = &mem->grp; |
780 | GNUNET_free (mem); | 834 | |
835 | grp->is_disconnecting = GNUNET_YES; | ||
836 | grp->disconnect_cb = part_cb; | ||
837 | grp->disconnect_cls = part_cls; | ||
838 | |||
839 | GNUNET_CLIENT_MANAGER_disconnect (mem->grp.client, GNUNET_YES, | ||
840 | &member_cleanup, mem); | ||
781 | } | 841 | } |
782 | 842 | ||
783 | 843 | ||