WiP
authorBart Polot <bart@net.in.tum.de>
Tue, 18 Oct 2011 17:06:44 +0000 (17:06 +0000)
committerBart Polot <bart@net.in.tum.de>
Tue, 18 Oct 2011 17:06:44 +0000 (17:06 +0000)
src/mesh/gnunet-service-mesh.c
src/mesh/mesh_protocol.h

index 486684507d00128a130af63aab7a6b720992adfa..29dd2c89d06627188f621cfd381a7604c37f91eb 100644 (file)
@@ -1703,6 +1703,25 @@ tunnel_send_multicast (struct MeshTunnel *t,
 }
 
 
+/**
+ * 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
  *
@@ -1924,53 +1943,6 @@ send_core_create_path (void *cls, size_t size, void *buf)
 }
 
 
-#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
@@ -2150,7 +2122,7 @@ send_core_data_raw (void *cls, size_t size, void *buf)
  * @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 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
   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;
index 12723fdacb140cad660e4b92f6216e9a9a27bb6a..d7e28af4591d7d1a9845a77b96199918acd1c744 100644 (file)
@@ -182,6 +182,30 @@ struct GNUNET_MESH_PathACK
 };
 
 
+/**
+ * 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
  */