gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r15772 - gnunet/src/mesh
Date: Sat, 25 Jun 2011 00:00:28 +0200

Author: bartpolot
Date: 2011-06-25 00:00:28 +0200 (Sat, 25 Jun 2011)
New Revision: 15772

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
WiP (in-tunnel data forwarding)


Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-06-24 21:48:45 UTC (rev 
15771)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-06-24 22:00:28 UTC (rev 
15772)
@@ -730,7 +730,7 @@
  * NULL and "size" zero if the socket was closed for
  * writing in the meantime.
  *
- * @param cls closure (data itself)
+ * @param cls closure (info_for_data_to_origin 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
@@ -762,7 +762,36 @@
     return total_size;
 }
 
+/**
+ * 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
+ * @return number of bytes written to buf
+ */
+static size_t
+send_core_data_from_origin (void *cls, size_t size, void *buf)
+{
+    struct GNUNET_MESH_DataMessageFromOrigin    *msg = cls;
+    size_t                                      total_size;
 
+    GNUNET_assert(NULL != msg);
+    total_size = ntohs(msg->header.size);
+
+    if (total_size > size) {
+        GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+                   "not enough buffer to send data futher\n");
+        return 0;
+    }
+    memcpy(msg, buf, total_size);
+    return total_size;
+}
+
+
 #if LATER
 /**
  * Function called to notify a client about the socket
@@ -1039,7 +1068,7 @@
         GNUNET_TIME_UNIT_FOREVER_REL,
         &id,
         size,
-        &send_core_data_to_origin,
+        &send_core_data_from_origin,
         msg);
     return GNUNET_OK;
 }




reply via email to

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