[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23179 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23179 - gnunet/src/mesh |
Date: |
Thu, 9 Aug 2012 17:47:36 +0200 |
Author: bartpolot
Date: 2012-08-09 17:47:36 +0200 (Thu, 09 Aug 2012)
New Revision: 23179
Added:
gnunet/src/mesh/mesh_common.c
Modified:
gnunet/src/mesh/Makefile.am
gnunet/src/mesh/gnunet-service-mesh.c
gnunet/src/mesh/mesh.h
gnunet/src/mesh/mesh_api.c
Log:
- add debug functions, refactor, add common code file
Modified: gnunet/src/mesh/Makefile.am
===================================================================
--- gnunet/src/mesh/Makefile.am 2012-08-09 15:46:50 UTC (rev 23178)
+++ gnunet/src/mesh/Makefile.am 2012-08-09 15:47:36 UTC (rev 23179)
@@ -42,7 +42,7 @@
$(top_builddir)/src/util/libgnunetutil.la
libgnunetmesh_la_SOURCES = \
- mesh_api.c mesh.h mesh_protocol.h
+ mesh_api.c mesh_common.c
libgnunetmesh_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(XLIB) \
@@ -63,7 +63,9 @@
gnunet_service_mesh_SOURCES = \
gnunet-service-mesh.c \
- mesh_tunnel_tree.c mesh_tunnel_tree.h
+ mesh_tunnel_tree.c \
+ mesh_common.c
+gnunet_service_mesh_CFLAGS = $(AM_CFLAGS)
gnunet_service_mesh_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/core/libgnunetcore.la \
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2012-08-09 15:46:50 UTC (rev
23178)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2012-08-09 15:47:36 UTC (rev
23179)
@@ -1981,7 +1981,8 @@
type = ntohs (payload->type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending to clients...\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "message of type %u\n", type);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "message of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (type));
memcpy (cbuf, msg, sizeof (cbuf));
switch (htons (msg->type))
@@ -4327,14 +4328,15 @@
mc = (struct GNUNET_MESH_Multicast *) mh;
mh = (struct GNUNET_MessageHeader *) &mc[1];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " multicast, payload type %u\n", ntohs (mh->type));
+ " multicast, payload type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" multicast, payload size %u\n", ntohs (mh->size));
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type %u\n",
- ntohs (mh->type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
}
}
#endif
@@ -5041,8 +5043,8 @@
return GNUNET_OK;
}
msg = (struct GNUNET_MESH_Unicast *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
/* Check tunnel */
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
@@ -5233,8 +5235,8 @@
return GNUNET_OK;
}
msg = (struct GNUNET_MESH_ToOrigin *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
@@ -5305,8 +5307,8 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK packet from %s!\n",
GNUNET_i2s (peer));
msg = (struct GNUNET_MESH_ACK *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h 2012-08-09 15:46:50 UTC (rev 23178)
+++ gnunet/src/mesh/mesh.h 2012-08-09 15:47:36 UTC (rev 23179)
@@ -310,5 +310,17 @@
};
+/**
+ * Convert a message type into a string to help debug
+ * Generated with:
+ * FIND: "#define ([^ ]+)[ ]*([0-9]+)"
+ * REPLACE: " case \2: return "\1"; break;"
+ *
+ * @param m Message type.
+ *
+ * @return Human readable string description.
+ */
+const char *
+GNUNET_MESH_DEBUG_M2S (uint16_t m);
#endif
Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c 2012-08-09 15:46:50 UTC (rev 23178)
+++ gnunet/src/mesh/mesh_api.c 2012-08-09 15:47:36 UTC (rev 23179)
@@ -1291,8 +1291,8 @@
GNUNET_assert (size >= th->size);
mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (to)];
psize = th->notify (th->notify_cls, size - sizeof (to), mh);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " to origin, type %u\n",
- ntohs (mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " to origin, type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
if (psize > 0)
{
psize += sizeof (to);
@@ -1315,8 +1315,8 @@
GNUNET_assert (size >= th->size);
mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (mc)];
psize = th->notify (th->notify_cls, size - sizeof (mc), mh);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " multicast, type %u\n",
- ntohs (mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " multicast, type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
if (psize > 0)
{
psize += sizeof (mc);
@@ -1339,8 +1339,8 @@
GNUNET_assert (size >= th->size);
mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (uc)];
psize = th->notify (th->notify_cls, size - sizeof (uc), mh);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " unicast, type %u\n",
- ntohs (mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " unicast, type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
if (psize > 0)
{
psize += sizeof (uc);
@@ -1360,8 +1360,8 @@
{
struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1];
- LOG (GNUNET_ERROR_TYPE_DEBUG, " mesh traffic, type %u\n",
- ntohs (mh->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " mesh traffic, type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
memcpy (cbuf, &th[1], th->size);
psize = th->size;
}
Added: gnunet/src/mesh/mesh_common.c
===================================================================
--- gnunet/src/mesh/mesh_common.c (rev 0)
+++ gnunet/src/mesh/mesh_common.c 2012-08-09 15:47:36 UTC (rev 23179)
@@ -0,0 +1,185 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file mesh/mesh.c
+ * @brief MESH helper functions
+ * @author Bartlomiej Polot
+ */
+
+#include "mesh.h"
+
+#if !defined(GNUNET_CULL_LOGGING)
+const char *
+GNUNET_MESH_DEBUG_M2S (uint16_t m)
+{
+ static char buf[32];
+ switch (m)
+ {
+ /**
+ * Request the creation of a path
+ */
+ case 256: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE"; break;
+
+ /**
+ * Request the modification of an existing path
+ */
+ case 257: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGE"; break;
+
+ /**
+ * Notify that a connection of a path is no longer valid
+ */
+ case 258: return "GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN"; break;
+
+ /**
+ * At some point, the route will spontaneously change
+ */
+ case 259: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED"; break;
+
+ /**
+ * Transport data in the mesh (origin->end) unicast
+ */
+ case 260: return "GNUNET_MESSAGE_TYPE_MESH_UNICAST"; break;
+
+ /**
+ * Transport data to all peers in a tunnel
+ */
+ case 261: return "GNUNET_MESSAGE_TYPE_MESH_MULTICAST"; break;
+
+ /**
+ * Transport data back in the mesh (end->origin)
+ */
+ case 262: return "GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN"; break;
+
+ /**
+ * Send origin an ACK that the path is complete
+ */
+ case 263: return "GNUNET_MESSAGE_TYPE_MESH_PATH_ACK"; break;
+
+ /**
+ * Avoid path timeouts
+ */
+ case 264: return "GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE"; break;
+
+ /**
+ * Request the destuction of a path
+ */
+ case 265: return "GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY"; break;
+
+ /**
+ * Request the destruction of a whole tunnel
+ */
+ case 266: return "GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY"; break;
+
+ /**
+ * ACK for a data packet.
+ */
+ case 267: return "GNUNET_MESSAGE_TYPE_MESH_ACK"; break;
+
+ /**
+ * Connect to the mesh service, specifying subscriptions
+ */
+ case 272: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT"; break;
+
+ /**
+ * Ask the mesh service to create a new tunnel
+ */
+ case 273: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE"; break;
+
+ /**
+ * Ask the mesh service to destroy a tunnel
+ */
+ case 274: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY"; break;
+
+ /**
+ * Ask the mesh service to add a peer to an existing tunnel
+ */
+ case 275: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD"; break;
+
+ /**
+ * Ask the mesh service to remove a peer from a tunnel
+ */
+ case 276: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL"; break;
+
+ /**
+ * Ask the mesh service to add a peer offering a service to an existing
tunnel
+ */
+ case 277: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_TYPE"; break;
+
+ /**
+ * Ask the mesh service to add a peer described by a service string
+ */
+ case 278: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX"; break;
+
+ /**
+ * Ask the mesh service to add a peer described by a service string
+ */
+ case 279: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING";
break;
+
+ /**
+ * Ask the mesh service to add a peer to the blacklist of an existing
tunnel
+ */
+ case 280: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST"; break;
+
+ /**
+ * Ask the mesh service to remove a peer from the blacklist of a tunnel
+ */
+ case 281: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST"; break;
+
+ /**
+ * Set tunnel speed to slowest peer
+ */
+ case 282: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN"; break;
+
+ /**
+ * Set tunnel speed to fastest peer
+ */
+ case 283: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX"; break;
+
+ /**
+ * Set tunnel buffering on.
+ */
+ case 284: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER"; break;
+
+ /**
+ * Set tunnel buffering off.
+ */
+ case 285: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER"; break;
+
+ /**
+ * Local ACK for data.
+ */
+ case 286: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK"; break;
+
+ /**
+ * 640kb should be enough for everybody
+ */
+ case 299: return "GNUNET_MESSAGE_TYPE_MESH_RESERVE_END"; break;
+ }
+ sprintf(buf, "%u (UNKNOWN TYPE)", m);
+ return buf;
+}
+#else
+const char *
+GNUNET_MESH_DEBUG_M2S (uint16_t m)
+{
+ return "";
+}
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23179 - gnunet/src/mesh,
gnunet <=