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);
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;
}
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);
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;
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;
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;
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);
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);
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))
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 */