gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r23180 - gnunet/src/mesh
Date: Thu, 9 Aug 2012 17:53:34 +0200

Author: bartpolot
Date: 2012-08-09 17:53:34 +0200 (Thu, 09 Aug 2012)
New Revision: 23180

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh.h
   gnunet/src/mesh/mesh_common.c
Log:
- refactoring

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2012-08-09 15:47:36 UTC (rev 
23179)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2012-08-09 15:53:34 UTC (rev 
23180)
@@ -1705,55 +1705,6 @@
 
/******************************************************************************/
 
 /**
- * Check if one pid is bigger than other, accounting for overflow.
- *
- * @param bigger Argument that should be bigger.
- * @param smaller Argument that should be smaller.
- *
- * @return True if bigger (arg1) has a higher value than smaller (arg 2).
- */
-static int
-is_pid_bigger (uint32_t bigger, uint32_t smaller)
-{
-    return (GNUNET_YES == PID_OVERFLOW(smaller, bigger) ||
-            (bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
-}
-
-/**
- * Get the higher ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Highest ACK value from the two.
- */
-static uint32_t
-max_pid (uint32_t a, uint32_t b)
-{
-  if (is_pid_bigger(a, b))
-    return a;
-  return b;
-}
-
-
-/**
- * Get the lower ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Lowest ACK value from the two.
- */
-static uint32_t
-min_pid (uint32_t a, uint32_t b)
-{
-  if (is_pid_bigger(a, b))
-    return b;
-  return a;
-}
-
-
-/**
  * Decrements the reference counter and frees all resources if needed
  *
  * @param mesh_data Data Descriptor used in a multicast message.
@@ -3567,7 +3518,7 @@
   if (0 == ctx.nchildren)
     return -1LL;
 
-  if (GNUNET_YES == t->nobuffer && is_pid_bigger(ctx.max_child_ack, 
t->fwd_pid))
+  if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ctx.max_child_ack, 
t->fwd_pid))
     ctx.max_child_ack = t->fwd_pid + 1; // Might overflow, it's ok.
 
   return (int64_t) ctx.max_child_ack;
@@ -3621,15 +3572,15 @@
   {
     if (-1 == ack ||
         (GNUNET_YES == t->speed_min &&
-         GNUNET_YES == is_pid_bigger (ack, t->clients_fc[i].fwd_ack)) ||
+         GNUNET_YES == GMC_is_pid_bigger (ack, t->clients_fc[i].fwd_ack)) ||
         (GNUNET_NO == t->speed_min &&
-         GNUNET_YES == is_pid_bigger (t->clients_fc[i].fwd_ack, ack)))
+         GNUNET_YES == GMC_is_pid_bigger (t->clients_fc[i].fwd_ack, ack)))
     {
       ack = t->clients_fc[i].fwd_ack;
     }
   }
 
-  if (GNUNET_YES == t->nobuffer && is_pid_bigger(ack, t->fwd_pid))
+  if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ack, t->fwd_pid))
     ack = (uint32_t) t->fwd_pid + 1; // Might overflow, it's ok.
 
   return (uint32_t) ack;
@@ -3667,15 +3618,15 @@
 
   if (GNUNET_YES == t->speed_min)
   {
-    ack = min_pid ((uint32_t) child_ack, ack);
-    ack = min_pid ((uint32_t) client_ack, ack);
+    ack = GMC_min_pid ((uint32_t) child_ack, ack);
+    ack = GMC_min_pid ((uint32_t) client_ack, ack);
   }
   else
   {
-    ack = max_pid ((uint32_t) child_ack, ack);
-    ack = max_pid ((uint32_t) client_ack, ack);
+    ack = GMC_max_pid ((uint32_t) child_ack, ack);
+    ack = GMC_max_pid ((uint32_t) client_ack, ack);
   }
-  if (GNUNET_YES == t->nobuffer && is_pid_bigger(ack, t->fwd_pid))
+  if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ack, t->fwd_pid))
     ack = t->fwd_pid + 1; // Might overflow 32 bits, it's ok!
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "c %u, bf %u, ch %u, cl %u, ACK: %u\n",
               count, buffer_free, child_ack, client_ack, ack);
@@ -3827,7 +3778,7 @@
   cinfo = tunnel_get_neighbor_fc (t, &peer);
 
   if (cinfo->bck_ack != cinfo->pid &&
-      GNUNET_NO == is_pid_bigger (cinfo->bck_ack, cinfo->pid))
+      GNUNET_NO == GMC_is_pid_bigger (cinfo->bck_ack, cinfo->pid))
     return;
 
   cinfo->bck_ack++;
@@ -5069,7 +5020,7 @@
   }
   t->skip += (pid - t->fwd_pid) - 1;
   t->fwd_pid = pid;
-  if (is_pid_bigger (pid, t->last_fwd_ack))
+  if (GMC_is_pid_bigger (pid, t->last_fwd_ack))
   {
     GNUNET_STATISTICS_update (stats, "# unsolicited unicast", 1, GNUNET_NO);
     GNUNET_break_op (0);
@@ -5104,7 +5055,7 @@
   GNUNET_CONTAINER_multihashmap_iterate (t->children_fc,
                                          &tunnel_add_skip,
                                          &neighbor);
-  if (is_pid_bigger (pid, cinfo->fwd_ack))
+  if (GMC_is_pid_bigger (pid, cinfo->fwd_ack))
   {
     GNUNET_STATISTICS_update (stats, "# unsolicited unicast", 1, GNUNET_NO);
     GNUNET_break_op (0);

Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h      2012-08-09 15:47:36 UTC (rev 23179)
+++ gnunet/src/mesh/mesh.h      2012-08-09 15:53:34 UTC (rev 23180)
@@ -311,6 +311,42 @@
 
 
 /**
+ * Check if one pid is bigger than other, accounting for overflow.
+ *
+ * @param bigger Argument that should be bigger.
+ * @param smaller Argument that should be smaller.
+ *
+ * @return True if bigger (arg1) has a higher value than smaller (arg 2).
+ */
+int
+GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
+
+
+/**
+ * Get the higher ACK value out of two values, taking in account overflow.
+ *
+ * @param a First ACK value.
+ * @param b Second ACK value.
+ *
+ * @return Highest ACK value from the two.
+ */
+uint32_t
+GMC_max_pid (uint32_t a, uint32_t b);
+
+
+/**
+ * Get the lower ACK value out of two values, taking in account overflow.
+ *
+ * @param a First ACK value.
+ * @param b Second ACK value.
+ *
+ * @return Lowest ACK value from the two.
+ */
+uint32_t
+GMC_min_pid (uint32_t a, uint32_t b);
+
+
+/**
  * Convert a message type into a string to help debug
  * Generated with:
  * FIND:        "#define ([^ ]+)[ ]*([0-9]+)"

Modified: gnunet/src/mesh/mesh_common.c
===================================================================
--- gnunet/src/mesh/mesh_common.c       2012-08-09 15:47:36 UTC (rev 23179)
+++ gnunet/src/mesh/mesh_common.c       2012-08-09 15:53:34 UTC (rev 23180)
@@ -19,13 +19,63 @@
 */
 
 /**
- * @file mesh/mesh.c
+ * @file mesh/mesh_common.c
  * @brief MESH helper functions
  * @author Bartlomiej Polot
  */
 
 #include "mesh.h"
 
+
+/**
+ * Check if one pid is bigger than other, accounting for overflow.
+ *
+ * @param bigger Argument that should be bigger.
+ * @param smaller Argument that should be smaller.
+ *
+ * @return True if bigger (arg1) has a higher value than smaller (arg 2).
+ */
+int
+GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
+{
+    return (GNUNET_YES == PID_OVERFLOW(smaller, bigger) ||
+            (bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
+}
+
+/**
+ * Get the higher ACK value out of two values, taking in account overflow.
+ *
+ * @param a First ACK value.
+ * @param b Second ACK value.
+ *
+ * @return Highest ACK value from the two.
+ */
+uint32_t
+GMC_max_pid (uint32_t a, uint32_t b)
+{
+  if (GMC_is_pid_bigger(a, b))
+    return a;
+  return b;
+}
+
+
+/**
+ * Get the lower ACK value out of two values, taking in account overflow.
+ *
+ * @param a First ACK value.
+ * @param b Second ACK value.
+ *
+ * @return Lowest ACK value from the two.
+ */
+uint32_t
+GMC_min_pid (uint32_t a, uint32_t b)
+{
+  if (GMC_is_pid_bigger(a, b))
+    return b;
+  return a;
+}
+
+
 #if !defined(GNUNET_CULL_LOGGING)
 const char *
 GNUNET_MESH_DEBUG_M2S (uint16_t m)




reply via email to

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