From 9407ee77841b771e774d51eaa2916bceed047c86 Mon Sep 17 00:00:00 2001 From: lurchi Date: Tue, 17 Jan 2017 03:00:11 +0100 Subject: [PATCH] More bugfixes to make gnunet-social usable - the host's entry message is not ignored anymore - guest-talk and host-anounce are working --- src/multicast/gnunet-service-multicast.c | 43 ++++++++++++++++++------ src/social/gnunet-social.c | 2 +- src/social/social_api.c | 2 +- 3 files changed, 34 insertions(+), 13 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) static void cadet_send_channel (struct Channel *chn, const struct GNUNET_MessageHeader *msg) { + uint16_t msg_size = ntohs (msg->size); + struct GNUNET_MessageHeader *msg_copy = GNUNET_malloc (msg_size); + GNUNET_memcpy (msg_copy, msg, msg_size); + struct CadetTransmitClosure *tcls = GNUNET_malloc (sizeof (*tcls)); tcls->chn = chn; - tcls->msg = msg; + tcls->msg = msg_copy; chn->msgs_pending++; chn->tmit_handle = GNUNET_CADET_notify_transmit_ready (chn->channel, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, - ntohs (msg->size), + msg_size, &cadet_notify_transmit_ready, tcls); GNUNET_assert (NULL != chn->tmit_handle); @@ -783,9 +787,21 @@ cadet_send_join_decision_cb (void *cls, const struct MulticastJoinDecisionMessageHeader *hdcsn = cls; struct Channel *chn = channel; + const struct MulticastJoinDecisionMessage *dcsn = + (struct MulticastJoinDecisionMessage *) &hdcsn[1]; + if (0 == memcmp (&hdcsn->member_pub_key, &chn->member_pub_key, sizeof (chn->member_pub_key)) && 0 == memcmp (&hdcsn->peer, &chn->peer, sizeof (chn->peer))) { + if (GNUNET_YES == ntohl (dcsn->is_admitted)) + { + chn->join_status = JOIN_ADMITTED; + } + else + { + chn->join_status = JOIN_REFUSED; + } + cadet_send_channel (chn, &hdcsn->header); return GNUNET_NO; } @@ -1536,6 +1552,7 @@ cadet_recv_join_request (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done(channel); const struct MulticastJoinRequestMessage * req = (const struct MulticastJoinRequestMessage *) m; uint16_t size = ntohs (m->size); @@ -1578,6 +1595,7 @@ cadet_recv_join_request (void *cls, chn->join_status = JOIN_WAITING; GNUNET_CONTAINER_multihashmap_put (channels_in, &chn->group_pub_hash, chn, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + *ctx = chn; client_send_all (&group_pub_hash, m); return GNUNET_OK; @@ -1593,10 +1611,14 @@ cadet_recv_join_decision (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done (channel); + const struct MulticastJoinDecisionMessageHeader * + hdcsn = (const struct MulticastJoinDecisionMessageHeader *) m; const struct MulticastJoinDecisionMessage * - dcsn = (const struct MulticastJoinDecisionMessage *) m; + dcsn = (const struct MulticastJoinDecisionMessage *) &hdcsn[1]; uint16_t size = ntohs (m->size); - if (size < sizeof (*dcsn)) + if (size < sizeof (struct MulticastJoinDecisionMessageHeader) + + sizeof (struct MulticastJoinDecisionMessage)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -1625,15 +1647,10 @@ cadet_recv_join_decision (void *cls, break; } - struct MulticastJoinDecisionMessageHeader * - hdcsn = GNUNET_malloc (size); - GNUNET_memcpy (hdcsn, dcsn, size); - hdcsn->peer = chn->peer; - + // FIXME: do we need to copy chn->peer or compare it with hdcsn->peer? struct Member *mem = (struct Member *) chn->group; client_send_join_decision (mem, hdcsn); - GNUNET_free (hdcsn); - if (GNUNET_YES == ntohs (dcsn->is_admitted)) + if (GNUNET_YES == ntohl (dcsn->is_admitted)) { chn->join_status = JOIN_ADMITTED; return GNUNET_OK; @@ -1654,6 +1671,7 @@ cadet_recv_message (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done(channel); const struct GNUNET_MULTICAST_MessageHeader * msg = (const struct GNUNET_MULTICAST_MessageHeader *) m; uint16_t size = ntohs (m->size); @@ -1699,6 +1717,7 @@ cadet_recv_request (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done(channel); const struct GNUNET_MULTICAST_RequestHeader * req = (const struct GNUNET_MULTICAST_RequestHeader *) m; uint16_t size = ntohs (m->size); @@ -1744,6 +1763,7 @@ cadet_recv_replay_request (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done(channel); struct MulticastReplayRequestMessage rep; uint16_t size = ntohs (m->size); if (size < sizeof (rep)) @@ -1786,6 +1806,7 @@ cadet_recv_replay_response (void *cls, void **ctx, const struct GNUNET_MessageHeader *m) { + GNUNET_CADET_receive_done(channel); //struct Channel *chn = *ctx; /* @todo FIXME: got replay error response, send request to other members */ diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index afd06028c..6d72ca552 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c @@ -360,7 +360,7 @@ notify_data (void *cls, uint16_t *data_size, void *data) if (0 == tmit->size) { - if (op_host_announce || op_host_assign || op_guest_talk) + if ((op_host_announce || op_host_assign || op_guest_talk) && !opt_follow) { exit_success (); } diff --git a/src/social/social_api.c b/src/social/social_api.c index d96c93d8f..82928a258 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -893,7 +893,7 @@ handle_guest_enter_decision (void *cls, struct GNUNET_SOCIAL_Guest *gst = cls; struct GNUNET_PSYC_Message *pmsg = NULL; - if (ntohs (dcsn->header.size) <= sizeof (*dcsn) + sizeof (*pmsg)) + if (ntohs (dcsn->header.size) > sizeof (*dcsn)) pmsg = (struct GNUNET_PSYC_Message *) GNUNET_MQ_extract_nested_mh (dcsn); if (NULL != gst->entry_dcsn_cb) -- 2.25.1