aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_tunnel.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-07 11:18:11 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-07 11:18:11 +0000
commit6aa2127441cd5605b5823753f1ee735aaa0a3f52 (patch)
tree698803c08d80b0a1f72a48743ccf758a80225d48 /src/mesh/gnunet-service-mesh_tunnel.c
parent50fc263f0dec5918c7aa16972760991f2271a15c (diff)
downloadgnunet-6aa2127441cd5605b5823753f1ee735aaa0a3f52.tar.gz
gnunet-6aa2127441cd5605b5823753f1ee735aaa0a3f52.zip
- internal api change: add channel direction autodetection in non-loopback channels
Diffstat (limited to 'src/mesh/gnunet-service-mesh_tunnel.c')
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c65
1 files changed, 54 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index d46137cb9..c80dc3614 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -756,7 +756,10 @@ rekey (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
756 * 756 *
757 * @param t Tunnel on which the data came. 757 * @param t Tunnel on which the data came.
758 * @param msg Data message. 758 * @param msg Data message.
759 * @param fwd Is this FWD data? (root -> dest) 759 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
760 * #GNUNET_YES if message is FWD on the respective channel (loopback)
761 * #GNUNET_NO if message is BCK on the respective channel (loopback)
762 * #GNUNET_SYSERR if message on a one-ended channel (remote)
760 */ 763 */
761void 764void
762handle_data (struct MeshTunnel3 *t, 765handle_data (struct MeshTunnel3 *t,
@@ -797,6 +800,17 @@ handle_data (struct MeshTunnel3 *t,
797 GMCH_handle_data (ch, msg, fwd); 800 GMCH_handle_data (ch, msg, fwd);
798} 801}
799 802
803
804/**
805 * Demultiplex data ACKs per channel and update appropriate channel buffer info.
806 *
807 * @param t Tunnel on which the DATA ACK came.
808 * @param msg DATA ACK message.
809 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
810 * #GNUNET_YES if message is FWD on the respective channel (loopback)
811 * #GNUNET_NO if message is BCK on the respective channel (loopback)
812 * #GNUNET_SYSERR if message on a one-ended channel (remote)
813 */
800void 814void
801handle_data_ack (struct MeshTunnel3 *t, 815handle_data_ack (struct MeshTunnel3 *t,
802 const struct GNUNET_MESH_DataACK *msg, 816 const struct GNUNET_MESH_DataACK *msg,
@@ -827,10 +841,16 @@ handle_data_ack (struct MeshTunnel3 *t,
827 GMCH_handle_data_ack (ch, msg, fwd); 841 GMCH_handle_data_ack (ch, msg, fwd);
828} 842}
829 843
844
845/**
846 * Handle channel create.
847 *
848 * @param t Tunnel on which the data came.
849 * @param msg Data message.
850 */
830void 851void
831handle_ch_create (struct MeshTunnel3 *t, 852handle_ch_create (struct MeshTunnel3 *t,
832 const struct GNUNET_MESH_ChannelCreate *msg, 853 const struct GNUNET_MESH_ChannelCreate *msg)
833 int fwd)
834{ 854{
835 struct MeshChannel *ch; 855 struct MeshChannel *ch;
836 size_t size; 856 size_t size;
@@ -852,11 +872,22 @@ handle_ch_create (struct MeshTunnel3 *t,
852 } 872 }
853 else 873 else
854 { 874 {
855 ch = GMCH_handle_create (t, msg, fwd); 875 ch = GMCH_handle_create (t, msg);
856 } 876 }
857 GMT_add_channel (t, ch); 877 GMT_add_channel (t, ch);
858} 878}
859 879
880
881/**
882 * Handle a CHANNEL ACK (SYNACK/ACK).
883 *
884 * @param t Tunnel on which the CHANNEL ACK came.
885 * @param msg CHANNEL ACK message.
886 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
887 * #GNUNET_YES if message is FWD on the respective channel (loopback)
888 * #GNUNET_NO if message is BCK on the respective channel (loopback)
889 * #GNUNET_SYSERR if message on a one-ended channel (remote)
890 */
860void 891void
861handle_ch_ack (struct MeshTunnel3 *t, 892handle_ch_ack (struct MeshTunnel3 *t,
862 const struct GNUNET_MESH_ChannelManage *msg, 893 const struct GNUNET_MESH_ChannelManage *msg,
@@ -887,6 +918,18 @@ handle_ch_ack (struct MeshTunnel3 *t,
887 GMCH_handle_ack (ch, msg, fwd); 918 GMCH_handle_ack (ch, msg, fwd);
888} 919}
889 920
921
922
923/**
924 * Handle a channel destruction message.
925 *
926 * @param t Tunnel on which the message came.
927 * @param msg Channel destroy message.
928 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
929 * #GNUNET_YES if message is FWD on the respective channel (loopback)
930 * #GNUNET_NO if message is BCK on the respective channel (loopback)
931 * #GNUNET_SYSERR if message on a one-ended channel (remote)
932 */
890void 933void
891handle_ch_destroy (struct MeshTunnel3 *t, 934handle_ch_destroy (struct MeshTunnel3 *t,
892 const struct GNUNET_MESH_ChannelManage *msg, 935 const struct GNUNET_MESH_ChannelManage *msg,
@@ -1017,7 +1060,10 @@ handle_pong (struct MeshTunnel3 *t,
1017 * 1060 *
1018 * @param t Tunnel this message came on. 1061 * @param t Tunnel this message came on.
1019 * @param msgh Message header. 1062 * @param msgh Message header.
1020 * @param fwd Is this message fwd? 1063 * @param fwd Is this message fwd? This only is meaningful in loopback channels.
1064 * #GNUNET_YES if message is FWD on the respective channel (loopback)
1065 * #GNUNET_NO if message is BCK on the respective channel (loopback)
1066 * #GNUNET_SYSERR if message on a one-ended channel (remote)
1021 */ 1067 */
1022static void 1068static void
1023handle_decrypted (struct MeshTunnel3 *t, 1069handle_decrypted (struct MeshTunnel3 *t,
@@ -1044,8 +1090,7 @@ handle_decrypted (struct MeshTunnel3 *t,
1044 1090
1045 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: 1091 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
1046 handle_ch_create (t, 1092 handle_ch_create (t,
1047 (struct GNUNET_MESH_ChannelCreate *) msgh, 1093 (struct GNUNET_MESH_ChannelCreate *) msgh);
1048 fwd);
1049 break; 1094 break;
1050 1095
1051 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: 1096 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
@@ -1078,12 +1123,10 @@ handle_decrypted (struct MeshTunnel3 *t,
1078 * 1123 *
1079 * @param t Tunnel this message came on. 1124 * @param t Tunnel this message came on.
1080 * @param msg Encrypted message. 1125 * @param msg Encrypted message.
1081 * @param fwd Is this message fwd?
1082 */ 1126 */
1083void 1127void
1084GMT_handle_encrypted (struct MeshTunnel3 *t, 1128GMT_handle_encrypted (struct MeshTunnel3 *t,
1085 const struct GNUNET_MESH_Encrypted *msg, 1129 const struct GNUNET_MESH_Encrypted *msg)
1086 int fwd)
1087{ 1130{
1088 size_t size = ntohs (msg->header.size); 1131 size_t size = ntohs (msg->header.size);
1089 size_t payload_size = size - sizeof (struct GNUNET_MESH_Encrypted); 1132 size_t payload_size = size - sizeof (struct GNUNET_MESH_Encrypted);
@@ -1097,7 +1140,7 @@ GMT_handle_encrypted (struct MeshTunnel3 *t,
1097 while (off < decrypted_size) 1140 while (off < decrypted_size)
1098 { 1141 {
1099 msgh = (struct GNUNET_MessageHeader *) &cbuf[off]; 1142 msgh = (struct GNUNET_MessageHeader *) &cbuf[off];
1100 handle_decrypted (t, msgh, fwd); 1143 handle_decrypted (t, msgh, GNUNET_SYSERR);
1101 off += ntohs (msgh->size); 1144 off += ntohs (msgh->size);
1102 } 1145 }
1103} 1146}