[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23030 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23030 - gnunet/src/mesh |
Date: |
Wed, 1 Aug 2012 15:04:29 +0200 |
Author: bartpolot
Date: 2012-08-01 15:04:29 +0200 (Wed, 01 Aug 2012)
New Revision: 23030
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
gnunet/src/mesh/mesh.h
gnunet/src/mesh/mesh_api.c
Log:
- wip
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2012-08-01 11:48:20 UTC (rev
23029)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2012-08-01 13:04:29 UTC (rev
23030)
@@ -78,6 +78,7 @@
/** FWD declaration */
struct MeshPeerInfo;
+struct MeshClient;
/**
@@ -259,8 +260,29 @@
};
-struct MeshClient; /* FWD declaration */
+/**
+ * Info collected during iteration of child nodes in order to get the ACK value
+ * for a tunnel.
+ */
+struct MeshTunnelChildIteratorContext
+{
+ /**
+ * Tunnel whose info is being collected.
+ */
+ struct MeshTunnel *t;
+ /**
+ * Maximum child ACK so far.
+ */
+ uint32_t max_child_ack;
+
+ /**
+ * Number of children nodes
+ */
+ unsigned int nchildren;
+};
+
+
/**
* Struct containing all information regarding a tunnel
* For an intermediate node the improtant info used will be:
@@ -308,11 +330,6 @@
uint32_t last_ack;
/**
- * Maximum child ACK.
- */
- uint32_t max_child_ack;
-
- /**
* How many messages are in the queue.
*/
unsigned int queue_n;
@@ -1622,7 +1639,18 @@
/****************** GENERAL HELPER FUNCTIONS
************************/
/******************************************************************************/
+static uint32_t
+max_ack (uint32_t a, uint32_t b)
+{
+}
+static uint32_t
+min_ack (uint32_t a, uint32_t b)
+{
+ return (max_ack (a, b) == a) ? b : a;
+}
+
+
/**
* Decrements the reference counter and frees all resources if needed
*
@@ -1827,7 +1855,6 @@
&hash,
t));
}
-
}
@@ -3253,7 +3280,8 @@
{
struct GNUNET_PeerIdentity peer_id;
struct MeshTunnelChildInfo *cinfo;
- struct MeshTunnel *t = cls;
+ struct MeshTunnelChildIteratorContext *ctx = cls;
+ struct MeshTunnel *t = ctx->t;
uint32_t ack;
GNUNET_PEER_resolve (id, &peer_id);
@@ -3277,16 +3305,16 @@
ack = cinfo->max_pid;
}
- if (0 == t->max_child_ack)
- t->max_child_ack = ack;
+ if (0 == ctx->max_child_ack)
+ ctx->max_child_ack = ack;
if (GNUNET_YES == t->speed_min)
{
- t->max_child_ack = t->max_child_ack > ack ? ack : t->max_child_ack;
+ ctx->max_child_ack = ctx->max_child_ack > ack ? ack : ctx->max_child_ack;
}
else
{
- t->max_child_ack = t->max_child_ack > ack ? t->max_child_ack : ack;
+ ctx->max_child_ack = ctx->max_child_ack > ack ? ctx->max_child_ack : ack;
}
}
@@ -3299,14 +3327,21 @@
*
* @param t Tunnel.
*
- * @return Maximum PID allowed, 0 if node has no children.
+ * @return Maximum PID allowed (uint32 MAX), -1 if node has no children.
*/
-static uint32_t
+static int64_t
tunnel_get_children_ack (struct MeshTunnel *t)
{
- t->max_child_ack = 0;
- tree_iterate_children (t->tree, tunnel_get_child_ack, t);
- return t->max_child_ack;
+ struct MeshTunnelChildIteratorContext ctx;
+ ctx.t = t;
+ ctx.max_child_ack = 0;
+ ctx.nchildren = 0;
+ tree_iterate_children (t->tree, tunnel_get_child_ack, &ctx);
+
+ if (0 == ctx.nchildren)
+ return -1LL;
+
+ return (int64_t) ctx.max_child_ack;
}
Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h 2012-08-01 11:48:20 UTC (rev 23029)
+++ gnunet/src/mesh/mesh.h 2012-08-01 13:04:29 UTC (rev 23030)
@@ -78,6 +78,11 @@
#define GNUNET_MESH_LOCAL_TUNNEL_ID_CLI 0x80000000
#define GNUNET_MESH_LOCAL_TUNNEL_ID_SERV 0xB0000000
+#define HIGH_PID 0xFFFF0000
+#define LOW_PID 0x0000FFFF
+
+#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
+
/******************************************************************************/
/************************** MESSAGES
******************************/
/******************************************************************************/
Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c 2012-08-01 11:48:20 UTC (rev 23029)
+++ gnunet/src/mesh/mesh_api.c 2012-08-01 13:04:29 UTC (rev 23030)
@@ -21,7 +21,6 @@
* @author Bartlomiej Polot
*
* STRUCTURE:
- * - CONSTANTS
* - DATA STRUCTURES
* - DECLARATIONS
* - AUXILIARY FUNCTIONS
@@ -44,15 +43,6 @@
/******************************************************************************/
-/************************ CONSTANTS
****************************/
-/******************************************************************************/
-
-#define HIGH_PID 0xFFFF0000
-#define LOW_PID 0x0000FFFF
-
-#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
-
-/******************************************************************************/
/************************ DATA STRUCTURES
****************************/
/******************************************************************************/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23030 - gnunet/src/mesh,
gnunet <=