diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-06-24 22:00:28 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-06-24 22:00:28 +0000 |
commit | b6d4eeb39fd0cd41df164bd0959f58b08aa45e83 (patch) | |
tree | 470b1ca2a56004a69c93eac95294af1de099cfff | |
parent | 8c707366f4d0dab2e5fdea591edd3dbaca659895 (diff) | |
download | gnunet-b6d4eeb39fd0cd41df164bd0959f58b08aa45e83.tar.gz gnunet-b6d4eeb39fd0cd41df164bd0959f58b08aa45e83.zip |
WiP (in-tunnel data forwarding)
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 33 |
1 files 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) | |||
730 | * NULL and "size" zero if the socket was closed for | 730 | * NULL and "size" zero if the socket was closed for |
731 | * writing in the meantime. | 731 | * writing in the meantime. |
732 | * | 732 | * |
733 | * @param cls closure (data itself) | 733 | * @param cls closure (info_for_data_to_origin with all info to build packet) |
734 | * @param size number of bytes available in buf | 734 | * @param size number of bytes available in buf |
735 | * @param buf where the callee should write the message | 735 | * @param buf where the callee should write the message |
736 | * @return number of bytes written to buf | 736 | * @return number of bytes written to buf |
@@ -762,6 +762,35 @@ send_core_data_to_origin (void *cls, size_t size, void *buf) | |||
762 | return total_size; | 762 | return total_size; |
763 | } | 763 | } |
764 | 764 | ||
765 | /** | ||
766 | * Function called to notify a client about the socket | ||
767 | * being ready to queue more data. "buf" will be | ||
768 | * NULL and "size" zero if the socket was closed for | ||
769 | * writing in the meantime. | ||
770 | * | ||
771 | * @param cls closure (data itself) | ||
772 | * @param size number of bytes available in buf | ||
773 | * @param buf where the callee should write the message | ||
774 | * @return number of bytes written to buf | ||
775 | */ | ||
776 | static size_t | ||
777 | send_core_data_from_origin (void *cls, size_t size, void *buf) | ||
778 | { | ||
779 | struct GNUNET_MESH_DataMessageFromOrigin *msg = cls; | ||
780 | size_t total_size; | ||
781 | |||
782 | GNUNET_assert(NULL != msg); | ||
783 | total_size = ntohs(msg->header.size); | ||
784 | |||
785 | if (total_size > size) { | ||
786 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
787 | "not enough buffer to send data futher\n"); | ||
788 | return 0; | ||
789 | } | ||
790 | memcpy(msg, buf, total_size); | ||
791 | return total_size; | ||
792 | } | ||
793 | |||
765 | 794 | ||
766 | #if LATER | 795 | #if LATER |
767 | /** | 796 | /** |
@@ -1039,7 +1068,7 @@ handle_mesh_data_unicast (void *cls, | |||
1039 | GNUNET_TIME_UNIT_FOREVER_REL, | 1068 | GNUNET_TIME_UNIT_FOREVER_REL, |
1040 | &id, | 1069 | &id, |
1041 | size, | 1070 | size, |
1042 | &send_core_data_to_origin, | 1071 | &send_core_data_from_origin, |
1043 | msg); | 1072 | msg); |
1044 | return GNUNET_OK; | 1073 | return GNUNET_OK; |
1045 | } | 1074 | } |