gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30263 - gnunet/src/mesh
Date: Thu, 17 Oct 2013 17:18:29 +0200

Author: bartpolot
Date: 2013-10-17 17:18:29 +0200 (Thu, 17 Oct 2013)
New Revision: 30263

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
Log:
- refactor


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-17 15:09:57 UTC 
(rev 30262)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-17 15:18:29 UTC 
(rev 30263)
@@ -490,6 +490,34 @@
 
 
 /**
+ * Is traffic coming from this sender 'FWD' traffic?
+ *
+ * @param c Connection to check.
+ * @param sender Peer identity of neighbor.
+ *
+ * @return GNUNET_YES in case the sender is the 'prev' hop and therefore
+ *         the traffic is 'FWD'. GNUNET_NO for BCK. GNUNET_SYSERR for errors.
+ */
+static int 
+is_fwd (const struct MeshConnection *c,
+        const struct GNUNET_PeerIdentity *sender)
+{
+  GNUNET_PEER_Id id;
+
+  id = GNUNET_PEER_search (sender);
+  if (GMP_get_short_id (get_prev_hop (c)) == id)
+    return GNUNET_YES;
+
+  if (GMP_get_short_id (get_next_hop (c)) == id)
+    return GNUNET_NO;
+
+  GNUNET_break (0);
+  return GNUNET_SYSERR;
+}
+
+
+
+/**
  * Send an ACK informing the predecessor about the available buffer space.
  *
  * Note that for fwd ack, the FWD mean forward *traffic* (root->dest),
@@ -500,7 +528,7 @@
  * @param fwd Is this FWD ACK? (Going dest->owner)
  */
 static void
-connection_send_ack (struct MeshConnection *c, unsigned int buffer, int fwd)
+send_ack (struct MeshConnection *c, unsigned int buffer, int fwd)
 {
   struct MeshFlowControl *next_fc;
   struct MeshFlowControl *prev_fc;
@@ -574,10 +602,37 @@
     GMT_change_state (t, MESH_TUNNEL3_WAITING);
   if (MESH_CONNECTION_READY != connection->state)
     connection_change_state (connection, MESH_CONNECTION_SENT);
+  
 }
 
 
 /**
+ * Send a notification that a connection is broken.
+ *
+ * @param c Connection that is broken.
+ * @param id1 Peer that has disconnected.
+ * @param id2 Peer that has disconnected.
+ * @param fwd Direction towards which to send it.
+ */
+static void
+send_broken (struct MeshConnection *c,
+             const struct GNUNET_PeerIdentity *id1,
+             const struct GNUNET_PeerIdentity *id2,
+             int fwd)
+{
+  struct GNUNET_MESH_ConnectionBroken msg;
+
+  msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken));
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN);
+  msg.cid = c->id;
+  msg.peer1 = *id1;
+  msg.peer2 = *id2;
+  GMC_send_prebuilt_message (&msg.header, c, NULL, fwd);
+}
+
+
+
+/**
  * Send keepalive packets for a connection.
  *
  * @param c Connection to keep alive..
@@ -1177,33 +1232,6 @@
 
 
 /**
- * Is traffic coming from this sender 'FWD' traffic?
- *
- * @param c Connection to check.
- * @param sender Peer identity of neighbor.
- *
- * @return GNUNET_YES in case the sender is the 'prev' hop and therefore
- *         the traffic is 'FWD'. GNUNET_NO for BCK. GNUNET_SYSERR for errors.
- */
-int 
-is_fwd (const struct MeshConnection *c,
-        const struct GNUNET_PeerIdentity *sender)
-{
-  GNUNET_PEER_Id id;
-
-  id = GNUNET_PEER_search (sender);
-  if (GMP_get_short_id (get_prev_hop (c)) == id)
-    return GNUNET_YES;
-
-  if (GMP_get_short_id (get_next_hop (c)) == id)
-    return GNUNET_NO;
-
-  GNUNET_break (0);
-  return GNUNET_SYSERR;
-}
-
-
-/**
  * Core handler for notifications of broken paths
  *
  * @param cls Closure (unused).
@@ -1707,7 +1735,7 @@
   else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  sending on connection\n");
-    connection_send_ack (c, buffer, fwd);
+    send_ack (c, buffer, fwd);
   }
 }
 
@@ -1956,35 +1984,11 @@
 void
 GMC_allow (struct MeshConnection *c, unsigned int buffer, int fwd)
 {
-  connection_send_ack (c, buffer, fwd);
+  send_ack (c, buffer, fwd);
 }
 
 
 /**
- * Send a notification that a connection is broken.
- *
- * @param c Connection that is broken.
- * @param id1 Peer that has disconnected.
- * @param id2 Peer that has disconnected.
- * @param fwd Direction towards which to send it.
- */
-static void
-send_broken (struct MeshConnection *c,
-             const struct GNUNET_PeerIdentity *id1,
-             const struct GNUNET_PeerIdentity *id2,
-             int fwd)
-{
-  struct GNUNET_MESH_ConnectionBroken msg;
-
-  msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN);
-  msg.cid = c->id;
-  msg.peer1 = *id1;
-  msg.peer2 = *id2;
-  GMC_send_prebuilt_message (&msg.header, c, NULL, fwd);
-}
-
-/**
  * Notify other peers on a connection of a broken link. Mark connections
  * to destroy after all traffic has been sent.
  *




reply via email to

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