diff options
author | lurchi <lurchi@strangeplace.net> | 2017-01-17 03:00:11 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-01-17 03:00:11 +0100 |
commit | 9407ee77841b771e774d51eaa2916bceed047c86 (patch) | |
tree | 506e3ec99a043750869a32448c428fab191d3b2f /src/multicast | |
parent | 2082c4e146e914087e020fb863141eb2ad7b89e9 (diff) | |
download | gnunet-9407ee77841b771e774d51eaa2916bceed047c86.tar.gz gnunet-9407ee77841b771e774d51eaa2916bceed047c86.zip |
More bugfixes to make gnunet-social usable
- the host's entry message is not ignored anymore
- guest-talk and host-anounce are working
Diffstat (limited to 'src/multicast')
-rw-r--r-- | src/multicast/gnunet-service-multicast.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index afe30e5c2..de65e0ab7 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -710,15 +710,19 @@ cadet_notify_transmit_ready (void *cls, size_t buf_size, void *buf) | |||
710 | static void | 710 | static void |
711 | cadet_send_channel (struct Channel *chn, const struct GNUNET_MessageHeader *msg) | 711 | cadet_send_channel (struct Channel *chn, const struct GNUNET_MessageHeader *msg) |
712 | { | 712 | { |
713 | uint16_t msg_size = ntohs (msg->size); | ||
714 | struct GNUNET_MessageHeader *msg_copy = GNUNET_malloc (msg_size); | ||
715 | GNUNET_memcpy (msg_copy, msg, msg_size); | ||
716 | |||
713 | struct CadetTransmitClosure *tcls = GNUNET_malloc (sizeof (*tcls)); | 717 | struct CadetTransmitClosure *tcls = GNUNET_malloc (sizeof (*tcls)); |
714 | tcls->chn = chn; | 718 | tcls->chn = chn; |
715 | tcls->msg = msg; | 719 | tcls->msg = msg_copy; |
716 | 720 | ||
717 | chn->msgs_pending++; | 721 | chn->msgs_pending++; |
718 | chn->tmit_handle | 722 | chn->tmit_handle |
719 | = GNUNET_CADET_notify_transmit_ready (chn->channel, GNUNET_NO, | 723 | = GNUNET_CADET_notify_transmit_ready (chn->channel, GNUNET_NO, |
720 | GNUNET_TIME_UNIT_FOREVER_REL, | 724 | GNUNET_TIME_UNIT_FOREVER_REL, |
721 | ntohs (msg->size), | 725 | msg_size, |
722 | &cadet_notify_transmit_ready, | 726 | &cadet_notify_transmit_ready, |
723 | tcls); | 727 | tcls); |
724 | GNUNET_assert (NULL != chn->tmit_handle); | 728 | GNUNET_assert (NULL != chn->tmit_handle); |
@@ -783,9 +787,21 @@ cadet_send_join_decision_cb (void *cls, | |||
783 | const struct MulticastJoinDecisionMessageHeader *hdcsn = cls; | 787 | const struct MulticastJoinDecisionMessageHeader *hdcsn = cls; |
784 | struct Channel *chn = channel; | 788 | struct Channel *chn = channel; |
785 | 789 | ||
790 | const struct MulticastJoinDecisionMessage *dcsn = | ||
791 | (struct MulticastJoinDecisionMessage *) &hdcsn[1]; | ||
792 | |||
786 | if (0 == memcmp (&hdcsn->member_pub_key, &chn->member_pub_key, sizeof (chn->member_pub_key)) | 793 | if (0 == memcmp (&hdcsn->member_pub_key, &chn->member_pub_key, sizeof (chn->member_pub_key)) |
787 | && 0 == memcmp (&hdcsn->peer, &chn->peer, sizeof (chn->peer))) | 794 | && 0 == memcmp (&hdcsn->peer, &chn->peer, sizeof (chn->peer))) |
788 | { | 795 | { |
796 | if (GNUNET_YES == ntohl (dcsn->is_admitted)) | ||
797 | { | ||
798 | chn->join_status = JOIN_ADMITTED; | ||
799 | } | ||
800 | else | ||
801 | { | ||
802 | chn->join_status = JOIN_REFUSED; | ||
803 | } | ||
804 | |||
789 | cadet_send_channel (chn, &hdcsn->header); | 805 | cadet_send_channel (chn, &hdcsn->header); |
790 | return GNUNET_NO; | 806 | return GNUNET_NO; |
791 | } | 807 | } |
@@ -1536,6 +1552,7 @@ cadet_recv_join_request (void *cls, | |||
1536 | void **ctx, | 1552 | void **ctx, |
1537 | const struct GNUNET_MessageHeader *m) | 1553 | const struct GNUNET_MessageHeader *m) |
1538 | { | 1554 | { |
1555 | GNUNET_CADET_receive_done(channel); | ||
1539 | const struct MulticastJoinRequestMessage * | 1556 | const struct MulticastJoinRequestMessage * |
1540 | req = (const struct MulticastJoinRequestMessage *) m; | 1557 | req = (const struct MulticastJoinRequestMessage *) m; |
1541 | uint16_t size = ntohs (m->size); | 1558 | uint16_t size = ntohs (m->size); |
@@ -1578,6 +1595,7 @@ cadet_recv_join_request (void *cls, | |||
1578 | chn->join_status = JOIN_WAITING; | 1595 | chn->join_status = JOIN_WAITING; |
1579 | GNUNET_CONTAINER_multihashmap_put (channels_in, &chn->group_pub_hash, chn, | 1596 | GNUNET_CONTAINER_multihashmap_put (channels_in, &chn->group_pub_hash, chn, |
1580 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1597 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1598 | *ctx = chn; | ||
1581 | 1599 | ||
1582 | client_send_all (&group_pub_hash, m); | 1600 | client_send_all (&group_pub_hash, m); |
1583 | return GNUNET_OK; | 1601 | return GNUNET_OK; |
@@ -1593,10 +1611,14 @@ cadet_recv_join_decision (void *cls, | |||
1593 | void **ctx, | 1611 | void **ctx, |
1594 | const struct GNUNET_MessageHeader *m) | 1612 | const struct GNUNET_MessageHeader *m) |
1595 | { | 1613 | { |
1614 | GNUNET_CADET_receive_done (channel); | ||
1615 | const struct MulticastJoinDecisionMessageHeader * | ||
1616 | hdcsn = (const struct MulticastJoinDecisionMessageHeader *) m; | ||
1596 | const struct MulticastJoinDecisionMessage * | 1617 | const struct MulticastJoinDecisionMessage * |
1597 | dcsn = (const struct MulticastJoinDecisionMessage *) m; | 1618 | dcsn = (const struct MulticastJoinDecisionMessage *) &hdcsn[1]; |
1598 | uint16_t size = ntohs (m->size); | 1619 | uint16_t size = ntohs (m->size); |
1599 | if (size < sizeof (*dcsn)) | 1620 | if (size < sizeof (struct MulticastJoinDecisionMessageHeader) + |
1621 | sizeof (struct MulticastJoinDecisionMessage)) | ||
1600 | { | 1622 | { |
1601 | GNUNET_break_op (0); | 1623 | GNUNET_break_op (0); |
1602 | return GNUNET_SYSERR; | 1624 | return GNUNET_SYSERR; |
@@ -1625,15 +1647,10 @@ cadet_recv_join_decision (void *cls, | |||
1625 | break; | 1647 | break; |
1626 | } | 1648 | } |
1627 | 1649 | ||
1628 | struct MulticastJoinDecisionMessageHeader * | 1650 | // FIXME: do we need to copy chn->peer or compare it with hdcsn->peer? |
1629 | hdcsn = GNUNET_malloc (size); | ||
1630 | GNUNET_memcpy (hdcsn, dcsn, size); | ||
1631 | hdcsn->peer = chn->peer; | ||
1632 | |||
1633 | struct Member *mem = (struct Member *) chn->group; | 1651 | struct Member *mem = (struct Member *) chn->group; |
1634 | client_send_join_decision (mem, hdcsn); | 1652 | client_send_join_decision (mem, hdcsn); |
1635 | GNUNET_free (hdcsn); | 1653 | if (GNUNET_YES == ntohl (dcsn->is_admitted)) |
1636 | if (GNUNET_YES == ntohs (dcsn->is_admitted)) | ||
1637 | { | 1654 | { |
1638 | chn->join_status = JOIN_ADMITTED; | 1655 | chn->join_status = JOIN_ADMITTED; |
1639 | return GNUNET_OK; | 1656 | return GNUNET_OK; |
@@ -1654,6 +1671,7 @@ cadet_recv_message (void *cls, | |||
1654 | void **ctx, | 1671 | void **ctx, |
1655 | const struct GNUNET_MessageHeader *m) | 1672 | const struct GNUNET_MessageHeader *m) |
1656 | { | 1673 | { |
1674 | GNUNET_CADET_receive_done(channel); | ||
1657 | const struct GNUNET_MULTICAST_MessageHeader * | 1675 | const struct GNUNET_MULTICAST_MessageHeader * |
1658 | msg = (const struct GNUNET_MULTICAST_MessageHeader *) m; | 1676 | msg = (const struct GNUNET_MULTICAST_MessageHeader *) m; |
1659 | uint16_t size = ntohs (m->size); | 1677 | uint16_t size = ntohs (m->size); |
@@ -1699,6 +1717,7 @@ cadet_recv_request (void *cls, | |||
1699 | void **ctx, | 1717 | void **ctx, |
1700 | const struct GNUNET_MessageHeader *m) | 1718 | const struct GNUNET_MessageHeader *m) |
1701 | { | 1719 | { |
1720 | GNUNET_CADET_receive_done(channel); | ||
1702 | const struct GNUNET_MULTICAST_RequestHeader * | 1721 | const struct GNUNET_MULTICAST_RequestHeader * |
1703 | req = (const struct GNUNET_MULTICAST_RequestHeader *) m; | 1722 | req = (const struct GNUNET_MULTICAST_RequestHeader *) m; |
1704 | uint16_t size = ntohs (m->size); | 1723 | uint16_t size = ntohs (m->size); |
@@ -1744,6 +1763,7 @@ cadet_recv_replay_request (void *cls, | |||
1744 | void **ctx, | 1763 | void **ctx, |
1745 | const struct GNUNET_MessageHeader *m) | 1764 | const struct GNUNET_MessageHeader *m) |
1746 | { | 1765 | { |
1766 | GNUNET_CADET_receive_done(channel); | ||
1747 | struct MulticastReplayRequestMessage rep; | 1767 | struct MulticastReplayRequestMessage rep; |
1748 | uint16_t size = ntohs (m->size); | 1768 | uint16_t size = ntohs (m->size); |
1749 | if (size < sizeof (rep)) | 1769 | if (size < sizeof (rep)) |
@@ -1786,6 +1806,7 @@ cadet_recv_replay_response (void *cls, | |||
1786 | void **ctx, | 1806 | void **ctx, |
1787 | const struct GNUNET_MessageHeader *m) | 1807 | const struct GNUNET_MessageHeader *m) |
1788 | { | 1808 | { |
1809 | GNUNET_CADET_receive_done(channel); | ||
1789 | //struct Channel *chn = *ctx; | 1810 | //struct Channel *chn = *ctx; |
1790 | 1811 | ||
1791 | /* @todo FIXME: got replay error response, send request to other members */ | 1812 | /* @todo FIXME: got replay error response, send request to other members */ |