gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17591 - gnunet/src/mesh
Date: Tue, 18 Oct 2011 19:06:44 +0200

Author: bartpolot
Date: 2011-10-18 19:06:44 +0200 (Tue, 18 Oct 2011)
New Revision: 17591

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh_protocol.h
Log:
WiP

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-10-18 16:32:34 UTC (rev 
17590)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-10-18 17:06:44 UTC (rev 
17591)
@@ -1704,6 +1704,25 @@
 
 
 /**
+ * Send a message to all peers in this tunnel that the tunnel is no longer
+ * valid.
+ *
+ * @param t The tunnel whose peers to notify.
+ */
+static void
+tunnel_send_destroy (struct MeshTunnel *t)
+{
+  struct GNUNET_MESH_TunnelDestroy msg;
+
+  msg.header.size = htons (sizeof (msg));
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);
+  msg.oid = my_full_id;
+  msg.tid = htonl (t->id.tid);
+  tunnel_send_multicast (t, &msg.header);
+}
+
+
+/**
  * Destroy the tunnel and free any allocated resources linked to it
  *
  * @param t the tunnel to destroy
@@ -1924,59 +1943,12 @@
 }
 
 
-#if LATER
 /**
  * Function called to notify a client about the socket
  * being ready to queue more data.  "buf" will be
  * NULL and "size" zero if the socket was closed for
  * writing in the meantime.
  *
- * @param cls closure (MeshDataDescriptor with all info to build packet)
- * @param size number of bytes available in buf
- * @param buf where the callee should write the message
- * @return number of bytes written to buf
- */
-static size_t
-send_core_data_to_origin (void *cls, size_t size, void *buf)
-{
-  struct MeshDataDescriptor *info = cls;
-  struct GNUNET_MESH_ToOrigin *msg = buf;
-  size_t total_size;
-
-  GNUNET_assert (NULL != info);
-  total_size = sizeof (struct GNUNET_MESH_ToOrigin) + info->size;
-  GNUNET_assert (total_size < 65536);   /* UNIT16_MAX */
-
-  if (total_size > size)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "not enough buffer to send data to origin\n");
-    return 0;
-  }
-  msg->header.size = htons (total_size);
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN);
-  GNUNET_PEER_resolve (info->origin->oid, &msg->oid);
-  msg->tid = htonl (info->origin->tid);
-  if (0 != info->size)
-  {
-    memcpy (&msg[1], &info[1], info->size);
-  }
-  if (NULL != info->client)
-  {
-    GNUNET_SERVER_receive_done (info->client, GNUNET_OK);
-  }
-  GNUNET_free (info);
-  return total_size;
-}
-#endif
-
-
-/**
- * Function called to notify a client about the socket
- * being ready to queue more data.  "buf" will be
- * NULL and "size" zero if the socket was closed for
- * writing in the meantime.
- *
  * @param cls closure (data itself)
  * @param size number of bytes available in buf
  * @param buf where the callee should write the message
@@ -2150,7 +2122,7 @@
  * @return Size of data put in buffer
  */
 static size_t
-send_p2p_tunnel_destroy (void *cls, size_t size, void *buf)
+send_core_tunnel_destroy (void *cls, size_t size, void *buf)
 {
   struct MeshTunnel *t = cls;
   struct MeshClient *c;
@@ -3221,7 +3193,6 @@
   t = GNUNET_CONTAINER_multihashmap_get (c->tunnels, &hash);
   GNUNET_CONTAINER_multihashmap_remove (c->tunnels, &hash, t);
 
-//   notify_tunnel_destroy(t);
   tunnel_destroy(t);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
   return;

Modified: gnunet/src/mesh/mesh_protocol.h
===================================================================
--- gnunet/src/mesh/mesh_protocol.h     2011-10-18 16:32:34 UTC (rev 17590)
+++ gnunet/src/mesh/mesh_protocol.h     2011-10-18 17:06:44 UTC (rev 17591)
@@ -183,6 +183,30 @@
 
 
 /**
+ * Message to destroy a tunnel
+ */
+struct GNUNET_MESH_TunnelDestroy
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
+     */
+  struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+  uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+  struct GNUNET_PeerIdentity oid;
+
+  /* TODO: signature */
+};
+
+
+/**
  * Message for mesh flow control
  */
 struct GNUNET_MESH_SpeedNotify




reply via email to

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