gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30914 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r30914 - gnunet/src/mesh
Date: Wed, 27 Nov 2013 19:11:03 +0100

Author: bartpolot
Date: 2013-11-27 19:11:03 +0100 (Wed, 27 Nov 2013)
New Revision: 30914

Modified:
   gnunet/src/mesh/gnunet-service-mesh_channel.c
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
   gnunet/src/mesh/mesh.h
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_common.c
Log:
- revamp mesh_common code, minor refactoring


Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-11-27 18:02:08 UTC 
(rev 30913)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-11-27 18:11:03 UTC 
(rev 30914)
@@ -322,7 +322,7 @@
   for (prev = rel->head_recv; NULL != prev; prev = prev->next)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, " prev %u\n", prev->mid);
-    if (GMC_is_pid_bigger (prev->mid, mid))
+    if (GM_is_pid_bigger (prev->mid, mid))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, " bingo!\n");
       GNUNET_CONTAINER_DLL_insert_before (rel->head_recv, rel->tail_recv,
@@ -467,7 +467,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "  sending %s ack to client on channel %s\n",
-       fwd ? "FWD" : "BCK", GMCH_2s (ch));
+       GM_f2s (fwd), GMCH_2s (ch));
 
   if (NULL == rel)
   {
@@ -614,7 +614,7 @@
     /* Skip copies with mid < target */
     target = mid + i + 1;
     LOG (GNUNET_ERROR_TYPE_DEBUG, " target %u\n", target);
-    while (NULL != copy && GMC_is_pid_bigger (target, copy->mid))
+    while (NULL != copy && GM_is_pid_bigger (target, copy->mid))
      copy = copy->next;
 
     /* Did we run out of copies? (previously freed, it's ok) */
@@ -625,7 +625,7 @@
     }
 
     /* Did we overshoot the target? (previously freed, it's ok) */
-    if (GMC_is_pid_bigger (copy->mid, target))
+    if (GM_is_pid_bigger (copy->mid, target))
     {
      LOG (GNUNET_ERROR_TYPE_DEBUG, " next copy %u\n", copy->mid);
      continue;
@@ -741,7 +741,7 @@
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "  sending channel %s ack for channel %s\n",
-              fwd ? "FWD" : "BCK", GMCH_2s (ch));
+              GM_f2s (fwd), GMCH_2s (ch));
 
   msg.chid = htonl (ch->gid);
   GMCH_send_prebuilt_message (&msg.header, ch, !fwd, GNUNET_NO);
@@ -784,7 +784,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "  channel confirm %s %s:%X\n",
-              fwd ? "FWD" : "BCK", GMT_2s (ch->t), ch->gid);
+              GM_f2s (fwd), GMT_2s (ch->t), ch->gid);
   ch->state = MESH_CHANNEL_READY;
 
   rel = fwd ? ch->root_rel : ch->dest_rel;
@@ -867,7 +867,7 @@
   size = ntohs (msg->size);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SAVE %u %s\n",
-       mid, GNUNET_MESH_DEBUG_M2S (type));
+       mid, GM_m2s (type));
   copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) + size);
   copy->mid = mid;
   copy->rel = rel;
@@ -955,7 +955,7 @@
   type = ntohs (msgh->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Loopback %s %s message!\n",
-       fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type));
+       GM_f2s (fwd), GM_m2s (type));
 
   switch (type)
   {
@@ -1211,7 +1211,7 @@
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "!!  Type %s, expected DATA\n",
-           GNUNET_MESH_DEBUG_M2S (copy->type));
+           GM_m2s (copy->type));
       continue;
     }
     if (copy->mid == ack + 1)
@@ -1593,8 +1593,8 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!! got mid %u\n", mid);
 
   if (GNUNET_NO == ch->reliable ||
-      ( !GMC_is_pid_bigger (rel->mid_recv, mid) &&
-        GMC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
+      ( !GM_is_pid_bigger (rel->mid_recv, mid) &&
+        GM_is_pid_bigger (rel->mid_recv + 64, mid) ) )
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RECV %u\n", mid);
     if (GNUNET_YES == ch->reliable)
@@ -1687,7 +1687,7 @@
   /* Free ACK'd copies: no need to retransmit those anymore */
   for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next)
   {
-    if (GMC_is_pid_bigger (copy->mid, ack))
+    if (GM_is_pid_bigger (copy->mid, ack))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "!!!  head %u, out!\n", copy->mid);
       channel_rel_free_sent (rel, msg);
@@ -1911,7 +1911,7 @@
                             int retransmission)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "GMCH Send %s %s on channel %s\n",
-       fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (ntohs (message->type)),
+       GM_f2s (fwd), GM_m2s (ntohs (message->type)),
        GMCH_2s (ch));
 
   if (GMT_is_loopback (ch->t))

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-27 18:02:08 UTC 
(rev 30913)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-27 18:11:03 UTC 
(rev 30914)
@@ -449,7 +449,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "connection send %s ack on %s\n",
-              fwd ? "FWD" : "BCK", GMC_2s (c));
+              GM_f2s (fwd), GMC_2s (c));
 
   /* Check if we need to transmit the ACK. */
   delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv;
@@ -478,7 +478,7 @@
   /* Check if message is already in queue */
   if (NULL != prev_fc->ack_msg)
   {
-    if (GMC_is_pid_bigger (ack, prev_fc->last_ack_sent))
+    if (GM_is_pid_bigger (ack, prev_fc->last_ack_sent))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, " canceling old ACK\n");
       GMC_cancel (prev_fc->ack_msg);
@@ -530,8 +530,8 @@
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "!  sent %s %s\n",
-       fwd ? "FWD" : "BCK",
-       GNUNET_MESH_DEBUG_M2S (type));
+       GM_f2s (fwd),
+       GM_m2s (type));
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!  C_P- %p %u\n", c, c->pending_messages);
   if (NULL != q)
   {
@@ -704,7 +704,7 @@
 
   t = connection->t;
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection %s ACK\n",
-       !fwd ? "FWD" : "BCK");
+       !GM_f2s (fwd));
   GMP_queue_add (get_hop (connection, fwd), NULL,
                  GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
                  sizeof (struct GNUNET_MESH_ConnectionACK),
@@ -760,7 +760,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "sending %s keepalive for connection %s]\n",
-       fwd ? "FWD" : "BCK", GMC_2s (c));
+       GM_f2s (fwd), GMC_2s (c));
 
   msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf;
   msg->header.size = htons (size);
@@ -876,7 +876,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "connection_unlock_queue %s on %s\n",
-              fwd ? "FWD" : "BCK", GMC_2s (c));
+              GM_f2s (fwd), GMC_2s (c));
 
   if (GMC_is_terminal (c, fwd))
   {
@@ -906,7 +906,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        " *** Cancel %s queues for connection %s\n",
-       fwd ? "FWD" : "BCK", GMC_2s (c));
+       GM_f2s (fwd), GMC_2s (c));
   if (NULL == c)
   {
     GNUNET_break (0);
@@ -1564,7 +1564,7 @@
   type = ntohs (msg->header.type);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n");
   LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message (#%u) from %s\n",
-       GNUNET_MESH_DEBUG_M2S (type), ntohl (msg->pid), GNUNET_i2s (peer));
+       GM_m2s (type), ntohl (msg->pid), GNUNET_i2s (peer));
 
   /* Check connection */
   c = connection_get (&msg->cid);
@@ -1602,7 +1602,7 @@
   /* Check PID */
   fc = fwd ? &c->bck_fc : &c->fwd_fc;
   pid = ntohl (msg->pid);
-  if (GMC_is_pid_bigger (pid, fc->last_ack_sent))
+  if (GM_is_pid_bigger (pid, fc->last_ack_sent))
   {
     GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1610,7 +1610,7 @@
                 pid, fc->last_pid_recv, fc->last_ack_sent);
     return GNUNET_OK;
   }
-  if (GNUNET_NO == GMC_is_pid_bigger (pid, fc->last_pid_recv))
+  if (GNUNET_NO == GM_is_pid_bigger (pid, fc->last_pid_recv))
   {
     GNUNET_STATISTICS_update (stats, "# duplicate PID", 1, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1691,7 +1691,7 @@
   type = ntohs (msg->header.type);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n");
   LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message from %s\n",
-              GNUNET_MESH_DEBUG_M2S (type), GNUNET_i2s (peer));
+              GM_m2s (type), GNUNET_i2s (peer));
 
   /* Check connection */
   c = connection_get (&msg->cid);
@@ -1853,12 +1853,12 @@
   ack = ntohl (msg->ack);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  ACK %u (was %u)\n",
               ack, fc->last_ack_recv);
-  if (GMC_is_pid_bigger (ack, fc->last_ack_recv))
+  if (GM_is_pid_bigger (ack, fc->last_ack_recv))
     fc->last_ack_recv = ack;
 
   /* Cancel polling if the ACK is big enough. */
   if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task &&
-      GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
+      GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Cancel poll\n");
     GNUNET_SCHEDULER_cancel (fc->poll_task);
@@ -2024,7 +2024,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "GMC send %s ACK on %s\n",
-       fwd ? "FWD" : "BCK", GMC_2s (c));
+       GM_f2s (fwd), GMC_2s (c));
 
   if (NULL == c)
   {
@@ -2342,7 +2342,7 @@
   struct MeshFlowControl *fc;
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
-  if (GMC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent))
+  if (GM_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent))
   {
     return 0;
   }
@@ -2477,7 +2477,7 @@
   struct MeshFlowControl *fc;
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
-  if (GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
+  if (GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
     return GNUNET_YES;
   return GNUNET_NO;
 }
@@ -2514,7 +2514,7 @@
   memcpy (data, message, size);
   type = ntohs (message->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u bytes) on connection %s\n",
-              GNUNET_MESH_DEBUG_M2S (type), size, GMC_2s (c));
+              GM_m2s (type), size, GMC_2s (c));
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   droppable = GNUNET_YES;
@@ -2545,7 +2545,7 @@
       LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", ntohl (emsg->pid));
       LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "     ack recv %u\n", fc->last_ack_recv);
-      if (GMC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv))
+      if (GM_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv))
       {
         GMC_start_poll (c, fwd);
       }
@@ -2733,7 +2733,7 @@
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL %s requested\n",
-       fwd ? "FWD" : "BCK");
+       GM_f2s (fwd));
   if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task || NULL != fc->poll_msg)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, " ***   not needed (%u, %p)\n",

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-11-27 18:02:08 UTC (rev 
30913)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-11-27 18:11:03 UTC (rev 
30914)
@@ -814,7 +814,7 @@
     case GNUNET_MESSAGE_TYPE_MESH_POLL:
       LOG (GNUNET_ERROR_TYPE_DEBUG,
                   "*   raw: %s\n",
-                  GNUNET_MESH_DEBUG_M2S (queue->type));
+                  GM_m2s (queue->type));
       data_size = send_core_data_raw (queue->cls, size, buf);
       break;
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
@@ -850,7 +850,7 @@
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
                 "Dropping message of type %s\n",
-                GNUNET_MESH_DEBUG_M2S (queue->type));
+                GM_m2s (queue->type));
     data_size = 0;
   }
 
@@ -915,7 +915,7 @@
   if (GNUNET_YES == clear_cls)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "#   queue destroy type %s\n",
-                GNUNET_MESH_DEBUG_M2S (queue->type));
+                GM_m2s (queue->type));
     switch (queue->type)
     {
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
@@ -934,7 +934,7 @@
       default:
         GNUNET_break (0);
         LOG (GNUNET_ERROR_TYPE_ERROR, "#   type %s unknown!\n",
-                    GNUNET_MESH_DEBUG_M2S (queue->type));
+                    GM_m2s (queue->type));
     }
   }
   GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue);
@@ -985,7 +985,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "queue add %s %s towards %s (size %u) on c %p (%s)\n",
-       fwd ? "FWD" : "BCK",  GNUNET_MESH_DEBUG_M2S (type), GMP_2s(peer),
+       GM_f2s (fwd),  GM_m2s (type), GMP_2s(peer),
        size, c, GMC_2s (c));
   GNUNET_assert (NULL != c);
 
@@ -1075,7 +1075,7 @@
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
                   "GMP_cancel_queue %s\n",
-                  GNUNET_MESH_DEBUG_M2S (q->type));
+                  GM_m2s (q->type));
       GMP_queue_destroy (q, GNUNET_YES);
 
       /* Get next from prev, q->next might be already freed:

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-11-27 18:02:08 UTC 
(rev 30913)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-11-27 18:11:03 UTC 
(rev 30914)
@@ -736,7 +736,7 @@
       break;
     default:
       LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n",
-           GNUNET_MESH_DEBUG_M2S (type));
+           GM_m2s (type));
       GNUNET_break (0);
   }
 
@@ -977,7 +977,7 @@
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n",
-              GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
+              GM_m2s (ntohs (msg[1].header.type)));
 
   /* Check channel */
   ch = GMT_get_channel (t, ntohl (msg->chid));
@@ -1314,7 +1314,7 @@
   type = ntohs (msgh->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Got a %s message!\n",
-       GNUNET_MESH_DEBUG_M2S (type));
+       GM_m2s (type));
 
   switch (type)
   {
@@ -2213,7 +2213,7 @@
       break;
     default:
       LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n",
-           GNUNET_MESH_DEBUG_M2S (type));
+           GM_m2s (type));
       GNUNET_break (0);
   }
 

Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h      2013-11-27 18:02:08 UTC (rev 30913)
+++ gnunet/src/mesh/mesh.h      2013-11-27 18:11:03 UTC (rev 30914)
@@ -200,6 +200,17 @@
 
 
 /**
+ * @brief Translate a fwd variable into a string representation, for logging.
+ *
+ * @param fwd Is FWD? (#GNUNET_YES or #GNUNET_NO)
+ *
+ * @return String representing FWD or BCK.
+ */
+char *
+GM_f2s (int fwd);
+
+
+/**
  * Check if one pid is bigger than other, accounting for overflow.
  *
  * @param bigger Argument that should be bigger.
@@ -208,7 +219,7 @@
  * @return True if bigger (arg1) has a higher value than smaller (arg 2).
  */
 int
-GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
+GM_is_pid_bigger (uint32_t bigger, uint32_t smaller);
 
 
 /**
@@ -220,7 +231,7 @@
  * @return Highest ACK value from the two.
  */
 uint32_t
-GMC_max_pid (uint32_t a, uint32_t b);
+GM_max_pid (uint32_t a, uint32_t b);
 
 
 /**
@@ -232,7 +243,7 @@
  * @return Lowest ACK value from the two.
  */
 uint32_t
-GMC_min_pid (uint32_t a, uint32_t b);
+GM_min_pid (uint32_t a, uint32_t b);
 
 
 /**
@@ -246,7 +257,7 @@
  * @return Human readable string description.
  */
 const char *
-GNUNET_MESH_DEBUG_M2S (uint16_t m);
+GM_m2s (uint16_t m);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2013-11-27 18:02:08 UTC (rev 30913)
+++ gnunet/src/mesh/mesh_api.c  2013-11-27 18:11:03 UTC (rev 30914)
@@ -1054,7 +1054,7 @@
   type = ntohs (msg->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a message: %s\n",
-       GNUNET_MESH_DEBUG_M2S (type));
+       GM_m2s (type));
   switch (type)
   {
     /* Notify of a new incoming channel */
@@ -1082,7 +1082,7 @@
     /* We shouldn't get any other packages, log and ignore */
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "unsolicited message form service (type %s)\n",
-         GNUNET_MESH_DEBUG_M2S (ntohs (msg->type)));
+         GM_m2s (ntohs (msg->type)));
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
   if (GNUNET_YES == h->in_receive)
@@ -1166,7 +1166,7 @@
         dmsg->id = htonl (ch->chid);
         dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA);
         LOG (GNUNET_ERROR_TYPE_DEBUG, "#  payload type %s\n",
-             GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
+             GM_m2s (ntohs (mh->type)));
                 ch->allow_send = GNUNET_NO;
       }
       else
@@ -1181,7 +1181,7 @@
       struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1];
 
       LOG (GNUNET_ERROR_TYPE_DEBUG, "#  mesh internal traffic, type %s\n",
-           GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
+           GM_m2s (ntohs (mh->type)));
       memcpy (cbuf, &th[1], th->size);
       psize = th->size;
     }
@@ -1243,7 +1243,7 @@
   size_t msize;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, " Sending message to service: %s\n",
-       GNUNET_MESH_DEBUG_M2S(ntohs(msg->type)));
+       GM_m2s(ntohs(msg->type)));
   msize = ntohs (msg->size);
   th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle) + msize);
   th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;

Modified: gnunet/src/mesh/mesh_common.c
===================================================================
--- gnunet/src/mesh/mesh_common.c       2013-11-27 18:02:08 UTC (rev 30913)
+++ gnunet/src/mesh/mesh_common.c       2013-11-27 18:11:03 UTC (rev 30914)
@@ -26,9 +26,33 @@
 
 #include "mesh.h"
 
+/**
+ * @brief Translate a fwd variable into a string representation, for logging.
+ *
+ * @param fwd Is FWD? (#GNUNET_YES or #GNUNET_NO)
+ *
+ * @return String representing FWD or BCK.
+ */
+char *
+GM_f2s (int fwd)
+{
+  if (GNUNET_YES == fwd)
+  {
+    return "FWD";
+  }
+  else if (GNUNET_NO == fwd)
+  {
+    return "BCK";
+  }
+  else
+  {
+    GNUNET_break (0);
+    return "";
+  }
+}
 
 int
-GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
+GM_is_pid_bigger (uint32_t bigger, uint32_t smaller)
 {
     return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) ||
             (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller)));
@@ -36,18 +60,18 @@
 
 
 uint32_t
-GMC_max_pid (uint32_t a, uint32_t b)
+GM_max_pid (uint32_t a, uint32_t b)
 {
-  if (GMC_is_pid_bigger(a, b))
+  if (GM_is_pid_bigger(a, b))
     return a;
   return b;
 }
 
 
 uint32_t
-GMC_min_pid (uint32_t a, uint32_t b)
+GM_min_pid (uint32_t a, uint32_t b)
 {
-  if (GMC_is_pid_bigger(a, b))
+  if (GM_is_pid_bigger(a, b))
     return b;
   return a;
 }
@@ -55,7 +79,7 @@
 
 #if !defined(GNUNET_CULL_LOGGING)
 const char *
-GNUNET_MESH_DEBUG_M2S (uint16_t m)
+GM_m2s (uint16_t m)
 {
   static char buf[32];
   switch (m)
@@ -185,7 +209,7 @@
 }
 #else
 const char *
-GNUNET_MESH_DEBUG_M2S (uint16_t m)
+GM_m2s (uint16_t m)
 {
   return "";
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]