#include "mesh.h"
#include "mesh_protocol.h"
-#define DEBUG GNUNET_YES
+#define MESH_API_DEBUG GNUNET_YES
#define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__)
types[ntypes] = htons (h->message_handlers[ntypes].type);
msg->applications = htons (napps);
msg->types = htons (ntypes);
-#if DEBUG
+#if MESH_API_DEBUG
LOG (GNUNET_ERROR_TYPE_DEBUG,
"mesh: Sending %lu bytes long message %d types and %d apps\n",
ntohs (msg->header.size), ntypes, napps);
struct GNUNET_MESH_Tunnel *t;
unsigned int i;
-#if DEBUG
+#if MESH_API_DEBUG
LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: ******* RECONNECT *******\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n");
const struct GNUNET_MESH_TunnelNotification *msg)
{
struct GNUNET_MESH_Tunnel *t;
- struct GNUNET_TRANSPORT_ATS_Information atsi;
+ struct GNUNET_ATS_Information atsi;
MESH_TunnelNumber tid;
tid = ntohl (msg->tunnel_id);
if (NULL == t)
{
- GNUNET_break (0);
return;
}
if (0 == t->owner)
{
struct GNUNET_MESH_Tunnel *t;
struct GNUNET_MESH_Peer *p;
- struct GNUNET_TRANSPORT_ATS_Information atsi;
+ struct GNUNET_ATS_Information atsi;
GNUNET_PEER_Id id;
uint16_t size;
handler = &h->message_handlers[i];
if (handler->type == type)
{
- struct GNUNET_TRANSPORT_ATS_Information atsi;
+ struct GNUNET_ATS_Information atsi;
atsi.type = 0;
atsi.value = 0;
GNUNET_MESH_disconnect (h);
return;
}
-#if DEBUG
+#if MESH_API_DEBUG
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
tsize = 0;
while ((NULL != (th = h->th_head)) && (size >= th->size))
{
-#if DEBUG
- LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: type: %u\n",
- ntohs (((struct GNUNET_MessageHeader *) &th[1])->type));
- LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: size: %u\n",
- ntohs (((struct GNUNET_MessageHeader *) &th[1])->size));
-#endif
if (NULL != th->notify)
{
if (th->tunnel->tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV)
ntohs (mh->type));
if (psize > 0)
{
- to.header.size = htons (th->size);
+ psize += sizeof (to);
+ GNUNET_assert (size >= psize);
+ to.header.size = htons (psize);
to.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
to.tid = htonl (th->tunnel->tid);
memset (&to.oid, 0, sizeof (struct GNUNET_PeerIdentity));
memset (&to.sender, 0, sizeof (struct GNUNET_PeerIdentity));
memcpy (cbuf, &to, sizeof (to));
- psize += sizeof (to);
}
}
else if (th->target == 0)
{
/* multicast */
struct GNUNET_MESH_Multicast mc;
+ struct GNUNET_MessageHeader *mh;
GNUNET_assert (size >= th->size);
+ mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (mc)];
psize =
- th->notify (th->notify_cls, size - sizeof (mc), &cbuf[sizeof (mc)]);
+ th->notify (th->notify_cls, size - sizeof (mc), mh);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "mesh: multicast, type %u\n",
+ ntohs (mh->type));
if (psize > 0)
{
- mc.header.size = htons (sizeof (mc) + th->size);
+ psize += sizeof (mc);
+ GNUNET_assert (size >= psize);
+ mc.header.size = htons (psize);
mc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
mc.tid = htonl (th->tunnel->tid);
memset (&mc.oid, 0, sizeof (struct GNUNET_PeerIdentity));
memcpy (cbuf, &mc, sizeof (mc));
- psize += sizeof (mc);
}
}
else
ntohs (mh->type));
if (psize > 0)
{
- uc.header.size = htons (th->size);
+ psize += sizeof (uc);
+ GNUNET_assert (size >= psize);
+ uc.header.size = htons (psize);
uc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_UNICAST);
uc.tid = htonl (th->tunnel->tid);
memset (&uc.oid, 0, sizeof (struct GNUNET_PeerIdentity));
GNUNET_PEER_resolve (th->target, &uc.destination);
memcpy (cbuf, &uc, sizeof (uc));
- psize += sizeof (uc);
}
}
}
{
if (tunnel->peers[i]->id == peer_id)
{
+ /* Peer already exists in tunnel */
GNUNET_PEER_change_rc (peer_id, -1);
GNUNET_break (0);
return;
uint32_t least_priority;
size_t overhead;
+#if MESH_API_DEBUG
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"mesh: mesh notify transmit ready called\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "mesh: target %s\n",
- GNUNET_i2s (target));
-
+ if (NULL != target)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "mesh: target %s\n",
+ GNUNET_i2s (target));
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "mesh: target multicast\n");
+#endif
GNUNET_assert (NULL != notify);
if (tunnel->mesh->npackets >= tunnel->mesh->max_queue_size &&
tunnel->npackets > 0)