#include "gnunet_multicast_service.h"
#include "multicast.h"
-/**
+#define LOG(kind,...) GNUNET_log_from (kind, "multicast-api",__VA_ARGS__)
+
+
+/**
* Handle for a request to send a message to all multicast group members
* (from the origin).
*/
{
GNUNET_MULTICAST_OriginTransmitNotify notify;
void *notify_cls;
+ struct GNUNET_MULTICAST_Origin *origin;
uint64_t message_id;
uint64_t group_generation;
*/
struct GNUNET_MULTICAST_Origin
{
- struct GNUNET_CRYPTO_EccPrivateKey priv_key;
+ struct GNUNET_CRYPTO_EddsaPrivateKey priv_key;
struct GNUNET_MULTICAST_OriginMessageHandle msg_handle;
GNUNET_MULTICAST_JoinCallback join_cb;
/**
* Public key of the sending member.
*/
- struct GNUNET_CRYPTO_EccPublicSignKey member_key;
+ struct GNUNET_CRYPTO_EddsaPublicKey member_key;
/**
* ECC signature of the request fragment.
*
* Signature must match the public key of the multicast group.
*/
- struct GNUNET_CRYPTO_EccSignature signature;
+ struct GNUNET_CRYPTO_EddsaSignature signature;
/**
* Purpose for the signature and size of the signed data.
*
* Signature must match the public key of the joining member.
*/
- struct GNUNET_CRYPTO_EccSignature signature;
+ struct GNUNET_CRYPTO_EddsaSignature signature;
/**
* Purpose for the signature and size of the signed data.
/**
* Public key of the target group.
*/
- struct GNUNET_CRYPTO_EccPublicSignKey group_key;
+ struct GNUNET_CRYPTO_EddsaPublicKey group_key;
/**
* Public key of the joining member.
*/
- struct GNUNET_CRYPTO_EccPublicSignKey member_key;
+ struct GNUNET_CRYPTO_EddsaPublicKey member_key;
/**
* Peer identity of the joining member.
*/
struct GNUNET_MULTICAST_Origin *
GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
+ const struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key,
uint64_t next_fragment_id,
GNUNET_MULTICAST_JoinCallback join_cb,
GNUNET_MULTICAST_MembershipTestCallback mem_test_cb,
static void
schedule_origin_to_all (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "schedule_origin_to_all()\n");
struct GNUNET_MULTICAST_Origin *orig = cls;
struct GNUNET_MULTICAST_OriginMessageHandle *mh = &orig->msg_handle;
= GNUNET_malloc (sizeof (*msg) + buf_size);
int ret = mh->notify (mh->notify_cls, &buf_size, &msg[1]);
- if (ret != GNUNET_YES || ret != GNUNET_NO)
+ if (! (GNUNET_YES == ret || GNUNET_NO == ret)
+ || buf_size > GNUNET_MULTICAST_FRAGMENT_MAX_SIZE)
{
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "MasterTransmitNotify() returned error or invalid message size.\n");
/* FIXME: handle error */
return;
}
+ if (GNUNET_NO == ret && 0 == buf_size)
+ return; /* Transmission paused. */
+
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
msg->header.size = htons (buf_size);
msg->message_id = mh->message_id;
- sizeof (msg->signature));
msg->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE);
- if (GNUNET_OK != GNUNET_CRYPTO_ecc_sign (&orig->priv_key, &msg->purpose,
+ if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&orig->priv_key, &msg->purpose,
&msg->signature))
{
/* FIXME: handle error */
* returned signed message.
* FIXME: Also send to local members in this group.
*/
- orig->message_cb (orig->cls, msg);
+ orig->message_cb (orig->cls, (const struct GNUNET_MessageHeader *) msg);
if (GNUNET_NO == ret)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 1),
- schedule_origin_to_all, mh);
+ schedule_origin_to_all, orig);
}
void *notify_cls)
{
struct GNUNET_MULTICAST_OriginMessageHandle *mh = &origin->msg_handle;
+ mh->origin = origin;
mh->message_id = message_id;
mh->group_generation = group_generation;
mh->notify = notify;
void
GNUNET_MULTICAST_origin_to_all_resume (struct GNUNET_MULTICAST_OriginMessageHandle *mh)
{
-
+ GNUNET_SCHEDULER_add_now (schedule_origin_to_all, mh->origin);
}
*/
struct GNUNET_MULTICAST_Member *
GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_EccPublicSignKey *group_key,
- const struct GNUNET_CRYPTO_EccPrivateKey *member_key,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *group_key,
+ const struct GNUNET_CRYPTO_EddsaPrivateKey *member_key,
const struct GNUNET_PeerIdentity *origin,
uint32_t relay_count,
const struct GNUNET_PeerIdentity *relays,