gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30911 - gnunet/src/mesh
Date: Wed, 27 Nov 2013 17:38:11 +0100

Author: bartpolot
Date: 2013-11-27 17:38:11 +0100 (Wed, 27 Nov 2013)
New Revision: 30911

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.c
Log:
- use only once KEEPALIVE message


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-27 16:08:09 UTC 
(rev 30910)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-11-27 16:38:11 UTC 
(rev 30911)
@@ -749,7 +749,7 @@
  * @param c Connection to keep alive..
  * @param fwd Is this a FWD keepalive? (owner -> dest).
  *
- * FIXME use only one type, register in GMC_send_prebuilt_message()
+ * FIXME register in GMC_send_prebuilt_message()
  */
 static void
 connection_keepalive (struct MeshConnection *c, int fwd)
@@ -757,18 +757,14 @@
   struct GNUNET_MESH_ConnectionKeepAlive *msg;
   size_t size = sizeof (struct GNUNET_MESH_ConnectionKeepAlive);
   char cbuf[size];
-  uint16_t type;
 
-  type = fwd ? GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE :
-               GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE;
-
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "sending %s keepalive for connection %s]\n",
        fwd ? "FWD" : "BCK", GMC_2s (c));
 
   msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf;
   msg->header.size = htons (size);
-  msg->header.type = htons (type);
+  msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE);
   msg->cid = c->id;
 
   GMC_send_prebuilt_message (&msg->header, c, fwd, NULL, NULL);
@@ -1964,6 +1960,7 @@
   struct GNUNET_MESH_ConnectionKeepAlive *msg;
   struct MeshConnection *c;
   struct MeshPeer *neighbor;
+  GNUNET_PEER_Id peer_id;
   int fwd;
 
   msg = (struct GNUNET_MESH_ConnectionKeepAlive *) message;
@@ -1978,16 +1975,26 @@
     return GNUNET_OK;
   }
 
-  fwd = GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE == ntohs (message->type) ?
-        GNUNET_YES : GNUNET_NO;
-
-  /* Check if origin is as expected */
-  neighbor = get_hop (c, fwd);
-  if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
+  /* Check if origin is as expected TODO refactor and reuse */
+  peer_id = GNUNET_PEER_search (peer);
+  neighbor = get_prev_hop (c);
+  if (peer_id == GMP_get_short_id (neighbor))
   {
-    GNUNET_break_op (0);
-    return GNUNET_OK;
+    fwd = GNUNET_YES;
   }
+  else
+  {
+    neighbor = get_next_hop (c);
+    if (peer_id == GMP_get_short_id (neighbor))
+    {
+      fwd = GNUNET_NO;
+    }
+    else
+    {
+      GNUNET_break_op (0);
+      return GNUNET_OK;
+    }
+  }
 
   connection_change_state (c, MESH_CONNECTION_READY);
   connection_reset_timeout (c, fwd);

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-11-27 16:08:09 UTC (rev 
30910)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-11-27 16:38:11 UTC (rev 
30911)
@@ -318,10 +318,8 @@
     sizeof (struct GNUNET_MESH_ConnectionBroken)},
   {&GMC_handle_destroy, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY,
     sizeof (struct GNUNET_MESH_ConnectionDestroy)},
-  {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE,
+  {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE,
     sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
-  {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE,
-    sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
   {&GMC_handle_ack, GNUNET_MESSAGE_TYPE_MESH_ACK,
     sizeof (struct GNUNET_MESH_ACK)},
   {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL,
@@ -923,14 +921,13 @@
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
         LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n");
         /* fall through */
-      case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
-      case GNUNET_MESSAGE_TYPE_MESH_ACK:
-      case GNUNET_MESSAGE_TYPE_MESH_POLL:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
       case GNUNET_MESSAGE_TYPE_MESH_KX:
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "#   prebuilt message\n");;
+      case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
+      case GNUNET_MESSAGE_TYPE_MESH_ACK:
+      case GNUNET_MESSAGE_TYPE_MESH_POLL:
         GNUNET_free_non_null (queue->cls);
         break;
 




reply via email to

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