gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22808 - gnunet/src/mesh
Date: Fri, 20 Jul 2012 19:46:04 +0200

Author: bartpolot
Date: 2012-07-20 19:46:04 +0200 (Fri, 20 Jul 2012)
New Revision: 22808

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_protocol.h
Log:
- add packet ID to both multicast and unicast

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2012-07-20 17:39:09 UTC (rev 
22807)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2012-07-20 17:46:04 UTC (rev 
22808)
@@ -311,11 +311,6 @@
   MESH_TunnelNumber local_tid_dest;
 
     /**
-     * Global count ID of the last *multicast* packet seen/sent.
-     */
-  uint32_t mid;
-
-    /**
      * Local count ID of the last packet seen/sent.
      */
   uint32_t pid;
@@ -3986,6 +3981,21 @@
     GNUNET_break_op (0);
     return GNUNET_OK;
   }
+  pid = ntohl (msg->pid);
+  if (t->pid == pid)
+  {
+    /* FIXME: already seen this packet, log dropping */
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                " Already seen mid %u, DROPPING!\n", pid);
+    return GNUNET_OK;
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                " mid %u not seen yet, forwarding\n", pid);
+  }
+  t->skip += (pid - t->pid) - 1;
+  t->pid = pid;
   tunnel_reset_timeout (t);
   pid = GNUNET_PEER_search (&msg->destination);
   if (pid == myid)
@@ -4024,6 +4034,7 @@
   struct GNUNET_MESH_Multicast *msg;
   struct MeshTunnel *t;
   size_t size;
+  uint32_t pid;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a multicast packet from %s\n",
               GNUNET_i2s (peer));
@@ -4043,19 +4054,21 @@
     GNUNET_break_op (0);
     return GNUNET_OK;
   }
-  if (t->mid == ntohl (msg->mid))
+  pid = ntohl (msg->pid);
+  if (t->pid == pid)
   {
     /* FIXME: already seen this packet, log dropping */
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                " Already seen mid %u, DROPPING!\n", t->mid);
+                " Already seen mid %u, DROPPING!\n", pid);
     return GNUNET_OK;
   }
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                " mid %u not seen yet, forwarding\n", ntohl (msg->mid));
+                " mid %u not seen yet, forwarding\n", pid);
   }
-  t->mid = ntohl (msg->mid);
+  t->skip += (pid - t->pid) - 1;
+  t->pid = pid;
   tunnel_reset_timeout (t);
 
   /* Transmit to locally interested clients */
@@ -4376,8 +4389,8 @@
   msg->oid = my_full_id;
   msg->tid = htonl (t->id.tid);
   msg->ttl = htonl (DEFAULT_TTL);
-  msg->mid = htonl (t->mid + 1);
-  t->mid++;
+  msg->pid = htonl (t->pid + 1);
+  t->pid++;
   payload = (struct GNUNET_MessageHeader *) &msg[1];
   payload->size = htons (sizeof (struct GNUNET_MessageHeader));
   payload->type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE);
@@ -5104,6 +5117,61 @@
 
 
 /**
+ * Handler for requests of seeting tunnel's buffering policy.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+static void
+handle_local_tunnel_buffer (void *cls, struct GNUNET_SERVER_Client *client,
+                            const struct GNUNET_MessageHeader *message)
+{
+  struct GNUNET_MESH_TunnelMessage *tunnel_msg;
+  struct MeshClient *c;
+  struct MeshTunnel *t;
+  MESH_TunnelNumber tid;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Got a BUFFER request from client!\n");
+
+  /* Sanity check for client registration */
+  if (NULL == (c = client_get (client)))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  by client %u\n", c->id);
+  tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message;
+
+  /* Retrieve tunnel */
+  tid = ntohl (tunnel_msg->tunnel_id);
+  t = tunnel_get_by_local_id(c, tid);
+  if (NULL == t)
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "  tunnel %X not found\n", tid);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+
+  switch (ntohs(message->type))
+  {
+      case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER:
+          t->buffering = GNUNET_YES;
+          break;
+      case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER:
+          t->buffering = GNUNET_NO;
+          break;
+      default:
+          GNUNET_break (0);
+  }
+}
+
+
+/**
  * Handler for connection requests to new peers
  *
  * @param cls closure
@@ -5671,6 +5739,8 @@
     memcpy (buf, data_msg, size);
     copy->oid = my_full_id;
     copy->tid = htonl (t->id.tid);
+    copy->ttl = htonl (DEFAULT_TTL);
+    copy->pid = htonl (t->pid + 1);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "  calling generic handler...\n");
     handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL, 0);
@@ -5828,7 +5898,7 @@
     copy->oid = my_full_id;
     copy->tid = htonl (t->id.tid);
     copy->ttl = htonl (DEFAULT_TTL);
-    copy->mid = htonl (t->mid + 1);
+    copy->pid = htonl (t->pid + 1);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "  calling generic handler...\n");
     handle_mesh_data_multicast (client, &my_full_id, &copy->header, NULL, 0);
@@ -5858,6 +5928,12 @@
   {&handle_local_tunnel_speed, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX,
    sizeof (struct GNUNET_MESH_TunnelMessage)},
+  {&handle_local_tunnel_buffer, NULL,
+   GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER,
+   sizeof (struct GNUNET_MESH_TunnelMessage)},
+  {&handle_local_tunnel_buffer, NULL,
+   GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER,
+   sizeof (struct GNUNET_MESH_TunnelMessage)},
   {&handle_local_connect_add, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD,
    sizeof (struct GNUNET_MESH_PeerControl)},

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2012-07-20 17:39:09 UTC (rev 22807)
+++ gnunet/src/mesh/mesh_api.c  2012-07-20 17:46:04 UTC (rev 22808)
@@ -1152,7 +1152,7 @@
           mc.header.size = htons (psize);
           mc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
           mc.tid = htonl (th->tunnel->tid);
-          mc.mid = 0;
+          mc.pid = 0;
           mc.ttl = 0;
           memset (&mc.oid, 0, sizeof (struct GNUNET_PeerIdentity));
           memcpy (cbuf, &mc, sizeof (mc));

Modified: gnunet/src/mesh/mesh_protocol.h
===================================================================
--- gnunet/src/mesh/mesh_protocol.h     2012-07-20 17:39:09 UTC (rev 22807)
+++ gnunet/src/mesh/mesh_protocol.h     2012-07-20 17:46:04 UTC (rev 22808)
@@ -90,7 +90,7 @@
     /**
      * Unique ID of the packet
      */
-  uint32_t mid GNUNET_PACKED;
+  uint32_t pid GNUNET_PACKED;
 
     /**
      * OID of the tunnel
@@ -119,6 +119,16 @@
   uint32_t tid GNUNET_PACKED;
 
     /**
+     * Number of hops to live
+     */
+  uint32_t ttl GNUNET_PACKED;
+
+    /**
+     * Unique ID of the packet
+     */
+  uint32_t pid GNUNET_PACKED;
+
+    /**
      * OID of the tunnel
      */
   struct GNUNET_PeerIdentity oid;




reply via email to

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