From b6d4eeb39fd0cd41df164bd0959f58b08aa45e83 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 24 Jun 2011 22:00:28 +0000 Subject: [PATCH] WiP (in-tunnel data forwarding) --- src/mesh/gnunet-service-mesh.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 78550b2a1..88c10140c 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -730,7 +730,7 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) * 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,6 +762,35 @@ send_core_data_to_origin (void *cls, size_t size, void *buf) 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 /** @@ -1039,7 +1068,7 @@ handle_mesh_data_unicast (void *cls, GNUNET_TIME_UNIT_FOREVER_REL, &id, size, - &send_core_data_to_origin, + &send_core_data_from_origin, msg); return GNUNET_OK; } -- 2.25.1