-bump name to 97
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_tunnel.c
index 8c0d14d97eb10620ede462384d00fa4845207e25..44ac78567a9d453eef55ec5c79eda6933da6b6a2 100644 (file)
@@ -21,6 +21,8 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
+#include "gnunet_statistics_service.h"
+
 #include "mesh_protocol_enc.h"
 
 #include "gnunet-service-mesh_tunnel.h"
@@ -179,6 +181,11 @@ struct MeshTunnelQueue
 /*******************************   GLOBALS  ***********************************/
 /******************************************************************************/
 
+/**
+ * Global handle to the statistics service.
+ */
+extern struct GNUNET_STATISTICS_Handle *stats;
+
 /**
  * Default TTL for payload packets.
  */
@@ -204,7 +211,6 @@ const static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
 /********************************   STATIC  ***********************************/
 /******************************************************************************/
 
-
 /**
  * Get string description for tunnel state.
  *
@@ -366,6 +372,10 @@ tunnel_send_queued_data (struct MeshTunnel2 *t, int fwd)
 }
 
 
+/******************************************************************************/
+/********************************    API    ***********************************/
+/******************************************************************************/
+
 /**
  * Cache a message to be sent once tunnel is online.
  *
@@ -394,11 +404,6 @@ GMT_queue_data (struct MeshTunnel2 *t,
 }
 
 
-
-/******************************************************************************/
-/********************************    API    ***********************************/
-/******************************************************************************/
-
 /**
  * Initialize the tunnel subsystem.
  *
@@ -550,7 +555,7 @@ GMT_destroy_empty (struct MeshTunnel2 *t)
 void
 GMT_destroy_if_empty (struct MeshTunnel2 *t)
 {
-  if (1 <= GMCH_count (t->channel_head))
+  if (1 < GMCH_count (t->channel_head))
     return;
 
   GMT_destroy_empty (t);
@@ -591,7 +596,7 @@ GMT_destroy (struct MeshTunnel2 *t)
   }
 
   GNUNET_STATISTICS_update (stats, "# tunnels", -1, GNUNET_NO);
-  t->peer->tunnel = NULL;
+  GMP_set_tunnel (t->peer, NULL);
 
   GNUNET_free (t);
 }
@@ -613,35 +618,36 @@ GMT_handle_decrypted (struct MeshTunnel2 *t,
   {
     case GNUNET_MESSAGE_TYPE_MESH_DATA:
       /* Don't send hop ACK, wait for client to ACK */
-      handle_data (t, (struct GNUNET_MESH_Data *) msgh, fwd);
+      GMCH_handle_data (t, (struct GNUNET_MESH_Data *) msgh, fwd);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK:
-      handle_data_ack (t, (struct GNUNET_MESH_DataACK *) msgh, fwd);
+      GMCH_handle_data_ack (t, (struct GNUNET_MESH_DataACK *) msgh, fwd);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
-      handle_channel_create (t,
-                             (struct GNUNET_MESH_ChannelCreate *) msgh,
-                             fwd);
+      GMCH_handle_create (t,
+                          (struct GNUNET_MESH_ChannelCreate *) msgh,
+                          fwd);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
-      handle_channel_ack (t,
-                          (struct GNUNET_MESH_ChannelManage *) msgh,
-                          fwd);
+      GMCH_handle_ack (t,
+                       (struct GNUNET_MESH_ChannelManage *) msgh,
+                       fwd);
       break;
 
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
-      handle_channel_destroy (t,
-                              (struct GNUNET_MESH_ChannelManage *) msgh,
-                              fwd);
+      GMCH_handle_destroy (t,
+                           (struct GNUNET_MESH_ChannelManage *) msgh,
+                           fwd);
       break;
 
     default:
+      GNUNET_break_op (0);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-                  "end-to-end message not known (%u)\n",
-                  ntohs (msgh->type));
+           "end-to-end message not known (%u)\n",
+           ntohs (msgh->type));
   }
 }