const char *buf;
struct GNUNET_MessageHeader pa;
+ /* FIXME: what is the format we shall allow for @a msg?
+ ONE payload item or multiple? Seems current cadet_api
+ at least in theory allows more than one. Next-gen
+ cadet_api will likely no more.
+
+ Regardless, the multi-message check below should pass,
+ albeit it does not :-(. */
/* Sanity check for message size */
payload_size = ntohs (msg->header.size) - sizeof (*msg);
- if ( (payload_size < sizeof (struct GNUNET_MessageHeader)) ||
- (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_size) )
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
buf = (const char *) &msg[1];
- do {
+ while (payload_size >= sizeof (struct GNUNET_MessageHeader))
+ {
/* need to memcpy() for alignment */
GNUNET_memcpy (&pa,
buf,
sizeof (pa));
payload_claimed_size = ntohs (pa.size);
if ( (payload_size < payload_claimed_size) ||
- (0 == payload_claimed_size) )
+ (payload_claimed_size < sizeof (struct GNUNET_MessageHeader)) ||
+ (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size) )
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
payload_size -= payload_claimed_size;
buf += payload_claimed_size;
- } while (payload_size >= sizeof (struct GNUNET_MessageHeader));
+ }
if (0 != payload_size)
{
GNUNET_break_op (0);
long id = (long) cls;
unsigned int counter;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tmt_rdy on %ld, filling buffer\n",
+ id);
if (0 == id)
th = NULL;
else if ((peers_requested - 1) == id)
GNUNET_assert (0);
counter = get_expected_target () == id ? ack_sent : data_sent;
msg_size = size_payload + counter;
- if (size < msg_size || NULL == buf)
+ if ( (size < msg_size) ||
+ (NULL == buf) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"size %u, buf %p, data_sent %u, ack_received %u\n",
if (SPEED_ACK == test)
data_sent++;
}
- else if (SPEED == test || SPEED_ACK == test)
+ else if ( (SPEED == test) ||
+ (SPEED_ACK == test) )
{
if (get_expected_target() == id)
ack_sent++;
" Sent message %u size %u\n",
counter,
(unsigned int) msg_size);
- if (data_sent < TOTAL_PACKETS && SPEED == test)
+ if ( (data_sent < TOTAL_PACKETS) &&
+ (SPEED == test) )
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " Scheduling message %d\n",
counter + 1);
data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
}