aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-06-24 21:48:45 +0000
committerBart Polot <bart@net.in.tum.de>2011-06-24 21:48:45 +0000
commit8c707366f4d0dab2e5fdea591edd3dbaca659895 (patch)
treee9d478f59304a15f191ddf84b2f79a815e35a469
parent3ec72b9c2457f12977fbdad9badf534b1cd8c4e5 (diff)
downloadgnunet-8c707366f4d0dab2e5fdea591edd3dbaca659895.tar.gz
gnunet-8c707366f4d0dab2e5fdea591edd3dbaca659895.zip
WiP
-rw-r--r--src/mesh/gnunet-service-mesh.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index afa9aec03..78550b2a1 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1007,16 +1007,41 @@ handle_mesh_data_unicast (void *cls,
1007 const struct GNUNET_TRANSPORT_ATS_Information 1007 const struct GNUNET_TRANSPORT_ATS_Information
1008 *atsi) 1008 *atsi)
1009{ 1009{
1010// struct GNUNET_MESH_DataMessageFromOrigin *msg = message; 1010 struct GNUNET_MESH_DataMessageFromOrigin *msg;
1011 struct GNUNET_PeerIdentity id;
1012 struct MeshTunnel *t;
1013 struct MeshPeerInfo *pi;
1014 size_t size;
1011 1015
1012 if (GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN == ntohs(message->type)) { 1016 size = ntohs(message->size);
1013 /* Retransmit to next in path of tunnel identified by message */ 1017 if (size < sizeof(struct GNUNET_MESH_DataMessageFromOrigin)) {
1014 1018 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
1015 return GNUNET_OK; 1019 "got data from origin packet: too short\n");
1016 } else { /* GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN */ 1020 return GNUNET_OK; // FIXME maybe SYSERR? peer misbehaving?
1017 /* Retransmit to previous in path of tunnel identified by message */
1018 return GNUNET_OK;
1019 } 1021 }
1022 msg = (struct GNUNET_MESH_DataMessageFromOrigin *) message;
1023 t = retrieve_tunnel(&msg->oid, ntohl(msg->tid));
1024 pi = GNUNET_CONTAINER_multihashmap_get(t->peers,
1025 &msg->destination.hashPubKey);
1026 if (NULL == pi) {
1027 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
1028 "got invalid data from origin packet: wrong destination\n");
1029 /* TODO are we so nice to try to deliver it anyway? maybe we missed
1030 * a Create_path packed that added the peer but we have it in the global
1031 * peer pool anyway...
1032 */
1033 return GNUNET_OK; // FIXME maybe SYSERR? peer misbehaving?
1034 }
1035 GNUNET_PEER_resolve(get_first_hop(pi->path), &id);
1036 GNUNET_CORE_notify_transmit_ready(core_handle,
1037 0,
1038 0,
1039 GNUNET_TIME_UNIT_FOREVER_REL,
1040 &id,
1041 size,
1042 &send_core_data_to_origin,
1043 msg);
1044 return GNUNET_OK;
1020} 1045}
1021 1046
1022 1047
@@ -1038,15 +1063,7 @@ handle_mesh_data_multicast (void *cls,
1038 *atsi) 1063 *atsi)
1039{ 1064{
1040// struct GNUNET_MESH_DataMessageMulticast *msg = message; 1065// struct GNUNET_MESH_DataMessageMulticast *msg = message;
1041 1066 return GNUNET_OK;
1042 if (GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN == ntohs(message->type)) {
1043 /* Retransmit to next in path of tunnel identified by message */
1044
1045 return GNUNET_OK;
1046 } else { /* GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN */
1047 /* Retransmit to previous in path of tunnel identified by message */
1048 return GNUNET_OK;
1049 }
1050} 1067}
1051 1068
1052 1069
@@ -1068,15 +1085,7 @@ handle_mesh_data_to_orig (void *cls,
1068 *atsi) 1085 *atsi)
1069{ 1086{
1070// struct GNUNET_MESH_DataMessageToOrigin *msg = message; 1087// struct GNUNET_MESH_DataMessageToOrigin *msg = message;
1071 1088 return GNUNET_OK;
1072 if (GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN == ntohs(message->type)) {
1073 /* Retransmit to next in path of tunnel identified by message */
1074
1075 return GNUNET_OK;
1076 } else { /* GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN */
1077 /* Retransmit to previous in path of tunnel identified by message */
1078 return GNUNET_OK;
1079 }
1080} 1089}
1081 1090
1082 1091