gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30597 - gnunet/src/mesh
Date: Thu, 7 Nov 2013 12:18:11 +0100

Author: bartpolot
Date: 2013-11-07 12:18:11 +0100 (Thu, 07 Nov 2013)
New Revision: 30597

Modified:
   gnunet/src/mesh/gnunet-service-mesh_channel.c
   gnunet/src/mesh/gnunet-service-mesh_channel.h
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.h
Log:
- internal api change: add channel direction autodetection in non-loopback 
channels


Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-11-07 10:39:56 UTC 
(rev 30596)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-11-07 11:18:11 UTC 
(rev 30597)
@@ -923,8 +923,7 @@
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
       GMCH_handle_create (ch->t,
-                          (struct GNUNET_MESH_ChannelCreate *) msgh,
-                          fwd);
+                          (struct GNUNET_MESH_ChannelCreate *) msgh);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
@@ -1444,12 +1443,16 @@
   return GNUNET_OK;
 }
 
+
 /**
  * Handler for mesh network payload traffic.
  *
  * @param ch Channel for the message.
  * @param msg Unencryted data message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_data (struct MeshChannel *ch,
@@ -1460,6 +1463,18 @@
   struct MeshClient *c;
   uint32_t mid;
 
+  /* If this is a remote (non-loopback) channel, find 'fwd'. */
+  if (GNUNET_SYSERR == fwd)
+  {
+    if (NULL != ch->dest && NULL != ch->root)
+    {
+      /* It is a loopback channel after all... */
+      GNUNET_break (0);
+      return;
+    }
+    fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
+  }
+
   /*  Initialize FWD/BCK data */
   c   = fwd ? ch->dest     : ch->root;
   rel = fwd ? ch->dest_rel : ch->root_rel;
@@ -1520,7 +1535,10 @@
  *
  * @param ch Channel on which we got this message.
  * @param msg Data message.
- * @param fwd Is this a fwd ACK? (dest->orig)
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_data_ack (struct MeshChannel *ch,
@@ -1533,9 +1551,21 @@
   uint32_t ack;
   int work;
 
+  /* If this is a remote (non-loopback) channel, find 'fwd'. */
+  if (GNUNET_SYSERR == fwd)
+  {
+    if (NULL != ch->dest && NULL != ch->root)
+    {
+      /* It is a loopback channel after all... */
+      GNUNET_break (0);
+      return;
+    }
+    fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
+  }
+
   ack = ntohl (msg->mid);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! %s ACK %u\n",
-              (GNUNET_YES == fwd) ? "FWD" : "BCK", ack);
+       (GNUNET_YES == fwd) ? "FWD" : "BCK", ack);
 
   if (GNUNET_YES == fwd)
   {
@@ -1602,14 +1632,14 @@
 /**
  * Handler for channel create messages.
  *
+ * Does not have fwd parameter because it's always 'FWD': channel is incoming.
+ *
  * @param t Tunnel this channel will be in.
- * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param msg Channel crate message.
  */
 struct MeshChannel *
 GMCH_handle_create (struct MeshTunnel3 *t,
-                    const struct GNUNET_MESH_ChannelCreate *msg,
-                    int fwd)
+                    const struct GNUNET_MESH_ChannelCreate *msg)
 {
   MESH_ChannelNumber chid;
   struct MeshChannel *ch;
@@ -1650,7 +1680,7 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Not Reliable\n");
 
   GMCH_send_create (ch);
-  channel_send_ack (ch, fwd);
+  channel_send_ack (ch, GNUNET_YES);
 
   return ch;
 }
@@ -1661,13 +1691,28 @@
  *
  * @param ch Channel.
  * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_ack (struct MeshChannel *ch,
                  const struct GNUNET_MESH_ChannelManage *msg,
                  int fwd)
 {
+  /* If this is a remote (non-loopback) channel, find 'fwd'. */
+  if (GNUNET_SYSERR == fwd)
+  {
+    if (NULL != ch->dest && NULL != ch->root)
+    {
+      /* It is a loopback channel after all... */
+      GNUNET_break (0);
+      return;
+    }
+    fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
+  }
+
   channel_confirm (ch, !fwd);
 }
 
@@ -1677,7 +1722,10 @@
  *
  * @param ch Channel to be destroyed of.
  * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_destroy (struct MeshChannel *ch,
@@ -1686,6 +1734,18 @@
 {
   struct MeshTunnel3 *t;
 
+  /* If this is a remote (non-loopback) channel, find 'fwd'. */
+  if (GNUNET_SYSERR == fwd)
+  {
+    if (NULL != ch->dest && NULL != ch->root)
+    {
+      /* It is a loopback channel after all... */
+      GNUNET_break (0);
+      return;
+    }
+    fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
+  }
+
   GMCH_debug (ch);
   if ( (fwd && NULL == ch->dest) || (!fwd && NULL == ch->root) )
   {

Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h       2013-11-07 10:39:56 UTC 
(rev 30596)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h       2013-11-07 11:18:11 UTC 
(rev 30597)
@@ -240,7 +240,10 @@
  *
  * @param ch Channel for the message.
  * @param msg Unencryted data message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_data (struct MeshChannel *ch,
@@ -252,7 +255,10 @@
  *
  * @param ch Channel on which we got this message.
  * @param msg Data message.
- * @param fwd Is this a fwd ACK? (dest->orig)
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_data_ack (struct MeshChannel *ch,
@@ -262,21 +268,24 @@
 /**
  * Handler for channel create messages.
  *
+ * Does not have fwd parameter because it's always 'FWD': channel is incoming.
+ *
  * @param t Tunnel this channel will be in.
- * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param msg Channel crate message.
  */
 struct MeshChannel *
 GMCH_handle_create (struct MeshTunnel3 *t,
-                    const struct GNUNET_MESH_ChannelCreate *msg,
-                    int fwd);
+                    const struct GNUNET_MESH_ChannelCreate *msg);
 
 /**
  * Handler for channel ack messages.
  *
  * @param ch Channel this channel is to be created in.
  * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_ack (struct MeshChannel *ch,
@@ -288,7 +297,10 @@
  *
  * @param ch Channel this channel is to be destroyed of.
  * @param msg Message.
- * @param fwd Is this FWD traffic? #GNUNET_YES : #GNUNET_NO;
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 GMCH_handle_destroy (struct MeshChannel *ch,

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-07 10:39:56 UTC 
(rev 30596)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-07 11:18:11 UTC 
(rev 30597)
@@ -1440,7 +1440,7 @@
       return GNUNET_OK;
     }
     fc->last_pid_recv = pid;
-    GMT_handle_encrypted (c->t, msg, fwd);
+    GMT_handle_encrypted (c->t, msg);
     GMC_send_ack (c, fwd);
     return GNUNET_OK;
   }

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-11-07 10:39:56 UTC 
(rev 30596)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-11-07 11:18:11 UTC 
(rev 30597)
@@ -756,7 +756,10 @@
  *
  * @param t Tunnel on which the data came.
  * @param msg Data message.
- * @param fwd Is this FWD data? (root -> dest)
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
 handle_data (struct MeshTunnel3 *t,
@@ -797,6 +800,17 @@
   GMCH_handle_data (ch, msg, fwd);
 }
 
+
+/**
+ * Demultiplex data ACKs per channel and update appropriate channel buffer 
info.
+ *
+ * @param t Tunnel on which the DATA ACK came.
+ * @param msg DATA ACK message.
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
+ */
 void
 handle_data_ack (struct MeshTunnel3 *t,
                  const struct GNUNET_MESH_DataACK *msg,
@@ -827,10 +841,16 @@
   GMCH_handle_data_ack (ch, msg, fwd);
 }
 
+
+/**
+ * Handle channel create.
+ *
+ * @param t Tunnel on which the data came.
+ * @param msg Data message.
+ */
 void
 handle_ch_create (struct MeshTunnel3 *t,
-                  const struct GNUNET_MESH_ChannelCreate *msg,
-                  int fwd)
+                  const struct GNUNET_MESH_ChannelCreate *msg)
 {
   struct MeshChannel *ch;
   size_t size;
@@ -852,11 +872,22 @@
   }
   else
   {
-    ch = GMCH_handle_create (t, msg, fwd);
+    ch = GMCH_handle_create (t, msg);
   }
   GMT_add_channel (t, ch);
 }
 
+
+/**
+ * Handle a CHANNEL ACK (SYNACK/ACK).
+ *
+ * @param t Tunnel on which the CHANNEL ACK came.
+ * @param msg CHANNEL ACK message.
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
+ */
 void
 handle_ch_ack (struct MeshTunnel3 *t,
                const struct GNUNET_MESH_ChannelManage *msg,
@@ -887,6 +918,18 @@
   GMCH_handle_ack (ch, msg, fwd);
 }
 
+
+
+/**
+ * Handle a channel destruction message.
+ *
+ * @param t Tunnel on which the message came.
+ * @param msg Channel destroy message.
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
+ */
 void
 handle_ch_destroy (struct MeshTunnel3 *t,
                    const struct GNUNET_MESH_ChannelManage *msg,
@@ -1017,7 +1060,10 @@
  *
  * @param t Tunnel this message came on.
  * @param msgh Message header.
- * @param fwd Is this message fwd?
+ * @param fwd Is this message fwd? This only is meaningful in loopback 
channels.
+ *            #GNUNET_YES if message is FWD on the respective channel 
(loopback)
+ *            #GNUNET_NO if message is BCK on the respective channel (loopback)
+ *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 static void
 handle_decrypted (struct MeshTunnel3 *t,
@@ -1044,8 +1090,7 @@
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
       handle_ch_create (t,
-                        (struct GNUNET_MESH_ChannelCreate *) msgh,
-                        fwd);
+                        (struct GNUNET_MESH_ChannelCreate *) msgh);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
@@ -1078,12 +1123,10 @@
  *
  * @param t Tunnel this message came on.
  * @param msg Encrypted message.
- * @param fwd Is this message fwd?
  */
 void
 GMT_handle_encrypted (struct MeshTunnel3 *t,
-                      const struct GNUNET_MESH_Encrypted *msg,
-                      int fwd)
+                      const struct GNUNET_MESH_Encrypted *msg)
 {
   size_t size = ntohs (msg->header.size);
   size_t payload_size = size - sizeof (struct GNUNET_MESH_Encrypted);
@@ -1097,7 +1140,7 @@
   while (off < decrypted_size)
   {
     msgh = (struct GNUNET_MessageHeader *) &cbuf[off];
-    handle_decrypted (t, msgh, fwd);
+    handle_decrypted (t, msgh, GNUNET_SYSERR);
     off += ntohs (msgh->size);
   }
 }

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-11-07 10:39:56 UTC 
(rev 30596)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-11-07 11:18:11 UTC 
(rev 30597)
@@ -220,12 +220,10 @@
  *
  * @param t Tunnel this message came on.
  * @param msg Message header.
- * @param fwd Is this message fwd?
  */
 void
 GMT_handle_encrypted (struct MeshTunnel3 *t,
-                      const struct GNUNET_MESH_Encrypted *msg,
-                      int fwd);
+                      const struct GNUNET_MESH_Encrypted *msg);
 
 /**
  * Demultiplex an encapsulated KX message by message type.




reply via email to

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