/*
* This file is part of GNUnet
- * Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+ * Copyright (C) 2013 GNUnet e.V.
*
* GNUnet is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
{
uint16_t size = ntohs (msg->size);
uint16_t type = ntohs (msg->type);
- GNUNET_log (kind, "Message of type %d and size %u:\n", type, size);
+
+ GNUNET_log (kind,
+ "Message of type %d and size %u:\n",
+ type,
+ size);
switch (type)
{
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE:
{
- struct GNUNET_PSYC_MessageHeader *pmsg
- = (struct GNUNET_PSYC_MessageHeader *) msg;
- GNUNET_log (kind, "\tID: %" PRIu64 "\tflags: %x" PRIu32 "\n",
- GNUNET_ntohll (pmsg->message_id), ntohl (pmsg->flags));
+ const struct GNUNET_PSYC_MessageHeader *pmsg
+ = (const struct GNUNET_PSYC_MessageHeader *) msg;
+ GNUNET_log (kind,
+ "\tID: %" PRIu64 "\tflags: %x" PRIu32 "\n",
+ GNUNET_ntohll (pmsg->message_id),
+ ntohl (pmsg->flags));
break;
}
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
{
- struct GNUNET_PSYC_MessageMethod *meth
- = (struct GNUNET_PSYC_MessageMethod *) msg;
- GNUNET_log (kind, "\t%.*s\n", size - sizeof (*meth), &meth[1]);
+ const struct GNUNET_PSYC_MessageMethod *meth
+ = (const struct GNUNET_PSYC_MessageMethod *) msg;
+ GNUNET_log (kind,
+ "\t%.*s\n",
+ (int) (size - sizeof (*meth)),
+ (const char *) &meth[1]);
break;
}
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
{
- struct GNUNET_PSYC_MessageModifier *mod
- = (struct GNUNET_PSYC_MessageModifier *) msg;
+ const struct GNUNET_PSYC_MessageModifier *mod
+ = (const struct GNUNET_PSYC_MessageModifier *) msg;
uint16_t name_size = ntohs (mod->name_size);
char oper = ' ' < mod->oper ? mod->oper : ' ';
- GNUNET_log (kind, "\t%c%.*s\t%.*s\n", oper, name_size, &mod[1],
- size - sizeof (*mod) - name_size,
- ((char *) &mod[1]) + name_size);
+ GNUNET_log (kind,
+ "\t%c%.*s\t%.*s\n",
+ oper,
+ (int) name_size,
+ (const char *) &mod[1],
+ (int) (size - sizeof (*mod) - name_size),
+ ((const char *) &mod[1]) + name_size);
break;
}
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
- GNUNET_log (kind, "\t%.*s\n", size - sizeof (*msg), &msg[1]);
+ GNUNET_log (kind,
+ "\t%.*s\n",
+ (int) (size - sizeof (*msg)),
+ (const char *) &msg[1]);
break;
}
}
struct GNUNET_PSYC_TransmitHandle *
GNUNET_PSYC_transmit_create (struct GNUNET_CLIENT_MANAGER_Connection *client)
{
- struct GNUNET_PSYC_TransmitHandle *tmit = GNUNET_malloc (sizeof (*tmit));
+ struct GNUNET_PSYC_TransmitHandle *tmit = GNUNET_new (struct GNUNET_PSYC_TransmitHandle);
+
tmit->client = client;
return tmit;
}
recv_error (struct GNUNET_PSYC_ReceiveHandle *recv)
{
if (NULL != recv->message_part_cb)
- recv->message_part_cb (recv->cb_cls, NULL, recv->message_id, recv->flags,
- 0, NULL);
+ recv->message_part_cb (recv->cb_cls, NULL, NULL);
if (NULL != recv->message_cb)
- recv->message_cb (recv->cb_cls, recv->message_id, recv->flags, NULL);
+ recv->message_cb (recv->cb_cls, NULL);
GNUNET_PSYC_receive_reset (recv);
}
{
uint16_t size = ntohs (msg->header.size);
uint32_t flags = ntohl (msg->flags);
- uint64_t message_id;
GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG,
(struct GNUNET_MessageHeader *) msg);
recv_error (recv);
return GNUNET_SYSERR;
}
- message_id = recv->message_id;
uint16_t pos = 0, psize = 0, ptype, size_eq, size_min;
}
if (NULL != recv->message_part_cb)
- recv->message_part_cb (recv->cb_cls, &recv->slave_pub_key,
- recv->message_id, recv->flags,
- 0, // FIXME: data_offset
- pmsg);
+ recv->message_part_cb (recv->cb_cls, msg, pmsg);
switch (ptype)
{
}
if (NULL != recv->message_cb)
- recv->message_cb (recv->cb_cls, message_id, flags, msg);
+ recv->message_cb (recv->cb_cls, msg);
return GNUNET_OK;
}
static void
parse_message_part_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
- uint64_t message_id, uint32_t flags, uint64_t data_offset,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_PSYC_MessageHeader *msg,
+ const struct GNUNET_MessageHeader *pmsg)
{
struct ParseMessageClosure *pmc = cls;
- if (NULL == msg)
+ if (NULL == pmsg)
{
pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_ERROR;
return;
}
- switch (ntohs (msg->type))
+ switch (ntohs (pmsg->type))
{
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
{
struct GNUNET_PSYC_MessageMethod *
- pmeth = (struct GNUNET_PSYC_MessageMethod *) msg;
+ pmeth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
*pmc->method_name = (const char *) &pmeth[1];
pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_METHOD;
break;
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
{
struct GNUNET_PSYC_MessageModifier *
- pmod = (struct GNUNET_PSYC_MessageModifier *) msg;
+ pmod = (struct GNUNET_PSYC_MessageModifier *) pmsg;
const char *name = (const char *) &pmod[1];
const void *value = name + ntohs (pmod->name_size);
}
case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
- *pmc->data = &msg[1];
- *pmc->data_size = ntohs (msg->size) - sizeof (*msg);
+ *pmc->data = &pmsg[1];
+ *pmc->data_size = ntohs (pmsg->size) - sizeof (*pmsg);
pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_DATA;
break;
* @param env
* The environment for the message with a list of modifiers.
* @param[out] data
- * Pointer to data inside @a pmsg.
+ * Pointer to data inside @a msg.
* @param[out] data_size
* Size of @data is written here.
*